aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>2007-03-21 23:11:09 +0000
committerjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>2007-03-21 23:11:09 +0000
commit2a0d91af2f8f6ca3142c8f73ea6869e7a914bb30 (patch)
treed4c7c3dae158e8603cd1a3c01fd8784ef478ba2e
parent0daec2bf14871072a4b3d3aebbbfc5eaa7608ef5 (diff)
downloadikiwiki-2a0d91af2f8f6ca3142c8f73ea6869e7a914bb30.tar
ikiwiki-2a0d91af2f8f6ca3142c8f73ea6869e7a914bb30.tar.gz
* 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.
-rw-r--r--IkiWiki.pm33
-rw-r--r--IkiWiki/Plugin/conditional.pm10
-rw-r--r--IkiWiki/Plugin/inline.pm6
-rw-r--r--debian/changelog13
-rw-r--r--doc/examples/softwaresite/bugs.mdwn4
-rw-r--r--doc/examples/softwaresite/bugs/done.mdwn3
-rw-r--r--doc/examples/softwaresite/bugs/fails_to_frobnicate.mdwn4
-rw-r--r--doc/examples/softwaresite/index.mdwn1
-rw-r--r--doc/plugins/inline.mdwn4
-rw-r--r--doc/plugins/write.mdwn7
-rw-r--r--po/ikiwiki.pot10
-rwxr-xr-xt/pagespec_match.t27
12 files changed, 91 insertions, 31 deletions
diff --git a/IkiWiki.pm b/IkiWiki.pm
index 9e71cc153..2d0f3c383 100644
--- a/IkiWiki.pm
+++ b/IkiWiki.pm
@@ -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);
} #}}}
diff --git a/IkiWiki/Plugin/conditional.pm b/IkiWiki/Plugin/conditional.pm
index ed533109a..22057c135 100644
--- a/IkiWiki/Plugin/conditional.pm
+++ b/IkiWiki/Plugin/conditional.pm
@@ -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;
} #}}}
diff --git a/IkiWiki/Plugin/inline.pm b/IkiWiki/Plugin/inline.pm
index 4dbf9f159..3a2e0a05f 100644
--- a/IkiWiki/Plugin/inline.pm
+++ b/IkiWiki/Plugin/inline.pm
@@ -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;
diff --git a/debian/changelog b/debian/changelog
index 8ad4ab502..0e0c76a9b 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -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
index 000000000..ad8d6cdb4
--- /dev/null
+++ b/doc/examples/softwaresite/bugs.mdwn
@@ -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
index 000000000..ad81deaac
--- /dev/null
+++ b/doc/examples/softwaresite/bugs/done.mdwn
@@ -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
index 000000000..89353f010
--- /dev/null
+++ b/doc/examples/softwaresite/bugs/fails_to_frobnicate.mdwn
@@ -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]].
diff --git a/doc/examples/softwaresite/index.mdwn b/doc/examples/softwaresite/index.mdwn
index 983426178..e2d180d1f 100644
--- a/doc/examples/softwaresite/index.mdwn
+++ b/doc/examples/softwaresite/index.mdwn
@@ -4,6 +4,7 @@ your example program needs. This is its wiki.
* [[download]]
* [[news]]
* [[documentation|doc]]
+* [[bugs]]
* [[contact]]
----
diff --git a/doc/plugins/inline.mdwn b/doc/plugins/inline.mdwn
index b7cf629da..f3af08abf 100644
--- a/doc/plugins/inline.mdwn
+++ b/doc/plugins/inline.mdwn
@@ -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
diff --git a/doc/plugins/write.mdwn b/doc/plugins/write.mdwn
index 5547ae699..be5f86924 100644
--- a/doc/plugins/write.mdwn
+++ b/doc/plugins/write.mdwn
@@ -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.
diff --git a/po/ikiwiki.pot b/po/ikiwiki.pot
index a114b880d..23a151555 100644
--- a/po/ikiwiki.pot
+++ b/po/ikiwiki.pot
@@ -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 ""
diff --git a/t/pagespec_match.t b/t/pagespec_match.t
index 63c2a5098..09e9582d1 100755
--- a/t/pagespec_match.t
+++ b/t/pagespec_match.t
@@ -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