new index file format
authorjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Thu, 23 Mar 2006 21:39:38 +0000 (21:39 +0000)
committerjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Thu, 23 Mar 2006 21:39:38 +0000 (21:39 +0000)
*warning* on upgrade to this version of ikiwiki, be sure to run --rebuild
to regenerate the index

doc/todo.mdwn
ikiwiki

index eb828adcd14ac45975f7e9f5886a2e8c5e8d9d61..1ab3e749a543aa923e680c984bc81ad091bc3497 100644 (file)
@@ -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 5c708919a9288c460c1094adf367b27e2f8777f8..4c815dfa3ca0013a2d59866f48d8b86d72e49295 100755 (executable)
--- a/ikiwiki
+++ b/ikiwiki
@@ -316,13 +316,19 @@ sub loadindex () { #{{{
        while (<IN>) {
                $_=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;
 } #}}}