summaryrefslogtreecommitdiff
path: root/IkiWiki
diff options
context:
space:
mode:
authorjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>2006-11-20 11:31:23 +0000
committerjoey <joey@0fa5a96a-9a0e-0410-b3b2-a0fd24251071>2006-11-20 11:31:23 +0000
commiteac31eff5c9147792c2886359b0faa4615e51e77 (patch)
treeba2f38eee49cc4163ecbcfd4d173fbaf650cbe73 /IkiWiki
parentbcb41d1de98fc88829b978fb750582ad4523a8a1 (diff)
shortcut stuff
Diffstat (limited to 'IkiWiki')
-rw-r--r--IkiWiki/Plugin/shortcut.pm13
1 files changed, 10 insertions, 3 deletions
diff --git a/IkiWiki/Plugin/shortcut.pm b/IkiWiki/Plugin/shortcut.pm
index d09d5879d..e4a9ab1a6 100644
--- a/IkiWiki/Plugin/shortcut.pm
+++ b/IkiWiki/Plugin/shortcut.pm
@@ -25,14 +25,14 @@ sub preprocess_shortcut (@) { #{{{
}
hook(type => "preprocess", no_override => 1, id => $params{name},
- call => sub { shortcut_expand($params{name}, $params{url}, @_) });
+ call => sub { shortcut_expand($params{url}, $params{desc}, @_) });
return "shortcut $params{name} points to $params{url}";
} # }}}
sub shortcut_expand ($$@) { #{{{
- my $name=shift;
my $url=shift;
+ my $desc=shift;
my %params=@_;
# Get params in original order.
@@ -51,8 +51,15 @@ sub shortcut_expand ($$@) { #{{{
my $encoded_text=$text;
$encoded_text=~s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
+ if (defined $desc) {
+ $desc=~s/\%s/$text/g;
+ }
+ else {
+ $desc=$text;
+ }
+
$url=~s/\%s/$encoded_text/g;
- return "<a href=\"$url\">$text</a>";
+ return "<a href=\"$url\">$desc</a>";
} #}}}
1