* Patch from Enrico that
authorjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Thu, 27 Jul 2006 21:38:02 +0000 (21:38 +0000)
committerjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>
Thu, 27 Jul 2006 21:38:02 +0000 (21:38 +0000)
  - allows preprocessor directives to have parameters with no specified
    value
  - fixes preprocessor directive parameter parsing so that
    foo=bar baz now means "foo=bar" and a "baz" with no value
  - Add a tag plugin that allows more easily tagging pages.
    The meta plugin can also still be used for this.

IkiWiki/Plugin/tag.pm [new file with mode: 0644]
IkiWiki/Render.pm
basewiki/preprocessordirective.mdwn
debian/changelog
doc/ikiwiki.setup
doc/plugins/meta.mdwn
doc/plugins/tag.mdwn [new file with mode: 0644]
doc/tags.mdwn

diff --git a/IkiWiki/Plugin/tag.pm b/IkiWiki/Plugin/tag.pm
new file mode 100644 (file)
index 0000000..841d508
--- /dev/null
@@ -0,0 +1,31 @@
+#!/usr/bin/perl
+# Ikiwiki tag plugin.
+package IkiWiki::Plugin::tag;
+
+use warnings;
+use strict;
+use IkiWiki;
+
+my %tag;
+
+sub import { #{{{
+       IkiWiki::hook(type => "preprocess", id => "tag", call => \&preprocess);
+} # }}}
+
+sub preprocess (@) { #{{{
+       if (! @_) {
+               return "";
+       }
+       my %params=@_;
+       my $page = $params{page};
+       delete $params{page};
+
+       foreach my $tag (keys %params) {
+               # hidden WikiLink
+               push @{$IkiWiki::links{$page}}, $tag;
+       }
+               
+       return "";
+} # }}}
+
+1
index e5a1679f8fbf9df3e91c54cb5f973ac3dca2d414..690945c49f89f91668763ebf5dfc32d5810b2a9a 100644 (file)
@@ -105,8 +105,13 @@ sub preprocess ($$;$) { #{{{
                        # Note: preserve order of params, some plugins may
                        # consider it significant.
                        my @params;
-                       while ($params =~ /(\w+)=\"?([^"]+)"?(\s+|$)/g) {
-                               push @params, $1, $2;
+                       while ($params =~ /(?:(\w+)=)?(?:"([^"]+)"|(\S+))(?:\s+|$)/g) {
+                               if (defined $1) {
+                                       push @params, $1, (defined $2 ? $2 : $3);
+                               }
+                               else {
+                                       push @params, (defined $2 ? $2 : $3), '';
+                               }
                        }
                        return $hooks{preprocess}{$command}{call}->(@params, page => $page);
                }
index ffa3fc7c4f7d697e214a26a1eb09f0977ea67882..f7d97520c8550f26cd1b81330375dd91fa045a94 100644 (file)
@@ -6,6 +6,11 @@ contain spaces and parameters. The general form is:
 This gets expanded before the rest of the page is processed, and can be used
 to transform the page in various ways.
 
+The quotes around values can be omitted if the value is a simple word.
+Also, some directives may use parameters without values, for example:
+
+\\[[tag foo]]
+
 Note that if a preprocessor directive has no parameters, a space still must
 be put after its name, to avoid confusion with a [[WikiLink]]. For example:
 
index 2bacb206c915c656a5ccd5a88b991203d5daa883..eaa4c8de421b50a99b14fb3e8228a0ab293a005f 100644 (file)
@@ -1,3 +1,15 @@
+ikiwiki (1.11) UNRELEASED; urgency=low
+
+  * Patch from Enrico that
+    - allows preprocessor directives to have parameters with no specified
+      value
+    - fixes preprocessor directive parameter parsing so that
+      foo=bar baz now means "foo=bar" and a "baz" with no value
+    - Add a tag plugin that allows more easily tagging pages.
+      The meta plugin can also still be used for this.
+
+ -- Joey Hess <joeyh@debian.org>  Thu, 27 Jul 2006 17:03:09 -0400
+
 ikiwiki (1.10) unstable; urgency=low
 
   * Run page through any relevant filters when generating a page preview.
index 8bc0e333609b5a0888fb518ea2acde215c33bb17..b79722db9be79295189667557cc04bc3f28f05a0 100644 (file)
@@ -71,7 +71,8 @@ use IkiWiki::Setup::Standard {
        #timeformat => '%c',
        
        # To add plugins, list them here.
-       #add_plugins => [qw{pagecount brokenlinks search smiley wikitext}],
+       #add_plugins => [qw{meta tag pagecount brokenlinks search smiley
+       #                   wikitext camelcase}],
        # If you want to disable any of the default plugins, list them here.
        #disable_plugins => [qw{inline htmlscrubber}],
 }
index 998dd5d869451ce2385ccb49ebed42b942b1a3fd..17a54c8d60a4a5c219892319300fb5db713c2839 100644 (file)
@@ -1,6 +1,4 @@
 This plugin allows inserting arbitrary metadata into the source of a page.
-This plugin is not enabled by default. If it is enabled, the title of this
-page will say it is. [[meta title="meta plugin (enabled)"]]
 Enter the metadata as follows:
 
        \\[[meta field="value"]]
@@ -41,3 +39,7 @@ You can use any field names you like, but here are some predefined ones:
 If the field is not treated specially (as the link and title fields are),
 the metadata will be written to the generated html page as a &lt;meta&gt;
 header.
+
+This plugin is included in ikiwiki, but it is not enabled by default. If
+it is enabled, the title of this page will say it is.
+[[meta title="meta plugin (enabled)"]]
diff --git a/doc/plugins/tag.mdwn b/doc/plugins/tag.mdwn
new file mode 100644 (file)
index 0000000..95a3466
--- /dev/null
@@ -0,0 +1,9 @@
+This plugin allows tagging pages. List tags as follows:
+
+       \\[[tag tech life linux]]
+
+The tags work the same as if you had put a (hidden) [[WikiLink]] on the page
+for each tag, so you can use a [[GlobList]] to link to all pages that are
+tagged with a given tag, for example.
+
+This plugin is included in ikiwiki, but is not enabled by default.
index 2b3d7398734f9f2e65ce6fb77411c8b02d8384c0..64313aec728ef320e429115d6ef227a00837543a 100644 (file)
@@ -9,9 +9,9 @@ typical wiki way to do so is to create a "CategoryFoo" page and link pages
 in the category to it. That is just another form of tagging.
 
 Sometimes you may want to tag a page without putting a visible link on it.
-The [[meta_plugin|plugins/meta]] allows you to do so, like this:
+The [[tag_plugin|plugins/tag]] allows you to do so, like this:
 
-       \\[[meta link=mytag]]
+       \\[[tag mytag othertag thirdtag]]
 
 One way to use these tags is to create a [[blog]] of pages that have a
 particular set of tags. Or just look at the [[BackLinks]] to a tag page to