From 7f80e52543891690e3136855bc29917e6b431aba Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 9 Nov 2008 15:31:57 -0500 Subject: Fix the link() pagespec to match links that are internally recorded as absolute. This fixes a problem exposed by the recent change to tags (a2839de9362187b67b0e3a564461e272e64fd9b4). That recorded tag links as absolute by including a leading slash in the link. The same could also be done with an absolute wikilink. In either case, link() would not match such links, unless the leading slash was included in the link to match. But that's not right, because pagespecs match absolute by default. So strip the leading slash. Note that to keep any existing `link(/foo)` pagespecs working after this change, the leading slash is removed from there, too. --- t/pagespec_match.t | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 't/pagespec_match.t') diff --git a/t/pagespec_match.t b/t/pagespec_match.t index c61d16122..7c0ac235b 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 => 56; +use Test::More tests => 58; BEGIN { use_ok("IkiWiki"); } @@ -40,6 +40,7 @@ $links{"bugs/bar"}=[qw{done}]; $links{"done"}=[]; $links{"examples/softwaresite/bugs/fails_to_frobnicate"}=[qw{done}]; $links{"examples/softwaresite/bugs/done"}=[]; +$links{"ook"}=[qw{/blog/tags/foo}]; ok(pagespec_match("foo", "link(bar)"), "link"); ok(pagespec_match("foo", "link(ba?)"), "glob link"); @@ -55,6 +56,8 @@ ok(pagespec_match("bar", "backlink(foo)"), "backlink"); ok(! pagespec_match("quux", "backlink(foo)"), "failed backlink"); ok(! pagespec_match("bar", ""), "empty pagespec should match nothing"); ok(! pagespec_match("bar", " "), "blank pagespec should match nothing"); +ok(pagespec_match("ook", "link(blog/tags/foo)"), "link internal absolute success"); +ok(pagespec_match("ook", "link(/blog/tags/foo)"), "link explicit absolute success"); $IkiWiki::pagectime{foo}=1154532692; # Wed Aug 2 11:26 EDT 2006 $IkiWiki::pagectime{bar}=1154532695; # after -- cgit v1.2.3 From c07a95ed8ecb84a2e7018c93c3d031f03bd25926 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 23 Dec 2008 17:11:04 -0500 Subject: remove globlist support No transition code implemented, but I will probably make a 2.x release that warns about found globlists. --- IkiWiki.pm | 45 -------------------------------------------- doc/ikiwiki/pagespec.mdwn | 19 ------------------- doc/plugins/contrib.mdwn | 2 +- doc/tips/upgrade_to_3.0.mdwn | 17 +++++++++++++++++ t/pagespec_match.t | 11 +---------- t/pagespec_merge.t | 12 ++++++------ 6 files changed, 25 insertions(+), 81 deletions(-) (limited to 't/pagespec_match.t') diff --git a/IkiWiki.pm b/IkiWiki.pm index 759bfbc65..f6adb360a 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -1596,37 +1596,6 @@ sub rcs_receive () { $hooks{rcs}{rcs_receive}{call}->(); } -sub globlist_to_pagespec ($) { - my @globlist=split(' ', shift); - - my (@spec, @skip); - foreach my $glob (@globlist) { - if ($glob=~/^!(.*)/) { - push @skip, $glob; - } - else { - push @spec, $glob; - } - } - - my $spec=join(' or ', @spec); - if (@skip) { - my $skip=join(' and ', @skip); - if (length $spec) { - $spec="$skip and ($spec)"; - } - else { - $spec=$skip; - } - } - return $spec; -} - -sub is_globlist ($) { - my $s=shift; - return ( $s =~ /[^\s]+\s+([^\s]+)/ && $1 ne "and" && $1 ne "or" ); -} - sub safequote ($) { my $s=shift; $s=~s/[{}]//g; @@ -1718,26 +1687,12 @@ sub pagespec_merge ($$) { my $b=shift; return $a if $a eq $b; - - # Support for old-style GlobLists. - if (is_globlist($a)) { - $a=globlist_to_pagespec($a); - } - if (is_globlist($b)) { - $b=globlist_to_pagespec($b); - } - return "($a) or ($b)"; } sub pagespec_translate ($) { my $spec=shift; - # Support for old-style GlobLists. - if (is_globlist($spec)) { - $spec=globlist_to_pagespec($spec); - } - # Convert spec to perl code. my $code=""; while ($spec=~m{ diff --git a/doc/ikiwiki/pagespec.mdwn b/doc/ikiwiki/pagespec.mdwn index d4dd265cc..86abe5745 100644 --- a/doc/ikiwiki/pagespec.mdwn +++ b/doc/ikiwiki/pagespec.mdwn @@ -72,22 +72,3 @@ filenames of the pages in the wiki, so a pagespec "foo" used on page "a/b" will not match a page named "a/foo" or "a/b/foo". To match relative to the directory of the page containing the pagespec, you can use "./". For example, "./foo" on page "a/b" matches page "a/foo". - -## Old syntax - -The old PageSpec syntax was called a "GlobList", and worked differently in -two ways: - -1. "and" and "or" were not used; any page matching any item from the list - matched. -2. If an item was prefixed with "`!`", then no page matching that item - matched, even if it matched an earlier list item. - -For example, here is the old way to match all pages except for the SandBox -and Discussion pages: - - * !SandBox !*/Discussion - -Using this old syntax is still supported. However, the old syntax is -deprecated and will be removed at some point, and using the new syntax is -recommended. diff --git a/doc/plugins/contrib.mdwn b/doc/plugins/contrib.mdwn index 7a28edaba..e22b13f71 100644 --- a/doc/plugins/contrib.mdwn +++ b/doc/plugins/contrib.mdwn @@ -2,6 +2,6 @@ Contributed [[plugins]]: (See [[install]] for installation help.) -[[!inline pages="plugins/contrib/* !*/Discussion" +[[!inline pages="plugins/contrib/* and !*/Discussion" feedpages="created_after(plugins/contrib/navbar)" archive="yes" rootpage="plugins/contrib" postformtext="Add a new plugin named:" show=0]] diff --git a/doc/tips/upgrade_to_3.0.mdwn b/doc/tips/upgrade_to_3.0.mdwn index 6c74d4fc9..bd47e96e5 100644 --- a/doc/tips/upgrade_to_3.0.mdwn +++ b/doc/tips/upgrade_to_3.0.mdwn @@ -49,6 +49,23 @@ Be sure to modify the find to list all pages in the wiki if you're using other markup than markdown. You will probably want to commit the changes when you're done too. +## GlobLists + +In 3.0, the old "GlobList" syntax for [[PageSpecs|ikiwiki/PageSpec]] is no +longer supported. A GlobList contains multiple term, but does not separate +them with "and" or "or": + + sandbox !*/Discussion + +To convert this to a modern PageSpec, simply add "and" or "or" as +appropriate between terms: + + sandbox and !*/Discussion + +GlobLists have been deprecated for more than two years. If your wiki dates +to the ikiwiki 1.0 era, you should check it for any that might have lurked +unnoticed in it since back then. + ## aggregateinternal If your wiki uses the [[aggregate|plugins/aggregate]] plugin, it will start diff --git a/t/pagespec_match.t b/t/pagespec_match.t index 7c0ac235b..69cf361de 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 => 58; +use Test::More tests => 51; BEGIN { use_ok("IkiWiki"); } @@ -77,12 +77,3 @@ ok(! pagespec_match("foo", "no_such_function(foo)"), "foo"); my $ret=pagespec_match("foo", "(invalid"); ok(! $ret, "syntax error"); ok($ret =~ /syntax error/, "error message"); - -# old style globlists -ok(pagespec_match("foo", "foo bar"), "simple list"); -ok(pagespec_match("bar", "foo bar"), "simple list 2"); -ok(pagespec_match("foo", "f?? !foz")); -ok(! pagespec_match("foo", "f?? !foo")); -ok(! pagespec_match("foo", "* !foo")); -ok(! pagespec_match("foo", "foo !foo")); -ok(! pagespec_match("foo.png", "* !*.*")); diff --git a/t/pagespec_merge.t b/t/pagespec_merge.t index cbb06219c..9e38d5761 100755 --- a/t/pagespec_merge.t +++ b/t/pagespec_merge.t @@ -28,17 +28,17 @@ ok(same("!foo", "!bar", "foo"), "double inversion failed match"); ok(same("!foo", "!bar", "bar"), "double inversion failed match 2"); ok(same("*", "!bar", "foo"), "glob+inversion match"); ok(same("*", "!bar", "bar"), "matching glob and matching inversion"); -ok(same("* !foo", "!bar", "bar"), "matching glob and matching inversion"); -ok(same("* !foo", "!bar", "foo"), "matching glob with matching inversion and non-matching inversion"); -ok(same("* !foo", "!foo", "foo"), "matching glob with matching inversion and matching inversion"); +ok(same("* and !foo", "!bar", "bar"), "matching glob and matching inversion"); +ok(same("* and !foo", "!bar", "foo"), "matching glob with matching inversion and non-matching inversion"); +ok(same("* and !foo", "!foo", "foo"), "matching glob with matching inversion and matching inversion"); ok(same("b??", "!b??", "bar"), "matching glob and matching inverted glob"); ok(same("f?? !f??", "!bar", "bar"), "matching glob and matching inverted glob"); ok(same("b??", "!b?z", "bar"), "matching glob and non-matching inverted glob"); ok(same("f?? !f?z", "!bar", "bar"), "matching glob and non-matching inverted glob"); ok(same("!foo bar baz", "!bar", "bar"), "matching list and matching inversion"); ok(pagespec_match("foo/Discussion", - IkiWiki::pagespec_merge("* !*/Discussion", "*/Discussion")), "should match"); -ok(same("* !*/Discussion", "*/Discussion", "foo/Discussion"), "Discussion merge 1"); -ok(same("*/Discussion", "* !*/Discussion", "foo/Discussion"), "Discussion merge 2"); + IkiWiki::pagespec_merge("* and !*/Discussion", "*/Discussion")), "should match"); +ok(same("* and !*/Discussion", "*/Discussion", "foo/Discussion"), "Discussion merge 1"); +ok(same("*/Discussion", "* and !*/Discussion", "foo/Discussion"), "Discussion merge 2"); ok(same("*/Discussion !*/bar", "*/bar !*/Discussion", "foo/Discussion"), "bidirectional merge 1"); ok(same("*/Discussion !*/bar", "*/bar !*/Discussion", "foo/bar"), "bidirectional merge 2"); -- cgit v1.2.3