]> sipb.mit.edu Git - ikiwiki.git/commitdiff
* Add all=no option to conditional, can be used to form conditionals that do
authorjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Wed, 9 May 2007 00:31:49 +0000 (00:31 +0000)
committerjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Wed, 9 May 2007 00:31:49 +0000 (00:31 +0000)
  not need to examine every page in the wiki.
* Use this to simplify the goodstuff detection in the plugin template.

IkiWiki/Plugin/conditional.pm
IkiWiki/Plugin/testpagespec.pm
debian/changelog
doc/plugins/conditional.mdwn
doc/templates/plugin.mdwn

index a7ed6590e52c26a6ab28b037c30e441dd73597f5..6c14361f7d2b39df373d0e7fda25bab8946fa23f 100644 (file)
@@ -13,15 +13,19 @@ sub import { #{{{
 sub preprocess_if (@) { #{{{
        my %params=@_;
 
-       if (! exists $params{test} || ! exists $params{then}) {
-               return "[[if ".gettext('"test" and "then" parameters are required')."]]";
+       foreach my $param (qw{test then}) {
+               if (! exists $params{$param}) {
+                       return "[[if ".sprintf(gettext('%s parameter is required'), $param)."]]";
+               }
        }
 
        my $result=0;
-       # An optimisation to avoid needless looping over every page
-       # and adding of dependencies for simple uses of some of the
-       # tests.
-       if ($params{test} =~ /^(enabled|sourcepage|destpage)\((.*)\)$/) {
+       if ((exists $params{all} && lc $params{all} eq "no") ||
+               # An optimisation to avoid needless looping over every page
+               # and adding of dependencies for simple uses of some of the
+               # tests.
+               $params{test} =~ /^(enabled|sourcepage|destpage)\((.*)\)$/) {
+               add_depends($params{page}, "$params{test} and $params{page}");
                $result=pagespec_match($params{page}, $params{test},
                                location => $params{page},
                                sourcepage => $params{page},
index 77fab497ee0e5abd8d88286d59fe9f4e0574db86..f9ec90d8791f8b5e6aa422ceb527fe272bfea9df 100644 (file)
@@ -14,7 +14,7 @@ sub preprocess (@) { #{{{
        
        foreach my $param (qw{match pagespec}) {
                if (! exists $params{$param}) {
-                       return "[[testpagespec missing $param parameter]]";
+                       return "[[testpagespec $param parameter is required]]";
                }
        }
 
index deb7fd04e31b4d4181ff56d9570b16b2c93fb1ac..e3863fbd2d431c178940d0d8193d1b15ed81eeec 100644 (file)
@@ -9,8 +9,11 @@ ikiwiki (2.1) UNRELEASED; urgency=low
     in.
   * Make testpagespec more robust, including checking for missing/bad
     parameters.
+  * Add all=no option to conditional, can be used to form conditionals that do
+    not need to examine every page in the wiki.
+  * Use this to simplify the goodstuff detection in the plugin template.
 
- -- Joey Hess <joeyh@debian.org>  Tue, 08 May 2007 17:21:13 -0400
+ -- Joey Hess <joeyh@debian.org>  Tue, 08 May 2007 20:12:25 -0400
 
 ikiwiki (2.00) unstable; urgency=low
 
index a8dd215898e1dd24eca087e4a94dd67c22522885..ba1cf9bb2f39137e8ab164dd2b21b1d17af5c815 100644 (file)
@@ -18,8 +18,14 @@ quotes to be included.
 The `test` is a [[PageSpec]]; if it matches any page in the wiki then it
 succeeds. So you can do things like testing for the existence of a page or
 pages, testing to see if any pages were created in a given month, and so
-on. The regular [[PageSpec]] syntax is expanded with the following
-additional tests:
+on.
+
+If you want the [[PageSpec]] to only match against the page that
+contains the conditional, rather than matching against all pages in the
+wiki, set the "all" parameter to "no".
+
+The regular [[PageSpec]] syntax is expanded with the following additional
+tests:
 
 * enabled(plugin)
 
index cb67902eaf6e5098d7bfd47d7969324a337258dd..b8421fafb9e16ad8933661f7d29276fa3634500e 100644 (file)
@@ -3,7 +3,7 @@ Plugin: <TMPL_VAR name><br />
 Author: <TMPL_VAR author><br />
 Included in ikiwiki: [[if test="sourcepage(plugins/contrib/*)" then="""no""" else="""yes"""]]<br />
 Enabled by default: <TMPL_IF core>yes<TMPL_ELSE>no</TMPL_IF><br />
-Included in [[/plugins/goodstuff]]: [[if test="backlink(plugins/goodstuff) and glob(plugins/<TMPL_VAR name>) and !sourcepage(plugins/contrib/*)" then="""yes""" else="""no"""]]<br />
+Included in [[/plugins/goodstuff]]: [[if test="backlink(plugins/goodstuff)" all=no then="""yes""" else="""no"""]]<br />
 Currently enabled: [[if test="enabled(<TMPL_VAR name>)" then="yes" else="no"]]<br />
 </span>
 [[if test="sourcepage(plugins/contrib/*)" then="""[[meta title="<TMPL_VAR name> (third party plugin)"]]"""]]