]> sipb.mit.edu Git - ikiwiki.git/commitdiff
* Added created_before and created_after PageSpec limits.
authorjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Thu, 3 Aug 2006 16:55:52 +0000 (16:55 +0000)
committerjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Thu, 3 Aug 2006 16:55:52 +0000 (16:55 +0000)
IkiWiki.pm
basewiki/pagespec.mdwn
debian/changelog
t/pagespec_match.t

index d9559bde45936348c51b0965c4da6262f00a3a16..a732be99956bda3c0539c5a6c1e9650ccc595376 100644 (file)
@@ -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);
 } #}}}
index 64710a2a5e72e349bc23db59899fa2281c4ae8b5..0890e399f1b429676553427bf2862920a00799e8 100644 (file)
@@ -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
index 868adca8b545afdfbac5777ed8995f4399c521d4..431a3285dff8b11a6cbfb5e7072640c776a451a2 100644 (file)
@@ -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
 
index 1863b9cbabf550752646de2cc079ee9138c2ae3f..20243dfa69855ab2c84539262a1f16940d320014 100755 (executable)
@@ -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");