From eac31eff5c9147792c2886359b0faa4615e51e77 Mon Sep 17 00:00:00 2001 From: joey Date: Mon, 20 Nov 2006 11:31:23 +0000 Subject: shortcut stuff --- IkiWiki/Plugin/shortcut.pm | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'IkiWiki') 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 "$text"; + return "$desc"; } #}}} 1 -- cgit v1.2.3