From 0f76f8774d67edcd5a31cfe918ef16819a54ee59 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 28 Jan 2008 22:56:25 -0500 Subject: add --- templates/change.tmpl | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 templates/change.tmpl (limited to 'templates/change.tmpl') diff --git a/templates/change.tmpl b/templates/change.tmpl new file mode 100644 index 000000000..af257a7ce --- /dev/null +++ b/templates/change.tmpl @@ -0,0 +1,15 @@ +[[meta title=""" +
+"""]] +[[meta author=""]] + + + + "> + diff + + + + + + -- cgit v1.2.3 From 5921b86fccde90e5a9c77623d808be06f40cbe47 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 28 Jan 2008 23:56:26 -0500 Subject: proof of concept implementation of static recentchanges Currently hardcoded to write to recentchanges/*, and the page format needs to be rethought to be usable for aggregation, but it basically works. --- IkiWiki/Plugin/recentchanges.pm | 92 +++++++++++++++++++++++++++++++++++++++++ doc/plugins/recentchanges.mdwn | 14 +++++++ doc/recentchanges.mdwn | 6 +-- doc/todo/recentchanges.mdwn | 7 +--- doc/wikitemplates.mdwn | 3 +- templates/change.tmpl | 42 ++++++++++++------- templates/recentchanges.tmpl | 65 +++-------------------------- 7 files changed, 145 insertions(+), 84 deletions(-) create mode 100644 IkiWiki/Plugin/recentchanges.pm create mode 100644 doc/plugins/recentchanges.mdwn (limited to 'templates/change.tmpl') diff --git a/IkiWiki/Plugin/recentchanges.pm b/IkiWiki/Plugin/recentchanges.pm new file mode 100644 index 000000000..94a2d4c33 --- /dev/null +++ b/IkiWiki/Plugin/recentchanges.pm @@ -0,0 +1,92 @@ +#!/usr/bin/perl +package IkiWiki::Plugin::recentchanges; + +use warnings; +use strict; +use IkiWiki 2.00; + +sub import { #{{{ + hook(type => "checkconfig", id => "recentchanges", + call => \&checkconfig); + hook(type => "needsbuild", id => "recentchanges", + call => \&needsbuild); + hook(type => "preprocess", id => "recentchanges", + call => \&preprocess); + hook(type => "htmlize", id => "_change", + call => \&htmlize); +} #}}} + +sub checkconfig () { #{{{ + updatechanges(); +} #}}} + +sub needsbuild () { #{{{ + # TODO +} #}}} + +sub preprocess (@) { #{{{ + my %params=@_; + + # TODO + + return ""; +} #}}} + +# Pages with extension _change have plain html markup, pass through. +sub htmlize (@) { #{{{ + my %params=@_; + return $params{content}; +} #}}} + +sub store ($$) { #{{{ + my $change=shift; + my $subdir=shift; + + my $page="$subdir/change_".IkiWiki::titlepage($change->{rev}); + + # Optimisation to avoid re-writing pages. Assumes commits never + # change, or that any changes are not important. + return if exists $pagesources{$page} && ! $config{rebuild}; + + # Limit pages to first 10, and add links to the changed pages. + my $is_excess = exists $change->{pages}[10]; + delete @{$change->{pages}}[10 .. @{$change->{pages}}] if $is_excess; + $change->{pages} = [ + map { + if (length $config{url}) { + $_->{link} = "{page},"")."\">". + IkiWiki::pagetitle($_->{page}).""; + } + else { + $_->{link} = IkiWiki::pagetitle($_->{page}); + } + $_; + } @{$change->{pages}} + ]; + push @{$change->{pages}}, { link => '...' } if $is_excess; + + # Fill out a template with the change info. + $change->{user} = IkiWiki::userlink($change->{user}); + my $ctime=$change->{when}; + $change->{when} = IkiWiki::displaytime($change->{when}, "%X %x"); + my $template=template("change.tmpl", blind_cache => 1); + $template->param(%$change); + $template->param(baseurl => "$config{url}/") if length $config{url}; + IkiWiki::run_hooks(pagetemplate => sub { + shift->(page => $page, destpage => $page, template => $template); + }); + + writefile($page."._change", $config{srcdir}, $template->output); + utime $ctime, $ctime, "$config{srcdir}/$page._change"; +} #}}} + +sub updatechanges () { #{{{ + my @changelog=IkiWiki::rcs_recentchanges(100); + foreach my $change (@changelog) { + store($change, "recentchanges"); + } + # TODO: delete old +} #}}} + +1 diff --git a/doc/plugins/recentchanges.mdwn b/doc/plugins/recentchanges.mdwn new file mode 100644 index 000000000..9e0d8dc51 --- /dev/null +++ b/doc/plugins/recentchanges.mdwn @@ -0,0 +1,14 @@ +[[template id=plugin name=recentchanges core=1 author="[[Joey]]"]] + +This plugin examines the [[revision_control_system|rcs]] history and +generates a page describing each recent change made to the wiki. These +pages can be joined together with [[inline]] to generate the +[[RecentChanges]] page. + +Typically only the RecentChanges page will use the plugin, but you can +use it elsewhere too if you like. It's used like this: + + \[[recentchanges pages="*" num=100 template=change]] + +The pages describing recent changes will be created as [[subpages|subpage]] +of the page where the `recentchanges` directive is placed. diff --git a/doc/recentchanges.mdwn b/doc/recentchanges.mdwn index 2e67f02e7..a027bf462 100644 --- a/doc/recentchanges.mdwn +++ b/doc/recentchanges.mdwn @@ -1,3 +1,3 @@ -ikiwiki generates the list of recent changes by examining the history of -the [[revision_control_system|rcs]] that the wiki is configured to use. You -have to have [[CGI]] set up for this feature to be enabled. +[[recentchanges pages="*" num=100 template=change]] +[[inline pages="recentchanges/change_* and !*/Discussion" +template=recentchanges show=0]] diff --git a/doc/todo/recentchanges.mdwn b/doc/todo/recentchanges.mdwn index bdd7948e4..75334659a 100644 --- a/doc/todo/recentchanges.mdwn +++ b/doc/todo/recentchanges.mdwn @@ -107,11 +107,8 @@ Here's a full design for redoing recentchanges, based on Ethan's ideas: aggregator, or they can set up their own page that uses the recentchanges directive for only the pages they want. * The `rcs_notify` functions will be removed. -* `rcs_getchange` is passed a change id (as returned from rcs_recentchanges) - and a partially filled out HTML::Template and fills out the remainer of the - template. So if a template is used that includes diffs, it will need to run - some expensive diffing operation, wikis with less resources can use a - template that doesn't include diffs and avoid that overhead. +* To add diffs, another plugin can add a pagetemplate hook that calls + a `rcs_diff`. (optional) * So to update the changes files, just call `rcs_recentchanges`, create files for each new id, and delete files for each id that is no longer included. diff --git a/doc/wikitemplates.mdwn b/doc/wikitemplates.mdwn index 4588b948e..8a579e183 100644 --- a/doc/wikitemplates.mdwn +++ b/doc/wikitemplates.mdwn @@ -10,11 +10,12 @@ located in /usr/share/ikiwiki/templates by default. * `page.tmpl` - Used for displaying all regular wiki pages. * `misc.tmpl` - Generic template used for any page that doesn't have a custom template. -* `recentchanges.tmpl` - Used for the RecentChanges page. * `editpage.tmpl` - Create/edit page. * `notifymail.tmpl` - Not a html template, this is used to generate change notification mails for users who have subscribed to changes to a page. +* `recentchanges.tmpl` - Used to generate a RecentChanges table with inline. +* `change.tmpl` - Used to create a page describing a change made to the wiki. * `passwordmail.tmpl` - Not a html template, this is used to generate the mail with the user's password in it. * `rsspage.tmpl` - Used for generating rss feeds for [blogs|[ikiwiki/blog]]. diff --git a/templates/change.tmpl b/templates/change.tmpl index af257a7ce..9dbc97ec2 100644 --- a/templates/change.tmpl +++ b/templates/change.tmpl @@ -1,15 +1,27 @@ -[[meta title=""" -
-"""]] -[[meta author=""]] - - - - "> - diff - - - - - - + + + + + + + + "> + diff + + + + + + + + + + + + + +
+
+
+ + diff --git a/templates/recentchanges.tmpl b/templates/recentchanges.tmpl index e03482f43..2e33b79f9 100644 --- a/templates/recentchanges.tmpl +++ b/templates/recentchanges.tmpl @@ -1,26 +1,4 @@ - - - - - -<TMPL_VAR TITLE> - - - - - - - - -
- -/ - -
- -
-
+ @@ -30,42 +8,9 @@ - - - - - - - - - - - - + + +
- - - "> - diff - - - - - - -
- - -
-
-
-
-
- - - - - + -- cgit v1.2.3 From 21f44880cdd8f23264b2416bf39793aadcb87df6 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 29 Jan 2008 01:48:55 -0500 Subject: non-tabular recentchanges display Doesn't look as good as the old table, but works as a rss feed. --- IkiWiki.pm | 23 +++++++++++++----- IkiWiki/CGI.pm | 53 ----------------------------------------- IkiWiki/Plugin/recentchanges.pm | 23 +++++++++++++----- doc/recentchanges.mdwn | 3 +-- doc/wikitemplates.mdwn | 1 - templates/change.tmpl | 49 ++++++++++++++++++------------------- templates/recentchanges.tmpl | 16 ------------- 7 files changed, 58 insertions(+), 110 deletions(-) delete mode 100644 templates/recentchanges.tmpl (limited to 'templates/change.tmpl') diff --git a/IkiWiki.pm b/IkiWiki.pm index 2c3ddac23..c70307b5f 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -607,14 +607,11 @@ sub htmllink ($$$;@) { #{{{ return "$linktext"; } #}}} -sub userlink ($) { #{{{ +sub openiduser ($) { #{{{ my $user=shift; - eval q{use CGI 'escapeHTML'}; - error($@) if $@; if ($user =~ m!^https?://! && eval q{use Net::OpenID::VerifiedIdentity; 1} && !$@) { - # Munge user-urls, as used by eg, OpenID. my $oid=Net::OpenID::VerifiedIdentity->new(identity => $user); my $display=$oid->display; # Convert "user.somehost.com" to "user [somehost.com]". @@ -626,10 +623,24 @@ sub userlink ($) { #{{{ $display=~s/^https?:\/\/(.+)\/([^\/]+)$/$2 [$1]/; } $display=~s!^https?://!!; # make sure this is removed - return "".escapeHTML($display).""; + eval q{use CGI 'escapeHTML'}; + error($@) if $@; + return escapeHTML($display); + } + return; +} + +sub userlink ($) { #{{{ + my $user=shift; + + my $oiduser=openiduser($user); + if (defined $oiduser) { + return "$oiduser"; } else { - return $user; + return htmllink("", "", escapeHTML( + length $config{userdir} ? $config{userdir}."/".$user : $user + ), noimageinline => 1); } } #}}} diff --git a/IkiWiki/CGI.pm b/IkiWiki/CGI.pm index 55ee5d86a..c8c1b63dd 100644 --- a/IkiWiki/CGI.pm +++ b/IkiWiki/CGI.pm @@ -84,53 +84,6 @@ sub decode_cgi_utf8 ($) { #{{{ } } #}}} -sub cgi_recentchanges ($) { #{{{ - my $q=shift; - - # Optimisation: building recentchanges means calculating lots of - # links. Memoizing htmllink speeds it up a lot (can't be memoized - # during page builds as the return values may change, but they - # won't here.) - eval q{use Memoize}; - error($@) if $@; - memoize("htmllink"); - - eval q{use Time::Duration}; - error($@) if $@; - - my $changelog=[rcs_recentchanges(100)]; - foreach my $change (@$changelog) { - $change->{when} = concise(ago(time - $change->{when})); - - $change->{user} = userlink($change->{user}); - - my $is_excess = exists $change->{pages}[10]; # limit pages to first 10 - delete @{$change->{pages}}[10 .. @{$change->{pages}}] if $is_excess; - $change->{pages} = [ - map { - $_->{link} = htmllink("", "", $_->{page}, - noimageinline => 1, - linktext => pagetitle($_->{page})); - $_; - } @{$change->{pages}} - ]; - push @{$change->{pages}}, { link => '...' } if $is_excess; - } - - my $template=template("recentchanges.tmpl"); - $template->param( - title => "RecentChanges", - indexlink => indexlink(), - wikiname => $config{wikiname}, - changelog => $changelog, - baseurl => baseurl(), - ); - run_hooks(pagetemplate => sub { - shift->(page => "", destpage => "", template => $template); - }); - print $q->header(-charset => 'utf-8'), $template->output; -} #}}} - # Check if the user is signed in. If not, redirect to the signin form and # save their place to return to later. sub needsignin ($$) { #{{{ @@ -661,12 +614,6 @@ sub cgi (;$$) { #{{{ } } - # Things that do not need a session. - if ($do eq 'recentchanges') { - cgi_recentchanges($q); - return; - } - # Need to lock the wiki before getting a session. lockwiki(); diff --git a/IkiWiki/Plugin/recentchanges.pm b/IkiWiki/Plugin/recentchanges.pm index 6b36ea4c8..fb9841ffd 100644 --- a/IkiWiki/Plugin/recentchanges.pm +++ b/IkiWiki/Plugin/recentchanges.pm @@ -67,14 +67,25 @@ sub store ($$) { #{{{ ]; push @{$change->{pages}}, { link => '...' } if $is_excess; + # Take the first line of the commit message as a summary. + my $m=shift @{$change->{message}}; + $change->{summary}=$m->{line}; + + # See if the committer is an openid. + my $oiduser=IkiWiki::openiduser($change->{user}); + if (defined $oiduser) { + $change->{authorurl}=$change->{user}; + $change->{user}=$oiduser; + } + elsif (length $config{url}) { + $change->{authorurl}="$config{url}/". + (length $config{userdir} ? "$config{userdir}/" : ""). + $change->{user}; + } + # Fill out a template with the change info. my $template=template("change.tmpl", blind_cache => 1); - $template->param( - user => IkiWiki::userlink($change->{user}), - when => IkiWiki::displaytime($change->{when}, "%X %x"), - pages => $change->{pages}, - message => $change->{message}, - ); + $template->param(%$change); $template->param(baseurl => "$config{url}/") if length $config{url}; IkiWiki::run_hooks(pagetemplate => sub { shift->(page => $page, destpage => $page, template => $template); diff --git a/doc/recentchanges.mdwn b/doc/recentchanges.mdwn index a027bf462..b2c7f5d07 100644 --- a/doc/recentchanges.mdwn +++ b/doc/recentchanges.mdwn @@ -1,3 +1,2 @@ [[recentchanges pages="*" num=100 template=change]] -[[inline pages="recentchanges/change_* and !*/Discussion" -template=recentchanges show=0]] +[[inline pages="recentchanges/change_* and !*/Discussion" show=0]] diff --git a/doc/wikitemplates.mdwn b/doc/wikitemplates.mdwn index b8341b637..1f6325b4b 100644 --- a/doc/wikitemplates.mdwn +++ b/doc/wikitemplates.mdwn @@ -11,7 +11,6 @@ located in /usr/share/ikiwiki/templates by default. * `misc.tmpl` - Generic template used for any page that doesn't have a custom template. * `editpage.tmpl` - Create/edit page. -* `recentchanges.tmpl` - Used to generate a RecentChanges table with inline. * `change.tmpl` - Used to create a page describing a change made to the wiki. * `passwordmail.tmpl` - Not a html template, this is used to generate the mail with the user's password in it. diff --git a/templates/change.tmpl b/templates/change.tmpl index 9dbc97ec2..f02b5eb19 100644 --- a/templates/change.tmpl +++ b/templates/change.tmpl @@ -1,27 +1,24 @@ +[[meta author=""""""]] + +[[meta authorurl=""""""]] + +[[meta title=""""""]] +

+ + +
+
+
+

+

+ + + + "> + diff + + + + +changed via - - - - - - - "> - diff - - - - - - - - - - - - - -
-
-
- - diff --git a/templates/recentchanges.tmpl b/templates/recentchanges.tmpl deleted file mode 100644 index 2e33b79f9..000000000 --- a/templates/recentchanges.tmpl +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - -
usertimechanges
-
-- cgit v1.2.3 From 38e79f206edf7a6ae80fb2beeb026eadff0a4e0c Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 29 Jan 2008 04:44:05 -0500 Subject: more style improvements --- IkiWiki/Plugin/recentchanges.pm | 11 +++++++--- doc/recentchanges.mdwn | 5 ++++- doc/style.css | 48 ++++++++++++++++++++++++++++++----------- templates/change.tmpl | 26 ++++++++++++++++------ templates/inlinechange.tmpl | 6 +----- 5 files changed, 68 insertions(+), 28 deletions(-) (limited to 'templates/change.tmpl') diff --git a/IkiWiki/Plugin/recentchanges.pm b/IkiWiki/Plugin/recentchanges.pm index fb9841ffd..bdd386c7b 100644 --- a/IkiWiki/Plugin/recentchanges.pm +++ b/IkiWiki/Plugin/recentchanges.pm @@ -68,8 +68,9 @@ sub store ($$) { #{{{ push @{$change->{pages}}, { link => '...' } if $is_excess; # Take the first line of the commit message as a summary. - my $m=shift @{$change->{message}}; - $change->{summary}=$m->{line}; + #my $m=shift @{$change->{message}}; + #$change->{summary}=$m->{line}; + #delete $change->{message} unless @{$change->{message}}; # See if the committer is an openid. my $oiduser=IkiWiki::openiduser($change->{user}); @@ -85,7 +86,11 @@ sub store ($$) { #{{{ # Fill out a template with the change info. my $template=template("change.tmpl", blind_cache => 1); - $template->param(%$change); + $template->param( + %$change, + commitdate => displaytime($change->{when}, "%x %x"), + wikiname => $config{wikiname}, + ); $template->param(baseurl => "$config{url}/") if length $config{url}; IkiWiki::run_hooks(pagetemplate => sub { shift->(page => $page, destpage => $page, template => $template); diff --git a/doc/recentchanges.mdwn b/doc/recentchanges.mdwn index b2c7f5d07..4e9ee91ec 100644 --- a/doc/recentchanges.mdwn +++ b/doc/recentchanges.mdwn @@ -1,2 +1,5 @@ +Recent changes to this wiki: + [[recentchanges pages="*" num=100 template=change]] -[[inline pages="recentchanges/change_* and !*/Discussion" show=0]] +[[inline pages="recentchanges/change_* and !*/Discussion" +template=inlinechange show=0]] diff --git a/doc/style.css b/doc/style.css index 0fa15d2b1..026d2c881 100644 --- a/doc/style.css +++ b/doc/style.css @@ -70,27 +70,49 @@ img { border-style: none; } -/* Stuff for the RecentChanges table. */ -tr.changeheader { +div.recentchanges { + border-style: solid; + border-width: 1px; + overflow: auto; + width: 100%; background: #eee; color: black !important; } -tr.changeinfo { - background: #eee; +.recentchanges .metadata { + padding: 0px 0.5em; +} +.recentchanges .changelog { + font-style: italic; + clear: both; + display: block; + padding: 1px 2px; + background: white !important; color: black !important; } -th.changeheader { - padding: 1px .3em; +.recentchanges .desc { + display: none; +} +.recentchanges .committer { + float: left; + margin: 0; + width: 40%; } -td.changeinfo { - padding: 1px .3em; +.recentchanges .committype { + float: left; + margin: 0; + width: 5%; + font-size: small; } -td.changetime { - white-space: nowrap; - padding: 1px .3em; +.recentchanges .changedate { + float: left; + margin: 0; + width: 35%; + font-size: small; } -td.changelog { - font-style: italic; +.recentchanges .pagelinks { + float: right; + margin: 0; + width: 60%; } /* Used for adding a blog page. */ diff --git a/templates/change.tmpl b/templates/change.tmpl index f02b5eb19..6df365250 100644 --- a/templates/change.tmpl +++ b/templates/change.tmpl @@ -2,16 +2,17 @@ [[meta authorurl=""""""]] -[[meta title=""""""]] -

+[[meta title="""update of 's """]] +


