From 1e5cd11635ef45e8223f56b952c8636d993e5908 Mon Sep 17 00:00:00 2001 From: joey Date: Fri, 27 Jul 2007 00:48:06 +0000 Subject: [PATCH] * Add a libdir config option to let ikiwiki load perl modules, including plugins, from a user-configurable directory. --- IkiWiki.pm | 7 ++++++- debian/changelog | 4 +++- doc/ikiwiki.setup | 2 ++ doc/plugins.mdwn | 8 -------- doc/plugins/contrib.mdwn | 4 ++++ doc/usage.mdwn | 6 ++++++ ikiwiki.in | 1 + 7 files changed, 22 insertions(+), 10 deletions(-) diff --git a/IkiWiki.pm b/IkiWiki.pm index e5d1c5c44..88dcdcb5b 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -86,6 +86,7 @@ sub defaultconfig () { #{{{ adminemail => undef, plugin => [qw{mdwn inline htmlscrubber passwordauth openid signinedit lockedit conditional}], + libdir => undef, timeformat => '%c', locale => undef, sslcookie => 0, @@ -140,8 +141,12 @@ sub checkconfig () { #{{{ } #}}} sub loadplugins () { #{{{ + if (defined $config{libdir}) { + unshift @INC, $config{libdir}; + } + loadplugin($_) foreach @{$config{plugin}}; - + run_hooks(getopt => sub { shift->() }); if (grep /^-/, @ARGV) { print STDERR "Unknown option: $_\n" diff --git a/debian/changelog b/debian/changelog index 5a1d94a69..b6ef74000 100644 --- a/debian/changelog +++ b/debian/changelog @@ -17,8 +17,10 @@ ikiwiki (2.5) UNRELEASED; urgency=low * Add templatefile hook. * Add pagetemplate plugin, which allows changing the template used for a page. (Not to be confused with the hook of the same name..) + * Add a libdir config option to let ikiwiki load perl modules, including + plugins, from a user-configurable directory. - -- Joey Hess Thu, 26 Jul 2007 16:16:55 -0400 + -- Joey Hess Thu, 26 Jul 2007 20:47:23 -0400 ikiwiki (2.4) unstable; urgency=low diff --git a/doc/ikiwiki.setup b/doc/ikiwiki.setup index a772ca60b..9d2859a86 100644 --- a/doc/ikiwiki.setup +++ b/doc/ikiwiki.setup @@ -109,6 +109,8 @@ use IkiWiki::Setup::Standard { # htmltidy fortune sidebar map rst anonok}], # If you want to disable any of the default plugins, list them here. #disable_plugins => [qw{inline htmlscrubber passwordauth openid}], + # To add a directory to the perl searh path, use this. + #libdir => "/home/me/.ikiwiki/", # For use with the tag plugin, make all tags be located under a # base page. diff --git a/doc/plugins.mdwn b/doc/plugins.mdwn index 255f13f67..3f154f1f0 100644 --- a/doc/plugins.mdwn +++ b/doc/plugins.mdwn @@ -11,14 +11,6 @@ To enable plugins, use the `--plugin` switch described in Enable the [[goodstuff]] plugin to get a nice selection of plugins that will fit most uses of ikiwiki. -Without administrator access, you can add some custom plugins by storing -yourcustomplugin.pm in /home/user/.ikiwiki/IkiWiki/Plugins (or any other -place, keeping the "IkiWiki/Plugins" part of the path) and adding this -line at the begining of your ikiwiki.setup file: - - BEGIN { push @INC, "/home/user/.ikiwiki" } - - ## Plugin directory [[inline pages="plugins/* and !plugins/type/* and !plugins/write and diff --git a/doc/plugins/contrib.mdwn b/doc/plugins/contrib.mdwn index ae234f67b..dc8b90771 100644 --- a/doc/plugins/contrib.mdwn +++ b/doc/plugins/contrib.mdwn @@ -13,3 +13,7 @@ IkiWiki::Plugin namespace, so they go in a IkiWiki/Plugin subdirectory inside the perl search path. For example, if your perl looks in `/usr/local/lib/site_perl` for modules, you can locally install ikiwiki plugins to `/usr/local/lib/site_perl/IkiWiki/Plugin` + +You can use the `libdir` configuration option to add a directory to the +search path. For example, if you set `libdir` to `/home/you/.ikiwiki/`, +then ikiwiki will look for plugins in `/home/you/.ikiwiki/IkiWiki/Plugins`. diff --git a/doc/usage.mdwn b/doc/usage.mdwn index a8bb92d68..c83f833fc 100644 --- a/doc/usage.mdwn +++ b/doc/usage.mdwn @@ -229,6 +229,12 @@ configuration options of their own. Disables use of a plugin. For example "--disable-plugin htmlscrubber" to do away with HTML sanitization. +* --libdir directory + + Makes ikiwiki look in the specified directory first, before the regular perl + library directories. For example, if you set libdir to "/home/you/.ikiwiki/", + you can install plugins in "/home/you/.ikiwiki/IkiWiki/Plugins/". + * --discussion, --no-discussion Enables or disables "Discussion" links from being added to the header of diff --git a/ikiwiki.in b/ikiwiki.in index 8cec3f5c0..fd864e0d8 100755 --- a/ikiwiki.in +++ b/ikiwiki.in @@ -50,6 +50,7 @@ sub getconfig () { #{{{ "httpauth!" => \$config{httpauth}, "userdir=s" => \$config{userdir}, "htmlext=s" => \$config{htmlext}, + "libdir" => \$config{libdir}, "exclude=s@" => sub { push @{$config{wiki_file_prune_regexps}}, $_[1]; },