From 88830016154d99a0155e1cee58582e9f32dcca51 Mon Sep 17 00:00:00 2001 From: joey Date: Sun, 30 Jul 2006 22:58:48 +0000 Subject: * 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 +++++++++++++++++++------- 2 files changed, 24 insertions(+), 9 deletions(-) (limited to 'IkiWiki/Plugin') 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 ""; -- cgit v1.2.3