summaryrefslogtreecommitdiff
path: root/IkiWiki
diff options
context:
space:
mode:
authorjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>2006-07-30 22:58:48 +0000
committerjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>2006-07-30 22:58:48 +0000
commit88830016154d99a0155e1cee58582e9f32dcca51 (patch)
treebcb92fbcb40f36d94de660d9fe5ddb6477ca06a4 /IkiWiki
parent26c2c63c97e6bfa704357503fdfd8d8834838851 (diff)
* 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.
Diffstat (limited to 'IkiWiki')
-rw-r--r--IkiWiki/Plugin/aggregate.pm7
-rw-r--r--IkiWiki/Plugin/meta.pm26
2 files changed, 24 insertions, 9 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/(?<!\\)\[\[/\\\[\[/g; # escape accidental wikilinks
# and preprocessor stuff
+ $template->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}.="<link href=\"".escapeHTML($value)."\" ".
- join(" ", map { escapeHTML("$_=\"$params{$_}\"") } keys %params).
+ $meta{$page}.="<link href=\"".encode_entities($value)."\" ".
+ join(" ", map { encode_entities($_)."=\"".encode_entities(decode_entities($params{$_}))."\"" } keys %params).
" />\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}.="<meta name=\"".escapeHTML($key)."\" content=\"".escapeHTML($value)."\" />\n";
+ $meta{$page}.="<meta name=\"".encode_entities($key).
+ "\" content=\"".encode_entities($value)."\" />\n";
}
return "";