X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/c8b4ba354f82fbbcebbbfca65b40a047f9920525..655d7925c60ecd7dd5dc3b35887f7a2573029796:/IkiWiki/Plugin/meta.pm diff --git a/IkiWiki/Plugin/meta.pm b/IkiWiki/Plugin/meta.pm index ec7a2d081..cfa4b84b1 100644 --- a/IkiWiki/Plugin/meta.pm +++ b/IkiWiki/Plugin/meta.pm @@ -4,13 +4,15 @@ package IkiWiki::Plugin::meta; use warnings; use strict; -use IkiWiki; +use IkiWiki 2.00; my %meta; my %title; my %permalink; my %author; my %authorurl; +my %license; +my %copyright; sub import { #{{{ hook(type => "preprocess", id => "meta", call => \&preprocess, scan => 1); @@ -45,6 +47,7 @@ sub preprocess (@) { #{{{ delete $params{$key}; my $page=$params{page}; delete $params{page}; + my $destpage=$params{destpage}; delete $params{destpage}; delete $params{preview}; @@ -65,7 +68,7 @@ sub preprocess (@) { #{{{ } } elsif ($key eq 'title') { - $title{$page}=encode_entities($value); + $title{$page}=HTML::Entities::encode_numeric($value); } elsif ($key eq 'permalink') { $permalink{$page}=$value; @@ -87,10 +90,10 @@ sub preprocess (@) { #{{{ if (! length $stylesheet) { return "[[meta ".gettext("stylesheet not found")."]]"; } - $meta{$page}.='\n"; + "\" type=\"text/css\" />\n"; } elsif ($key eq 'openid') { if (exists $params{server}) { @@ -100,6 +103,33 @@ sub preprocess (@) { #{{{ $meta{$page}.='\n"; } + elsif ($key eq 'license') { + $meta{$page}.="\n"; + $license{$page}=$value; + } + elsif ($key eq 'copyright') { + $meta{$page}.="\n"; + $copyright{$page}=$value; + } + elsif ($key eq 'forward') { + my $delay=0; + my $dest_url; + my $text; + if (exists $params{delay}) { + $delay=$params{delay}; + } + # Is this a wikilink? + if ($value =~ /^\[\[(.*)\]\]$/) { + $text=htmllink($page, $destpage, $1); + $dest_url=urlto(bestlink($page, $1), $destpage); + } else { + $text="$dest_url"; + $dest_url=$value; + } +# TODO. $meta{$page}.=scrub(""); + $meta{$page}.=""; + return "You are being forwarded to $text."; + } else { $meta{$page}.=scrub("\n"); @@ -117,6 +147,7 @@ sub preprocess (@) { #{{{ sub pagetemplate (@) { #{{{ my %params=@_; my $page=$params{page}; + my $destpage=$params{destpage}; my $template=$params{template}; $template->param(meta => $meta{$page}) @@ -131,7 +162,26 @@ sub pagetemplate (@) { #{{{ 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} || + $license{$page} ne $license{$destpage})) { + $template->param(license => IkiWiki::linkify($page, $destpage, $license{$page})); + } + if (exists $copyright{$page} && $template->query(name => "copyright") && + ($page eq $destpage || ! exists $copyright{$destpage} || + $copyright{$page} ne $copyright{$destpage})) { + $template->param(copyright => IkiWiki::linkify($page, $destpage, $copyright{$page})); + } } # }}} 1