From 88830016154d99a0155e1cee58582e9f32dcca51 Mon Sep 17 00:00:00 2001 From: joey Date: Sun, 30 Jul 2006 22:58:48 +0000 Subject: [PATCH] * Change meta tags to use html entity-escaped text for values, so that quotes and such can be represented in title tags. * Depend and build-depend on HTML::Parser for HTML::Entities which is used for the above. * Make --rebuild also cause --aggregate to re-download and write aggregated pages. * Avoid outputting duplicate meta info. * Include title metadata on aggregated posts for capitalised and un-munged titles. --- IkiWiki/Plugin/aggregate.pm | 7 +++++-- IkiWiki/Plugin/meta.pm | 26 +++++++++++++++++++------- debian/changelog | 13 +++++++++++-- debian/control | 6 +++--- doc/plugins/aggregate.mdwn | 2 +- doc/plugins/meta.mdwn | 3 +++ doc/usage.mdwn | 4 ++++ templates/aggregatepost.tmpl | 3 +++ 8 files changed, 49 insertions(+), 15 deletions(-) diff --git a/IkiWiki/Plugin/aggregate.pm b/IkiWiki/Plugin/aggregate.pm index 9c28651f0..98e534366 100644 --- a/IkiWiki/Plugin/aggregate.pm +++ b/IkiWiki/Plugin/aggregate.pm @@ -188,7 +188,8 @@ sub aggregate () { #{{{ die $@ if $@; foreach my $feed (values %feeds) { - next unless time - $feed->{lastupdate} >= $feed->{updateinterval}; + next unless $IkiWiki::config{rebuild} || + time - $feed->{lastupdate} >= $feed->{updateinterval}; $feed->{lastupdate}=time; $feed->{newposts}=0; $IkiWiki::forcerebuild{$feed->{sourcepage}}=1; @@ -277,7 +278,7 @@ sub add_page (@) { #{{{ eval q{use Digest::MD5 'md5_hex'}; require Encode; my $digest=md5_hex(Encode::encode_utf8($params{content})); - return unless ! exists $guid->{md5} || $guid->{md5} ne $digest; + return unless ! exists $guid->{md5} || $guid->{md5} ne $digest || $IkiWiki::config{rebuild}; $guid->{md5}=$digest; # Create the page. @@ -285,6 +286,8 @@ sub add_page (@) { #{{{ my $content=$params{content}; $params{content}=~s/(?param(title => $params{title}) + if defined $params{title} && length($params{title}); $template->param(content => $params{content}); $template->param(url => $feed->{url}); $template->param(name => $feed->{name}); diff --git a/IkiWiki/Plugin/meta.pm b/IkiWiki/Plugin/meta.pm index 15a8bad84..bac163469 100644 --- a/IkiWiki/Plugin/meta.pm +++ b/IkiWiki/Plugin/meta.pm @@ -12,10 +12,20 @@ my %title; sub import { #{{{ IkiWiki::hook(type => "preprocess", id => "meta", call => \&preprocess); + IkiWiki::hook(type => "filter", id => "meta", + call => \&filter); IkiWiki::hook(type => "pagetemplate", id => "meta", call => \&pagetemplate); } # }}} +sub filter (@) { #{{{ + my %params=@_; + + $meta{$params{page}}=''; + + return $params{content}; +} # }}} + sub preprocess (@) { #{{{ if (! @_) { return ""; @@ -28,13 +38,15 @@ sub preprocess (@) { #{{{ delete $params{page}; delete $params{destpage}; - eval q{use CGI 'escapeHTML'}; + eval q{use HTML::Entities}; + # Always dencode, even if encoding later, since it might not be + # fully encoded. + $value=decode_entities($value); if ($key eq 'link') { if (%params) { - $meta{$page}='' unless exists $meta{$page}; - $meta{$page}.="\n"; } else { @@ -43,11 +55,11 @@ sub preprocess (@) { #{{{ } } elsif ($key eq 'title') { - $title{$page}=escapeHTML($value); + $title{$page}=$value; } else { - $meta{$page}='' unless exists $meta{$page}; - $meta{$page}.="\n"; + $meta{$page}.="\n"; } return ""; diff --git a/debian/changelog b/debian/changelog index 6f33a3236..26b427333 100644 --- a/debian/changelog +++ b/debian/changelog @@ -11,8 +11,17 @@ ikiwiki (1.13) UNRELEASED; urgency=low --wrappers to do that. * Add %IkiWiki::forcerebuild to provide a way for plugins like aggregate to update pages that haven't changed on disk. - - -- Joey Hess Sat, 29 Jul 2006 20:10:51 -0400 + * Change meta tags to use html entity-escaped text for values, so that + quotes and such can be represented in title tags. + * Depend and build-depend on HTML::Parser for HTML::Entities which is used + for the above. + * Make --rebuild also cause --aggregate to re-download and write aggregated + pages. + * Avoid outputting duplicate meta info. + * Include title metadata on aggregated posts for capitalised and un-munged + titles. + + -- Joey Hess Sun, 30 Jul 2006 18:17:28 -0400 ikiwiki (1.12) unstable; urgency=low diff --git a/debian/control b/debian/control index a556fa2ed..e03455652 100644 --- a/debian/control +++ b/debian/control @@ -2,15 +2,15 @@ Source: ikiwiki Section: web Priority: optional Build-Depends: perl, debhelper (>= 5) -Build-Depends-Indep: dpkg-dev (>= 1.9.0), markdown, libhtml-template-perl, libhtml-scrubber-perl, wdg-html-validator, libtext-wikiformat-perl +Build-Depends-Indep: dpkg-dev (>= 1.9.0), markdown, libhtml-template-perl, libhtml-scrubber-perl, wdg-html-validator, libtext-wikiformat-perl, libhtml-parser-perl Maintainer: Joey Hess Standards-Version: 3.7.2 Package: ikiwiki Architecture: all -Depends: ${perl:Depends}, libxml-simple-perl, markdown, libtimedate-perl, libhtml-template-perl, libhtml-scrubber-perl, libcgi-formbuilder-perl (>= 3.02.02), libtime-duration-perl, libcgi-session-perl, libmail-sendmail-perl, gcc | c-compiler, libc6-dev | libc-dev +Depends: ${perl:Depends}, libxml-simple-perl, markdown, libtimedate-perl, libhtml-template-perl, libhtml-scrubber-perl, libcgi-formbuilder-perl (>= 3.02.02), libtime-duration-perl, libcgi-session-perl, libmail-sendmail-perl, gcc | c-compiler, libc6-dev | libc-dev, libhtml-parser-perl Recommends: subversion | git-core, hyperestraier -Suggests: viewcvs, librpc-xml-perl, libtext-wikiformat-perl, polygen, tidy, libxml-feed-perl, libhtml-parser-perl +Suggests: viewcvs, librpc-xml-perl, libtext-wikiformat-perl, polygen, tidy, libxml-feed-perl Description: a wiki compiler ikiwiki converts a directory full of wiki pages into html pages suitable for publishing on a website. Unlike many wikis, ikiwiki does not have its diff --git a/doc/plugins/aggregate.mdwn b/doc/plugins/aggregate.mdwn index 85152170f..4cd5b57ac 100644 --- a/doc/plugins/aggregate.mdwn +++ b/doc/plugins/aggregate.mdwn @@ -13,7 +13,7 @@ aggregated feeds. ## setup Make sure that you have the [[html]] plugin enabled, as the created pages are -in html format. The [[tag]] plugin is also recommended. +in html format. The [[meta]] and [[tag]] plugins are also recommended. You will need to run ikiwiki periodically from a cron job, passing it the --aggregate parameter, to make it check for new posts. Here's an example diff --git a/doc/plugins/meta.mdwn b/doc/plugins/meta.mdwn index 238233e11..32392ed54 100644 --- a/doc/plugins/meta.mdwn +++ b/doc/plugins/meta.mdwn @@ -40,6 +40,9 @@ 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. +The field value is treated as HTML entity-escaped text, so you can include +a quote in the text by writing `"` and so on. + 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/usage.mdwn b/doc/usage.mdwn index a6ded5ec2..aab5330b6 100644 --- a/doc/usage.mdwn +++ b/doc/usage.mdwn @@ -71,6 +71,10 @@ These options control the mode that ikiwiki is operating in. If the aggregate plugin is enabled, this makes ikiwiki poll configured feeds and save new posts to the srcdir. + Note that to rebuild previously aggregated posts, use the --rebuild option + along with this one. --rebuild will also force feeds to be polled even if + they were polled recently. + # CONFIG OPTIONS These options configure the wiki. Note that plugins can add additional diff --git a/templates/aggregatepost.tmpl b/templates/aggregatepost.tmpl index aa8bc27e4..689a23341 100644 --- a/templates/aggregatepost.tmpl +++ b/templates/aggregatepost.tmpl @@ -10,3 +10,6 @@ From [[tag ]] + +[[meta title=""]] + -- 2.44.0