sub import { #{{{
hook(type => "needsbuild", id => "meta", call => \&needsbuild);
- hook(type => "preprocess", id => "meta", call => \&preprocess);
+ hook(type => "preprocess", id => "meta", call => \&preprocess, scan => 1);
hook(type => "pagetemplate", id => "meta", call => \&pagetemplate);
} # }}}
# fully encoded.
$value=decode_entities($value);
+ # Metadata collection that needs to happen during the scan pass.
if ($key eq 'title') {
$title{$page}=HTML::Entities::encode_numeric($value);
}
- elsif ($key eq 'permalink') {
- $permalink{$page}=$value;
- push @{$meta{$page}}, scrub('<link rel="bookmark" href="'.encode_entities($value).'" />');
- }
elsif ($key eq 'date') {
eval q{use Date::Parse};
if (! $@) {
$IkiWiki::pagectime{$page}=$time if defined $time;
}
}
+ elsif ($key eq 'license') {
+ push @{$meta{$page}}, '<link rel="license" href="#page_license" />';
+ $license{$page}=$value;
+ return "";
+ }
+ elsif ($key eq 'copyright') {
+ push @{$meta{$page}}, '<link rel="copyright" href="#page_copyright" />';
+ $copyright{$page}=$value;
+ return "";
+ }
+ elsif ($key eq 'link' && ! %params) {
+ # hidden WikiLink
+ push @{$links{$page}}, $value;
+ return "";
+ }
+ elsif ($key eq 'author') {
+ $author{$page}=$value;
+ # fallthorough
+ }
+ elsif ($key eq 'authorurl') {
+ $authorurl{$page}=$value;
+ # fallthrough
+ }
+
+ if (! defined wantarray) {
+ # avoid collecting duplicate data during scan pass
+ return;
+ }
+
+ # Metadata collection that happens only during preprocessing pass.
+ if ($key eq 'permalink') {
+ $permalink{$page}=$value;
+ push @{$meta{$page}}, scrub('<link rel="bookmark" href="'.encode_entities($value).'" />');
+ }
elsif ($key eq 'stylesheet') {
my $rel=exists $params{rel} ? $params{rel} : "alternate stylesheet";
my $title=exists $params{title} ? $params{title} : $value;
push @{$meta{$page}}, '<link href="'.encode_entities($value).
'" rel="openid.delegate" />';
}
- elsif ($key eq 'license') {
- push @{$meta{$page}}, '<link rel="license" href="#page_license" />';
- $license{$page}=$value;
- }
- elsif ($key eq 'copyright') {
- push @{$meta{$page}}, '<link rel="copyright" href="#page_copyright" />';
- $copyright{$page}=$value;
- }
elsif ($key eq 'redir') {
return "" if $page ne $destpage;
my $safe=0;
push @{$meta{$page}}, $redir;
}
elsif ($key eq 'link') {
- return "[[meta ".gettext("link is no longer supported")."]]";
+ if (%params) {
+ $meta{$page}.=scrub("<link href=\"".encode_entities($value)."\" ".
+ join(" ", map {
+ encode_entities($_)."=\"".encode_entities(decode_entities($params{$_}))."\""
+ } keys %params).
+ " />\n");
+ }
}
else {
push @{$meta{$page}}, scrub('<meta name="'.encode_entities($key).
'" content="'.encode_entities($value).'" />');
- if ($key eq 'author') {
- $author{$page}=$value;
- }
- elsif ($key eq 'authorurl') {
- $authorurl{$page}=$value;
- }
}
return "";
if exists $author{$page} && $template->query(name => "author");
$template->param(authorurl => $authorurl{$page})
if exists $authorurl{$page} && $template->query(name => "authorurl");
-
- if ($page ne $destpage &&
- ((exists $license{$page} && ! exists $license{$destpage}) ||
- (exists $copyright{$page} && ! exists $copyright{$destpage}))) {
- # Force a scan of the destpage to get its copyright/license
- # info. If the info is declared after an inline, it will
- # otherwise not be available at this point.
- IkiWiki::scan($pagesources{$destpage});
- }
if (exists $license{$page} && $template->query(name => "license") &&
($page eq $destpage || ! exists $license{$destpage} ||
* inline: Add copyright/license info on a per-post basis to atom
feeds if available. (rss doesn't allow such info on a per-post basis)
+ * Also include overall copyright/license and author info in atom feeds if
+ available.
* meta: Allow copyright/license metadata to contain arbitrary markup.
+ * Call preprocessor hooks in void context during the scan pass. This allows
+ the hook to determine if it's just scanning, and avoid expensive
+ operations.
+ * img: Detect scan mode and avoid generating and writing the image file
+ during it, for a 2x speedup.
+ * meta: Run in scan mode again (more intelligently) and re-add support for
+ meta link.
+ * Fix support for the case where metadata appears after an inline directive.
+ This was broken in version 2.16.
-- Joey Hess <joeyh@debian.org> Wed, 09 Jan 2008 00:34:46 -0500