aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--IkiWiki.pm26
-rw-r--r--basewiki/pagespec.mdwn21
-rw-r--r--debian/changelog3
-rwxr-xr-xt/pagespec_match.t7
4 files changed, 47 insertions, 10 deletions
diff --git a/IkiWiki.pm b/IkiWiki.pm
index d9559bde4..a732be999 100644
--- a/IkiWiki.pm
+++ b/IkiWiki.pm
@@ -553,7 +553,7 @@ sub pagespec_translate ($) { #{{{
elsif ($word eq "(" || $word eq ")" || $word eq "!") {
$code.=" ".$word;
}
- elsif ($word =~ /^(link|backlink|creation_month|creation_year|creation_day)\((.+)\)$/) {
+ elsif ($word =~ /^(link|backlink|created_before|created_after|creation_month|creation_year|creation_day)\((.+)\)$/) {
$code.=" match_$1(\$page, ".safequote($2).")";
}
else {
@@ -598,6 +598,30 @@ sub match_backlink ($$) { #{{{
match_link(pop, pop);
} #}}}
+sub match_created_before ($$) { #{{{
+ my $page=shift;
+ my $testpage=shift;
+
+ if (exists $pagectime{$testpage}) {
+ return $pagectime{$page} < $pagectime{$testpage};
+ }
+ else {
+ return 0;
+ }
+} #}}}
+
+sub match_created_after ($$) { #{{{
+ my $page=shift;
+ my $testpage=shift;
+
+ if (exists $pagectime{$testpage}) {
+ return $pagectime{$page} > $pagectime{$testpage};
+ }
+ else {
+ return 0;
+ }
+} #}}}
+
sub match_creation_day ($$) { #{{{
return ((gmtime($pagectime{shift()}))[3] == shift);
} #}}}
diff --git a/basewiki/pagespec.mdwn b/basewiki/pagespec.mdwn
index 64710a2a5..0890e399f 100644
--- a/basewiki/pagespec.mdwn
+++ b/basewiki/pagespec.mdwn
@@ -21,16 +21,23 @@ match all pages except for Discussion pages and the SandBox:
* and !SandBox and !*/Discussion
-It's also possible to match pages that link to a given page, by writing
-"`link(page)`". Or, match pages that a given page links to, by
-writing "`backlink(page)`". Or match pages created in a given month, year,
-or day of the month by writing "`creation_month(month)`",
-"`creation_year(year)`" or "`creation_day(mday)`".
+Some more elaborate limits can be added to what matches using any of these
+functions:
+
+* "`link(page)`" - match only pages that link to a given page
+* "`backlink(page)`" - match only pages that a given page links to
+* "`creation_month(month)`" - match only pages created on the given month
+* "`creation_day(mday)`" - or day of the month
+* "`creation_year(year)`" - or year
+* "`created_after(page)`" - match only pages created after the given page
+ was created
+* "`created_before(page)`" - match only pages created before the given page
+ was created
For example, to match all pages in a blog that link to the page about music
-and were written on Mondays in 2005:
+and were written in 2005:
- blog/* and link(music) and creation_year(2005) and creation_day(0)
+ blog/* and link(music) and creation_year(2005)
More complex expressions can also be created, by using parentheses for
grouping. For example, to match pages in a blog that are tagged with either
diff --git a/debian/changelog b/debian/changelog
index 868adca8b..431a3285d 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -2,8 +2,9 @@ ikiwiki (1.15) UNRELEASED; urgency=low
* Remove CDPATH and other env vars perl taint checking doesn't like.
Closes: #381279
+ * Added created_before and created_after PageSpec limits.
- -- Joey Hess <joeyh@debian.org> Thu, 3 Aug 2006 12:12:53 -0400
+ -- Joey Hess <joeyh@debian.org> Thu, 3 Aug 2006 12:52:51 -0400
ikiwiki (1.14) unstable; urgency=low
diff --git a/t/pagespec_match.t b/t/pagespec_match.t
index 1863b9cba..20243dfa6 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 => 31;
+use Test::More tests => 35;
BEGIN { use_ok("IkiWiki"); }
@@ -26,6 +26,11 @@ ok(IkiWiki::pagespec_match("bar", "backlink(foo)"));
ok(! IkiWiki::pagespec_match("quux", "backlink(foo)"));
$IkiWiki::pagectime{foo}=1154532692; # Wed Aug 2 11:26 EDT 2006
+$IkiWiki::pagectime{bar}=1154532695; # after
+ok(IkiWiki::pagespec_match("foo", "created_before(bar)"));
+ok(! IkiWiki::pagespec_match("foo", "created_after(bar)"));
+ok(! IkiWiki::pagespec_match("bar", "created_before(foo)"));
+ok(IkiWiki::pagespec_match("bar", "created_after(foo)"));
ok(IkiWiki::pagespec_match("foo", "creation_year(2006)"), "year");
ok(! IkiWiki::pagespec_match("foo", "creation_year(2005)"), "other year");
ok(IkiWiki::pagespec_match("foo", "creation_month(8)"), "month");