From ca0be85c59002ae9d01140cba587ffe909252471 Mon Sep 17 00:00:00 2001 From: joey Date: Thu, 23 Mar 2006 21:39:38 +0000 Subject: [PATCH] new index file format *warning* on upgrade to this version of ikiwiki, be sure to run --rebuild to regenerate the index --- doc/todo.mdwn | 4 +--- ikiwiki | 30 ++++++++++++++++++++---------- 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/doc/todo.mdwn b/doc/todo.mdwn index eb828adcd..1ab3e749a 100644 --- a/doc/todo.mdwn +++ b/doc/todo.mdwn @@ -90,12 +90,10 @@ Requirements: * Need to keep track of creation dates of pages in the index file. * Need to keep track of the globlists in the index file. - - Probably need to redesign the index file format to allow for this sort - of future expansion. * Need to pick a good token and note that the token will need to be passed multiple parameters. Possibly something like this: - [[embed pages="myblog/*" show="30"]] + [[inline pages="myblog/*" show="30"]] ## revisit case diff --git a/ikiwiki b/ikiwiki index 5c708919a..4c815dfa3 100755 --- a/ikiwiki +++ b/ikiwiki @@ -316,13 +316,19 @@ sub loadindex () { #{{{ while () { $_=possibly_foolish_untaint($_); chomp; - my ($mtime, $file, $rendered, @links)=split(' ', $_); - my $page=pagename($file); - $pagesources{$page}=$file; - $oldpagemtime{$page}=$mtime; - $oldlinks{$page}=[@links]; - $links{$page}=[@links]; - $renderedfiles{$page}=$rendered; + my %items; + $items{link}=[]; + foreach my $i (split(/ /, $_)) { + my ($item, $val)=split(/=/, $i, 2); + push @{$items{$item}}, $val; + } + + my $page=pagename($items{src}[0]); + $pagesources{$page}=$items{src}[0]; + $oldpagemtime{$page}=$items{mtime}[0]; + $oldlinks{$page}=[@{$items{link}}]; + $links{$page}=[@{$items{link}}]; + $renderedfiles{$page}=$items{dest}[0]; } close IN; } #}}} @@ -334,9 +340,13 @@ sub saveindex () { #{{{ open (OUT, ">$config{wikistatedir}/index") || error("cannot write to $config{wikistatedir}/index: $!"); foreach my $page (keys %oldpagemtime) { - print OUT "$oldpagemtime{$page} $pagesources{$page} $renderedfiles{$page} ". - join(" ", @{$links{$page}})."\n" - if $oldpagemtime{$page}; + my $line="mtime=$oldpagemtime{$page} ". + "src=$pagesources{$page} ". + "dest=$renderedfiles{$page}"; + if ($oldpagemtime{$page}) { + $line.=" link=$_" foreach @{$links{$page}}; + } + print OUT $line."\n"; } close OUT; } #}}} -- 2.26.2