2006-06-02 06:49:12 +02:00
|
|
|
#!/usr/bin/perl
|
|
|
|
# Ikiwiki metadata plugin.
|
|
|
|
package IkiWiki::Plugin::meta;
|
|
|
|
|
|
|
|
use warnings;
|
|
|
|
use strict;
|
2007-04-27 04:55:52 +02:00
|
|
|
use IkiWiki 2.00;
|
2006-06-02 06:49:12 +02:00
|
|
|
|
2008-01-29 23:16:51 +01:00
|
|
|
my %metaheaders;
|
2006-06-02 06:49:12 +02:00
|
|
|
|
|
|
|
sub import { #{{{
|
* meta: Drop support for "meta link", since supporting this for internal
links required meta to be run during scan, which complicated its data
storage, since it had to clear data stored during the scan pass to avoid
duplicating it during the normal preprocessing pass.
* If you used "meta link", you should switch to either "meta openid" (for
openid delegations), or tags (for internal, invisible links). I assume
that nobody really used "meta link" for external, non-openid links, since
the htmlscrubber ate those. (Tell me differently and I'll consider bringing
back that support.)
* meta: Improved data storage.
* meta: Drop the hackish filter hook that was used to clear
stored data before preprocessing, this hack was ugly, and broken (cf:
liw's disappearing openids).
* aggregate: Convert filter hook to a needsbuild hook.
2007-12-16 21:56:09 +01:00
|
|
|
hook(type => "needsbuild", id => "meta", call => \&needsbuild);
|
2008-01-09 08:38:43 +01:00
|
|
|
hook(type => "preprocess", id => "meta", call => \&preprocess, scan => 1);
|
2006-09-10 00:50:27 +02:00
|
|
|
hook(type => "pagetemplate", id => "meta", call => \&pagetemplate);
|
2006-06-02 06:49:12 +02:00
|
|
|
} # }}}
|
|
|
|
|
* meta: Drop support for "meta link", since supporting this for internal
links required meta to be run during scan, which complicated its data
storage, since it had to clear data stored during the scan pass to avoid
duplicating it during the normal preprocessing pass.
* If you used "meta link", you should switch to either "meta openid" (for
openid delegations), or tags (for internal, invisible links). I assume
that nobody really used "meta link" for external, non-openid links, since
the htmlscrubber ate those. (Tell me differently and I'll consider bringing
back that support.)
* meta: Improved data storage.
* meta: Drop the hackish filter hook that was used to clear
stored data before preprocessing, this hack was ugly, and broken (cf:
liw's disappearing openids).
* aggregate: Convert filter hook to a needsbuild hook.
2007-12-16 21:56:09 +01:00
|
|
|
sub needsbuild (@) { #{{{
|
|
|
|
my $needsbuild=shift;
|
|
|
|
foreach my $page (keys %pagestate) {
|
|
|
|
if (exists $pagestate{$page}{meta}) {
|
2008-01-29 23:36:25 +01:00
|
|
|
if (exists $pagesources{$page} &&
|
|
|
|
grep { $_ eq $pagesources{$page} } @$needsbuild) {
|
* meta: Drop support for "meta link", since supporting this for internal
links required meta to be run during scan, which complicated its data
storage, since it had to clear data stored during the scan pass to avoid
duplicating it during the normal preprocessing pass.
* If you used "meta link", you should switch to either "meta openid" (for
openid delegations), or tags (for internal, invisible links). I assume
that nobody really used "meta link" for external, non-openid links, since
the htmlscrubber ate those. (Tell me differently and I'll consider bringing
back that support.)
* meta: Improved data storage.
* meta: Drop the hackish filter hook that was used to clear
stored data before preprocessing, this hack was ugly, and broken (cf:
liw's disappearing openids).
* aggregate: Convert filter hook to a needsbuild hook.
2007-12-16 21:56:09 +01:00
|
|
|
# remove state, it will be re-added
|
|
|
|
# if the preprocessor directive is still
|
|
|
|
# there during the rebuild
|
|
|
|
delete $pagestate{$page}{meta};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2006-07-31 00:58:48 +02:00
|
|
|
|
2007-03-21 19:52:56 +01:00
|
|
|
sub scrub ($) { #{{{
|
|
|
|
if (IkiWiki::Plugin::htmlscrubber->can("sanitize")) {
|
|
|
|
return IkiWiki::Plugin::htmlscrubber::sanitize(content => shift);
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return shift;
|
|
|
|
}
|
|
|
|
} #}}}
|
|
|
|
|
2008-02-10 23:17:44 +01:00
|
|
|
sub safeurl ($) { #{{{
|
|
|
|
my $url=shift;
|
|
|
|
if (exists $IkiWiki::Plugin::htmlscrubber::{safe_url_regexp} &&
|
|
|
|
defined $IkiWiki::Plugin::htmlscrubber::safe_url_regexp) {
|
|
|
|
return $url=~/$IkiWiki::Plugin::htmlscrubber::safe_url_regexp/;
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
} #}}}
|
|
|
|
|
2008-01-09 07:05:54 +01:00
|
|
|
sub htmlize ($$$) { #{{{
|
|
|
|
my $page = shift;
|
|
|
|
my $destpage = shift;
|
|
|
|
|
2008-01-09 20:35:23 +01:00
|
|
|
return IkiWiki::htmlize($page, pagetype($pagesources{$page}),
|
2008-01-09 07:05:54 +01:00
|
|
|
IkiWiki::linkify($page, $destpage,
|
2008-01-09 20:35:23 +01:00
|
|
|
IkiWiki::preprocess($page, $destpage, shift)));
|
2008-01-09 07:05:54 +01:00
|
|
|
}
|
|
|
|
|
2006-06-02 06:49:12 +02:00
|
|
|
sub preprocess (@) { #{{{
|
* meta: Drop support for "meta link", since supporting this for internal
links required meta to be run during scan, which complicated its data
storage, since it had to clear data stored during the scan pass to avoid
duplicating it during the normal preprocessing pass.
* If you used "meta link", you should switch to either "meta openid" (for
openid delegations), or tags (for internal, invisible links). I assume
that nobody really used "meta link" for external, non-openid links, since
the htmlscrubber ate those. (Tell me differently and I'll consider bringing
back that support.)
* meta: Improved data storage.
* meta: Drop the hackish filter hook that was used to clear
stored data before preprocessing, this hack was ugly, and broken (cf:
liw's disappearing openids).
* aggregate: Convert filter hook to a needsbuild hook.
2007-12-16 21:56:09 +01:00
|
|
|
return "" unless @_;
|
2006-06-02 06:49:12 +02:00
|
|
|
my %params=@_;
|
|
|
|
my $key=shift;
|
|
|
|
my $value=$params{$key};
|
|
|
|
delete $params{$key};
|
|
|
|
my $page=$params{page};
|
|
|
|
delete $params{page};
|
2007-12-08 20:37:41 +01:00
|
|
|
my $destpage=$params{destpage};
|
2006-07-28 01:47:13 +02:00
|
|
|
delete $params{destpage};
|
2007-03-07 06:53:47 +01:00
|
|
|
delete $params{preview};
|
2006-06-02 06:49:12 +02:00
|
|
|
|
2006-07-31 00:58:48 +02:00
|
|
|
eval q{use HTML::Entities};
|
* meta: Drop support for "meta link", since supporting this for internal
links required meta to be run during scan, which complicated its data
storage, since it had to clear data stored during the scan pass to avoid
duplicating it during the normal preprocessing pass.
* If you used "meta link", you should switch to either "meta openid" (for
openid delegations), or tags (for internal, invisible links). I assume
that nobody really used "meta link" for external, non-openid links, since
the htmlscrubber ate those. (Tell me differently and I'll consider bringing
back that support.)
* meta: Improved data storage.
* meta: Drop the hackish filter hook that was used to clear
stored data before preprocessing, this hack was ugly, and broken (cf:
liw's disappearing openids).
* aggregate: Convert filter hook to a needsbuild hook.
2007-12-16 21:56:09 +01:00
|
|
|
# Always decode, even if encoding later, since it might not be
|
2006-07-31 00:58:48 +02:00
|
|
|
# fully encoded.
|
|
|
|
$value=decode_entities($value);
|
2006-06-02 08:11:22 +02:00
|
|
|
|
2008-01-09 08:38:43 +01:00
|
|
|
# Metadata collection that needs to happen during the scan pass.
|
* meta: Drop support for "meta link", since supporting this for internal
links required meta to be run during scan, which complicated its data
storage, since it had to clear data stored during the scan pass to avoid
duplicating it during the normal preprocessing pass.
* If you used "meta link", you should switch to either "meta openid" (for
openid delegations), or tags (for internal, invisible links). I assume
that nobody really used "meta link" for external, non-openid links, since
the htmlscrubber ate those. (Tell me differently and I'll consider bringing
back that support.)
* meta: Improved data storage.
* meta: Drop the hackish filter hook that was used to clear
stored data before preprocessing, this hack was ugly, and broken (cf:
liw's disappearing openids).
* aggregate: Convert filter hook to a needsbuild hook.
2007-12-16 21:56:09 +01:00
|
|
|
if ($key eq 'title') {
|
2008-01-29 23:16:51 +01:00
|
|
|
$pagestate{$page}{meta}{title}=HTML::Entities::encode_numeric($value);
|
* meta: Drop support for "meta link", since supporting this for internal
links required meta to be run during scan, which complicated its data
storage, since it had to clear data stored during the scan pass to avoid
duplicating it during the normal preprocessing pass.
* If you used "meta link", you should switch to either "meta openid" (for
openid delegations), or tags (for internal, invisible links). I assume
that nobody really used "meta link" for external, non-openid links, since
the htmlscrubber ate those. (Tell me differently and I'll consider bringing
back that support.)
* meta: Improved data storage.
* meta: Drop the hackish filter hook that was used to clear
stored data before preprocessing, this hack was ugly, and broken (cf:
liw's disappearing openids).
* aggregate: Convert filter hook to a needsbuild hook.
2007-12-16 21:56:09 +01:00
|
|
|
}
|
2008-01-09 08:38:43 +01:00
|
|
|
elsif ($key eq 'license') {
|
2008-01-29 23:16:51 +01:00
|
|
|
push @{$metaheaders{$page}}, '<link rel="license" href="#page_license" />';
|
|
|
|
$pagestate{$page}{meta}{license}=$value;
|
2008-01-09 08:38:43 +01:00
|
|
|
return "";
|
|
|
|
}
|
|
|
|
elsif ($key eq 'copyright') {
|
2008-01-29 23:16:51 +01:00
|
|
|
push @{$metaheaders{$page}}, '<link rel="copyright" href="#page_copyright" />';
|
|
|
|
$pagestate{$page}{meta}{copyright}=$value;
|
2008-01-09 08:38:43 +01:00
|
|
|
return "";
|
|
|
|
}
|
|
|
|
elsif ($key eq 'link' && ! %params) {
|
|
|
|
# hidden WikiLink
|
|
|
|
push @{$links{$page}}, $value;
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
elsif ($key eq 'author') {
|
2008-01-29 23:16:51 +01:00
|
|
|
$pagestate{$page}{meta}{author}=$value;
|
2008-01-09 08:38:43 +01:00
|
|
|
# fallthorough
|
|
|
|
}
|
|
|
|
elsif ($key eq 'authorurl') {
|
2008-02-10 23:17:44 +01:00
|
|
|
$pagestate{$page}{meta}{authorurl}=$value if safeurl($value);
|
2008-01-09 08:38:43 +01:00
|
|
|
# fallthrough
|
|
|
|
}
|
|
|
|
|
|
|
|
if (! defined wantarray) {
|
|
|
|
# avoid collecting duplicate data during scan pass
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
# Metadata collection that happens only during preprocessing pass.
|
2008-01-09 08:41:38 +01:00
|
|
|
if ($key eq 'date') {
|
|
|
|
eval q{use Date::Parse};
|
|
|
|
if (! $@) {
|
|
|
|
my $time = str2time($value);
|
|
|
|
$IkiWiki::pagectime{$page}=$time if defined $time;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
elsif ($key eq 'permalink') {
|
2008-02-10 23:17:44 +01:00
|
|
|
if (safeurl($value)) {
|
|
|
|
$pagestate{$page}{meta}{permalink}=$value;
|
|
|
|
push @{$metaheaders{$page}}, scrub('<link rel="bookmark" href="'.encode_entities($value).'" />');
|
|
|
|
}
|
2008-01-09 08:38:43 +01:00
|
|
|
}
|
* meta: Drop support for "meta link", since supporting this for internal
links required meta to be run during scan, which complicated its data
storage, since it had to clear data stored during the scan pass to avoid
duplicating it during the normal preprocessing pass.
* If you used "meta link", you should switch to either "meta openid" (for
openid delegations), or tags (for internal, invisible links). I assume
that nobody really used "meta link" for external, non-openid links, since
the htmlscrubber ate those. (Tell me differently and I'll consider bringing
back that support.)
* meta: Improved data storage.
* meta: Drop the hackish filter hook that was used to clear
stored data before preprocessing, this hack was ugly, and broken (cf:
liw's disappearing openids).
* aggregate: Convert filter hook to a needsbuild hook.
2007-12-16 21:56:09 +01:00
|
|
|
elsif ($key eq 'stylesheet') {
|
|
|
|
my $rel=exists $params{rel} ? $params{rel} : "alternate stylesheet";
|
|
|
|
my $title=exists $params{title} ? $params{title} : $value;
|
|
|
|
# adding .css to the value prevents using any old web
|
|
|
|
# editable page as a stylesheet
|
|
|
|
my $stylesheet=bestlink($page, $value.".css");
|
|
|
|
if (! length $stylesheet) {
|
|
|
|
return "[[meta ".gettext("stylesheet not found")."]]";
|
|
|
|
}
|
2008-01-29 23:16:51 +01:00
|
|
|
push @{$metaheaders{$page}}, '<link href="'.urlto($stylesheet, $page).
|
* meta: Drop support for "meta link", since supporting this for internal
links required meta to be run during scan, which complicated its data
storage, since it had to clear data stored during the scan pass to avoid
duplicating it during the normal preprocessing pass.
* If you used "meta link", you should switch to either "meta openid" (for
openid delegations), or tags (for internal, invisible links). I assume
that nobody really used "meta link" for external, non-openid links, since
the htmlscrubber ate those. (Tell me differently and I'll consider bringing
back that support.)
* meta: Improved data storage.
* meta: Drop the hackish filter hook that was used to clear
stored data before preprocessing, this hack was ugly, and broken (cf:
liw's disappearing openids).
* aggregate: Convert filter hook to a needsbuild hook.
2007-12-16 21:56:09 +01:00
|
|
|
'" rel="'.encode_entities($rel).
|
|
|
|
'" title="'.encode_entities($title).
|
|
|
|
"\" type=\"text/css\" />";
|
|
|
|
}
|
|
|
|
elsif ($key eq 'openid') {
|
2008-02-10 23:17:44 +01:00
|
|
|
if (exists $params{server} && safeurl($params{server})) {
|
2008-01-29 23:16:51 +01:00
|
|
|
push @{$metaheaders{$page}}, '<link href="'.encode_entities($params{server}).
|
* meta: Drop support for "meta link", since supporting this for internal
links required meta to be run during scan, which complicated its data
storage, since it had to clear data stored during the scan pass to avoid
duplicating it during the normal preprocessing pass.
* If you used "meta link", you should switch to either "meta openid" (for
openid delegations), or tags (for internal, invisible links). I assume
that nobody really used "meta link" for external, non-openid links, since
the htmlscrubber ate those. (Tell me differently and I'll consider bringing
back that support.)
* meta: Improved data storage.
* meta: Drop the hackish filter hook that was used to clear
stored data before preprocessing, this hack was ugly, and broken (cf:
liw's disappearing openids).
* aggregate: Convert filter hook to a needsbuild hook.
2007-12-16 21:56:09 +01:00
|
|
|
'" rel="openid.server" />';
|
2008-03-11 14:00:59 +01:00
|
|
|
push @{$metaheaders{$page}}, '<link href="'.encode_entities($params{server}).
|
|
|
|
'" rel="openid2.provider" />';
|
2006-06-02 06:49:12 +02:00
|
|
|
}
|
2008-02-10 23:17:44 +01:00
|
|
|
if (safeurl($value)) {
|
|
|
|
push @{$metaheaders{$page}}, '<link href="'.encode_entities($value).
|
|
|
|
'" rel="openid.delegate" />';
|
2008-03-11 14:00:59 +01:00
|
|
|
push @{$metaheaders{$page}}, '<link href="'.encode_entities($value).
|
|
|
|
'" rel="openid2.local_id" />';
|
2008-02-10 23:17:44 +01:00
|
|
|
}
|
2008-03-12 15:35:25 +01:00
|
|
|
if (exists $params{"xrds-location"} && safeurl($params{"xrds-location"})) {
|
2008-03-11 14:00:30 +01:00
|
|
|
push @{$metaheaders{$page}}, '<meta http-equiv="X-XRDS-Location"'.
|
2008-03-12 15:35:25 +01:00
|
|
|
'content="'.encode_entities($params{"xrds-location"}).'" />';
|
2008-03-11 14:00:30 +01:00
|
|
|
}
|
* meta: Drop support for "meta link", since supporting this for internal
links required meta to be run during scan, which complicated its data
storage, since it had to clear data stored during the scan pass to avoid
duplicating it during the normal preprocessing pass.
* If you used "meta link", you should switch to either "meta openid" (for
openid delegations), or tags (for internal, invisible links). I assume
that nobody really used "meta link" for external, non-openid links, since
the htmlscrubber ate those. (Tell me differently and I'll consider bringing
back that support.)
* meta: Improved data storage.
* meta: Drop the hackish filter hook that was used to clear
stored data before preprocessing, this hack was ugly, and broken (cf:
liw's disappearing openids).
* aggregate: Convert filter hook to a needsbuild hook.
2007-12-16 21:56:09 +01:00
|
|
|
}
|
2007-12-08 20:58:29 +01:00
|
|
|
elsif ($key eq 'redir') {
|
* meta: Drop support for "meta link", since supporting this for internal
links required meta to be run during scan, which complicated its data
storage, since it had to clear data stored during the scan pass to avoid
duplicating it during the normal preprocessing pass.
* If you used "meta link", you should switch to either "meta openid" (for
openid delegations), or tags (for internal, invisible links). I assume
that nobody really used "meta link" for external, non-openid links, since
the htmlscrubber ate those. (Tell me differently and I'll consider bringing
back that support.)
* meta: Improved data storage.
* meta: Drop the hackish filter hook that was used to clear
stored data before preprocessing, this hack was ugly, and broken (cf:
liw's disappearing openids).
* aggregate: Convert filter hook to a needsbuild hook.
2007-12-16 21:56:09 +01:00
|
|
|
return "" if $page ne $destpage;
|
2007-12-08 20:58:29 +01:00
|
|
|
my $safe=0;
|
2007-12-08 21:17:37 +01:00
|
|
|
if ($value !~ /^\w+:\/\//) {
|
2007-12-22 16:21:00 +01:00
|
|
|
my ($redir_page, $redir_anchor) = split /\#/, $value;
|
|
|
|
|
|
|
|
add_depends($page, $redir_page);
|
|
|
|
my $link=bestlink($page, $redir_page);
|
2007-12-08 20:58:29 +01:00
|
|
|
if (! length $link) {
|
|
|
|
return "[[meta ".gettext("redir page not found")."]]";
|
|
|
|
}
|
2007-12-09 01:39:32 +01:00
|
|
|
|
|
|
|
$value=urlto($link, $page);
|
2007-12-22 16:21:00 +01:00
|
|
|
$value.='#'.$redir_anchor if defined $redir_anchor;
|
2007-12-09 01:39:32 +01:00
|
|
|
$safe=1;
|
|
|
|
|
|
|
|
# redir cycle detection
|
2007-12-08 23:40:50 +01:00
|
|
|
$pagestate{$page}{meta}{redir}=$link;
|
2007-12-09 01:39:32 +01:00
|
|
|
my $at=$page;
|
|
|
|
my %seen;
|
|
|
|
while (exists $pagestate{$at}{meta}{redir}) {
|
|
|
|
if ($seen{$at}) {
|
|
|
|
return "[[meta ".gettext("redir cycle is not allowed")."]]";
|
|
|
|
}
|
|
|
|
$seen{$at}=1;
|
|
|
|
$at=$pagestate{$at}{meta}{redir};
|
2007-12-08 23:40:50 +01:00
|
|
|
}
|
2007-12-08 20:58:29 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
$value=encode_entities($value);
|
|
|
|
}
|
|
|
|
my $delay=int(exists $params{delay} ? $params{delay} : 0);
|
2008-03-21 05:24:06 +01:00
|
|
|
my $redir="<meta http-equiv=\"refresh\" content=\"$delay; URL=$value\" />";
|
2007-12-08 20:58:29 +01:00
|
|
|
if (! $safe) {
|
|
|
|
$redir=scrub($redir);
|
|
|
|
}
|
2008-01-29 23:16:51 +01:00
|
|
|
push @{$metaheaders{$page}}, $redir;
|
2007-03-21 19:52:56 +01:00
|
|
|
}
|
* meta: Drop support for "meta link", since supporting this for internal
links required meta to be run during scan, which complicated its data
storage, since it had to clear data stored during the scan pass to avoid
duplicating it during the normal preprocessing pass.
* If you used "meta link", you should switch to either "meta openid" (for
openid delegations), or tags (for internal, invisible links). I assume
that nobody really used "meta link" for external, non-openid links, since
the htmlscrubber ate those. (Tell me differently and I'll consider bringing
back that support.)
* meta: Improved data storage.
* meta: Drop the hackish filter hook that was used to clear
stored data before preprocessing, this hack was ugly, and broken (cf:
liw's disappearing openids).
* aggregate: Convert filter hook to a needsbuild hook.
2007-12-16 21:56:09 +01:00
|
|
|
elsif ($key eq 'link') {
|
2008-01-09 08:38:43 +01:00
|
|
|
if (%params) {
|
2008-01-29 23:16:51 +01:00
|
|
|
push @{$metaheaders{$page}}, scrub("<link href=\"".encode_entities($value)."\" ".
|
2008-01-09 08:38:43 +01:00
|
|
|
join(" ", map {
|
|
|
|
encode_entities($_)."=\"".encode_entities(decode_entities($params{$_}))."\""
|
|
|
|
} keys %params).
|
|
|
|
" />\n");
|
|
|
|
}
|
2007-09-14 20:11:10 +02:00
|
|
|
}
|
2008-03-02 15:51:31 +01:00
|
|
|
elsif ($key eq 'robots') {
|
|
|
|
push @{$metaheaders{$page}}, '<meta name="robots"'.
|
2008-03-11 23:02:01 +01:00
|
|
|
' content="'.encode_entities($value).'" />';
|
2008-03-02 15:51:31 +01:00
|
|
|
}
|
2006-06-02 06:49:12 +02:00
|
|
|
else {
|
2008-01-29 23:16:51 +01:00
|
|
|
push @{$metaheaders{$page}}, scrub('<meta name="'.encode_entities($key).
|
* meta: Drop support for "meta link", since supporting this for internal
links required meta to be run during scan, which complicated its data
storage, since it had to clear data stored during the scan pass to avoid
duplicating it during the normal preprocessing pass.
* If you used "meta link", you should switch to either "meta openid" (for
openid delegations), or tags (for internal, invisible links). I assume
that nobody really used "meta link" for external, non-openid links, since
the htmlscrubber ate those. (Tell me differently and I'll consider bringing
back that support.)
* meta: Improved data storage.
* meta: Drop the hackish filter hook that was used to clear
stored data before preprocessing, this hack was ugly, and broken (cf:
liw's disappearing openids).
* aggregate: Convert filter hook to a needsbuild hook.
2007-12-16 21:56:09 +01:00
|
|
|
'" content="'.encode_entities($value).'" />');
|
2006-06-02 06:49:12 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return "";
|
|
|
|
} # }}}
|
|
|
|
|
2006-07-28 01:41:58 +02:00
|
|
|
sub pagetemplate (@) { #{{{
|
|
|
|
my %params=@_;
|
|
|
|
my $page=$params{page};
|
2007-09-14 21:09:16 +02:00
|
|
|
my $destpage=$params{destpage};
|
2006-07-28 01:41:58 +02:00
|
|
|
my $template=$params{template};
|
2006-06-02 06:49:12 +02:00
|
|
|
|
2008-01-29 23:16:51 +01:00
|
|
|
if (exists $metaheaders{$page} && $template->query(name => "meta")) {
|
* meta: Drop support for "meta link", since supporting this for internal
links required meta to be run during scan, which complicated its data
storage, since it had to clear data stored during the scan pass to avoid
duplicating it during the normal preprocessing pass.
* If you used "meta link", you should switch to either "meta openid" (for
openid delegations), or tags (for internal, invisible links). I assume
that nobody really used "meta link" for external, non-openid links, since
the htmlscrubber ate those. (Tell me differently and I'll consider bringing
back that support.)
* meta: Improved data storage.
* meta: Drop the hackish filter hook that was used to clear
stored data before preprocessing, this hack was ugly, and broken (cf:
liw's disappearing openids).
* aggregate: Convert filter hook to a needsbuild hook.
2007-12-16 21:56:09 +01:00
|
|
|
# avoid duplicate meta lines
|
|
|
|
my %seen;
|
2008-01-29 23:16:51 +01:00
|
|
|
$template->param(meta => join("\n", grep { (! $seen{$_}) && ($seen{$_}=1) } @{$metaheaders{$page}}));
|
* meta: Drop support for "meta link", since supporting this for internal
links required meta to be run during scan, which complicated its data
storage, since it had to clear data stored during the scan pass to avoid
duplicating it during the normal preprocessing pass.
* If you used "meta link", you should switch to either "meta openid" (for
openid delegations), or tags (for internal, invisible links). I assume
that nobody really used "meta link" for external, non-openid links, since
the htmlscrubber ate those. (Tell me differently and I'll consider bringing
back that support.)
* meta: Improved data storage.
* meta: Drop the hackish filter hook that was used to clear
stored data before preprocessing, this hack was ugly, and broken (cf:
liw's disappearing openids).
* aggregate: Convert filter hook to a needsbuild hook.
2007-12-16 21:56:09 +01:00
|
|
|
}
|
2008-01-29 23:16:51 +01:00
|
|
|
if (exists $pagestate{$page}{meta}{title} && $template->query(name => "title")) {
|
|
|
|
$template->param(title => $pagestate{$page}{meta}{title});
|
2006-08-12 19:51:32 +02:00
|
|
|
$template->param(title_overridden => 1);
|
|
|
|
}
|
2007-09-14 21:09:16 +02:00
|
|
|
|
2008-01-29 23:16:51 +01:00
|
|
|
foreach my $field (qw{author authorurl permalink}) {
|
|
|
|
$template->param($field => $pagestate{$page}{meta}{$field})
|
|
|
|
if exists $pagestate{$page}{meta}{$field} && $template->query(name => $field);
|
2007-09-14 21:09:16 +02:00
|
|
|
}
|
2008-01-29 23:16:51 +01:00
|
|
|
|
|
|
|
foreach my $field (qw{license copyright}) {
|
|
|
|
if (exists $pagestate{$page}{meta}{$field} && $template->query(name => $field) &&
|
|
|
|
($page eq $destpage || ! exists $pagestate{$destpage}{meta}{$field} ||
|
|
|
|
$pagestate{$page}{meta}{$field} ne $pagestate{$destpage}{meta}{$field})) {
|
|
|
|
$template->param($field => htmlize($page, $destpage, $pagestate{$page}{meta}{$field}));
|
|
|
|
}
|
2007-09-14 21:09:16 +02:00
|
|
|
}
|
2006-06-02 06:49:12 +02:00
|
|
|
} # }}}
|
|
|
|
|
2008-01-29 23:16:51 +01:00
|
|
|
sub match { #{{{
|
|
|
|
my $field=shift;
|
|
|
|
my $page=shift;
|
|
|
|
|
|
|
|
# turn glob into a safe regexp
|
|
|
|
my $re=quotemeta(shift);
|
|
|
|
$re=~s/\\\*/.*/g;
|
|
|
|
$re=~s/\\\?/./g;
|
|
|
|
|
|
|
|
my $val;
|
|
|
|
if (exists $pagestate{$page}{meta}{$field}) {
|
|
|
|
$val=$pagestate{$page}{meta}{$field};
|
|
|
|
}
|
|
|
|
elsif ($field eq 'title') {
|
|
|
|
$val=pagetitle($page);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (defined $val) {
|
|
|
|
if ($val=~/^$re$/i) {
|
|
|
|
return IkiWiki::SuccessReason->new("$re matches $field of $page");
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return IkiWiki::FailReason->new("$re does not match $field of $page");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
return IkiWiki::FailReason->new("$page does not have a $field");
|
|
|
|
}
|
|
|
|
} #}}}
|
|
|
|
|
|
|
|
package IkiWiki::PageSpec;
|
|
|
|
|
|
|
|
sub match_title ($$;@) { #{{{
|
|
|
|
IkiWiki::Plugin::meta::match("title", @_);
|
|
|
|
} #}}}
|
|
|
|
|
|
|
|
sub match_author ($$;@) { #{{{
|
|
|
|
IkiWiki::Plugin::meta::match("author", @_);
|
|
|
|
} #}}}
|
|
|
|
|
|
|
|
sub match_authorurl ($$;@) { #{{{
|
|
|
|
IkiWiki::Plugin::meta::match("authorurl", @_);
|
|
|
|
} #}}}
|
|
|
|
|
|
|
|
sub match_license ($$;@) { #{{{
|
|
|
|
IkiWiki::Plugin::meta::match("license", @_);
|
|
|
|
} #}}}
|
|
|
|
|
|
|
|
sub match_copyright ($$;@) { #{{{
|
|
|
|
IkiWiki::Plugin::meta::match("copyright", @_);
|
|
|
|
} #}}}
|
|
|
|
|
2006-06-02 06:49:12 +02:00
|
|
|
1
|