diff options
author | Joey Hess <joey@kodama.kitenet.net> | 2008-09-27 16:45:27 -0400 |
---|---|---|
committer | Joey Hess <joey@kodama.kitenet.net> | 2008-09-27 16:45:27 -0400 |
commit | a5d3acd37cd52a5cf0045ae4d300a2ef13a07a6e (patch) | |
tree | c3d541291f291d3fbce4fe4f2816eec29403a32c /IkiWiki.pm | |
parent | 61426a71868a6863115b0a4e0467756e97953092 (diff) | |
download | ikiwiki-a5d3acd37cd52a5cf0045ae4d300a2ef13a07a6e.tar ikiwiki-a5d3acd37cd52a5cf0045ae4d300a2ef13a07a6e.tar.gz |
Add %wikistate, which is like %pagestate except not specific to a given page, and is preserved across rebuilds.
Diffstat (limited to 'IkiWiki.pm')
-rw-r--r-- | IkiWiki.pm | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/IkiWiki.pm b/IkiWiki.pm index 9a81c7da4..e303c8f4f 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -12,16 +12,16 @@ use Storable; use open qw{:utf8 :std}; use vars qw{%config %links %oldlinks %pagemtime %pagectime %pagecase - %pagestate %renderedfiles %oldrenderedfiles %pagesources - %destsources %depends %hooks %forcerebuild $gettext_obj - %loaded_plugins}; + %pagestate %wikistate %renderedfiles %oldrenderedfiles + %pagesources %destsources %depends %hooks %forcerebuild + $gettext_obj %loaded_plugins}; use Exporter q{import}; our @EXPORT = qw(hook debug error template htmlpage add_depends pagespec_match bestlink htmllink readfile writefile pagetype srcfile pagename displaytime will_render gettext urlto targetpage add_underlay pagetitle titlepage linkpage - %config %links %pagestate %renderedfiles + %config %links %pagestate %wikistate %renderedfiles %pagesources %destsources); our $VERSION = 2.00; # plugin interface version, next is ikiwiki version our $version='unknown'; # VERSION_AUTOREPLACE done by Makefile, DNE @@ -1318,9 +1318,11 @@ sub loadindex () { #{{{ my $pages; if (exists $index->{version} && ! ref $index->{version}) { $pages=$index->{page}; + %wikistate=%{$index->{state}}; } else { $pages=$index; + %wikistate=(); } foreach my $src (keys %$pages) { @@ -1368,6 +1370,7 @@ sub saveindex () { #{{{ my $newfile="$config{wikistatedir}/indexdb.new"; my $cleanup = sub { unlink($newfile) }; open (my $out, '>', $newfile) || error("cannot write to $newfile: $!", $cleanup); + my %index; foreach my $page (keys %pagemtime) { next unless $pagemtime{$page}; @@ -1392,6 +1395,14 @@ sub saveindex () { #{{{ } } } + + $index{state}={}; + foreach my $id (@hookids) { + foreach my $key (keys %{$wikistate{$id}}) { + $index{state}{$id}{$key}=$wikistate{$id}{$key}; + } + } + $index{version}="3"; my $ret=Storable::nstore_fd(\%index, $out); return if ! defined $ret || ! $ret; |