2 # Ikiwiki metadata plugin.
3 package IkiWiki::Plugin::meta;
13 IkiWiki::hook(type => "preprocess", id => "meta",
14 call => \&preprocess);
15 IkiWiki::hook(type => "pagetemplate", id => "meta",
16 call => \&pagetemplate);
19 sub preprocess (@) { #{{{
25 my $value=$params{$key};
27 my $page=$params{page};
29 delete $params{destpage};
31 eval q{use CGI 'escapeHTML'};
35 $meta{$page}='' unless exists $meta{$page};
36 $meta{$page}.="<link href=\"".escapeHTML($value)."\" ".
37 join(" ", map { escapeHTML("$_=\"$params{$_}\"") } keys %params).
42 push @{$IkiWiki::links{$page}}, $value;
45 elsif ($key eq 'title') {
46 $title{$page}=escapeHTML($value);
49 $meta{$page}='' unless exists $meta{$page};
50 $meta{$page}.="<meta name=\"".escapeHTML($key)."\" content=\"".escapeHTML($value)."\" />\n";
56 sub pagetemplate (@) { #{{{
58 my $page=$params{page};
59 my $template=$params{template};
61 $template->param(meta => $meta{$page})
62 if exists $meta{$page} && $template->query(name => "meta");
63 $template->param(title => $title{$page})
64 if exists $title{$page} && $template->query(name => "title");