]> sipb.mit.edu Git - ikiwiki.git/commitdiff
* Fix link() PageSpecs to not just look at the raw link text, but at where
authorjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Wed, 21 Mar 2007 23:11:09 +0000 (23:11 +0000)
committerjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Wed, 21 Mar 2007 23:11:09 +0000 (23:11 +0000)
  that given link points based on the page doing the linking. Note that this
  could make such PageSpecs match different things than before, if you
  relied on the old behavior of them only matching the raw link text.
* This required changing the match_* interface, adding a third parameter.
* Allow link() PageSpecs to match relative, as is allowed with globs.a
* Add postform option to inline plugin.
* Add an bug tracker to the softwaresite example.

12 files changed:
IkiWiki.pm
IkiWiki/Plugin/conditional.pm
IkiWiki/Plugin/inline.pm
debian/changelog
doc/examples/softwaresite/bugs.mdwn [new file with mode: 0644]
doc/examples/softwaresite/bugs/done.mdwn [new file with mode: 0644]
doc/examples/softwaresite/bugs/fails_to_frobnicate.mdwn [new file with mode: 0644]
doc/examples/softwaresite/index.mdwn
doc/plugins/inline.mdwn
doc/plugins/write.mdwn
po/ikiwiki.pot
t/pagespec_match.t

