* 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.
master
joey 2007-03-24 15:10:58 +00:00
parent dc0bf7982f
commit bbb0b3e72f
10 changed files with 39 additions and 50 deletions

View File

@ -8,7 +8,7 @@ use HTML::Entities;
use URI::Escape q{uri_escape_utf8}; use URI::Escape q{uri_escape_utf8};
use open qw{:utf8 :std}; 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 %renderedfiles %oldrenderedfiles %pagesources %depends %hooks
%forcerebuild $gettext_obj}; %forcerebuild $gettext_obj};
@ -672,7 +672,7 @@ sub loadindex () { #{{{
my $page=pagename($items{src}[0]); my $page=pagename($items{src}[0]);
if (! $config{rebuild}) { if (! $config{rebuild}) {
$pagesources{$page}=$items{src}[0]; $pagesources{$page}=$items{src}[0];
$oldpagemtime{$page}=$items{mtime}[0]; $pagemtime{$page}=$items{mtime}[0];
$oldlinks{$page}=[@{$items{link}}]; $oldlinks{$page}=[@{$items{link}}];
$links{$page}=[@{$items{link}}]; $links{$page}=[@{$items{link}}];
$depends{$page}=$items{depends}[0] if exists $items{depends}; $depends{$page}=$items{depends}[0] if exists $items{depends};
@ -694,9 +694,9 @@ sub saveindex () { #{{{
my $newfile="$config{wikistatedir}/index.new"; my $newfile="$config{wikistatedir}/index.new";
my $cleanup = sub { unlink($newfile) }; my $cleanup = sub { unlink($newfile) };
open (OUT, ">$newfile") || error("cannot write to $newfile: $!", $cleanup); open (OUT, ">$newfile") || error("cannot write to $newfile: $!", $cleanup);
foreach my $page (keys %oldpagemtime) { foreach my $page (keys %pagemtime) {
next unless $oldpagemtime{$page}; next unless $pagemtime{$page};
my $line="mtime=$oldpagemtime{$page} ". my $line="mtime=$pagemtime{$page} ".
"ctime=$pagectime{$page} ". "ctime=$pagectime{$page} ".
"src=$pagesources{$page}"; "src=$pagesources{$page}";
$line.=" dest=$_" foreach @{$renderedfiles{$page}}; $line.=" dest=$_" foreach @{$renderedfiles{$page}};

View File

@ -96,6 +96,9 @@ sub preprocess_inline (@) { #{{{
if (exists $params{sort} && $params{sort} eq 'title') { if (exists $params{sort} && $params{sort} eq 'title') {
@list=sort @list; @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') { elsif (! exists $params{sort} || $params{sort} eq 'age') {
@list=sort { $pagectime{$b} <=> $pagectime{$a} } @list; @list=sort { $pagectime{$b} <=> $pagectime{$a} } @list;
} }
@ -116,6 +119,10 @@ sub preprocess_inline (@) { #{{{
} }
add_depends($params{page}, $params{pages}); 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 $rssurl=rsspage(basename($params{page}));
my $atomurl=atompage(basename($params{page})); my $atomurl=atompage(basename($params{page}));

View File

@ -192,7 +192,6 @@ sub render ($) { #{{{
writefile(htmlpage($page), $config{destdir}, writefile(htmlpage($page), $config{destdir},
genpage($page, $content, mtime($srcfile))); genpage($page, $content, mtime($srcfile)));
$oldpagemtime{$page}=time;
} }
else { else {
my $srcfd=readfile($srcfile, 1, 1); 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) { foreach my $file (@files) {
my $page=pagename($file); my $page=pagename($file);
$pagesources{$page}=$file; $pagesources{$page}=$file;
if (! $oldpagemtime{$page}) { if (! $pagemtime{$page}) {
push @add, $file; push @add, $file;
$pagecase{lc $page}=$page; $pagecase{lc $page}=$page;
if ($config{getctime} && -e "$config{srcdir}/$file") { if ($config{getctime} && -e "$config{srcdir}/$file") {
@ -306,13 +304,13 @@ sub refresh () { #{{{
} }
} }
my @del; my @del;
foreach my $page (keys %oldpagemtime) { foreach my $page (keys %pagemtime) {
if (! $exists{$page}) { if (! $exists{$page}) {
debug(sprintf(gettext("removing old page %s"), $page)); debug(sprintf(gettext("removing old page %s"), $page));
push @del, $pagesources{$page}; push @del, $pagesources{$page};
$links{$page}=[]; $links{$page}=[];
$renderedfiles{$page}=[]; $renderedfiles{$page}=[];
$oldpagemtime{$page}=0; $pagemtime{$page}=0;
prune($config{destdir}."/".$_) prune($config{destdir}."/".$_)
foreach @{$oldrenderedfiles{$page}}; foreach @{$oldrenderedfiles{$page}};
delete $pagesources{$page}; delete $pagesources{$page};
@ -324,10 +322,12 @@ sub refresh () { #{{{
foreach my $file (@files) { foreach my $file (@files) {
my $page=pagename($file); my $page=pagename($file);
if (! exists $oldpagemtime{$page} || my $mtime=mtime(srcfile($file));
mtime(srcfile($file)) > $oldpagemtime{$page} || if (! exists $pagemtime{$page} ||
$mtime > $pagemtime{$page} ||
$forcerebuild{$page}) { $forcerebuild{$page}) {
debug(sprintf(gettext("scanning %s"), $file)); debug(sprintf(gettext("scanning %s"), $file));
$pagemtime{$page}=$mtime;
push @changed, $file; push @changed, $file;
scan($file); scan($file);
} }

6
debian/changelog vendored
View File

@ -11,8 +11,12 @@ ikiwiki (1.48) UNRELEASED; urgency=low
* Make ikiwiki's stylesheet support printing by hiding parts of the page * Make ikiwiki's stylesheet support printing by hiding parts of the page
that shouldn't appear in a printout: Search box, actions bar, that shouldn't appear in a printout: Search box, actions bar,
blog post form, tags, backlinks, and feed buttons. 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 ikiwiki (1.47) unstable; urgency=low

View File

@ -1,3 +1,3 @@
recently fixed [[bugs]] 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]]

View 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 a tag changing; the problem is that once the tag is changed, ikiwiki does
not know that the page used to match before. not know that the page used to match before.
Another example would be a pagespec that allowed only matching new pages: [[done]]
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.

View File

@ -1,3 +1,3 @@
recently fixed [[bugs]] recently fixed [[bugs]]
[[inline pages="./* and link(./done) and !*/Discussion" show=10]] [[inline pages="./* and link(./done) and !*/Discussion" sort=mtime show=10]]

View File

@ -52,5 +52,6 @@ directive:
for editing and discussion (if they would be shown at the top of the page for editing and discussion (if they would be shown at the top of the page
itself). itself).
* `sort` - Controls how inlined pages are sorted. The default, "age" is to * `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. * `reverse` - If set to "yes", causes the sort order to be reversed.

View File

@ -1,3 +1,3 @@
recently fixed [[TODO]] items 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]]

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: PACKAGE VERSION\n" "Project-Id-Version: PACKAGE VERSION\n"
"Report-Msgid-Bugs-To: \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" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -30,7 +30,7 @@ msgid "%s is not an editable page"
msgstr "" msgstr ""
#: ../IkiWiki/CGI.pm:418 ../IkiWiki/Plugin/brokenlinks.pm:24 #: ../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/Plugin/orphans.pm:28 ../IkiWiki/Render.pm:97
#: ../IkiWiki/Render.pm:165 #: ../IkiWiki/Render.pm:165
msgid "discussion" msgid "discussion"
@ -147,21 +147,21 @@ msgstr ""
msgid "Must specify url to wiki with --url when using --rss or --atom" msgid "Must specify url to wiki with --url when using --rss or --atom"
msgstr "" msgstr ""
#: ../IkiWiki/Plugin/inline.pm:103 #: ../IkiWiki/Plugin/inline.pm:106
#, perl-format #, perl-format
msgid "unknown sort type %s" msgid "unknown sort type %s"
msgstr "" msgstr ""
#: ../IkiWiki/Plugin/inline.pm:145 #: ../IkiWiki/Plugin/inline.pm:152
#, perl-format #, perl-format
msgid "nonexistant template %s" msgid "nonexistant template %s"
msgstr "" msgstr ""
#: ../IkiWiki/Plugin/inline.pm:182 ../IkiWiki/Render.pm:101 #: ../IkiWiki/Plugin/inline.pm:189 ../IkiWiki/Render.pm:101
msgid "Discussion" msgid "Discussion"
msgstr "" msgstr ""
#: ../IkiWiki/Plugin/inline.pm:397 #: ../IkiWiki/Plugin/inline.pm:404
msgid "RPC::XML::Client not found, not pinging" msgid "RPC::XML::Client not found, not pinging"
msgstr "" msgstr ""
@ -420,17 +420,17 @@ msgid ""
"notifications" "notifications"
msgstr "" msgstr ""
#: ../IkiWiki/Render.pm:251 ../IkiWiki/Render.pm:271 #: ../IkiWiki/Render.pm:249 ../IkiWiki/Render.pm:269
#, perl-format #, perl-format
msgid "skipping bad filename %s" msgid "skipping bad filename %s"
msgstr "" msgstr ""
#: ../IkiWiki/Render.pm:311 #: ../IkiWiki/Render.pm:309
#, perl-format #, perl-format
msgid "removing old page %s" msgid "removing old page %s"
msgstr "" msgstr ""
#: ../IkiWiki/Render.pm:330 #: ../IkiWiki/Render.pm:329
#, perl-format #, perl-format
msgid "scanning %s" msgid "scanning %s"
msgstr "" msgstr ""