* Add --tagbase option to tag plugin.
require IkiWiki::Rcs::Stub;
}
require IkiWiki::Rcs::Stub;
}
+ if (exists $hooks{checkconfig}) {
+ foreach my $id (keys %{$hooks{checkconfig}}) {
+ $hooks{checkconfig}{$id}{call}->();
+ }
+ }
+} #}}}
+
+sub loadplugins () { #{{{
foreach my $plugin (@{$config{plugin}}) {
my $mod="IkiWiki::Plugin::".possibly_foolish_untaint($plugin);
eval qq{use $mod};
foreach my $plugin (@{$config{plugin}}) {
my $mod="IkiWiki::Plugin::".possibly_foolish_untaint($plugin);
eval qq{use $mod};
error("Failed to load plugin $mod: $@");
}
}
error("Failed to load plugin $mod: $@");
}
}
-
- if (exists $hooks{checkconfig}) {
- foreach my $id (keys %{$hooks{checkconfig}}) {
- $hooks{checkconfig}{$id}{call}->();
- }
- }
} #}}}
sub error ($) { #{{{
} #}}}
sub error ($) { #{{{
use IkiWiki;
sub import { #{{{
use IkiWiki;
sub import { #{{{
+ IkiWiki::hook(type => "getopt", id => "skeleton",
+ call => \&getopt);
IkiWiki::hook(type => "checkconfig", id => "skeleton",
call => \&checkconfig);
IkiWiki::hook(type => "preprocess", id => "skeleton",
IkiWiki::hook(type => "checkconfig", id => "skeleton",
call => \&checkconfig);
IkiWiki::hook(type => "preprocess", id => "skeleton",
+sub getopt () { #{{{
+ IkiWiki::debug("skeleton plugin getopt");
+} #}}}
+
sub checkconfig () { #{{{
IkiWiki::debug("skeleton plugin checkconfig");
} #}}}
sub checkconfig () { #{{{
IkiWiki::debug("skeleton plugin checkconfig");
} #}}}
my %tags;
sub import { #{{{
my %tags;
sub import { #{{{
+ IkiWiki::hook(type => "getopt", id => "tag",
+ call => \&getopt);
IkiWiki::hook(type => "preprocess", id => "tag",
call => \&preprocess);
IkiWiki::hook(type => "pagetemplate", id => "tag",
call => \&pagetemplate);
} # }}}
IkiWiki::hook(type => "preprocess", id => "tag",
call => \&preprocess);
IkiWiki::hook(type => "pagetemplate", id => "tag",
call => \&pagetemplate);
} # }}}
+sub getopt () { #{{{
+ eval q{use Getopt::Long};
+ Getopt::Long::Configure('pass_through');
+ GetOptions("tagbase=s" => \$IkiWiki::config{tagbase});
+} #}}}
+
sub preprocess (@) { #{{{
if (! @_) {
return "";
sub preprocess (@) { #{{{
if (! @_) {
return "";
$tags{$page} = [];
foreach my $tag (keys %params) {
$tags{$page} = [];
foreach my $tag (keys %params) {
+ if (exists $IkiWiki::config{tagbase}) {
+ $tag=$IkiWiki::config{tagbase}."/".$tag;
+ }
push @{$tags{$page}}, $tag;
# hidden WikiLink
push @{$IkiWiki::links{$page}}, $tag;
push @{$tags{$page}}, $tag;
# hidden WikiLink
push @{$IkiWiki::links{$page}}, $tag;
debug("refreshing wiki..");
}
debug("refreshing wiki..");
}
checkconfig();
lockwiki();
loadindex();
checkconfig();
lockwiki();
loadindex();
+ikiwiki (1.12) UNRELEASED; urgency=low
+
+ * Add getopt hook type, this allows plugins to add new command-line options.
+ * Add --tagbase option to tag plugin.
+
+ -- Joey Hess <joeyh@debian.org> Fri, 28 Jul 2006 01:17:48 -0400
+
ikiwiki (1.11) unstable; urgency=low
* Patch from Enrico that
ikiwiki (1.11) unstable; urgency=low
* Patch from Enrico that
for each tag, so you can use a [[GlobList]] to link to all pages that are
tagged with a given tag, for example.
for each tag, so you can use a [[GlobList]] to link to all pages that are
tagged with a given tag, for example.
+This plugin has a configuration option. Set --tagbase=tag and all tags will
+be located inside a "tag" subdirectory, so in the above example, the tags
+are really set to tag/tech, tag/life, and tag/linux. This is a useful way
+to avoid having to write the full path to tags, if you want to keep them
+grouped together out of the way.
+
This plugin is included in ikiwiki, but is not enabled by default. If it is
enabled, you'll see a note below that this page is tagged with the "tags"
tag.
This plugin is included in ikiwiki, but is not enabled by default. If it is
enabled, you'll see a note below that this page is tagged with the "tags"
tag.
Beyond PreProcessorDirectives, Other types of hooks that can be used by
plugins include:
Beyond PreProcessorDirectives, Other types of hooks that can be used by
plugins include:
+## getopt
+
+ IkiWiki::hook(type => "getopt", id => "foo", call => \&getopt);
+
+This allows for plugins to perform their own processing of command-line
+options and so add options to the ikiwiki command line. It's called during
+command line processing, with @ARGV full of any options that ikiwiki was
+not able to process on its own. The function should process any options it
+can, removing them from @ARGV. It should take care not to abort if it sees
+an option it cannot process, and should just skip over those options and
+leave them in @ARGV.
+
## checkconfig
IkiWiki::hook(type => "checkconfig", id => "foo", call => \&checkconfig);
## checkconfig
IkiWiki::hook(type => "checkconfig", id => "foo", call => \&checkconfig);
-These options configure the wiki.
+These options configure the wiki. Note that plugins can add additional
+configuration options of their own.
if (! exists $ENV{WRAPPED_OPTIONS}) {
%config=defaultconfig();
eval q{use Getopt::Long};
if (! exists $ENV{WRAPPED_OPTIONS}) {
%config=defaultconfig();
eval q{use Getopt::Long};
+ Getopt::Long::Configure('pass_through');
GetOptions(
"setup|s=s" => \$config{setup},
"wikiname=s" => \$config{wikiname},
GetOptions(
"setup|s=s" => \$config{setup},
"wikiname=s" => \$config{wikiname},
) || usage();
if (! $config{setup}) {
) || usage();
if (! $config{setup}) {
+ loadplugins();
+ if (exists $hooks{getopt}) {
+ foreach my $id (keys %{$hooks{getopt}}) {
+ $hooks{getopt}{$id}{call}->();
+ }
+ }
+ if (grep /^-/, @ARGV) {
+ print STDERR "Unknown option: $_\n"
+ foreach grep /^-/, @ARGV;
+ usage();
+ }
usage() unless @ARGV == 2;
$config{srcdir} = possibly_foolish_untaint(shift @ARGV);
$config{destdir} = possibly_foolish_untaint(shift @ARGV);
usage() unless @ARGV == 2;
$config{srcdir} = possibly_foolish_untaint(shift @ARGV);
$config{destdir} = possibly_foolish_untaint(shift @ARGV);
if ($@) {
error("WRAPPED_OPTIONS: $@");
}
if ($@) {
error("WRAPPED_OPTIONS: $@");
}