-

-

- +

+ diff --git a/templates/inlinechange.tmpl b/templates/inlinechange.tmpl index 669911184..340a157d1 100644 --- a/templates/inlinechange.tmpl +++ b/templates/inlinechange.tmpl @@ -1,11 +1,7 @@ -
+
-
Date:
- - -
-- cgit v1.2.3 From 6446b6723939c91a5a925d28447d28a6eb15cfe8 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 29 Jan 2008 04:53:45 -0500 Subject: move message to end --- templates/change.tmpl | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'templates/change.tmpl') diff --git a/templates/change.tmpl b/templates/change.tmpl index 6df365250..e25cbf3b8 100644 --- a/templates/change.tmpl +++ b/templates/change.tmpl @@ -3,13 +3,6 @@ [[meta authorurl=""""""]] [[meta title="""update of 's """]] -
- - -
-
-
-
+
+ + +
+
+
+
-- cgit v1.2.3 From f630b6ca370d9c3069b068ff1ed12ce0449cf2e4 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 29 Jan 2008 16:07:57 -0500 Subject: really use unmunged author in metadata --- templates/change.tmpl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'templates/change.tmpl') diff --git a/templates/change.tmpl b/templates/change.tmpl index e25cbf3b8..570d47559 100644 --- a/templates/change.tmpl +++ b/templates/change.tmpl @@ -1,4 +1,4 @@ -[[meta author=""""""]] +[[meta author=""""""]] [[meta authorurl=""""""]] -- cgit v1.2.3 From 64a8c828b8cfa342118dd6e28b9dff43d83c6311 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 29 Jan 2008 17:16:51 -0500 Subject: * meta: Add pagespec functions to match against title, author, authorurl, license, and copyright. This can be used to create custom RecentChanges. * meta: To support the pagespec functions, metadata about pages has to be retained as pagestate. * Fix encoding bug when pagestate values contained spaces. --- IkiWiki.pm | 2 +- IkiWiki/Plugin/meta.pm | 122 +++++++++++++++++++++++++++-------------- IkiWiki/Render.pm | 1 + debian/changelog | 5 ++ doc/ikiwiki/pagespec.mdwn | 7 ++- doc/plugins/recentchanges.mdwn | 14 +++++ doc/plugins/write.mdwn | 18 +++--- docwiki.setup | 4 +- po/ikiwiki.pot | 32 +++++------ templates/change.tmpl | 2 +- 10 files changed, 136 insertions(+), 71 deletions(-) (limited to 'templates/change.tmpl') diff --git a/IkiWiki.pm b/IkiWiki.pm index db2605672..016c664b5 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -973,7 +973,7 @@ sub saveindex () { #{{{ if (exists $pagestate{$page}) { foreach my $id (@hookids) { foreach my $key (keys %{$pagestate{$page}{$id}}) { - $line.=' '.$id.'_'.encode_entities($key)."=".encode_entities($pagestate{$page}{$id}{$key}); + $line.=' '.$id.'_'.encode_entities($key)."=".encode_entities($pagestate{$page}{$id}{$key}, " \t\n"); } } } diff --git a/IkiWiki/Plugin/meta.pm b/IkiWiki/Plugin/meta.pm index d2c6e7f8b..849a13e37 100644 --- a/IkiWiki/Plugin/meta.pm +++ b/IkiWiki/Plugin/meta.pm @@ -6,13 +6,7 @@ use warnings; use strict; use IkiWiki 2.00; -my %meta; -my %title; -my %permalink; -my %author; -my %authorurl; -my %license; -my %copyright; +my %metaheaders; sub import { #{{{ hook(type => "needsbuild", id => "meta", call => \&needsbuild); @@ -71,16 +65,16 @@ sub preprocess (@) { #{{{ # Metadata collection that needs to happen during the scan pass. if ($key eq 'title') { - $title{$page}=HTML::Entities::encode_numeric($value); + $pagestate{$page}{meta}{title}=HTML::Entities::encode_numeric($value); } elsif ($key eq 'license') { - push @{$meta{$page}}, ''; - $license{$page}=$value; + push @{$metaheaders{$page}}, ''; + $pagestate{$page}{meta}{license}=$value; return ""; } elsif ($key eq 'copyright') { - push @{$meta{$page}}, ''; - $copyright{$page}=$value; + push @{$metaheaders{$page}}, ''; + $pagestate{$page}{meta}{copyright}=$value; return ""; } elsif ($key eq 'link' && ! %params) { @@ -89,11 +83,11 @@ sub preprocess (@) { #{{{ return ""; } elsif ($key eq 'author') { - $author{$page}=$value; + $pagestate{$page}{meta}{author}=$value; # fallthorough } elsif ($key eq 'authorurl') { - $authorurl{$page}=$value; + $pagestate{$page}{meta}{authorurl}=$value; # fallthrough } @@ -111,8 +105,8 @@ sub preprocess (@) { #{{{ } } elsif ($key eq 'permalink') { - $permalink{$page}=$value; - push @{$meta{$page}}, scrub(''); + $pagestate{$page}{meta}{permalink}=$value; + push @{$metaheaders{$page}}, scrub(''); } elsif ($key eq 'stylesheet') { my $rel=exists $params{rel} ? $params{rel} : "alternate stylesheet"; @@ -123,17 +117,17 @@ sub preprocess (@) { #{{{ if (! length $stylesheet) { return "[[meta ".gettext("stylesheet not found")."]]"; } - push @{$meta{$page}}, '"; } elsif ($key eq 'openid') { if (exists $params{server}) { - push @{$meta{$page}}, ''; } - push @{$meta{$page}}, ''; } elsif ($key eq 'redir') { @@ -172,11 +166,11 @@ sub preprocess (@) { #{{{ if (! $safe) { $redir=scrub($redir); } - push @{$meta{$page}}, $redir; + push @{$metaheaders{$page}}, $redir; } elsif ($key eq 'link') { if (%params) { - push @{$meta{$page}}, scrub("'); } @@ -197,32 +191,80 @@ sub pagetemplate (@) { #{{{ my $destpage=$params{destpage}; my $template=$params{template}; - if (exists $meta{$page} && $template->query(name => "meta")) { + if (exists $metaheaders{$page} && $template->query(name => "meta")) { # avoid duplicate meta lines my %seen; - $template->param(meta => join("\n", grep { (! $seen{$_}) && ($seen{$_}=1) } @{$meta{$page}})); + $template->param(meta => join("\n", grep { (! $seen{$_}) && ($seen{$_}=1) } @{$metaheaders{$page}})); } - if (exists $title{$page} && $template->query(name => "title")) { - $template->param(title => $title{$page}); + if (exists $pagestate{$page}{meta}{title} && $template->query(name => "title")) { + $template->param(title => $pagestate{$page}{meta}{title}); $template->param(title_overridden => 1); } - $template->param(permalink => $permalink{$page}) - if exists $permalink{$page} && $template->query(name => "permalink"); - $template->param(author => $author{$page}) - if exists $author{$page} && $template->query(name => "author"); - $template->param(authorurl => $authorurl{$page}) - if exists $authorurl{$page} && $template->query(name => "authorurl"); - if (exists $license{$page} && $template->query(name => "license") && - ($page eq $destpage || ! exists $license{$destpage} || - $license{$page} ne $license{$destpage})) { - $template->param(license => htmlize($page, $destpage, $license{$page})); + foreach my $field (qw{author authorurl permalink}) { + $template->param($field => $pagestate{$page}{meta}{$field}) + if exists $pagestate{$page}{meta}{$field} && $template->query(name => $field); } - if (exists $copyright{$page} && $template->query(name => "copyright") && - ($page eq $destpage || ! exists $copyright{$destpage} || - $copyright{$page} ne $copyright{$destpage})) { - $template->param(copyright => htmlize($page, $destpage, $copyright{$page})); + + foreach my $field (qw{license copyright}) { + if (exists $pagestate{$page}{meta}{$field} && $template->query(name => $field) && + ($page eq $destpage || ! exists $pagestate{$destpage}{meta}{$field} || + $pagestate{$page}{meta}{$field} ne $pagestate{$destpage}{meta}{$field})) { + $template->param($field => htmlize($page, $destpage, $pagestate{$page}{meta}{$field})); + } } } # }}} +sub match { #{{{ + my $field=shift; + my $page=shift; + + # turn glob into a safe regexp + my $re=quotemeta(shift); + $re=~s/\\\*/.*/g; + $re=~s/\\\?/./g; + + my $val; + if (exists $pagestate{$page}{meta}{$field}) { + $val=$pagestate{$page}{meta}{$field}; + } + elsif ($field eq 'title') { + $val=pagetitle($page); + } + + if (defined $val) { + if ($val=~/^$re$/i) { + return IkiWiki::SuccessReason->new("$re matches $field of $page"); + } + else { + return IkiWiki::FailReason->new("$re does not match $field of $page"); + } + } + else { + return IkiWiki::FailReason->new("$page does not have a $field"); + } +} #}}} + +package IkiWiki::PageSpec; + +sub match_title ($$;@) { #{{{ + IkiWiki::Plugin::meta::match("title", @_); +} #}}} + +sub match_author ($$;@) { #{{{ + IkiWiki::Plugin::meta::match("author", @_); +} #}}} + +sub match_authorurl ($$;@) { #{{{ + IkiWiki::Plugin::meta::match("authorurl", @_); +} #}}} + +sub match_license ($$;@) { #{{{ + IkiWiki::Plugin::meta::match("license", @_); +} #}}} + +sub match_copyright ($$;@) { #{{{ + IkiWiki::Plugin::meta::match("copyright", @_); +} #}}} + 1 diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm index 4495b9cfd..76e8ef1f4 100644 --- a/IkiWiki/Render.pm +++ b/IkiWiki/Render.pm @@ -377,6 +377,7 @@ sub refresh () { #{{{ $pagemtime{$page}=$mtime; if (isinternal($page)) { push @internal, $file; + scan($file); } else { push @needsbuild, $file; diff --git a/debian/changelog b/debian/changelog index c608531e1..77202ed1f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -31,6 +31,11 @@ ikiwiki (2.21) UNRELEASED; urgency=low the svnrepo and notify settings, though both will be ignored if left in setup files. Also gone with it is the "user()" pagespec. * Add refresh hook. + * meta: Add pagespec functions to match against title, author, authorurl, + license, and copyright. This can be used to create custom RecentChanges. + * meta: To support the pagespec functions, metadata about pages has to be + retained as pagestate. + * Fix encoding bug when pagestate values contained spaces. -- Joey Hess Fri, 11 Jan 2008 15:09:37 -0500 diff --git a/doc/ikiwiki/pagespec.mdwn b/doc/ikiwiki/pagespec.mdwn index e1a476202..3cd6bb9f4 100644 --- a/doc/ikiwiki/pagespec.mdwn +++ b/doc/ikiwiki/pagespec.mdwn @@ -33,10 +33,13 @@ functions: was created * "`created_before(page)`" - match only pages created before the given page was created -* "`glob(foo)`" - match pages that match the given glob `foo`. Just writing +* "`glob(someglob)`" - match pages that match the given glob. Just writing the glob by itself is actually a shorthand for this function. -* "`internal(foo)`" - like `glob()`, but matches even internal-use +* "`internal(glob)`" - like `glob()`, but matches even internal-use pages that globs do not usually match. +* "`title(glob)`", "`author(glob)`", "`authorurl(glob)`", + "`license(glob)`", "`copyright(glob)`" - match pages that have the given + metadata, matching the specified glob. For example, to match all pages in a blog that link to the page about music and were written in 2005: diff --git a/doc/plugins/recentchanges.mdwn b/doc/plugins/recentchanges.mdwn index 8647985c9..b48dcbacf 100644 --- a/doc/plugins/recentchanges.mdwn +++ b/doc/plugins/recentchanges.mdwn @@ -10,3 +10,17 @@ plugin, but you can use it elsewhere too if you like. It's used like this: \[[inline pages="internal(recentchanges/change_*)" template=recentchanges show=0]] + +Here's an example of how to show only changes to "bugs/*". +This matches against the title of the change, which includes a list of +modified pages. + + \[[inline pages="internal(recentchanges/change_*) and title(*bugs/*)" + template=recentchanges show=0]] + +Here's an example of how to show only changes that Joey didn't make. +(Joey commits sometimes as user `joey`, and sometimes via openid.) + + \[[inline pages="internal(recentchanges/change_*) and + !author(joey) and !author(http://joey.kitenet.net*)" + template=recentchanges show=0]] diff --git a/doc/plugins/write.mdwn b/doc/plugins/write.mdwn index 79da6a612..9c3a36b8f 100644 --- a/doc/plugins/write.mdwn +++ b/doc/plugins/write.mdwn @@ -533,18 +533,16 @@ rendered to. ## Internal use pages -Sometimes it's useful to put pages in the wiki without having them be -rendered to individual html files. Such internal use pages are collected -together to form the RecentChanges page, for example. +Sometimes it's useful to put pages in the wiki without the overhead of +having them be rendered to individual html files. Such internal use pages +are collected together to form the RecentChanges page, for example. To make an internal use page, register a filename extension that starts -with "_". Internal use pages cannot be edited with the web interface, are -not scanned for wikilinks (though wikilinks and preprocessor directives can -appear on them, this is rarely a good idea and should be done with caution), -and are not matched by regular PageSpecs glob patterns, but instead only by a -special `internal()` [[ikiwiki/PageSpec]]. - -Ikiwiki is optimised to handle lots of internal use pages, very quickly. +with "_". Internal use pages cannot be edited with the web interface, +generally shouldn't contain wikilinks or preprocessor directives (use +either on them with extreme caution), and are not matched by regular +PageSpecs glob patterns, but instead only by a special `internal()` +[[ikiwiki/PageSpec]]. ## RCS plugins diff --git a/docwiki.setup b/docwiki.setup index e8f680a20..ab9696b81 100644 --- a/docwiki.setup +++ b/docwiki.setup @@ -15,6 +15,8 @@ use IkiWiki::Setup::Standard { syslog => 0, userdir => "users", usedirs => 0, + rcs => "git", + rss => 1, + url => "http://ikiwiki.info/", add_plugins => [qw{goodstuff version haiku polygen fortune}], - disable_plugins => [qw{recentchanges}], } diff --git a/po/ikiwiki.pot b/po/ikiwiki.pot index 4e43f5da9..027e10e8a 100644 --- a/po/ikiwiki.pot +++ b/po/ikiwiki.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2008-01-29 15:46-0500\n" +"POT-Creation-Date: 2008-01-29 17:15-0500\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -47,8 +47,8 @@ msgstr "" #: ../IkiWiki/CGI.pm:382 ../IkiWiki/Plugin/brokenlinks.pm:24 #: ../IkiWiki/Plugin/inline.pm:241 ../IkiWiki/Plugin/opendiscussion.pm:17 -#: ../IkiWiki/Plugin/orphans.pm:28 ../IkiWiki/Render.pm:100 -#: ../IkiWiki/Render.pm:180 +#: ../IkiWiki/Plugin/orphans.pm:28 ../IkiWiki/Render.pm:101 +#: ../IkiWiki/Render.pm:181 msgid "discussion" msgstr "" @@ -218,7 +218,7 @@ msgstr "" msgid "nonexistant template %s" msgstr "" -#: ../IkiWiki/Plugin/inline.pm:249 ../IkiWiki/Render.pm:104 +#: ../IkiWiki/Plugin/inline.pm:249 ../IkiWiki/Render.pm:105 msgid "Discussion" msgstr "" @@ -240,15 +240,15 @@ msgstr "" msgid "failed to load Markdown.pm perl module (%s) or /usr/bin/markdown (%s)" msgstr "" -#: ../IkiWiki/Plugin/meta.pm:124 +#: ../IkiWiki/Plugin/meta.pm:118 msgid "stylesheet not found" msgstr "" -#: ../IkiWiki/Plugin/meta.pm:148 +#: ../IkiWiki/Plugin/meta.pm:142 msgid "redir page not found" msgstr "" -#: ../IkiWiki/Plugin/meta.pm:161 +#: ../IkiWiki/Plugin/meta.pm:155 msgid "redir cycle is not allowed" msgstr "" @@ -503,47 +503,47 @@ msgstr "" msgid "getctime not implemented" msgstr "" -#: ../IkiWiki/Render.pm:280 ../IkiWiki/Render.pm:301 +#: ../IkiWiki/Render.pm:281 ../IkiWiki/Render.pm:302 #, perl-format msgid "skipping bad filename %s" msgstr "" -#: ../IkiWiki/Render.pm:350 +#: ../IkiWiki/Render.pm:351 #, perl-format msgid "removing old page %s" msgstr "" -#: ../IkiWiki/Render.pm:389 +#: ../IkiWiki/Render.pm:391 #, perl-format msgid "scanning %s" msgstr "" -#: ../IkiWiki/Render.pm:394 +#: ../IkiWiki/Render.pm:396 #, perl-format msgid "rendering %s" msgstr "" -#: ../IkiWiki/Render.pm:415 +#: ../IkiWiki/Render.pm:417 #, perl-format msgid "rendering %s, which links to %s" msgstr "" -#: ../IkiWiki/Render.pm:436 +#: ../IkiWiki/Render.pm:438 #, perl-format msgid "rendering %s, which depends on %s" msgstr "" -#: ../IkiWiki/Render.pm:475 +#: ../IkiWiki/Render.pm:477 #, perl-format msgid "rendering %s, to update its backlinks" msgstr "" -#: ../IkiWiki/Render.pm:487 +#: ../IkiWiki/Render.pm:489 #, perl-format msgid "removing %s, no longer rendered by %s" msgstr "" -#: ../IkiWiki/Render.pm:513 +#: ../IkiWiki/Render.pm:515 #, perl-format msgid "ikiwiki: cannot render %s" msgstr "" diff --git a/templates/change.tmpl b/templates/change.tmpl index 570d47559..f9941ae70 100644 --- a/templates/change.tmpl +++ b/templates/change.tmpl @@ -2,7 +2,7 @@ [[meta authorurl=""""""]] -[[meta title="""update of 's """]] +[[meta title="""update of 's """]] - + -- cgit v1.2.3 From e40a9b05111f83af2dc24be76a131b490d6f6956 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 29 Jan 2008 18:25:13 -0500 Subject: more HTML::Template fun fix whitespace that led to bad wrapping and display --- templates/change.tmpl | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) (limited to 'templates/change.tmpl') diff --git a/templates/change.tmpl b/templates/change.tmpl index 1d1a17516..845677cce 100644 --- a/templates/change.tmpl +++ b/templates/change.tmpl @@ -7,12 +7,13 @@
Changed pages:
- - - diff - - - + + +diff + + + +
Changed by:
@@ -30,9 +31,9 @@
- -
-
+ +
+
-- cgit v1.2.3 From 7da5b9948eccdc8ca9e348a295a8cc516701b043 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 29 Jan 2008 18:27:41 -0500 Subject: more whitespace nonsense --- templates/change.tmpl | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'templates/change.tmpl') diff --git a/templates/change.tmpl b/templates/change.tmpl index 845677cce..16ef08a85 100644 --- a/templates/change.tmpl +++ b/templates/change.tmpl @@ -7,10 +7,7 @@
Changed pages:
- - -diff - +diff -- cgit v1.2.3