diff --git a/IkiWiki/Plugin/inline.pm b/IkiWiki/Plugin/inline.pm index 6ecdf0d38..b22109a93 100644 --- a/IkiWiki/Plugin/inline.pm +++ b/IkiWiki/Plugin/inline.pm @@ -100,7 +100,7 @@ sub get_inline_content ($$) { #{{{ my $file=$pagesources{$page}; my $type=pagetype($file); if ($type ne 'unknown') { - return htmlize($type, linkify($page, $parentpage, readfile(srcfile($file)))); + return htmlize($type, preprocess($page, linkify($page, $parentpage, readfile(srcfile($file))), 1)); } else { return ""; diff --git a/IkiWiki/Plugin/meta.pm b/IkiWiki/Plugin/meta.pm new file mode 100644 index 000000000..8244cf718 --- /dev/null +++ b/IkiWiki/Plugin/meta.pm @@ -0,0 +1,61 @@ +#!/usr/bin/perl +# Ikiwiki metadata plugin. +package IkiWiki::Plugin::meta; + +use warnings; +use strict; +use IkiWiki; + +my %meta; +my %title; + +sub import { #{{{ + IkiWiki::hook(type => "preprocess", id => "meta", + call => \&preprocess); + IkiWiki::hook(type => "pagetemplate", id => "meta", + call => \&pagetemplate); +} # }}} + +sub preprocess (@) { #{{{ + if (! @_) { + return ""; + } + my %params=@_; + my $key=shift; + my $value=$params{$key}; + delete $params{$key}; + my $page=$params{page}; + delete $params{page}; + + if ($key eq 'link') { + if (%params) { + $meta{$page}='' unless exists $meta{$page}; + $meta{$page}.="\n"; + } + else { + # hidden WikiLink + push @{$IkiWiki::links{$page}}, $value; + } + } + elsif ($key eq 'title') { + $title{$page}=$value; + } + else { + $meta{$page}='' unless exists $meta{$page}; + $meta{$page}.="\n"; + } + + return ""; +} # }}} + +sub pagetemplate ($$) { #{{{ + my $page=shift; + my $template=shift; + + $template->param(meta => $meta{$page}) if exists $meta{$page}; + $template->param(title => $title{$page}) if exists $title{$page}; +} # }}} + +1 diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm index 886a30f6b..0dfa03cd4 100644 --- a/IkiWiki/Render.pm +++ b/IkiWiki/Render.pm @@ -95,9 +95,10 @@ sub parentlinks ($) { #{{{ return @ret; } #}}} -sub preprocess ($$) { #{{{ +sub preprocess ($$;$) { #{{{ my $page=shift; my $content=shift; + my $onlystrip=shift || 0; # strip directives without processing my $handle=sub { my $escape=shift; @@ -106,12 +107,17 @@ sub preprocess ($$) { #{{{ if (length $escape) { return "[[$command $params]]"; } + elsif ($onlystrip) { + return ""; + } elsif (exists $hooks{preprocess}{$command}) { - my %params; - while ($params =~ /(\w+)=\"([^"]+)"(\s+|$)/g) { - $params{$1}=$2; + # Note: preserve order of params, some plugins may + # consider it significant. + my @params; + while ($params =~ /(\w+)=\"?([^"]+)"?(\s+|$)/g) { + push @params, $1, $2; } - return $hooks{preprocess}{$command}{call}->(page => $page, %params); + return $hooks{preprocess}{$command}{call}->(@params, page => $page); } else { return "[[$command not processed]]"; @@ -190,12 +196,6 @@ sub genpage ($$$) { #{{{ $template->param(have_actions => 1); } - if (exists $hooks{pagetemplate}) { - foreach my $id (keys %{$hooks{pagetemplate}}) { - $hooks{pagetemplate}{$id}{call}->($page, $template); - } - } - $template->param( title => $title, wikiname => $config{wikiname}, @@ -205,6 +205,12 @@ sub genpage ($$$) { #{{{ mtime => displaytime($mtime), styleurl => styleurl($page), ); + + if (exists $hooks{pagetemplate}) { + foreach my $id (keys %{$hooks{pagetemplate}}) { + $hooks{pagetemplate}{$id}{call}->($page, $template); + } + } return $template->output; } #}}} diff --git a/Makefile.PL b/Makefile.PL index b20070869..89a8f3232 100755 --- a/Makefile.PL +++ b/Makefile.PL @@ -16,7 +16,7 @@ extra_build: --wikiname="ikiwiki" --verbose --no-rcs \ --exclude=/discussion --no-discussion \ --plugin=brokenlinks --plugin=pagecount \ - --plugin=orphans --plugin=haiku + --plugin=orphans --plugin=haiku --plugin=meta ./mdwn2man ikiwiki 1 doc/usage.mdwn > ikiwiki.man ./mdwn2man ikiwiki-mass-rebuild 8 doc/ikiwiki-mass-rebuild.mdwn > ikiwiki-mass-rebuild.man diff --git a/debian/changelog b/debian/changelog index 31932d857..e60eb9a3e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -13,11 +13,18 @@ ikiwiki (1.5) UNRELEASED; urgency=low pages that link to my home page in the wiki" - Locking any pages that are linked to from a particular page, so that lists of locks can be exposed in the wiki. - * Reorganised the doc wiki's todo/* pages, using a [[done]] tag to flag + * Reorganised the doc wiki's todo/* pages, using a link/tag to flag when a todo item is done, instead of the previous moving it to a different subdir. + * Allow pagetemplate plugins to override *anything* in the template. + * Add a meta plugin, which allows specifying various metadata about pages, + like license and author. It also allows for inserting html link and meta + tags into html, overriding the title, and adding hidden WikiLinks, which + can be useful when using link-based globbing for page categorisation. + * Remove preprocessor directives from inlined pages. + * Allow simple preprocessor directive values to be specified w/o quotes. - -- Joey Hess Thu, 1 Jun 2006 21:30:03 -0400 + -- Joey Hess Thu, 1 Jun 2006 23:47:43 -0400 ikiwiki (1.4) unstable; urgency=low diff --git a/doc/bugs.mdwn b/doc/bugs.mdwn index c646242aa..3bcd1998a 100644 --- a/doc/bugs.mdwn +++ b/doc/bugs.mdwn @@ -30,6 +30,5 @@ underlaydir gets a mtime newer than the mtime the removed file had. * ikiwiki will generate html formatted error messages to the command line if --cgi is set, even if it's not yet running as a cgi -* if a page containing an rss feed happens to show up in an rss feed, - the preprocessor directives won't be expanded (good) but are left in - raw rather than removed (bad). +* The meta plugin doesn't affect a page if it's being inlined. Probably + setting the title with it should override the title of the blog post. diff --git a/doc/features.mdwn b/doc/features.mdwn index ac5dc0375..30fe5987b 100644 --- a/doc/features.mdwn +++ b/doc/features.mdwn @@ -35,7 +35,7 @@ Some of ikiwiki's features: Arbitrarily deep hierarchies of pages with fairly simple and useful [[SubPage/LinkingRules]] -* [[blog]]s +* [[blogging|blog]] You can turn any page in the wiki into a [[blog]]. Pages matching a specified [[GlobList]] will be displayed as a weblog within the blog @@ -44,7 +44,9 @@ Some of ikiwiki's features: Ikiwiki's own [[TODO]], [[news]], and [[plugins]] pages are good examples of some of the flexible ways that this can be used. - Note that this also includes support for tag-based blogging. +* [[tags]] + + You can tag pages and use these tags in various ways. * Fast compiler diff --git a/doc/plugins/meta.mdwn b/doc/plugins/meta.mdwn new file mode 100644 index 000000000..371713a31 --- /dev/null +++ b/doc/plugins/meta.mdwn @@ -0,0 +1,45 @@ +This plugin allows inserting arbitrary metadata into the source of a page. +Enter the metadata as follows: + + \\[[meta field="value"]] + \\[[meta field="value" param="value" param="value"]] + +The first form sets a given field to a given value, while the second form +also specifies some additional sub-parameters. + +You can use any field names you like, but here are some predefined ones: + +* link + + Specifies a link to another page. This is used to generate a html + <link> tag, and also as a way to make the wiki treat one page as + linking to another without displaying a user-visible link. The latter + can be useful when using links to categorise pages. A html link tag + would look like this: + + \\[[meta link="foo.css" rel="stylesheet" type="text/css"]] + + A non-user-visible [[WikiLink]] would instead look like this: + + \\[[meta link=otherpage]] + +* title + + Overrides the title of the page, which is generally the same as the + page name. + +* license + + Specifies a copyright license for the page, for example, "GPL". + +* author + + Specifies the author of a page. + +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 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/write.mdwn b/doc/plugins/write.mdwn index 245f7c9ee..b2b7c6ff8 100644 --- a/doc/plugins/write.mdwn +++ b/doc/plugins/write.mdwn @@ -35,10 +35,12 @@ This is probably the most common use of a plugin. Replace "foo" with the command name that will be used inside brackers for the preprocessor directive. -Each time the directive is processed, the referenced function (`preprocess` in the example above) is called, and is passed named parameters. A -"page" parameter gives the name of the page that embedded the preprocessor directive. All parameters included in the directive are included -as named parameters as well. Whatever the function returns goes onto the -page in place of the directive. +Each time the directive is processed, the referenced function (`preprocess` +in the example above) is called, and is passed named parameters. A "page" +parameter gives the name of the page that embedded the preprocessor +directive. All parameters included in the directive are included as named +parameters as well. Whatever the function returns goes onto the page in +place of the directive. ## Error handing diff --git a/doc/roadmap.mdwn b/doc/roadmap.mdwn index 8e9c5b462..eef5bd755 100644 --- a/doc/roadmap.mdwn +++ b/doc/roadmap.mdwn @@ -14,8 +14,10 @@ Released 29 April 2006. * Unit test suite (with tests of at least core stuff like [[GlobList]]). * [[Plugins]] +* [[Tags]] * Should have fully working [[todo/done/utf8]] support. * [[Optimised_rendering|todo/optimisations]] if possible. Deal with other scalability issues. * improved [[todo/html]] stylesheets and templates * A version of the logo in a different font, possibly with the dots on the i's highlighted in some other color. * Support for at least one RCS aside from svn. Once it supports two, it should quickly grow to support them all.. See [[about_rcs_backends]] +* Support for one other markup language, probably restructured text. diff --git a/doc/tags.mdwn b/doc/tags.mdwn new file mode 100644 index 000000000..fd2315f88 --- /dev/null +++ b/doc/tags.mdwn @@ -0,0 +1,18 @@ +While ikiwiki supports hierarchically categorising pages by creating +[[SubPage]]s, that's often not flexible enough, and it can also be useful +to tag pages in various non-hierarchical ways. + +Since this is a wiki, tagging is just a form of linking. For example, since +this page links to [[features]], it can be considered to have something to +do with ikiwiki's features. If you want to put pages into a category, the +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: + + \\[[meta link=mytag]] + +One way to use these tags is to create a [[blog]] of pages that have a +particular set of tags. [[Plugins]] can be written to do anything else with +tags that you might desire. diff --git a/doc/todo/blogging.mdwn b/doc/todo/blogging.mdwn index 680570d84..a5e776256 100644 --- a/doc/todo/blogging.mdwn +++ b/doc/todo/blogging.mdwn @@ -1,5 +1,5 @@ -- Should probably add params to control various rss fields like the blog - title, its author email, its copyright info, etc. +- Blog title, author email, copyright info and anything else supported by + rss should be able to be specified using the meta plugin. - The [[TODO]] page would work better if the first N were shown in full, and then all open items were shown in summary. Maybe add this mode. - Add Discussion and Edit links at the bottom of each inlined post. diff --git a/doc/todo/lists.mdwn b/doc/todo/lists.mdwn index 933012493..912666cd7 100644 --- a/doc/todo/lists.mdwn +++ b/doc/todo/lists.mdwn @@ -1,8 +1,3 @@ * list of all missing pages - done - -* list of registered users, with the names being links to any userpages. - - Might be a plugin, but how to let the wiki know that the page - needs an update whever a new user is added? + [[done]] diff --git a/doc/todo/metadata.mdwn b/doc/todo/metadata.mdwn index 044e65abe..c647c0cff 100644 --- a/doc/todo/metadata.mdwn +++ b/doc/todo/metadata.mdwn @@ -9,3 +9,9 @@ Uses for this include: * Any metadata that's generally useful on html pages. * Maybe as an alternate way to tag a page, like linking to the tag, except it doesn't have to show up in the page text. +* Recording page licenses. + +[[meta link=done]] +[[meta title="supporting metadata..."]] +[[meta author="Joey Hess"]] +[[meta link="foo.css" rel="stylesheet" type="text/css"]] diff --git a/doc/todo/pluggablerenderers.mdwn b/doc/todo/pluggablerenderers.mdwn index bbf28c305..3b7e9ffc7 100644 --- a/doc/todo/pluggablerenderers.mdwn +++ b/doc/todo/pluggablerenderers.mdwn @@ -1,14 +1 @@ -I'm considering a configurable rendering pipeline for each supported -filename extension. So for ".mdwn" files, it would send the content through -linkify, markdown, and finalize, while for ".wiki" files it might send it -through just a wiki formatter and finalize. - -This would allow not only supporting more types of markup, but changing -what style of [[WikiLink]]s are supported, maybe some people want to add -[[CamelCase]] for example, or don't like the [[SubPage/LinkingRules]]. - -There also needs to be a step before finalize, where stuff like lists of pages -that linked back to it could be added to the page. However, doing linkbacks -also needs to tie into the main logic, to determine what pages need to be -renered, so maybe that won't be a plugin. - +Should be able to plug in support for rst or other markup formats. diff --git a/templates/page.tmpl b/templates/page.tmpl index c2430f044..ce92ab38a 100644 --- a/templates/page.tmpl +++ b/templates/page.tmpl @@ -5,6 +5,9 @@ <TMPL_VAR TITLE> + + +