summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Hess <joey@kodama.kitenet.net>2008-09-27 16:34:09 -0400
committerJoey Hess <joey@kodama.kitenet.net>2008-09-27 16:35:56 -0400
commit61426a71868a6863115b0a4e0467756e97953092 (patch)
treee17a4fdef2d2391440ba58d31bc7f45ef9fe4ddb
parent8d04a1de61fb7498085c2ff59418aa4d2a0189d2 (diff)
Reorganize index file, add a format version field.
Upgrades to the new index format should be transparent. The version field is 3, because 1 was the old textual index, 2 was the pre-versioned format. This also includes some efficiency improvements to index loading, by not copying a hash and using a reference.
-rw-r--r--IkiWiki.pm48
-rw-r--r--IkiWiki/Plugin/edittemplate.pm6
-rw-r--r--debian/changelog4
-rw-r--r--po/ikiwiki.pot12
4 files changed, 45 insertions, 25 deletions
diff --git a/IkiWiki.pm b/IkiWiki.pm
index c15ec3822..9a81c7da4 100644
--- a/IkiWiki.pm
+++ b/IkiWiki.pm
@@ -1309,31 +1309,40 @@ sub loadindex () { #{{{
return;
}
}
- my $ret=Storable::fd_retrieve($in);
- if (! defined $ret) {
+
+ my $index=Storable::fd_retrieve($in);
+ if (! defined $index) {
return 0;
}
- my %index=%$ret;
- foreach my $src (keys %index) {
- my %d=%{$index{$src}};
+
+ my $pages;
+ if (exists $index->{version} && ! ref $index->{version}) {
+ $pages=$index->{page};
+ }
+ else {
+ $pages=$index;
+ }
+
+ foreach my $src (keys %$pages) {
+ my $d=$pages->{$src};
my $page=pagename($src);
- $pagectime{$page}=$d{ctime};
+ $pagectime{$page}=$d->{ctime};
if (! $config{rebuild}) {
$pagesources{$page}=$src;
- $pagemtime{$page}=$d{mtime};
- $renderedfiles{$page}=$d{dest};
- if (exists $d{links} && ref $d{links}) {
- $links{$page}=$d{links};
- $oldlinks{$page}=[@{$d{links}}];
+ $pagemtime{$page}=$d->{mtime};
+ $renderedfiles{$page}=$d->{dest};
+ if (exists $d->{links} && ref $d->{links}) {
+ $links{$page}=$d->{links};
+ $oldlinks{$page}=[@{$d->{links}}];
}
- if (exists $d{depends}) {
- $depends{$page}=$d{depends};
+ if (exists $d->{depends}) {
+ $depends{$page}=$d->{depends};
}
- if (exists $d{state}) {
- $pagestate{$page}=$d{state};
+ if (exists $d->{state}) {
+ $pagestate{$page}=$d->{state};
}
}
- $oldrenderedfiles{$page}=[@{$d{dest}}];
+ $oldrenderedfiles{$page}=[@{$d->{dest}}];
}
foreach my $page (keys %pagesources) {
$pagecase{lc $page}=$page;
@@ -1364,7 +1373,7 @@ sub saveindex () { #{{{
next unless $pagemtime{$page};
my $src=$pagesources{$page};
- $index{$src}={
+ $index{page}{$src}={
ctime => $pagectime{$page},
mtime => $pagemtime{$page},
dest => $renderedfiles{$page},
@@ -1372,17 +1381,18 @@ sub saveindex () { #{{{
};
if (exists $depends{$page}) {
- $index{$src}{depends} = $depends{$page};
+ $index{page}{$src}{depends} = $depends{$page};
}
if (exists $pagestate{$page}) {
foreach my $id (@hookids) {
foreach my $key (keys %{$pagestate{$page}{$id}}) {
- $index{$src}{state}{$id}{$key}=$pagestate{$page}{$id}{$key};
+ $index{page}{$src}{state}{$id}{$key}=$pagestate{$page}{$id}{$key};
}
}
}
}
+ $index{version}="3";
my $ret=Storable::nstore_fd(\%index, $out);
return if ! defined $ret || ! $ret;
close $out || error("failed saving to $newfile: $!", $cleanup);
diff --git a/IkiWiki/Plugin/edittemplate.pm b/IkiWiki/Plugin/edittemplate.pm
index 846b4e7c8..189a066d8 100644
--- a/IkiWiki/Plugin/edittemplate.pm
+++ b/IkiWiki/Plugin/edittemplate.pm
@@ -16,6 +16,8 @@ sub import { #{{{
call => \&preprocess);
hook(type => "formbuilder", id => "edittemplate",
call => \&formbuilder);
+ hook(type => "refresh", id => "edittemplate",
+ call => \&refresh);
} #}}}
sub getsetup () { #{{{
@@ -138,4 +140,8 @@ sub filltemplate ($$) { #{{{
return $template->output;
} #}}}
+sub refresh () {
+
+}
+
1
diff --git a/debian/changelog b/debian/changelog
index 1483bec64..2ea92c4c3 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -19,6 +19,10 @@ ikiwiki (2.66) UNRELEASED; urgency=low
untidied content if tidy crashes. In either case, it seems best to tidy
the content to nothing.
* htmltidy: Avoid spewing tidy errors to stderr.
+ * Add %wikistate, which is like %pagestate except not specific to a given
+ page, and is preserved across rebuilds.
+ * Reorganize index file, add a format version field. Upgrades to the new
+ index format should be transparent.
-- Joey Hess <joeyh@debian.org> Thu, 25 Sep 2008 13:45:55 -0400
diff --git a/po/ikiwiki.pot b/po/ikiwiki.pot
index f8796acfe..f338750ea 100644
--- a/po/ikiwiki.pot
+++ b/po/ikiwiki.pot
@@ -8,7 +8,7 @@ msgid ""
msgstr ""
"Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2008-09-27 14:12-0400\n"
+"POT-Creation-Date: 2008-09-27 16:35-0400\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
@@ -220,20 +220,20 @@ msgstr ""
msgid "editing %s"
msgstr ""
-#: ../IkiWiki/Plugin/edittemplate.pm:51
+#: ../IkiWiki/Plugin/edittemplate.pm:53
msgid "template not specified"
msgstr ""
-#: ../IkiWiki/Plugin/edittemplate.pm:54
+#: ../IkiWiki/Plugin/edittemplate.pm:56
msgid "match not specified"
msgstr ""
-#: ../IkiWiki/Plugin/edittemplate.pm:62
+#: ../IkiWiki/Plugin/edittemplate.pm:64
#, perl-format
msgid "edittemplate %s registered for %s"
msgstr ""
-#: ../IkiWiki/Plugin/edittemplate.pm:133
+#: ../IkiWiki/Plugin/edittemplate.pm:135
msgid "failed to process"
msgstr ""
@@ -910,7 +910,7 @@ msgstr ""
msgid "preprocessing loop detected on %s at depth %i"
msgstr ""
-#: ../IkiWiki.pm:1614
+#: ../IkiWiki.pm:1624
msgid "yes"
msgstr ""