* 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.
master
joey 2006-07-30 22:58:48 +00:00
parent 26c2c63c97
commit 8883001615
8 changed files with 48 additions and 14 deletions

View File

@ -188,7 +188,8 @@ sub aggregate () { #{{{
die $@ if $@; die $@ if $@;
foreach my $feed (values %feeds) { 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->{lastupdate}=time;
$feed->{newposts}=0; $feed->{newposts}=0;
$IkiWiki::forcerebuild{$feed->{sourcepage}}=1; $IkiWiki::forcerebuild{$feed->{sourcepage}}=1;
@ -277,7 +278,7 @@ sub add_page (@) { #{{{
eval q{use Digest::MD5 'md5_hex'}; eval q{use Digest::MD5 'md5_hex'};
require Encode; require Encode;
my $digest=md5_hex(Encode::encode_utf8($params{content})); 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; $guid->{md5}=$digest;
# Create the page. # Create the page.
@ -285,6 +286,8 @@ sub add_page (@) { #{{{
my $content=$params{content}; my $content=$params{content};
$params{content}=~s/(?<!\\)\[\[/\\\[\[/g; # escape accidental wikilinks $params{content}=~s/(?<!\\)\[\[/\\\[\[/g; # escape accidental wikilinks
# and preprocessor stuff # and preprocessor stuff
$template->param(title => $params{title})
if defined $params{title} && length($params{title});
$template->param(content => $params{content}); $template->param(content => $params{content});
$template->param(url => $feed->{url}); $template->param(url => $feed->{url});
$template->param(name => $feed->{name}); $template->param(name => $feed->{name});

View File

@ -12,10 +12,20 @@ my %title;
sub import { #{{{ sub import { #{{{
IkiWiki::hook(type => "preprocess", id => "meta", IkiWiki::hook(type => "preprocess", id => "meta",
call => \&preprocess); call => \&preprocess);
IkiWiki::hook(type => "filter", id => "meta",
call => \&filter);
IkiWiki::hook(type => "pagetemplate", id => "meta", IkiWiki::hook(type => "pagetemplate", id => "meta",
call => \&pagetemplate); call => \&pagetemplate);
} # }}} } # }}}
sub filter (@) { #{{{
my %params=@_;
$meta{$params{page}}='';
return $params{content};
} # }}}
sub preprocess (@) { #{{{ sub preprocess (@) { #{{{
if (! @_) { if (! @_) {
return ""; return "";
@ -28,13 +38,15 @@ sub preprocess (@) { #{{{
delete $params{page}; delete $params{page};
delete $params{destpage}; 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 ($key eq 'link') {
if (%params) { if (%params) {
$meta{$page}='' unless exists $meta{$page}; $meta{$page}.="<link href=\"".encode_entities($value)."\" ".
$meta{$page}.="<link href=\"".escapeHTML($value)."\" ". join(" ", map { encode_entities($_)."=\"".encode_entities(decode_entities($params{$_}))."\"" } keys %params).
join(" ", map { escapeHTML("$_=\"$params{$_}\"") } keys %params).
" />\n"; " />\n";
} }
else { else {
@ -43,11 +55,11 @@ sub preprocess (@) { #{{{
} }
} }
elsif ($key eq 'title') { elsif ($key eq 'title') {
$title{$page}=escapeHTML($value); $title{$page}=$value;
} }
else { else {
$meta{$page}='' unless exists $meta{$page}; $meta{$page}.="<meta name=\"".encode_entities($key).
$meta{$page}.="<meta name=\"".escapeHTML($key)."\" content=\"".escapeHTML($value)."\" />\n"; "\" content=\"".encode_entities($value)."\" />\n";
} }
return ""; return "";

11
debian/changelog vendored
View File

@ -11,8 +11,17 @@ ikiwiki (1.13) UNRELEASED; urgency=low
--wrappers to do that. --wrappers to do that.
* Add %IkiWiki::forcerebuild to provide a way for plugins like aggregate * Add %IkiWiki::forcerebuild to provide a way for plugins like aggregate
to update pages that haven't changed on disk. to update pages that haven't changed on disk.
* 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 <joeyh@debian.org> Sat, 29 Jul 2006 20:10:51 -0400 -- Joey Hess <joeyh@debian.org> Sun, 30 Jul 2006 18:17:28 -0400
ikiwiki (1.12) unstable; urgency=low ikiwiki (1.12) unstable; urgency=low

6
debian/control vendored
View File

@ -2,15 +2,15 @@ Source: ikiwiki
Section: web Section: web
Priority: optional Priority: optional
Build-Depends: perl, debhelper (>= 5) 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 <joeyh@debian.org> Maintainer: Joey Hess <joeyh@debian.org>
Standards-Version: 3.7.2 Standards-Version: 3.7.2
Package: ikiwiki Package: ikiwiki
Architecture: all 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 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 Description: a wiki compiler
ikiwiki converts a directory full of wiki pages into html pages suitable 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 for publishing on a website. Unlike many wikis, ikiwiki does not have its

View File

@ -13,7 +13,7 @@ aggregated feeds.
## setup ## setup
Make sure that you have the [[html]] plugin enabled, as the created pages are 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 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 --aggregate parameter, to make it check for new posts. Here's an example

View File

@ -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 &lt;meta&gt; the metadata will be written to the generated html page as a &lt;meta&gt;
header. header.
The field value is treated as HTML entity-escaped text, so you can include
a quote in the text by writing `&quot;` and so on.
This plugin is included in ikiwiki, but it is not enabled by default. If 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. it is enabled, the title of this page will say it is.
[[meta title="meta plugin (enabled)"]] [[meta title="meta plugin (enabled)"]]

View File

@ -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 If the aggregate plugin is enabled, this makes ikiwiki poll configured
feeds and save new posts to the srcdir. 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 # CONFIG OPTIONS
These options configure the wiki. Note that plugins can add additional These options configure the wiki. Note that plugins can add additional

View File

@ -10,3 +10,6 @@ From <a href="<TMPL_VAR URL>"><TMPL_VAR NAME></a>
<TMPL_LOOP NAME="TAGS"> <TMPL_LOOP NAME="TAGS">
[[tag <TMPL_VAR TAG>]] [[tag <TMPL_VAR TAG>]]
</TMPL_LOOP> </TMPL_LOOP>
<TMPL_IF NAME="TITLE">
[[meta title="<TMPL_VAR NAME="TITLE" ESCAPE=HTML>"]]
</TMPL_IF>