Merge branch 'master' of ssh://git.ikiwiki.info
authorJoey Hess <joey@kitenet.net>
Wed, 2 Jan 2013 19:32:30 +0000 (15:32 -0400)
committerJoey Hess <joey@kitenet.net>
Wed, 2 Jan 2013 19:32:30 +0000 (15:32 -0400)
.gitignore
IkiWiki/Plugin/opendiscussion.pm
IkiWiki/Plugin/trail.pm
debian/changelog
doc/bugs/opendiscussion_should_respect_the_discussion_option.mdwn
t/trail.t

index fe1c3d441cc362d12390c70d8e3c9266f1ac5021..f8991a63dcc3100130f9b575cba36a568184df6d 100644 (file)
@@ -9,6 +9,7 @@ ikiwiki.out
 ikiwiki-transition.out
 ikiwiki-calendar.out
 pm_to_blib
+/MYMETA.yml
 *.man
 /po/cover_db
 po/po2wiki_stamp
index 2805f60efdb6d415a19aeb17195df8ff2543487b..808d3cd2bd730c3847a876e016df9145c4bb32a9 100644 (file)
@@ -25,7 +25,7 @@ sub canedit ($$) {
        my $cgi=shift;
        my $session=shift;
 
-       return "" if $page=~/(\/|^)\Q$config{discussionpage}\E$/i;
+       return "" if $config{discussion} && $page=~/(\/|^)\Q$config{discussionpage}\E$/i;
        return "" if pagespec_match($page, "postcomment(*)");
        return undef;
 }
index cf0f0a15e874aa672ba5a9eff09859e3e6b1343a..cb94855fdd1181cb8113001f838db491db0bcc4d 100644 (file)
@@ -62,12 +62,20 @@ sub getsetup () {
                },
 }
 
