responses
[ikiwiki.git] / doc / todo / shortcut_optional_parameters.mdwn
1 Consider the "All files in this package search" on
2 <http://packages.debian.org>.  The URL for such a search looks like this:
3
4     http://packages.debian.org/cgi-bin/search_contents.pl?word=packagename&searchmode=filelist&case=insensitive&version=unstable&arch=i386
5
6 To create a "debfiles" [[shortcut|shortcuts]] that takes a package name, you
7 could just hardcode the architecture and distribution:
8
9     \[[shortcut name=debfiles url="http://packages.debian.org/cgi-bin/search_contents.pl?word=%s&searchmode=filelist&case=insensitive&version=unstable&arch=i386"]]
10     \[[debfiles ikiwiki]]
11
12 But what if you could have them as optional parameters instead?  The syntax
13 for the invocation should look like this:
14
15     \[[debfiles ikiwiki dist=testing]]
16
17 Some possible syntax choices for the shortcut definition:
18
19     \[[shortcut name=debfiles url="http://packages.debian.org/cgi-bin/search_contents.pl?word=%s&searchmode=filelist&case=insensitive&version=%(dist)s&arch=%(arch)s" dist="unstable" arch="i386"]]
20     \[[shortcut name=debfiles url="http://packages.debian.org/cgi-bin/search_contents.pl?word=%s&searchmode=filelist&case=insensitive&version=%(dist=unstable)s&arch=%(arch=i386)s"]]
21     \[[shortcut name=debfiles url="http://packages.debian.org/cgi-bin/search_contents.pl?word=%s&searchmode=filelist&case=insensitive&version=%{dist=unstable}&arch=%{arch=i386}"]]
22     \[[shortcut name=debfiles url="http://packages.debian.org/cgi-bin/search_contents.pl?word=$*&searchmode=filelist&case=insensitive&version=${dist=unstable}&arch=${arch=i386}"]]
23
24 --[[JoshTriplett]]
25
26 Well, you can already do this kind of thing with templates. Invocation does
27 look different:
28
29     \[[template id=debfiles package=ikiwiki dist=testing]]
30
31 --[[Joey]]