From: joey Date: Fri, 4 Aug 2006 00:01:51 +0000 (+0000) Subject: * Make aggregator save permalinks and author name to pages as metadata. X-Git-Tag: 1.16~16 X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/commitdiff_plain/c5919df5f3697e0f8968e2b8f49cd15c1e0aa412?hp=e8b39b094116e8b50cf12fe56b9c6a04f05683e5 * Make aggregator save permalinks and author name to pages as metadata. * Add permalink and author support to meta plugin, affecting RSS feeds and blog pages. * Change titlepage() to encode utf-8 alnum characters. This is necessary to avoid UTF-8 creeping into filenames in urls. (There are still some other ways that it can get in.) --- diff --git a/IkiWiki.pm b/IkiWiki.pm index a732be999..1a5cf52dd 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -272,7 +272,9 @@ sub pagetitle ($) { #{{{ sub titlepage ($) { #{{{ my $title=shift; $title=~y/ /_/; - $title=~s/([^-[:alnum:]_:+\/.])/"__".ord($1)."__"/eg; + # Note: [:alnum:] is not used here, on purpose; unicode + # not allowed in urls. + $title=~s/([^-A-Za-z0-9_:+\/.])/"__".ord($1)."__"/eg; return $title; } #}}} diff --git a/IkiWiki/Plugin/aggregate.pm b/IkiWiki/Plugin/aggregate.pm index d6592fef3..c6ed6b209 100644 --- a/IkiWiki/Plugin/aggregate.pm +++ b/IkiWiki/Plugin/aggregate.pm @@ -289,9 +289,8 @@ sub add_page (@) { #{{{ $template->param(title => $params{title}) if defined $params{title} && length($params{title}); $template->param(content => htmlescape(htmlabs($params{content}, $feed->{feedurl}))); - $template->param(url => $feed->{url}); $template->param(name => $feed->{name}); - $template->param(link => urlabs($params{link}, $feed->{feedurl})) + $template->param(permalink => urlabs($params{link}, $feed->{feedurl})) if defined $params{link}; if (ref $feed->{tags}) { $template->param(tags => [map { tag => $_ }, @{$feed->{tags}}]); diff --git a/IkiWiki/Plugin/inline.pm b/IkiWiki/Plugin/inline.pm index d8f2ca0d8..71e71c02e 100644 --- a/IkiWiki/Plugin/inline.pm +++ b/IkiWiki/Plugin/inline.pm @@ -173,6 +173,7 @@ sub genrss ($@) { #{{{ $itemtemplate->param( title => pagetitle(basename($p)), url => "$config{url}/$renderedfiles{$p}", + permalink => "$config{url}/$renderedfiles{$p}", pubdate => date_822($pagectime{$p}), content => absolute_urls(get_inline_content($p, $page), $url), ); @@ -180,6 +181,7 @@ sub genrss ($@) { #{{{ shift->(page => $p, destpage => $page, template => $itemtemplate); }); + $content.=$itemtemplate->output; $itemtemplate->clear_params; } @@ -191,7 +193,6 @@ sub genrss ($@) { #{{{ pageurl => $url, content => $content, ); - run_hooks(pagetemplate => sub { shift->(page => $page, destpage => $page, template => $template); diff --git a/IkiWiki/Plugin/meta.pm b/IkiWiki/Plugin/meta.pm index bac163469..b6226ed88 100644 --- a/IkiWiki/Plugin/meta.pm +++ b/IkiWiki/Plugin/meta.pm @@ -8,6 +8,8 @@ use IkiWiki; my %meta; my %title; +my %permalink; +my %author; sub import { #{{{ IkiWiki::hook(type => "preprocess", id => "meta", @@ -57,9 +59,15 @@ sub preprocess (@) { #{{{ elsif ($key eq 'title') { $title{$page}=$value; } + elsif ($key eq 'permalink') { + $permalink{$page}=$value; + } else { $meta{$page}.="\n"; + if ($key eq 'author') { + $author{$page}=$value; + } } return ""; @@ -74,6 +82,11 @@ sub pagetemplate (@) { #{{{ if exists $meta{$page} && $template->query(name => "meta"); $template->param(title => $title{$page}) if exists $title{$page} && $template->query(name => "title"); + $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"); + } # }}} 1 diff --git a/debian/changelog b/debian/changelog index ab053e496..aca30fc81 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,8 +4,14 @@ ikiwiki (1.16) UNRELEASED; urgency=low the current support is a crude hack due to limitations of XML::Feed: xml:base is not supported, neither is Content-Location. And of course, relative links in RSS feeds are ill-undefined.. - - -- Joey Hess Thu, 3 Aug 2006 17:29:51 -0400 + * Make aggregator save permalinks and author name to pages as metadata. + * Add permalink and author support to meta plugin, affecting RSS feeds + and blog pages. + * Change titlepage() to encode utf-8 alnum characters. This is necessary + to avoid UTF-8 creeping into filenames in urls. (There are still + some other ways that it can get in.) + + -- Joey Hess Thu, 3 Aug 2006 18:45:36 -0400 ikiwiki (1.15) unstable; urgency=low diff --git a/doc/plugins/meta.mdwn b/doc/plugins/meta.mdwn index 32392ed54..cacb462c9 100644 --- a/doc/plugins/meta.mdwn +++ b/doc/plugins/meta.mdwn @@ -36,6 +36,10 @@ You can use any field names you like, but here are some predefined ones: Specifies the author of a page. +* permalink + + Specifies the permalink to the page, for use in RSS feeds. + 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. diff --git a/doc/todo/aggregation.mdwn b/doc/todo/aggregation.mdwn index dec242ea6..53b3133e2 100644 --- a/doc/todo/aggregation.mdwn +++ b/doc/todo/aggregation.mdwn @@ -1,4 +1 @@ * Still need to support feed expiry. -* Need to store page author metadata and include it in the rss feed. - Permalink to? Also, that stuff could be presented better in the html blog - view, also using the metadata. diff --git a/templates/aggregatepost.tmpl b/templates/aggregatepost.tmpl index 689a23341..50c09fff8 100644 --- a/templates/aggregatepost.tmpl +++ b/templates/aggregatepost.tmpl @@ -1,15 +1,12 @@ -

- -From - -; permalink - - -

+
[[tag ]] [[meta title=""]] + +[[meta permalink=""]] + +[[meta author=""]] diff --git a/templates/inlinepage.tmpl b/templates/inlinepage.tmpl index c2ddff867..6840f3681 100644 --- a/templates/inlinepage.tmpl +++ b/templates/inlinepage.tmpl @@ -5,6 +5,12 @@ Posted + +by + + +(permalink) + diff --git a/templates/rssitem.tmpl b/templates/rssitem.tmpl index 421600591..c7e587e1c 100644 --- a/templates/rssitem.tmpl +++ b/templates/rssitem.tmpl @@ -1,10 +1,15 @@ + + <TMPL_VAR AUTHOR ESCAPE=HTML>: <TMPL_VAR TITLE ESCAPE=HTML> + + <TMPL_VAR TITLE ESCAPE=HTML> + - + - + diff --git a/templates/rsspage.tmpl b/templates/rsspage.tmpl index e7676ebbd..d78f94edf 100644 --- a/templates/rsspage.tmpl +++ b/templates/rsspage.tmpl @@ -1,5 +1,6 @@ - + <TMPL_VAR TITLE ESCAPE=HTML>