+# Cache of pages' old titles, so we can tell whether they changed
+my %old_trail_titles;
+
 sub needsbuild (@) {
        my $needsbuild=shift;
+
        foreach my $page (keys %pagestate) {
                if (exists $pagestate{$page}{trail}) {
                        if (exists $pagesources{$page} &&
                            grep { $_ eq $pagesources{$page} } @$needsbuild) {
+                               # Remember its title, so we can know whether
+                               # it changed.
+                               $old_trail_titles{$page} = title_of($page);
+
                                # Remove state, it will be re-added
                                # if the preprocessor directive is still
                                # there during the rebuild. {item} is the
@@ -78,6 +86,7 @@ sub needsbuild (@) {
                        }
                }
        }
+
        return $needsbuild;
 }
 
@@ -230,6 +239,12 @@ sub trails_differ {
                if (! exists $new->{$trail}) {
                        return 1;
                }
+
+               if (exists $old_trail_titles{$trail} &&
+                       title_of($trail) ne $old_trail_titles{$trail}) {
+                       return 1;
+               }
+
                my ($old_p, $old_n) = @{$old->{$trail}};
                my ($new_p, $new_n) = @{$new->{$trail}};
                $old_p = "" unless defined $old_p;
@@ -239,9 +254,20 @@ sub trails_differ {
                if ($old_p ne $new_p) {
                        return 1;
                }
+
+               if (exists $old_trail_titles{$old_p} &&
+                       title_of($old_p) ne $old_trail_titles{$old_p}) {
+                       return 1;
+               }
+
                if ($old_n ne $new_n) {
                        return 1;
                }
+
+               if (exists $old_trail_titles{$old_n} &&
+                       title_of($old_n) ne $old_trail_titles{$old_n}) {
+                       return 1;
+               }
        }
 
        foreach my $trail (keys %$new) {
@@ -318,8 +344,6 @@ sub prerender {
                        $prev = $members->[$i - 1] if $i > 0;
                        my $next = $members->[$i + 1];
 
-                       add_depends($member, $trail, deptype("presence"));
-
                        $member_to_trails{$member}{$trail} = [$prev, $next];
                }
 
@@ -359,6 +383,12 @@ sub prerender {
 sub build_affected {
        my %affected;
 
+       # In principle we might not have done this yet, although in practice
+       # at least the trail itself has probably changed, and its template
+       # almost certainly contains TRAILS or TRAILLOOP, triggering our
+       # prerender as a side-effect.
+       prerender();
+
        foreach my $member (keys %rebuild_trail_members) {
                $affected{$member} = sprintf(gettext("building %s, its previous or next page has changed"), $member);
        }
@@ -406,13 +436,11 @@ sub pagetemplate (@) {
                        my ($prevurl, $nexturl, $prevtitle, $nexttitle);
 
                        if (defined $prev) {
-                               add_depends($params{destpage}, $prev, deptype("presence"));
                                $prevurl = urlto($prev, $page);
                                $prevtitle = title_of($prev);
                        }
 
                        if (defined $next) {
-                               add_depends($params{destpage}, $next, deptype("presence"));
                                $nexturl = urlto($next, $page);
                                $nexttitle = title_of($next);
                        }
index 948fdcc8445c48734dd6adaeb0050c46dbd7ce5b..fdd8308b94401b867b19f3c57c9096dd7e83141d 100644 (file)
@@ -3,7 +3,10 @@ ikiwiki (3.20121213) UNRELEASED; urgency=low
   * htmlscrubber: Allow the bitcoin URI scheme.
   * aggregate: When run with --aggregate, if an aggregation is already
     running, don't go on and --refresh.
-  * trail: Converted all dependencies to presence dependencies.
+  * trail: Avoid excess dependencies between pages in the trail
+    and the page defining the trail. Thanks, smcv.
+  * opendiscussion: Don't allow editing discussion pages if discussion pages
+    are disabled. (smcv)
 
  -- Joey Hess <joeyh@debian.org>  Sat, 22 Dec 2012 16:15:24 -0400
 
index 318f79d6af4478aa03441bd9a80ba88bd4edf501..cacd2b73b946c92e628163e06f2b13db6416bdb5 100644 (file)
@@ -7,3 +7,5 @@ the `discussionpage` setting to be edited anonymously, even if
 
 (If it respected the `discussion` option, the combination of
 `opendiscussion` and `moderatedcomments` might be good for blogs.)
+
+[[done]] --[[smcv]]
index 2e4b9278d1a324875684324b114b324431c55df7..dce3b3c7e4df551984c30c6ed0a0cecac53631ed 100755 (executable)
--- a/t/trail.t
+++ b/t/trail.t
@@ -15,11 +15,11 @@ sub check_trail {
 
 sub check_no_trail {
        my $file=shift;
-       my $trailname=shift;
+       my $trailname=shift || qr/\w+/;
        my $blob=readfile("t/tmp/out/$file");
        my ($trailline)=$blob=~/^trail=$trailname\s+(.*)$/m;
        $trailline="" unless defined $trailline;
-       ok($trailline !~ /^trail=$trailname\s+/, "no $trailname in $file");
+       ok($trailline !~ /^trail=$trailname\s+/, "no trail $trailname in $file");
 }
 
 my $blob;
@@ -96,6 +96,18 @@ write_old_file("sorting.mdwn",
        '[[!trailitems pagenames="sorting/beginning sorting/middle sorting/end"]] ' .
        '[[!inline pages="sorting/old or sorting/ancient or sorting/new" trail="yes"]] ' .
        '[[!traillink linked2]]');
+write_old_file("limited/a.mdwn", "a");
+write_old_file("limited/b.mdwn", "b");
+write_old_file("limited/c.mdwn", "c");
+write_old_file("limited/d.mdwn", "d");
+write_old_file("limited.mdwn",
+       '[[!inline pages="limited/*" trail="yes" show=2 sort=title]]');
+write_old_file("untrail/a.mdwn", "a");
+write_old_file("untrail/b.mdwn", "b");
+write_old_file("untrail.mdwn", "[[!traillink a]] [[!traillink b]]");
+write_old_file("retitled/a.mdwn", "a");
+write_old_file("retitled.mdwn",
+       '[[!meta title="the old title"]][[!traillink a]]');
 
 write_old_file("meme.mdwn", <<EOF
 [[!trail]]
@@ -178,6 +190,24 @@ check_trail("sorting/old.html", "n=sorting/ancient p=sorting/new");
 check_trail("sorting/ancient.html", "n=sorting/linked2 p=sorting/old");
 check_trail("sorting/linked2.html", "n= p=sorting/ancient");
 
+# If the inline has a limited number of pages, the trail still contains
+# everything.
+$blob = readfile("t/tmp/out/limited.html");
+ok($blob =~ /<a href="(\.\/)?limited\/a.html">a<\/a>/m);
+ok($blob =~ /<a href="(\.\/)?limited\/b.html">b<\/a>/m);
+ok($blob !~ /<a href="(\.\/)?limited\/c.html">/m);
+ok($blob !~ /<a href="(\.\/)?limited\/d.html">/m);
+check_trail("limited/a.html", "n=limited/b p=");
+check_trail("limited/b.html", "n=limited/c p=limited/a");
+check_trail("limited/c.html", "n=limited/d p=limited/b");
+check_trail("limited/d.html", "n= p=limited/c");
+
+check_trail("untrail/a.html", "n=untrail/b p=");
+check_trail("untrail/b.html", "n= p=untrail/a");
+
+$blob = readfile("t/tmp/out/retitled/a.html");
+ok($blob =~ /\^ the old title \^/m);
+
 # Make some changes and refresh. These writefile calls don't set an
 # old mtime, so they're strictly newer than the "old" files.
 
@@ -192,6 +222,16 @@ writefile("sorting.mdwn", "t/tmp/in",
        readfile("t/tmp/in/sorting.mdwn") .
        '[[!trailoptions sort="title" reverse="yes"]]'); 
 
+writefile("retitled.mdwn", "t/tmp/in",
+       '[[!meta title="the new title"]][[!traillink a]]');
+
+# If the inline has a limited number of pages, the trail still depends on
+# everything.
+writefile("limited.html", "t/tmp/out", "[this gets rebuilt]");
+writefile("limited/c.mdwn", "t/tmp/in", '[[!meta title="New C page"]]c');
+
+writefile("untrail.mdwn", "t/tmp/in", "no longer a trail");
+
 ok(! system("$command -refresh"));
 
 check_trail("add/a.html", "n=add/b p=");
@@ -218,4 +258,35 @@ check_trail("sorting/a/b.html", "n=sorting/ancient p=sorting/beginning");
 check_trail("sorting/ancient.html", "n=sorting/z/a p=sorting/a/b");
 check_trail("sorting/z/a.html", "n= p=sorting/ancient");
 
+# If the inline has a limited number of pages, the trail still depends on
+# everything, so it gets rebuilt even though it doesn't strictly need it.
+# This means we could use it as a way to recompute the order of members
+# and the contents of their trail navbars, allowing us to fix the regression
+# described in [[bugs/trail excess dependencies]] without a full content
+# dependency.
+$blob = readfile("t/tmp/out/limited.html");
+ok($blob =~ /<a href="(\.\/)?limited\/a.html">a<\/a>/m);
+ok($blob =~ /<a href="(\.\/)?limited\/b.html">b<\/a>/m);
+ok($blob !~ /<a href="(\.\/)?limited\/c.html">/m);
+ok($blob !~ /<a href="(\.\/)?limited\/d.html">/m);
+check_trail("limited/a.html", "n=limited/b p=");
+check_trail("limited/b.html", "n=limited/c p=limited/a");
+check_trail("limited/c.html", "n=limited/d p=limited/b");
+check_trail("limited/d.html", "n= p=limited/c");
+# Also, b and d should pick up the change to c. This regressed with the
+# change to using a presence dependency.
+$blob = readfile("t/tmp/out/limited/b.html");
+ok($blob =~ /New C page &gt;/m);
+$blob = readfile("t/tmp/out/limited/d.html");
+ok($blob =~ /&lt; New C page/m);
+
+# Members of a retitled trail should pick up that change.
+# This regressed with the change to using a presence dependency.
+$blob = readfile("t/tmp/out/retitled/a.html");
+ok($blob =~ /\^ the new title \^/m);
+
+# untrail is no longer a trail, so these are no longer in it.
+check_no_trail("untrail/a.html");
+check_no_trail("untrail/b.html");
+
 ok(! system("rm -rf t/tmp"));