index 9e71cc153c4aaaad37328bb3eb74b947d2084ae8..2d0f3c38333c7574c9ceb251ee58321eb8580acd 100644 (file)
@@ -921,7 +921,7 @@ sub pagespec_translate ($) { #{{{
                }
                elsif ($word =~ /^(\w+)\((.*)\)$/) {
                        if (exists $IkiWiki::PageSpec::{"match_$1"}) {
-                               $code.=" IkiWiki::PageSpec::match_$1(\$page, ".safequote($2).")";
+                               $code.="IkiWiki::PageSpec::match_$1(\$page, ".safequote($2).", \$from)";
                        }
                        else {
                                $code.=" 0";
@@ -968,22 +968,35 @@ sub match_glob ($$$) { #{{{
        return $page=~/^$glob$/i;
 } #}}}
 
-sub match_link ($$) { #{{{
+sub match_link ($$$) { #{{{
        my $page=shift;
        my $link=lc(shift);
+       my $from=shift;
+       if (! defined $from){
+               $from = "";
+       }
+
+       # relative matching
+       if ($link =~ m!^\.! && defined $from) {
+               $from=~s!/?[^/]+$!!;
+               $link=~s!^\./!!;
+               $link="$from/$link" if length $from;
+       }
 
        my $links = $IkiWiki::links{$page} or return undef;
+       return 0 unless @$links;
+       my $bestlink = IkiWiki::bestlink($from, $link);
        foreach my $p (@$links) {
-               return 1 if lc $p eq $link;
+               return 1 if $bestlink eq IkiWiki::bestlink($page, $p);
        }
        return 0;
 } #}}}
 
-sub match_backlink ($$) { #{{{
-       match_link(pop, pop);
+sub match_backlink ($$$) { #{{{
+       match_link($_[1], $_[0], $_[3]);
 } #}}}
 
-sub match_created_before ($$) { #{{{
+sub match_created_before ($$$) { #{{{
        my $page=shift;
        my $testpage=shift;
 
@@ -995,7 +1008,7 @@ sub match_created_before ($$) { #{{{
        }
 } #}}}
 
-sub match_created_after ($$) { #{{{
+sub match_created_after ($$$) { #{{{
        my $page=shift;
        my $testpage=shift;
 
@@ -1007,15 +1020,15 @@ sub match_created_after ($$) { #{{{
        }
 } #}}}
 
-sub match_creation_day ($$) { #{{{
+sub match_creation_day ($$$) { #{{{
        return ((gmtime($IkiWiki::pagectime{shift()}))[3] == shift);
 } #}}}
 
-sub match_creation_month ($$) { #{{{
+sub match_creation_month ($$$) { #{{{
        return ((gmtime($IkiWiki::pagectime{shift()}))[4] + 1 == shift);
 } #}}}
 
-sub match_creation_year ($$) { #{{{
+sub match_creation_year ($$$) { #{{{
        return ((gmtime($IkiWiki::pagectime{shift()}))[5] + 1900 == shift);
 } #}}}
 
index ed533109ac113fc5bba4836258ee1bb6bac29cd0..22057c1359f6cf90800d0f60130024167ded1567 100644 (file)
@@ -28,7 +28,7 @@ sub preprocess_if (@) { #{{{
        # tests.
        if ($params{test} =~ /^(enabled|sourcepage|destpage)\((.*)\)$/) {
                $result=eval "IkiWiki::PageSpec::match_$1(undef, ".
-                       IkiWiki::safequote($2).")";
+                       IkiWiki::safequote($2).", \$params{page})";
        }
        else {
                add_depends($params{page}, $params{test});
@@ -59,7 +59,7 @@ sub preprocess_if (@) { #{{{
 
 package IkiWiki::PageSpec;
 
-sub match_enabled ($$) { #{{{
+sub match_enabled ($$$) { #{{{
        shift;
        my $plugin=shift;
        
@@ -67,7 +67,7 @@ sub match_enabled ($$) { #{{{
        return UNIVERSAL::can("IkiWiki::Plugin::".$plugin, "import");
 } #}}}
 
-sub match_sourcepage ($$) { #{{{
+sub match_sourcepage ($$$) { #{{{
        shift;
        my $glob=shift;
        
@@ -75,7 +75,7 @@ sub match_sourcepage ($$) { #{{{
                $IkiWiki::Plugin::conditional::sourcepage);
 } #}}}
 
-sub match_destpage ($$) { #{{{
+sub match_destpage ($$$) { #{{{
        shift;
        my $glob=shift;
        
@@ -83,7 +83,7 @@ sub match_destpage ($$) { #{{{
                $IkiWiki::Plugin::conditional::sourcepage);
 } #}}}
 
-sub match_included ($$) { #{{{
+sub match_included ($$$) { #{{{
        return $IkiWiki::Plugin::conditional::sourcepage ne $IkiWiki::Plugin::conditional::destpage;
 } #}}}
 
index 4dbf9f159605aeaccd0e9379061e6a06c2e3a1a1..3a2e0a05f340362ffc29f2dabfdfa3605dbe7500 100644 (file)
@@ -121,11 +121,13 @@ sub preprocess_inline (@) { #{{{
        my $atomurl=atompage(basename($params{page}));
        my $ret="";
 
-       if (exists $params{rootpage} && $config{cgiurl}) {
+       if ($config{cgiurl} && (exists $params{rootpage} ||
+                       (exists $params{postform} && yesno($params{postform})))) {
                # Add a blog post form, with feed buttons.
                my $formtemplate=template("blogpost.tmpl", blind_cache => 1);
                $formtemplate->param(cgiurl => $config{cgiurl});
-               $formtemplate->param(rootpage => $params{rootpage});
+               $formtemplate->param(rootpage => 
+                       exists $params{rootpage} ? $params{rootpage} : $params{page});
                $formtemplate->param(rssurl => $rssurl) if $feeds && $rss;
                $formtemplate->param(atomurl => $atomurl) if $feeds && $atom;
                $ret.=$formtemplate->output;
index 8ad4ab502a1cbb8c4c7c96a7f6f6dbad5ff3c52a..0e0c76a9b02c214c679eb07caa75163bf6d0168c 100644 (file)
@@ -1,3 +1,16 @@
+ikiwiki (1.48) UNRELEASED; urgency=low
+
+  * Fix link() PageSpecs to not just look at the raw link text, but at where
+    that given link points based on the page doing the linking. Note that this
+    could make such PageSpecs match different things than before, if you
+    relied on the old behavior of them only matching the raw link text.
+  * This required changing the match_* interface, adding a third parameter.
+  * Allow link() PageSpecs to match relative, as is allowed with globs.a
+  * Add postform option to inline plugin.
+  * Add an bug tracker to the softwaresite example.
+
+ -- Joey Hess <joeyh@debian.org>  Wed, 21 Mar 2007 16:58:00 -0400
+
 ikiwiki (1.47) unstable; urgency=low
 
   * Fix a security hole that allowed insertion of unsafe content via the meta
diff --git a/doc/examples/softwaresite/bugs.mdwn b/doc/examples/softwaresite/bugs.mdwn
new file mode 100644 (file)
index 0000000..ad8d6cd
--- /dev/null
@@ -0,0 +1,4 @@
+This is FooBar's bug list. Link bugs to [[bugs/done]] when done.
+
+[[inline pages="./bugs/* and !./bugs/done and !link(done) 
+and !*/Discussion" actions=yes postform=yes show=0]]
diff --git a/doc/examples/softwaresite/bugs/done.mdwn b/doc/examples/softwaresite/bugs/done.mdwn
new file mode 100644 (file)
index 0000000..ad81dea
--- /dev/null
@@ -0,0 +1,3 @@
+recently fixed [[bugs]]
+
+[[inline pages="./* and link(./done) and !*/Discussion" show=10]]
diff --git a/doc/examples/softwaresite/bugs/fails_to_frobnicate.mdwn b/doc/examples/softwaresite/bugs/fails_to_frobnicate.mdwn
new file mode 100644 (file)
index 0000000..89353f0
--- /dev/null
@@ -0,0 +1,4 @@
+FooBar, when used with the `--frob` option, fails to properly forbnicate
+output.
+
+> This is fixed in [[news/version_1.0]]; marking this bug [[done]].
index 983426178dabfb39710d9e9a05f4d6596fe60b08..e2d180d1fc1b609c28dba237ddda74c29776a9b3 100644 (file)
@@ -4,6 +4,7 @@ your example program needs. This is its wiki.
 * [[download]]
 * [[news]]
 * [[documentation|doc]]
+* [[bugs]]
 * [[contact]]
 
 ----
index b7cf629da98c68cfdf2043b9b336c7ed4555f6eb..f3af08abf44586192b6ae4f1b91d19611fb44c90 100644 (file)
@@ -29,7 +29,9 @@ directive:
   configured to use atom feeds, set to "no" to disable.
 * `feeds` - controls generation of all types of feeds. Set to "no" to
   disable generating any feeds.
-* `rootpage` - Enables a form to post new pages to a [[blog]].
+* `postform` - Set to "yes" to enables a form to post new pages to a [[blog]].
+* `rootpage` - Also enables a form to post new pages to a [[blog]], and
+  allows specifying of a page that is used as the parent page for new pages.
 * `archive` - If set to "yes", only list page titles and some metadata, not
   full controls.
 * `quick` - Build archives in quick mode, without reading page contents for
index 5547ae6999d5a70de49f01b70c2f650bc7396ebd..be5f8692484b710e8e94b47bfbbd5903a38c9591 100644 (file)
@@ -431,6 +431,7 @@ See [[about_RCS_backends]] for some more info.
 It's also possible to write plugins that add new functions to
 [[PageSpecs|PageSpec]]. Such a plugin should add a function to the
 IkiWiki::PageSpec package, that is named `match_foo`, where "foo()" is
-how it will be accessed in a [[PageSpec]]. The function will be passed two
-parameters: The name of the page being matched, and the thing to match
-against. It should return true if the page matches.
+how it will be accessed in a [[PageSpec]]. The function will be passed
+three parameters: The name of the page being matched, the thing to match
+against, and the page that the matching is occuring on. It should return
+true if the page matches.
index a114b880d25ac3c0206cf32ff501582de1587086..23a15155566838cd58803c1eefba277321b80aa2 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 15:14-0400\n"
+"POT-Creation-Date: 2007-03-21 18:59-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:172 ../IkiWiki/Plugin/opendiscussion.pm:17
+#: ../IkiWiki/Plugin/inline.pm:174 ../IkiWiki/Plugin/opendiscussion.pm:17
 #: ../IkiWiki/Plugin/orphans.pm:28 ../IkiWiki/Render.pm:97
 #: ../IkiWiki/Render.pm:165
 msgid "discussion"
@@ -152,16 +152,16 @@ msgstr ""
 msgid "unknown sort type %s"
 msgstr ""
 
-#: ../IkiWiki/Plugin/inline.pm:143
+#: ../IkiWiki/Plugin/inline.pm:145
 #, perl-format
 msgid "nonexistant template %s"
 msgstr ""
 
-#: ../IkiWiki/Plugin/inline.pm:180 ../IkiWiki/Render.pm:101
+#: ../IkiWiki/Plugin/inline.pm:182 ../IkiWiki/Render.pm:101
 msgid "Discussion"
 msgstr ""
 
-#: ../IkiWiki/Plugin/inline.pm:395
+#: ../IkiWiki/Plugin/inline.pm:397
 msgid "RPC::XML::Client not found, not pinging"
 msgstr ""
 
index 63c2a50987e5aced61375b4499b2b1c7abff1bc9..09e9582d16a655c61911300c5e3074671a718ff1 100755 (executable)
@@ -1,7 +1,7 @@
 #!/usr/bin/perl
 use warnings;
 use strict;
-use Test::More tests => 42;
+use Test::More tests => 46;
 
 BEGIN { use_ok("IkiWiki"); }
 
@@ -25,11 +25,28 @@ ok(pagespec_match("a/b/foo", "./*", "a/b"), "relative 2");
 ok(pagespec_match("foo", "./*", "a"), "relative toplevel");
 ok(pagespec_match("foo/bar", "*", "baz"), "absolute");
 
+# The link and backlink stuff needs this.
+$config{userdir}="";
 $links{foo}=[qw{bar baz}];
-ok(pagespec_match("foo", "link(bar)", ""));
-ok(! pagespec_match("foo", "link(quux)", ""));
-ok(pagespec_match("bar", "backlink(foo)", ""));
-ok(! pagespec_match("quux", "backlink(foo)", ""));
+$links{bar}=[];
+$links{baz}=[];
+$links{"bugs/foo"}=[qw{bugs/done}];
+$links{"bugs/done"}=[];
+$links{"bugs/bar"}=[qw{done}];
+$links{"done"}=[];
+$links{"examples/softwaresite/bugs/fails_to_frobnicate"}=[qw{done}];
+$links{"examples/softwaresite/bugs/done"}=[];
+
+ok(pagespec_match("foo", "link(bar)", ""), "link");
+ok(! pagespec_match("foo", "link(quux)", ""), "failed link");
+ok(pagespec_match("bugs/foo", "link(done)", "bugs/done"), "link match to bestlink");
+ok(! pagespec_match("examples/softwaresite/bugs/done", "link(done)", 
+               "bugs/done"), "link match to bestlink");
+ok(pagespec_match("examples/softwaresite/bugs/fails_to_frobnicate", 
+               "link(./done)", "examples/softwaresite/bugs/done"), "link relative");
+ok(! pagespec_match("foo", "link(./bar)", "foo/bar"), "link relative fail");
+ok(pagespec_match("bar", "backlink(foo)", ""), "backlink");
+ok(! pagespec_match("quux", "backlink(foo)", ""), "failed backlink");
 
 $IkiWiki::pagectime{foo}=1154532692; # Wed Aug  2 11:26 EDT 2006
 $IkiWiki::pagectime{bar}=1154532695; # after