IkiWiki/Plugin/meta.pm <redir>: Support for specifying anchors.

master
Thomas Schwinge 2007-12-22 16:21:00 +01:00 committed by Joey Hess
parent 8937e5e285
commit 1ac0fd03bb
2 changed files with 8 additions and 2 deletions

View File

@ -108,13 +108,16 @@ sub preprocess (@) { #{{{
return "" if $page ne $destpage; return "" if $page ne $destpage;
my $safe=0; my $safe=0;
if ($value !~ /^\w+:\/\//) { if ($value !~ /^\w+:\/\//) {
add_depends($page, $value); my ($redir_page, $redir_anchor) = split /\#/, $value;
my $link=bestlink($page, $value);
add_depends($page, $redir_page);
my $link=bestlink($page, $redir_page);
if (! length $link) { if (! length $link) {
return "[[meta ".gettext("redir page not found")."]]"; return "[[meta ".gettext("redir page not found")."]]";
} }
$value=urlto($link, $page); $value=urlto($link, $page);
$value.='#'.$redir_anchor if defined $redir_anchor;
$safe=1; $safe=1;
# redir cycle detection # redir cycle detection

View File

@ -85,6 +85,9 @@ Supported fields:
However, this latter syntax won't be allowed if the [[htmlscrubber]] is However, this latter syntax won't be allowed if the [[htmlscrubber]] is
enabled, since it can be used to insert unsafe content. enabled, since it can be used to insert unsafe content.
For both cases, an anchor to jump to inside the destination page may also be
specified using the common `PAGE#ANCHOR` syntax.
If the field is not one of the above predefined fields, the metadata will be If the field is not one of the above predefined fields, the metadata will be
written to the generated html page as a &lt;meta&gt; header. However, this written to the generated html page as a &lt;meta&gt; header. However, this
won't be allowed if the [[htmlscrubber]] is enabled, since it can be used to won't be allowed if the [[htmlscrubber]] is enabled, since it can be used to