* Reorganised the doc wiki's todo/* pages, using a link/tag to flag

* 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.
master
joey 2006-06-02 04:49:12 +00:00
parent f1b3b728c1
commit d534483b9b
16 changed files with 179 additions and 46 deletions

View File

@ -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 "";

View File

@ -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}.="<link href=\"$value\" ".
join(" ", map { "$_=\"$params{$_}\"" } keys %params).
" />\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}.="<meta name=\"$key\" content=\"$value\" />\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

View File

@ -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;
} #}}}

View File

@ -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

11
debian/changelog vendored
View File

@ -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 <joeyh@debian.org> Thu, 1 Jun 2006 21:30:03 -0400
-- Joey Hess <joeyh@debian.org> Thu, 1 Jun 2006 23:47:43 -0400
ikiwiki (1.4) unstable; urgency=low

View File

@ -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.

View File

@ -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

View File

@ -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
&lt;link&gt; 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 &lt;meta&gt;
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)"]]

View File

@ -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

View File

@ -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.

18
doc/tags.mdwn 100644
View File

@ -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.

View File

@ -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.

View File

@ -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]]

View File

@ -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"]]

View File

@ -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.

View File

@ -5,6 +5,9 @@
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title><TMPL_VAR TITLE></title>
<link rel="stylesheet" href="<TMPL_VAR STYLEURL>" type="text/css" />
<TMPL_IF NAME="META">
<TMPL_VAR META>
</TMPL_IF>
</head>
<body>