2 # Ikiwiki metadata plugin.
3 package IkiWiki::Plugin::meta;
13 IkiWiki::hook(type => "preprocess", id => "meta",
14 call => \&preprocess);
15 IkiWiki::hook(type => "filter", id => "meta",
17 IkiWiki::hook(type => "pagetemplate", id => "meta",
18 call => \&pagetemplate);
24 $meta{$params{page}}='';
26 return $params{content};
29 sub preprocess (@) { #{{{
35 my $value=$params{$key};
37 my $page=$params{page};
39 delete $params{destpage};
41 eval q{use HTML::Entities};
42 # Always dencode, even if encoding later, since it might not be
44 $value=decode_entities($value);
48 $meta{$page}.="<link href=\"".encode_entities($value)."\" ".
49 join(" ", map { encode_entities($_)."=\"".encode_entities(decode_entities($params{$_}))."\"" } keys %params).
54 push @{$IkiWiki::links{$page}}, $value;
57 elsif ($key eq 'title') {
61 $meta{$page}.="<meta name=\"".encode_entities($key).
62 "\" content=\"".encode_entities($value)."\" />\n";
68 sub pagetemplate (@) { #{{{
70 my $page=$params{page};
71 my $template=$params{template};
73 $template->param(meta => $meta{$page})
74 if exists $meta{$page} && $template->query(name => "meta");
75 $template->param(title => $title{$page})
76 if exists $title{$page} && $template->query(name => "title");