From 5017ffd8a512c09d3c34764709791812acfc5515 Mon Sep 17 00:00:00 2001 From: joey Date: Thu, 27 Jul 2006 21:38:02 +0000 Subject: [PATCH] * 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. --- IkiWiki/Plugin/tag.pm | 31 +++++++++++++++++++++++++++++ IkiWiki/Render.pm | 9 +++++++-- basewiki/preprocessordirective.mdwn | 5 +++++ debian/changelog | 12 +++++++++++ doc/ikiwiki.setup | 3 ++- doc/plugins/meta.mdwn | 6 ++++-- doc/plugins/tag.mdwn | 9 +++++++++ doc/tags.mdwn | 4 ++-- 8 files changed, 72 insertions(+), 7 deletions(-) create mode 100644 IkiWiki/Plugin/tag.pm create mode 100644 doc/plugins/tag.mdwn diff --git a/IkiWiki/Plugin/tag.pm b/IkiWiki/Plugin/tag.pm new file mode 100644 index 000000000..841d508bf --- /dev/null +++ b/IkiWiki/Plugin/tag.pm @@ -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 diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm index e5a1679f8..690945c49 100644 --- a/IkiWiki/Render.pm +++ b/IkiWiki/Render.pm @@ -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); } diff --git a/basewiki/preprocessordirective.mdwn b/basewiki/preprocessordirective.mdwn index ffa3fc7c4..f7d97520c 100644 --- a/basewiki/preprocessordirective.mdwn +++ b/basewiki/preprocessordirective.mdwn @@ -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: diff --git a/debian/changelog b/debian/changelog index 2bacb206c..eaa4c8de4 100644 --- a/debian/changelog +++ b/debian/changelog @@ -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 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. diff --git a/doc/ikiwiki.setup b/doc/ikiwiki.setup index 8bc0e3336..b79722db9 100644 --- a/doc/ikiwiki.setup +++ b/doc/ikiwiki.setup @@ -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}], } diff --git a/doc/plugins/meta.mdwn b/doc/plugins/meta.mdwn index 998dd5d86..17a54c8d6 100644 --- a/doc/plugins/meta.mdwn +++ b/doc/plugins/meta.mdwn @@ -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 <meta> 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 index 000000000..95a346622 --- /dev/null +++ b/doc/plugins/tag.mdwn @@ -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. diff --git a/doc/tags.mdwn b/doc/tags.mdwn index 2b3d73987..64313aec7 100644 --- a/doc/tags.mdwn +++ b/doc/tags.mdwn @@ -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 -- 2.45.0