Merge branch 'master' of ssh://git.ikiwiki.info/srv/git/ikiwiki.info
authorJoey Hess <joey@gnu.kitenet.net>
Sat, 1 Aug 2009 01:06:15 +0000 (21:06 -0400)
committerJoey Hess <joey@gnu.kitenet.net>
Sat, 1 Aug 2009 01:06:15 +0000 (21:06 -0400)
Conflicts:
doc/post-commit/discussion.mdwn

13 files changed:
IkiWiki/Plugin/inline.pm
IkiWiki/Plugin/map.pm
IkiWiki/Plugin/pagestats.pm
IkiWiki/Render.pm
debian/changelog
doc/bugs/map_fails_to_close_ul_element_for_empty_list.mdwn
doc/ikiwiki/directive/inline.mdwn
doc/ikiwiki/directive/pagestats.mdwn
doc/post-commit/discussion.mdwn
doc/todo/backlinks_result_is_lossy.mdwn
doc/todo/inline_plugin:_specifying_ordered_page_names.mdwn
doc/todo/pagestats_among_a_subset_of_pages.mdwn
doc/todo/source_link.mdwn

index 9d5ebc34daaeb6aa942f41b1424ece4ba00c9036..e7d6f250e5cfee1d563bfb40bdf8d541cb7aad1e 100644 (file)
@@ -151,7 +151,7 @@ my %feedlinks;
 sub preprocess_inline (@) {
        my %params=@_;
        
-       if (! exists $params{pages}) {
+       if (! exists $params{pages} && ! exists $params{pagenames}) {
                error gettext("missing pages parameter");
        }
        my $raw=yesno($params{raw});
@@ -183,28 +183,47 @@ sub preprocess_inline (@) {
                $params{template} = $archive ? "archivepage" : "inlinepage";
        }
 
-       my @list=pagespec_match_list(
-               [ grep { $_ ne $params{page} } keys %pagesources ],
-               $params{pages}, location => $params{page});
+       my @list;
 
-       if (exists $params{sort} && $params{sort} eq 'title') {
-               @list=sort { pagetitle(basename($a)) cmp pagetitle(basename($b)) } @list;
-       }
-       elsif (exists $params{sort} && $params{sort} eq 'title_natural') {
-               eval q{use Sort::Naturally};
-               if ($@) {
-                       error(gettext("Sort::Naturally needed for title_natural sort"));
+       if (exists $params{pagenames}) {
+
+               foreach my $p (qw(sort pages)) {
+                       if (exists $params{$p}) {
+                               error sprintf(gettext("the %s and %s parameters cannot be used together"),
+                                       "pagenames", $p);
+                       }
                }
-               @list=sort { Sort::Naturally::ncmp(pagetitle(basename($a)), pagetitle(basename($b))) } @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;
+
+               @list = split ' ', $params{pagenames};
+               my $_;
+               @list = map { bestlink($params{page}, $_) } @list;
+
+               $params{pages} = join(" or ", @list);
        }
        else {
-               error sprintf(gettext("unknown sort type %s"), $params{sort});
+               @list = pagespec_match_list(
+                       [ grep { $_ ne $params{page} } keys %pagesources ],
+                       $params{pages}, location => $params{page});
+
+               if (exists $params{sort} && $params{sort} eq 'title') {
+                       @list=sort { pagetitle(basename($a)) cmp pagetitle(basename($b)) } @list;
+               }
+               elsif (exists $params{sort} && $params{sort} eq 'title_natural') {
+                       eval q{use Sort::Naturally};
+                       if ($@) {
+                               error(gettext("Sort::Naturally needed for title_natural sort"));
+                       }
+                       @list=sort { Sort::Naturally::ncmp(pagetitle(basename($a)), pagetitle(basename($b))) } @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;
+               }
+               else {
+                       error sprintf(gettext("unknown sort type %s"), $params{sort});
+               }
        }
 
        if (yesno($params{reverse})) {
index 120451b5dbde60a26ae165e391cf56232cc30111..826dbbd66ba68dee4401b259c2d3b87ae7e5d1ea 100644 (file)
@@ -80,7 +80,17 @@ sub preprocess (@) {
        my $indent=0;
        my $openli=0;
        my $addparent="";
-       my $map = "<div class='map'>\n<ul>\n";
+       my $map = "<div class='map'>\n";
+
+       # Return empty div if %mapitems is empty
+       if (!scalar(keys %mapitems)) {
+               $map .= "</div>\n";
+               return $map; 
+       } 
+       else { # continue populating $map
+               $map .= "<ul>\n";
+       }
+
        foreach my $item (sort keys %mapitems) {
                my @linktext = (length $mapitems{$item} ? (linktext => $mapitems{$item}) : ());
                $item=~s/^\Q$common_prefix\E\///
index 8ab5d36662ce71716a1733e1a4b5de223c92602b..874ead7e6de669c1d33c66b74984ef90504f9b8e 100644 (file)
@@ -38,13 +38,22 @@ sub preprocess (@) {
        # Needs to update whenever a page is added or removed, so
        # register a dependency.
        add_depends($params{page}, $params{pages});
+       add_depends($params{page}, $params{among}) if exists $params{among};
        
        my %counts;
        my $max = 0;
        foreach my $page (pagespec_match_list([keys %links],
                        $params{pages}, location => $params{page})) {
                use IkiWiki::Render;
-               $counts{$page} = scalar(IkiWiki::backlinks($page));
+
+               my @backlinks = IkiWiki::backlink_pages($page);
+
+               if (exists $params{among}) {
+                       @backlinks = pagespec_match_list(\@backlinks,
+                               $params{among}, location => $params{page});
+               }
+
+               $counts{$page} = scalar(@backlinks);
                $max = $counts{$page} if $counts{$page} > $max;
        }
 
@@ -63,6 +72,8 @@ sub preprocess (@) {
 
                my $res = "<div class='pagecloud'>\n";
                foreach my $page (sort keys %counts) {
+                       next unless $counts{$page} > 0;
+
                        my $class = $classes[$counts{$page} * scalar(@classes) / ($max + 1)];
                        $res .= "<span class=\"$class\">".
                                htmllink($params{page}, $params{destpage}, $page).
index bed9cb777c6505195218d00d09842d29a85785bd..5cb67ea07ec34a4f1eb7b6a3176179fa2d5f182a 100644 (file)
@@ -24,13 +24,19 @@ sub calculate_backlinks () {
        $backlinks_calculated=1;
 }
 
-sub backlinks ($) {
+sub backlink_pages ($) {
        my $page=shift;
 
        calculate_backlinks();
 
+       return keys %{$backlinks{$page}};
+}
+
+sub backlinks ($) {
+       my $page=shift;
+
        my @links;
-       foreach my $p (keys %{$backlinks{$page}}) {
+       foreach my $p (backlink_pages($page)) {
                my $href=urlto($p, $page);
                 
                # Trim common dir prefixes from both pages.
index aa14939600b7bd0a3674b63197ad72ad8685467b..50bb0b9459e1792eb9bc8e45491f436c868bdec5 100644 (file)
@@ -9,6 +9,13 @@ ikiwiki (3.15) UNRELEASED; urgency=low
     the po file, for use by wikis whose primary language is not English.
   * Add Danish basewiki translation by Jonas Smedegaard.
   * img: Fix adding of dependency from page to the image.
+  * pagestats: add `among` parameter, which only counts links from specified
+    pages (smcv)
+  * pagestats: when making a tag cloud, don't emit links where the tag is
+    unused (smcv)
+  * map: Avoid emitting an unclosed ul element if the map is empty. (harishcm)
+  * inline: Add pagenames parameter that can be used to list a set of
+    pages to inline, in a specific order, without using a PageSpec. (smcv)
 
  -- Joey Hess <joeyh@debian.org>  Tue, 02 Jun 2009 17:03:41 -0400
 
index 0a67934aa454404e9820bc463af76c8f3e708146..5e842ca7f98710d94ca387003440b2d17b9899bb 100644 (file)
@@ -68,6 +68,8 @@ Patch:
 
 [[!template id=gitbranch author="[[harishcm]]" branch=smcv/ready/harishcm-map-fix]]
 
+> [[merged|done]] --[[Joey]] 
+
 Patch:
 
     --- /usr/local/share/perl/5.8.8/IkiWiki/Plugin/map.pm
index 8afd65a05e84541fbb13e69a9b870c79579e8d73..9c55e07c2ec95805c51f4fed1b1265ad27b51b6d 100644 (file)
@@ -113,6 +113,11 @@ Here are some less often needed parameters:
   For example, set "feedfile=feed" to cause it to generate `page/feed.atom`
   and/or `page/feed.rss`. This option is not supported if the wiki is
   configured not to use `usedirs`.
+* `pagenames` - If given instead of `pages`, this is interpreted as a
+  space-separated list of links to pages (with the same
+  [[SubPage/LinkingRules]] as in a [[ikiwiki/WikiLink]]), and they are inlined
+  in exactly the order given: the `sort` and `pages` parameters cannot be used
+  in conjunction with this one.
 
 [[!meta robots="noindex, follow"]]
 
index cfb5737a565898bbb31babcfbee8155df38c7ead..426f3e4afdf6aeda4fb782812555ead457b3a3e1 100644 (file)
@@ -12,4 +12,14 @@ And here's how to create a table of all the pages on the wiki:
 
        \[[!pagestats style="table"]]
 
+The optional `among` parameter limits counting to pages that match a
+[[ikiwiki/PageSpec]]. For instance, to display a cloud of tags used on blog
+entries, you could use:
+
+       \[[!pagestats pages="tags/*" among="blog/posts/*"]]
+
+or to display a cloud of tags related to Linux, you could use:
+
+       \[[!pagestats pages="tags/* and not tags/linux" among="tagged(linux)"]]
+
 [[!meta robots="noindex, follow"]]
index 52642c36bb580a1b255a0e496d41ffb4c4fc970c..6ae0d9bcb3889d0bf4b7d97f2369f3701be5022c 100644 (file)
@@ -48,19 +48,71 @@ Thanks
 
 -----
 
-I'm working on an [[rcs]] plugin for CVS, adapted from `svn.pm`, in order to integrate ikiwiki at sites where that's all they've got. What's working so far: web commit (post-commit hook and all), diff, add (under certain conditions), and remove. What's not working: with rcs_add(), iff any of the new page's parent dirs aren't already under CVS control and the post-commit hook is enabled, the browser and ikiwiki stall for several seconds trying to add it, then time out. (If I kill ikiwiki when this is happening, it cvs adds the topmost parent that needed adding; if I wait for timeout, it doesn't. I think.) If I disable the post-commit hook and do the same kind of thing, the page is created and saved.
-
-In case you're lucky enough not to know, cvs adds on directories are weird -- they operate immediately against the repository, unlike file adds:
+I'm working on an [[rcs]] plugin for CVS, adapted from `svn.pm`, in order
+to integrate ikiwiki at sites where that's all they've got. What's working
+so far: web commit (post-commit hook and all), diff, add (under certain
+conditions), and remove. What's not working: with rcs_add(), iff any of the
+new page's parent dirs aren't already under CVS control and the post-commit
+hook is enabled, the browser and ikiwiki stall for several seconds trying
+to add it, then time out. (If I kill ikiwiki when this is happening, it cvs
+adds the topmost parent that needed adding; if I wait for timeout, it
+doesn't. I think.) If I disable the post-commit hook and do the same kind
+of thing, the page is created and saved.
+
+In case you're lucky enough not to know, cvs adds on directories are weird
+-- they operate immediately against the repository, unlike file adds:
 
     $ cvs add randomdir
     Directory /Users/schmonz/Documents/cvswiki/repository/ikiwiki/randomdir added to the repository
 
-I was able to work out that when I'm seeing this page save misbehavior, my plugin is somewhere inside `system("cvs", "-Q", "add", "$file")`, which was never returning. If I changed it to anything other than cvs it iterated correctly over all the parent dirs which needed to be added to CVS, in the proper order. (cvs add isn't recursive, sadly.)
+I was able to work out that when I'm seeing this page save misbehavior, my
+plugin is somewhere inside `system("cvs", "-Q", "add", "$file")`, which was
+never returning. If I changed it to anything other than cvs it iterated
+correctly over all the parent dirs which needed to be added to CVS, in the
+proper order. (cvs add isn't recursive, sadly.)
 
 Can you offer an educated guess what's going wrong here? --[[Schmonz]]
 
 > Got `rcs_recentchanges` working, believe it or not, thanks to [cvsps](http://www.cobite.com/cvsps/). If I can figure out this interaction between the post-commit hook and `cvs add` on directories, the CVS plugin is mostly done. Could it be a locking issue? Where should I be looking? Any suggestions appreciated. --[[Schmonz]]
 
->> Okay, it is definitely a locking issue. First, on the conjecture that `cvs add <directory>` was triggering the post-commit hook and confusing ikiwiki, I wrapped the ikiwiki post-commit binary with a shell script that exited 0 if the triggering file was a directory. The first half of the conjecture was correct -- my wrapper got triggered -- but the web add of `one/two/three.mdwn` (where `one` and `two` weren't existing CVS-controlled dirs) remained hung as before. There were two ikiwiki processes running. On a whim, I killed the one with the higher PID; `cvs add one` immediately completed successfully, then back to a hang and two ikiwiki processes. I killed the newer one again and then `cvs add one/two` and `cvs add one/two/three.mdwn` completed and the web add was successful. --[[Schmonz]]
+>> Okay, it is definitely a locking issue. First, on the conjecture that
+>> `cvs add <directory>` was triggering the post-commit hook and confusing
+>> ikiwiki, I wrapped the ikiwiki post-commit binary with a shell script
+>> that exited 0 if the triggering file was a directory. The first half of
+>> the conjecture was correct -- my wrapper got triggered -- but the web
+>> add of `one/two/three.mdwn` (where `one` and `two` weren't existing
+>> CVS-controlled dirs) remained hung as before. There were two ikiwiki
+>> processes running. On a whim, I killed the one with the higher PID; `cvs
+>> add one` immediately completed successfully, then back to a hang and two
+>> ikiwiki processes. I killed the newer one again and then `cvs add
+>> one/two` and `cvs add one/two/three.mdwn` completed and the web add was
+>> successful. --[[Schmonz]]
+
+>>> Aaaaaand I was wrong about the second half of the conjecture being
+>>> wrong. The wrapper script wasn't correctly identifying directories;
+>>> with that fixed, everything works. I've created a
+>>> [[plugins/contrib/cvs]] plugin page. Thanks for listening. :-)
+>>> --[[Schmonz]]
+
+>> Here is a comment I committed to my laptop from Madrid Airport before
+>> your most recent updates, in case it's still useful:
+>>
+>> Locking certianly seems likely to be a problem. ikiwiki calls `rcs_add`
+>> *before* disabling the post-commit plugin, since all over VCS allow
+>> adding something in a staged manner. You can see this in, for example,
+>> `editpage.pm` lines 391+.
+>> 
+>> So I guess what happens is that ikiwiki has taken the wiki lock, calls
+>> `rcs_add`, which does a `cvs add`, which runs the post commit hook,
+>> since it is not disabled -- which blocks waiting for the wiki lock.
+>>
+>> I guess you can fix this in either of three ways: Modify lots of places
+>> in ikiwiki to disable the post commit hook before calling `rcs_add`,
+>> or make cvs's `rcs_add` temporarily disable the commit hook and
+>> re-enable it (but only if it was not already disabled, somehow),
+>> or make cvs's `rcs_add` only make note that it needs to call `cvs add`
+>> later, and do so at `rcs_commit`. The last of these seems easist,
+>> especially since ikiwiki always commits after an add, in the same
+>> process, so you could just use a temporary list of things to add.
+>> --[[Joey]] 
 
->>> Aaaaaand I was wrong about the second half of the conjecture being wrong. The wrapper script wasn't correctly identifying directories; with that fixed, everything works. I've created a [[plugins/contrib/cvs]] plugin page. Thanks for listening. :-) --[[Schmonz]]
index 02e5b244037c36af3ce38c1f9ad15cac801b5a55..11b5fbcaeb8e41db3ebebf049366b3076c033e66 100644 (file)
@@ -9,3 +9,5 @@ A commit on my `among` branch splits it into IkiWiki::backlink_pages
 (which returns the keys of $backlinks{$page}, and might be suitable for
 exporting) and IkiWiki::backlinks (which calls backlink_pages, then performs
 the same lossy transformation as before on the result).
+
+[[done]] --[[Joey]]
index 457b4788437673e7e7a934f797389c1f9c6914a5..bbde04f838d7c7091f835421d99a294107d916f9 100644 (file)
@@ -14,3 +14,8 @@ uses it internally (as it has already collected the pages in order). It could al
 be useful for other things, like [[todo/wikitrails]]. --[[smcv]]
 
 [[!tag plugins/inline]]
+
+> It's sort of a pity that a pagespec like "a or b or c" doesn't somehow
+> match to (a, b, c) in that order, but I don't see how that would be
+> generally possible. While this feels a bit like bloat and inline already
+> has far too many parameters, I have [[merged|done]] it. --[[Joey]] 
index 446e5cc1b54f683e4e2c4f736c730ba9335925b4..fd15d6a4224b869a6af4fc325486f42cc9050d65 100644 (file)
@@ -25,3 +25,5 @@ I use this on my tag pages on one site, with the following template:
       archive="yes" quick="yes" reverse="yes" timeformat="%x"]]
 
 --[[smcv]]
+
+> [[merged|done]] thanks --[[Joey]] 
index 813e061eb7a65b3242423418d2f5298d1bee842b..ce8c9d1719b74bce453cbad2d1cbaddb4357edc2 100644 (file)
@@ -24,6 +24,9 @@ I just implemented this.  There is one [[patch]] to the default page template, a
 >>
 >> --[[smcv]]
 
+>>> I need a copyright&license statement, so debian/copyright can be updated for
+>>> the plugin, before I can merge this. Otherwise ready. --[[Joey]]
+
 >>> That looks like a nice set of fixes.  One more that might be worthwhile: instead of reading the page source into a var, and then writing it out later, it might be nice to just
 >>>  `print readfile(srcfile(pagesources{$page}));` at the appropriate point. -- [[Will]]