shortcut stuff
parent
bcb41d1de9
commit
eac31eff5c
|
@ -25,14 +25,14 @@ sub preprocess_shortcut (@) { #{{{
|
||||||
}
|
}
|
||||||
|
|
||||||
hook(type => "preprocess", no_override => 1, id => $params{name},
|
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}";
|
return "shortcut $params{name} points to $params{url}";
|
||||||
} # }}}
|
} # }}}
|
||||||
|
|
||||||
sub shortcut_expand ($$@) { #{{{
|
sub shortcut_expand ($$@) { #{{{
|
||||||
my $name=shift;
|
|
||||||
my $url=shift;
|
my $url=shift;
|
||||||
|
my $desc=shift;
|
||||||
my %params=@_;
|
my %params=@_;
|
||||||
|
|
||||||
# Get params in original order.
|
# Get params in original order.
|
||||||
|
@ -51,8 +51,15 @@ sub shortcut_expand ($$@) { #{{{
|
||||||
my $encoded_text=$text;
|
my $encoded_text=$text;
|
||||||
$encoded_text=~s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
|
$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;
|
$url=~s/\%s/$encoded_text/g;
|
||||||
return "<a href=\"$url\">$text</a>";
|
return "<a href=\"$url\">$desc</a>";
|
||||||
} #}}}
|
} #}}}
|
||||||
|
|
||||||
1
|
1
|
||||||
|
|
|
@ -21,7 +21,7 @@ extra_build:
|
||||||
--plugin=orphans --plugin=haiku --plugin=meta \
|
--plugin=orphans --plugin=haiku --plugin=meta \
|
||||||
--plugin=tag --plugin=polygen --plugin=pagestats \
|
--plugin=tag --plugin=polygen --plugin=pagestats \
|
||||||
--plugin=fortune --plugin=aggregate --plugin=map \
|
--plugin=fortune --plugin=aggregate --plugin=map \
|
||||||
--plugin=template --plugin=toc
|
--plugin=template --plugin=toc --plugin=shortcut
|
||||||
./mdwn2man ikiwiki 1 doc/usage.mdwn > ikiwiki.man
|
./mdwn2man ikiwiki 1 doc/usage.mdwn > ikiwiki.man
|
||||||
./mdwn2man ikiwiki-mass-rebuild 8 doc/ikiwiki-mass-rebuild.mdwn > ikiwiki-mass-rebuild.man
|
./mdwn2man ikiwiki-mass-rebuild 8 doc/ikiwiki-mass-rebuild.mdwn > ikiwiki-mass-rebuild.man
|
||||||
./pm_filter $(PREFIX) $(VER) < ikiwiki.pl > ikiwiki.out
|
./pm_filter $(PREFIX) $(VER) < ikiwiki.pl > ikiwiki.out
|
||||||
|
|
|
@ -2,8 +2,9 @@ This page controls what shortcut links the wiki supports.
|
||||||
|
|
||||||
* [[shortcut name=google url="http://www.google.com/search?q=%s"]]
|
* [[shortcut name=google url="http://www.google.com/search?q=%s"]]
|
||||||
* [[shortcut name=wikipedia url="http://en.wikipedia.org/wiki/%s"]]
|
* [[shortcut name=wikipedia url="http://en.wikipedia.org/wiki/%s"]]
|
||||||
* [[shortcut name=debbug url="http://bugs.debian.org/%s"]]
|
* [[shortcut name=debbug url="http://bugs.debian.org/%s" desc="bug #%s"]]
|
||||||
* [[shortcut name=cpan url="http://search.cpan.org/search?mode=dist&query=%s"]]
|
* [[shortcut name=cpan url="http://search.cpan.org/search?mode=dist&query=%s"]]
|
||||||
|
|
||||||
To add a new shortcut, use the "shortcut" preprocessor directive. "%s" in
|
To add a new shortcut, use the "shortcut" preprocessor directive. "%s" is
|
||||||
the url becomes the text passed to the named shortcut.
|
replaced with the text passed to the named shortcut. The optional desc
|
||||||
|
parameter controls the description of the link.
|
||||||
|
|
|
@ -11,8 +11,9 @@ ikiwiki (1.34) UNRELEASED; urgency=low
|
||||||
affiliate program.
|
affiliate program.
|
||||||
* Change how post signin actions are propigated through the signin process;
|
* Change how post signin actions are propigated through the signin process;
|
||||||
they're now stored in the session.
|
they're now stored in the session.
|
||||||
|
* Add optional "desc" parameter to shortcut definitions.
|
||||||
|
|
||||||
-- Joey Hess <joeyh@debian.org> Sun, 19 Nov 2006 16:40:26 -0500
|
-- Joey Hess <joeyh@debian.org> Mon, 20 Nov 2006 06:14:51 -0500
|
||||||
|
|
||||||
ikiwiki (1.33) unstable; urgency=low
|
ikiwiki (1.33) unstable; urgency=low
|
||||||
|
|
||||||
|
|
|
@ -5,14 +5,16 @@ most unix-like systems.
|
||||||
Ikiwiki is a perl program, and needs a recent version of perl such as
|
Ikiwiki is a perl program, and needs a recent version of perl such as
|
||||||
5.8.8. (5.8.0 has been reported not to work).
|
5.8.8. (5.8.0 has been reported not to work).
|
||||||
|
|
||||||
Ikiwiki requires the `Text::MarkDown`, `URI` and `HTML::Parser` perl
|
Ikiwiki requires the [[cpan Text::MarkDown]], [[cpan URI]] and
|
||||||
modules be installed, and also uses the following perl modules if
|
[[cpan HTML::Parser]] perl modules be installed, and also uses the
|
||||||
available:
|
following perl modules if available:
|
||||||
`CGI::Session` `CGI::FormBuilder` (version 3.02.02 or newer)
|
[[cpan CGI::Session]], [[cpan CGI::FormBuilder]] (version 3.02.02 or newer,
|
||||||
`HTML::Template` `Mail::Sendmail` `Time::Duration` `Date::Parse`,
|
but 3.0401 might be broken),
|
||||||
`HTML::Scrubber`, `RPC::XML`, `XML::Simple`, `XML::Feed`, `File::MimeInfo`.
|
[[cpan HTML::Template]], [[cpan Mail::Sendmail]], [[cpan Time::Duration]]
|
||||||
|
[[cpan TimeDate]], [[cpan HTML::Scrubber]], [[cpan RPC::XML]],
|
||||||
|
[[cpan XML::Simple]], [[cpan XML::Feed]], [[cpan File::MimeInfo]].
|
||||||
|
|
||||||
The [[tla]] support also needs the `MailTools` perl module.
|
The [[tla]] support also needs the [[cpan MailTools]] perl module.
|
||||||
|
|
||||||
Various [[plugins]] use other libraries and utlities; see their individual
|
Various [[plugins]] use other libraries and utlities; see their individual
|
||||||
documentation for details.
|
documentation for details.
|
||||||
|
@ -20,9 +22,9 @@ documentation for details.
|
||||||
If you want to install from the tarball, you should make sure that the
|
If you want to install from the tarball, you should make sure that the
|
||||||
required perl modules are installed, then run:
|
required perl modules are installed, then run:
|
||||||
|
|
||||||
perl Makefile.PL # PREFIX=/dir to install elsewhere
|
perl Makefile.PL # PREFIX=/dir to install elsewhere
|
||||||
make
|
make
|
||||||
make test # optional
|
make test # optional
|
||||||
make install
|
make install
|
||||||
|
|
||||||
See [[download]] for where to get it.
|
See [[download]] for where to get it.
|
||||||
|
|
|
@ -4,5 +4,5 @@
|
||||||
Enables use of Discordian dates. `--timeformat` can be used to change
|
Enables use of Discordian dates. `--timeformat` can be used to change
|
||||||
the date format; see `ddate(1)`.
|
the date format; see `ddate(1)`.
|
||||||
|
|
||||||
This plugin requires the DateTime and DateTime::Calendar::Discordian
|
This plugin requires the [[cpan DateTime]] and
|
||||||
perl modules.
|
[[cpan DateTime::Calendar::Discordian]] perl modules.
|
||||||
|
|
|
@ -10,7 +10,7 @@ whitelisted using the same lists as used by Mark Pilgrim's Universal Feed
|
||||||
Parser, documented at <http://feedparser.org/docs/html-sanitization.html>.
|
Parser, documented at <http://feedparser.org/docs/html-sanitization.html>.
|
||||||
Notably it strips `style`, `link`, and the `style` attribute.
|
Notably it strips `style`, `link`, and the `style` attribute.
|
||||||
|
|
||||||
It uses the HTML::Scrubber perl module to perform its html
|
It uses the [[cpan HTML::Scrubber]] perl module to perform its html
|
||||||
sanitisation, and this perl module also deals with various entity encoding
|
sanitisation, and this perl module also deals with various entity encoding
|
||||||
tricks.
|
tricks.
|
||||||
|
|
||||||
|
|
|
@ -4,9 +4,9 @@
|
||||||
This plugin allows users to use their [OpenID](http://openid.net/) to log
|
This plugin allows users to use their [OpenID](http://openid.net/) to log
|
||||||
into the wiki.
|
into the wiki.
|
||||||
|
|
||||||
The plugin needs the `Net::OpenID::Consumer` perl module. The
|
The plugin needs the [[cpan Net::OpenID::Consumer]] perl module. The
|
||||||
`LWPx::ParanoidAgent` perl module is used if available, for added
|
[[cpan LWPx::ParanoidAgent]] perl module is used if available, for added
|
||||||
security. Finally, the `Crypt::SSLeay` perl module is needed to support
|
security. Finally, the [[cpan Crypt::SSLeay]] perl module is needed to support
|
||||||
users entering "https" OpenID urls.
|
users entering "https" OpenID urls.
|
||||||
|
|
||||||
This plugin has a configuration option. You can set `--openidsignup`
|
This plugin has a configuration option. You can set `--openidsignup`
|
||||||
|
|
|
@ -27,9 +27,10 @@ To create a template, make a page in the wiki named `template/foo`. Note
|
||||||
that this is a different location than the directory used for the
|
that this is a different location than the directory used for the
|
||||||
[[templates]] used to build the wiki itself, which is not inside the wiki.
|
[[templates]] used to build the wiki itself, which is not inside the wiki.
|
||||||
|
|
||||||
The template uses the syntax used by the HTML::Template perl module, which
|
The template uses the syntax used by the [[cpan HTML::Template]] perl
|
||||||
allows for some fairly complex things to be done. Consult its documentation
|
module, which allows for some fairly complex things to be done. Consult its
|
||||||
for the full syntax, but all you really need to know are a few things:
|
documentation for the full syntax, but all you really need to know are a
|
||||||
|
few things:
|
||||||
|
|
||||||
* To insert the value of a variable, use `<TMPL_VAR variable>`.
|
* To insert the value of a variable, use `<TMPL_VAR variable>`.
|
||||||
* To make a block of text conditional on a variable being set use
|
* To make a block of text conditional on a variable being set use
|
||||||
|
|
|
@ -2,9 +2,9 @@
|
||||||
[[tag type/format]]
|
[[tag type/format]]
|
||||||
|
|
||||||
This plugin allows ikiwiki to process pages written in the original wiki
|
This plugin allows ikiwiki to process pages written in the original wiki
|
||||||
text format. To use it, you need to have the Text::WikiFormat perl module
|
text format. To use it, you need to have the [[cpan Text::WikiFormat]] perl
|
||||||
installed, enable the plugin, then files with the extention `.wiki` will be
|
module installed, enable the plugin, then files with the extention `.wiki`
|
||||||
processed as wiki text.
|
will be processed as wiki text.
|
||||||
|
|
||||||
Wiki formatting is very simple. An item wrapped in three single quotes is
|
Wiki formatting is very simple. An item wrapped in three single quotes is
|
||||||
strong. An item wrapped in two single quotes is emphasized. Four or more
|
strong. An item wrapped in two single quotes is emphasized. Four or more
|
||||||
|
|
|
@ -1 +1,19 @@
|
||||||
[[plugins/shortcut]] creates link shortcut [[PreprocessorDirective]]s, which substitute their argument into the specified shortcut URL to generate the link target, and use the argument as the link text. For example, given the example [[shortcuts]], `\[[wikipedia ikiwiki]]` generates a link to <http://en.wikipedia.org/wiki/ikiwiki>, with the link text "ikiwiki". This works well in many cases; however, for things like the `debbug` example, it simply uses the number as the link text, which does not always provide enough context to understand the link at first glance. For example, `\[[debbug 397501]]` generates a link to <http://bugs.debian.org/397501>, with just "397501" as the link text. While [[plugins/template]] provides a general solution for arbitrary cases, it would help to have a simple option via the shortcut plugin to set the link text, with a `%s` substitution. Thus, something like `\[[shortcut name=debbug url="http://bugs.debian.org/%s" desc="bug #%s"]]` might suffice on a Debian-specific wiki to indicate a bug number, while a more general wiki might use something like `\[[shortcut name=debbug url="http://bugs.debian.org/%s" desc="Debian bug #%s"]]`.
|
[[plugins/shortcut]] creates link shortcut [[PreprocessorDirective]]s,
|
||||||
|
which substitute their argument into the specified shortcut URL to generate
|
||||||
|
the link target, and use the argument as the link text. For example, given
|
||||||
|
the example [[shortcuts]], `\[[wikipedia ikiwiki]]` generates a link to
|
||||||
|
<http://en.wikipedia.org/wiki/ikiwiki>, with the link text "ikiwiki". This
|
||||||
|
works well in many cases; however, for things like the `debbug` example, it
|
||||||
|
simply uses the number as the link text, which does not always provide
|
||||||
|
enough context to understand the link at first glance. For example,
|
||||||
|
`\[[debbug 397501]]` generates a link to <http://bugs.debian.org/397501>,
|
||||||
|
with just "397501" as the link text. While [[plugins/template]] provides a
|
||||||
|
general solution for arbitrary cases, it would help to have a simple option
|
||||||
|
via the shortcut plugin to set the link text, with a `%s` substitution.
|
||||||
|
Thus, something like `\[[shortcut name=debbug
|
||||||
|
url="http://bugs.debian.org/%s" desc="bug #%s"]]` might suffice on a
|
||||||
|
Debian-specific wiki to indicate a bug number, while a more general wiki
|
||||||
|
might use something like `\[[shortcut name=debbug
|
||||||
|
url="http://bugs.debian.org/%s" desc="Debian bug #%s"]]`.
|
||||||
|
|
||||||
|
> [[todo/done]] --[[Joey]]
|
||||||
|
|
Loading…
Reference in New Issue