summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--IkiWiki.pm19
-rw-r--r--IkiWiki/Plugin/inline.pm5
-rw-r--r--IkiWiki/Plugin/nicebundle.pm29
-rw-r--r--IkiWiki/Plugin/toggle.pm94
-rw-r--r--IkiWiki/UserInfo.pm4
-rwxr-xr-xMakefile.PL7
-rw-r--r--debian/changelog8
-rw-r--r--doc/ikiwiki.setup5
-rw-r--r--doc/plugins/nicebundle.mdwn27
-rw-r--r--doc/plugins/passwordauth.mdwn1
-rw-r--r--doc/plugins/toggle.mdwn32
-rw-r--r--doc/plugins/type/bundle.mdwn1
12 files changed, 216 insertions, 16 deletions
diff --git a/IkiWiki.pm b/IkiWiki.pm
index 703b596a8..5f7bdfd06 100644
--- a/IkiWiki.pm
+++ b/IkiWiki.pm
@@ -116,13 +116,8 @@ sub checkconfig () { #{{{
} #}}}
sub loadplugins () { #{{{
- foreach my $plugin (@{$config{plugin}}) {
- my $mod="IkiWiki::Plugin::".possibly_foolish_untaint($plugin);
- eval qq{use $mod};
- if ($@) {
- error("Failed to load plugin $mod: $@");
- }
- }
+ loadplugin($_) foreach @{$config{plugin}};
+
run_hooks(getopt => sub { shift->() });
if (grep /^-/, @ARGV) {
print STDERR "Unknown option: $_\n"
@@ -131,6 +126,16 @@ sub loadplugins () { #{{{
}
} #}}}
+sub loadplugin ($) { #{{{
+ my $plugin=shift;
+
+ my $mod="IkiWiki::Plugin::".possibly_foolish_untaint($plugin);
+ eval qq{use $mod};
+ if ($@) {
+ error("Failed to load plugin $mod: $@");
+ }
+} #}}}
+
sub error ($) { #{{{
if ($config{cgi}) {
print "Content-type: text/html\n\n";
diff --git a/IkiWiki/Plugin/inline.pm b/IkiWiki/Plugin/inline.pm
index e65b8ae71..937bd281d 100644
--- a/IkiWiki/Plugin/inline.pm
+++ b/IkiWiki/Plugin/inline.pm
@@ -352,6 +352,9 @@ sub pingurl (@) { #{{{
setsid() or error("Can't start a new session: $!");
open STDERR, '>&STDOUT' or error("Can’t dup stdout: $!");
+ # Don't need to keep a lock on the wiki as a daemon.
+ IkiWiki::unlockwiki();
+
foreach my $page (keys %toping) {
my $title=pagetitle(basename($page));
my $url="$config{url}/".htmlpage($page);
@@ -375,6 +378,8 @@ sub pingurl (@) { #{{{
}
}
}
+
+ exit 0; # daemon done
} #}}}
1
diff --git a/IkiWiki/Plugin/nicebundle.pm b/IkiWiki/Plugin/nicebundle.pm
new file mode 100644
index 000000000..7139a2af8
--- /dev/null
+++ b/IkiWiki/Plugin/nicebundle.pm
@@ -0,0 +1,29 @@
+#!/usr/bin/perl
+package IkiWiki::Plugin::nicebundle;
+
+use warnings;
+use strict;
+use IkiWiki;
+
+my @bundle=qw{
+ brokenlinks
+ img
+ map
+ meta
+ orphans
+ pagecount
+ pagestats
+ shortcut
+ smiley
+ tag
+ template
+ toc
+ toggle
+ otl
+};
+
+sub import { #{{{
+ IkiWiki::loadplugin($_) foreach @bundle;
+} # }}}
+
+1
diff --git a/IkiWiki/Plugin/toggle.pm b/IkiWiki/Plugin/toggle.pm
new file mode 100644
index 000000000..7981d3701
--- /dev/null
+++ b/IkiWiki/Plugin/toggle.pm
@@ -0,0 +1,94 @@
+#!/usr/bin/perl
+package IkiWiki::Plugin::toggle;
+
+use warnings;
+use strict;
+use IkiWiki;
+
+# Here's the javascript that makes this possible. A key feature is the use
+# of css to hide toggleables, to avoid any flashing on page load. The css
+# is only emitted after the javascript tests that it's going to be able to
+# show the toggleables.
+my $javascript=<<'EOF';
+<script type="text/javascript">
+<!--
+if (document.getElementById && document.getElementsByTagName && document.createTextNode) {
+ document.write('<style type="text/css">div.toggleable { display: none; }</style>');
+ window.onload = inittoggle;
+}
+
+function inittoggle() {
+ var as = getElementsByClass('toggle');
+ for (var i = 0; i < as.length; i++) {
+ var id = as[i].href.match(/#(\w.+)/)[1];
+ document.getElementById(id).style.display="none";
+ as[i].onclick = function() {
+ toggle(this);
+ return false;
+ }
+ }
+}
+
+function toggle(s) {
+ var id = s.href.match(/#(\w.+)/)[1];
+ style = document.getElementById(id).style;
+ if (style.display == "none")
+ style.display = "block";
+ else
+ style.display = "none";
+}
+
+function getElementsByClass(class) {
+ var ret = new Array();
+ var pattern = new RegExp("(^|\\s)"+class+"(\\s|$)");
+ var els = document.getElementsByTagName('*');
+ for (i = 0, j = 0; i < els.length; i++) {
+ if ( pattern.test(els[i].className) ) {
+ ret[j] = els[i];
+ j++;
+ }
+ }
+ return ret;
+}
+//-->
+</script>
+EOF
+
+sub import { #{{{
+ hook(type => "preprocess", id => "toggle",
+ call => \&preprocess_toggle);
+ hook(type => "preprocess", id => "toggleable",
+ call => \&preprocess_toggleable, scan => 1);
+ hook(type => "format", id => "toggle", call => \&format);
+} # }}}
+
+sub preprocess_toggle (@) { #{{{
+ my %params=(id => "default", text => "more", @_);
+
+ return "<a class=\"toggle\" href=\"#$params{page}.$params{id}\">$params{text}</a>";
+} # }}}
+
+sub preprocess_toggleable (@) { #{{{
+ my %params=(id => "default", text => "", @_);
+
+ # Preprocess the text to expand any preprocessor directives
+ # embedded inside it. This is why scan is set for this preprocessor
+ # directive, since it could expand to something with a link in it.
+ $params{text}=IkiWiki::preprocess($params{page}, $params{destpage}, $params{text});
+
+ # Should really be a postprocessor directive, oh well. Work around
+ # markdown's dislike of markdown inside a <div>.
+ return "<div class=\"toggleable\" id=\"$params{page}.$params{id}\"></div>\n\n$params{text}<div class=\"toggleableend\"></div>";
+} # }}}
+
+sub format (@) { #{{{
+ my %params=@_;
+
+ if ($params{content}=~s!(<div class="toggleable" id="[^"]+">)</div>!$1!g) {
+ $params{content}=~s/<div class="toggleableend">//g;
+ $params{content}=~s!^<\/body>!$javascript</body>!m;
+ }
+ return $params{content};
+} # }}}
+
+1
diff --git a/IkiWiki/UserInfo.pm b/IkiWiki/UserInfo.pm
index 34f05203a..fd823c963 100644
--- a/IkiWiki/UserInfo.pm
+++ b/IkiWiki/UserInfo.pm
@@ -150,6 +150,8 @@ sub send_commit_mails ($$$@) { #{{{
setsid() or error("Can't start a new session: $!");
open STDERR, '>&STDOUT' or error("Can’t dup stdout: $!");
+ unlockwiki(); # don't need to keep a lock on the wiki
+
eval q{use Mail::Sendmail};
error($@) if $@;
foreach my $email (@email_recipients) {
@@ -160,6 +162,8 @@ sub send_commit_mails ($$$@) { #{{{
Message => $template->output,
) or error("Failed to send update notification mail");
}
+
+ exit 0; # daemon process done
}
} #}}}
diff --git a/Makefile.PL b/Makefile.PL
index 6e75097c8..b02eb15b0 100755
--- a/Makefile.PL
+++ b/Makefile.PL
@@ -27,11 +27,8 @@ extra_build:
./ikiwiki.in doc html --templatedir=templates --underlaydir=basewiki \
--wikiname="ikiwiki" --verbose --no-rcs \
--exclude=/discussion --no-discussion \
- --plugin=brokenlinks --plugin=pagecount \
- --plugin=orphans --plugin=haiku --plugin=meta \
- --plugin=tag --plugin=polygen --plugin=pagestats \
- --plugin=fortune --plugin=aggregate --plugin=map \
- --plugin=template --plugin=toc --plugin=shortcut
+ --plugin=nicebundle \
+ --plugin=haiku --plugin=polygen --plugin=fortune
./mdwn2man ikiwiki 1 doc/usage.mdwn > ikiwiki.man
./mdwn2man ikiwiki-mass-rebuild 8 doc/ikiwiki-mass-rebuild.mdwn > ikiwiki-mass-rebuild.man
./pm_filter $(PREFIX) $(VER) $(PROBABLE_INST_LIB) < ikiwiki.in > ikiwiki.out
diff --git a/debian/changelog b/debian/changelog
index 83864231a..3ef8c7160 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -9,6 +9,12 @@ ikiwiki (1.34) UNRELEASED; urgency=low
* Add openidsignup config option.
* Make the openid plugin support the callbacks from myopenid.com via its
affiliate program.
+ * Add toggle plugin.
+ * Introduce the nicebundle. This is a kind of plugin, that just enables
+ many other plugins. It's an easy way to boost ikiwiki from its default,
+ basic wiki, to a full-featured wiki, without manually picking the right
+ set of plugins. New plugins will be added to the nicebundle from time to
+ time.
* Change how post signin actions are propigated through the signin process;
they're now stored in the session.
* Add optional "desc" parameter to shortcut definitions.
@@ -35,7 +41,7 @@ ikiwiki (1.34) UNRELEASED; urgency=low
time/hang if the mail server is unhappy.
* Factor out commit mail sending code into new function.
- -- Joey Hess <joeyh@debian.org> Tue, 21 Nov 2006 11:58:30 -0500
+ -- Joey Hess <joeyh@debian.org> Tue, 21 Nov 2006 19:25:14 -0500
ikiwiki (1.33) unstable; urgency=low
diff --git a/doc/ikiwiki.setup b/doc/ikiwiki.setup
index 90af6dd5d..7f0975f5d 100644
--- a/doc/ikiwiki.setup
+++ b/doc/ikiwiki.setup
@@ -93,9 +93,8 @@ use IkiWiki::Setup::Standard {
syslog => 0,
# To add plugins, list them here.
- #add_plugins => [qw{meta tag pagecount brokenlinks search smiley
- # wikitext camelcase pagestats htmltidy fortune
- # sidebar map rst toc linkmap openid}],
+ #add_plugins => [qw{nicebundle openid search wikitext camelcase
+ # htmltidy fortune sidebar map rst}],
# If you want to disable any of the default plugins, list them here.
#disable_plugins => [qw{inline htmlscrubber passwordauth}],
diff --git a/doc/plugins/nicebundle.mdwn b/doc/plugins/nicebundle.mdwn
new file mode 100644
index 000000000..eeca30b3e
--- /dev/null
+++ b/doc/plugins/nicebundle.mdwn
@@ -0,0 +1,27 @@
+[[template id=plugin name=nicebundle included=1 author="[[Joey]]"]]
+[[tag type/bundle]]
+
+This plugin enables a bunch of other plugins -- basically all the ones that
+are not too intrusive, work well with little configuration, and are nice to
+have on any capable wiki. The plugins in this bundle are not enabled by
+default in ikiwiki, so that by default ikiwiki is limited to a few [[core]]
+wiki features. If you want a more capable wiki, enable this plugin bundle.
+
+Currently included:
+
+* [[brokenlinks]]
+* [[img]]
+* [[map]]
+* [[meta]]
+* [[orphans]]
+* [[pagecount]]
+* [[pagestats]]
+* [[shortcut]]
+* [[smiley]]
+* [[tag]]
+* [[template]]
+* [[toc]]
+* [[toggle]]
+* [[otl]]
+
+New plugins will be added to this bundle from time to time.
diff --git a/doc/plugins/passwordauth.mdwn b/doc/plugins/passwordauth.mdwn
index aded8829f..dacdffac6 100644
--- a/doc/plugins/passwordauth.mdwn
+++ b/doc/plugins/passwordauth.mdwn
@@ -1,5 +1,6 @@
[[template id=plugin name=passwordauth core=1 included=1 author="[[Joey]]"]]
[[tag type/auth]]
+[[tag type/core]]
This plugin lets ikiwiki prompt for a user name and password when logging
into the wiki. It also handles registering users, mailing passwords, and
diff --git a/doc/plugins/toggle.mdwn b/doc/plugins/toggle.mdwn
new file mode 100644
index 000000000..b59004e6e
--- /dev/null
+++ b/doc/plugins/toggle.mdwn
@@ -0,0 +1,32 @@
+[[template id=plugin name=toggle included=1 author="[[Joey]]"]]
+[[tag type/chrome]]
+
+With this plugin you can create links on pages that, when clicked, toggle
+display of other parts of the page.
+
+It uses javascript to accomplish this; browsers without javascript will
+always see the full page content.
+
+Example use:
+
+ \[[toggle id="ipsum" text="show"]]
+
+ \[[toggleable id="ipsum" text="""
+ Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do
+ eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim
+ ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut
+ aliquip ex ea commodo consequat.
+
+ [[toggle id="ipsum" text="hide"]]
+ """]]
+
+Clicking on "more" will toggle the display of the togglable text.
+
+Note that you can include wiki markup in the toggleable text,
+including even additional toggles, as shown in the above example.
+
+Also, the toggle and the togglable definitions do not need to be next to
+each other, but can be located anywhere on the page. There can also be
+mutiple toggles that all toggle a single togglable.
+
+The id has a default value of "default", so can be omitted in simple cases.
diff --git a/doc/plugins/type/bundle.mdwn b/doc/plugins/type/bundle.mdwn
new file mode 100644
index 000000000..0bf049ece
--- /dev/null
+++ b/doc/plugins/type/bundle.mdwn
@@ -0,0 +1 @@
+These plugins enable whole bundles of other plugins.