]> sipb.mit.edu Git - ikiwiki.git/commitdiff
* Finally fixed the longstanding inline removal bug.
authorjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Sat, 24 Mar 2007 15:10:58 +0000 (15:10 +0000)
committerjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Sat, 24 Mar 2007 15:10:58 +0000 (15:10 +0000)
* Renamed %oldpagemtime to a more accurately named %pagemtime and fix it to
  actually store pages' mtimes.
* Add "mtime" sort parameter to inline plugin.

IkiWiki.pm
IkiWiki/Plugin/inline.pm
IkiWiki/Render.pm
debian/changelog
doc/bugs/done.mdwn
doc/bugs/inline_page_not_updated_on_removal.mdwn
doc/examples/softwaresite/bugs/done.mdwn
doc/plugins/inline.mdwn
doc/todo/done.mdwn
po/ikiwiki.pot

index 2d0f3c38333c7574c9ceb251ee58321eb8580acd..a290b479a5756ff6a3c28449c2e174f327b8ac62 100644 (file)
@@ -8,7 +8,7 @@ use HTML::Entities;
 use URI::Escape q{uri_escape_utf8};
 use open qw{:utf8 :std};
 
-use vars qw{%config %links %oldlinks %oldpagemtime %pagectime %pagecase
+use vars qw{%config %links %oldlinks %pagemtime %pagectime %pagecase
             %renderedfiles %oldrenderedfiles %pagesources %depends %hooks
            %forcerebuild $gettext_obj};
 
@@ -672,7 +672,7 @@ sub loadindex () { #{{{
                my $page=pagename($items{src}[0]);
                if (! $config{rebuild}) {
                        $pagesources{$page}=$items{src}[0];
-                       $oldpagemtime{$page}=$items{mtime}[0];
+                       $pagemtime{$page}=$items{mtime}[0];
                        $oldlinks{$page}=[@{$items{link}}];
                        $links{$page}=[@{$items{link}}];
                        $depends{$page}=$items{depends}[0] if exists $items{depends};
@@ -694,9 +694,9 @@ sub saveindex () { #{{{
        my $newfile="$config{wikistatedir}/index.new";
        my $cleanup = sub { unlink($newfile) };
        open (OUT, ">$newfile") || error("cannot write to $newfile: $!", $cleanup);
-       foreach my $page (keys %oldpagemtime) {
-               next unless $oldpagemtime{$page};
-               my $line="mtime=$oldpagemtime{$page} ".
+       foreach my $page (keys %pagemtime) {
+               next unless $pagemtime{$page};
+               my $line="mtime=$pagemtime{$page} ".
                        "ctime=$pagectime{$page} ".
                        "src=$pagesources{$page}";
                $line.=" dest=$_" foreach @{$renderedfiles{$page}};
index 3a2e0a05f340362ffc29f2dabfdfa3605dbe7500..dcaaa21eb29f3ea2136a0e2d1a49a3bc7de66665 100644 (file)
@@ -96,6 +96,9 @@ sub preprocess_inline (@) { #{{{
        if (exists $params{sort} && $params{sort} eq 'title') {
                @list=sort @list;
        }
+       elsif (exists $params{sort} && $params{sort} eq 'mtime') {
+               @list=sort { $pagemtime{$b} <=> $pagemtime{$a} } @list;
+       }
        elsif (! exists $params{sort} || $params{sort} eq 'age') {
                @list=sort { $pagectime{$b} <=> $pagectime{$a} } @list;
        }
@@ -116,6 +119,10 @@ sub preprocess_inline (@) { #{{{
        }
 
        add_depends($params{page}, $params{pages});
+       # Explicitly add all currently displayed pages as dependencies, so
+       # that if they are removed or otherwise changed, the inline will be
+       # sure to be updated.
+       add_depends($params{page}, join(" or ", @list));
 
        my $rssurl=rsspage(basename($params{page}));
        my $atomurl=atompage(basename($params{page}));
index 990b803de16c0dbc4b96542f83cf17c094b73cd8..c5d885810f1ff1041308d428e8761e3589849ed6 100644 (file)
@@ -192,7 +192,6 @@ sub render ($) { #{{{
                
                writefile(htmlpage($page), $config{destdir},
                        genpage($page, $content, mtime($srcfile)));
-               $oldpagemtime{$page}=time;
        }
        else {
                my $srcfd=readfile($srcfile, 1, 1);
@@ -218,7 +217,6 @@ sub render ($) { #{{{
                                }
                        }
                });
-               $oldpagemtime{$file}=time;
        }
 } #}}}
 
@@ -294,7 +292,7 @@ sub refresh () { #{{{
        foreach my $file (@files) {
                my $page=pagename($file);
                $pagesources{$page}=$file;
-               if (! $oldpagemtime{$page}) {
+               if (! $pagemtime{$page}) {
                        push @add, $file;
                        $pagecase{lc $page}=$page;
                        if ($config{getctime} && -e "$config{srcdir}/$file") {
@@ -306,13 +304,13 @@ sub refresh () { #{{{
                }
        }
        my @del;
-       foreach my $page (keys %oldpagemtime) {
+       foreach my $page (keys %pagemtime) {
                if (! $exists{$page}) {
                        debug(sprintf(gettext("removing old page %s"), $page));
                        push @del, $pagesources{$page};
                        $links{$page}=[];
                        $renderedfiles{$page}=[];
-                       $oldpagemtime{$page}=0;
+                       $pagemtime{$page}=0;
                        prune($config{destdir}."/".$_)
                                foreach @{$oldrenderedfiles{$page}};
                        delete $pagesources{$page};
@@ -324,10 +322,12 @@ sub refresh () { #{{{
        foreach my $file (@files) {
                my $page=pagename($file);
                
-               if (! exists $oldpagemtime{$page} ||
-                   mtime(srcfile($file)) > $oldpagemtime{$page} ||
+               my $mtime=mtime(srcfile($file));
+               if (! exists $pagemtime{$page} ||
+                   $mtime > $pagemtime{$page} ||
                    $forcerebuild{$page}) {
                        debug(sprintf(gettext("scanning %s"), $file));
+                       $pagemtime{$page}=$mtime;
                        push @changed, $file;
                        scan($file);
                }
index c76efa241549bceac4bc7d7ca4be913071c32b52..dda5aa78b08485b492dc3aab3c27b95115471570 100644 (file)
@@ -11,8 +11,12 @@ ikiwiki (1.48) UNRELEASED; urgency=low
   * Make ikiwiki's stylesheet support printing by hiding parts of the page
     that shouldn't appear in a printout: Search box, actions bar,
     blog post form, tags, backlinks, and feed buttons.
+  * Finally fixed the longstanding inline removal bug.
+  * Renamed %oldpagemtime to a more accurately named %pagemtime and fix it to
+    actually store pages' mtimes.
+  * Add "mtime" sort parameter to inline plugin.
 
- -- Joey Hess <joeyh@debian.org>  Wed, 21 Mar 2007 19:46:32 -0400
+ -- Joey Hess <joeyh@debian.org>  Fri, 23 Mar 2007 16:16:39 -0400
 
 ikiwiki (1.47) unstable; urgency=low
 
index a92862bd4de981da369db9eb746c5364e2e345cd..2821220019dfbddd22d4431fea2accb8ed590549 100644 (file)
@@ -1,3 +1,3 @@
 recently fixed [[bugs]]
 
-[[inline pages="link(bugs/done) and !bugs and !*/Discussion" show="10"]]
+[[inline pages="link(bugs/done) and !bugs and !*/Discussion" sort=mtime show=10]]
index 7f5e49871abb0053e717b696e7c00e5dfeb2a3de..fc626cab10652e91c4776e762b7ee95ade253577 100644 (file)
@@ -6,27 +6,4 @@ This only happens if the page is removed from the inlined pagespec due to
 a tag changing; the problem is that once the tag is changed, ikiwiki does
 not know that the page used to match before.
 
-Another example would be a pagespec that allowed only matching new pages:
-
-       newer(1 day)
-
-Obviously, the pages that matches are going to change, and again once they
-do, ikiwiki will no longer know that they matched before, so it won't know
-to remove them from a page that used that to inline them.
-
-To fix, seems I would need to record the actual list of pages that are
-currently included on an inline page, and do a comparison to see if any
-have changed. 
-
-At first I thought, why not just add them to the dependencies
-explicitly, but that failed because the dependencies GlobList failed to match
-when a negated expression like "!tag(bugs/done)" is matched. It is,
-however, doable with PageSpecs:
-
-       (real deps here) or (list of all currently inlined pages here)
-
-However, it's not really clear to me how to _remove_ inlined pages from the
-deps when they stop being inlined for whatever reason. So a separate list
-would be better.
-
-So this is blocked by [[todo/plugin_data_storage]] I suppose.
+[[done]]
index ad81deaac7811d80dd00582dd78867d6b8a1937e..af88c1c7c307aa0460dc3f0c9adbbbbcc112db6c 100644 (file)
@@ -1,3 +1,3 @@
 recently fixed [[bugs]]
 
-[[inline pages="./* and link(./done) and !*/Discussion" show=10]]
+[[inline pages="./* and link(./done) and !*/Discussion" sort=mtime show=10]]
index f3af08abf44586192b6ae4f1b91d19611fb44c90..fd894baa1c8c33664c7fecbe8825c432c4555a29 100644 (file)
@@ -52,5 +52,6 @@ directive:
   for editing and discussion (if they would be shown at the top of the page
   itself).
 * `sort` - Controls how inlined pages are sorted. The default, "age" is to
-  sort newest pages first. Setting it to "title" will sort pages by title.
+  sort newest created pages first. Setting it to "title" will sort pages by
+  title, and "mtime" sorts most recently modified pages first.
 * `reverse` - If set to "yes", causes the sort order to be reversed.
index 8d01666c0ec468b7f32fcd55574e19dc9e6fe9ab..0ad5656a0b8dd4452d02d593240c3092bb149a13 100644 (file)
@@ -1,3 +1,3 @@
 recently fixed [[TODO]] items
 
-[[inline pages="link(todo/done) and !todo and !*/Discussion" show="10"]]
+[[inline pages="link(todo/done) and !todo and !*/Discussion" sort=mtime show=10]]
index 23a15155566838cd58803c1eefba277321b80aa2..b1fdeda215873be6505e472fbb8587f3ed4bb904 100644 (file)
@@ -8,7 +8,7 @@ msgid ""
 msgstr ""
 "Project-Id-Version: PACKAGE VERSION\n"
 "Report-Msgid-Bugs-To: \n"
-"POT-Creation-Date: 2007-03-21 18:59-0400\n"
+"POT-Creation-Date: 2007-03-23 16:36-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"
@@ -30,7 +30,7 @@ msgid "%s is not an editable page"
 msgstr ""
 
 #: ../IkiWiki/CGI.pm:418 ../IkiWiki/Plugin/brokenlinks.pm:24
-#: ../IkiWiki/Plugin/inline.pm:174 ../IkiWiki/Plugin/opendiscussion.pm:17
+#: ../IkiWiki/Plugin/inline.pm:181 ../IkiWiki/Plugin/opendiscussion.pm:17
 #: ../IkiWiki/Plugin/orphans.pm:28 ../IkiWiki/Render.pm:97
 #: ../IkiWiki/Render.pm:165
 msgid "discussion"
@@ -147,21 +147,21 @@ msgstr ""
 msgid "Must specify url to wiki with --url when using --rss or --atom"
 msgstr ""
 
-#: ../IkiWiki/Plugin/inline.pm:103
+#: ../IkiWiki/Plugin/inline.pm:106
 #, perl-format
 msgid "unknown sort type %s"
 msgstr ""
 
-#: ../IkiWiki/Plugin/inline.pm:145
+#: ../IkiWiki/Plugin/inline.pm:152
 #, perl-format
 msgid "nonexistant template %s"
 msgstr ""
 
-#: ../IkiWiki/Plugin/inline.pm:182 ../IkiWiki/Render.pm:101
+#: ../IkiWiki/Plugin/inline.pm:189 ../IkiWiki/Render.pm:101
 msgid "Discussion"
 msgstr ""
 
-#: ../IkiWiki/Plugin/inline.pm:397
+#: ../IkiWiki/Plugin/inline.pm:404
 msgid "RPC::XML::Client not found, not pinging"
 msgstr ""
 
@@ -420,17 +420,17 @@ msgid ""
 "notifications"
 msgstr ""
 
-#: ../IkiWiki/Render.pm:251 ../IkiWiki/Render.pm:271
+#: ../IkiWiki/Render.pm:249 ../IkiWiki/Render.pm:269
 #, perl-format
 msgid "skipping bad filename %s"
 msgstr ""
 
-#: ../IkiWiki/Render.pm:311
+#: ../IkiWiki/Render.pm:309
 #, perl-format
 msgid "removing old page %s"
 msgstr ""
 
-#: ../IkiWiki/Render.pm:330
+#: ../IkiWiki/Render.pm:329
 #, perl-format
 msgid "scanning %s"
 msgstr ""