From a405b46c3b6020e1fa3631bfe5fd982f315c977f Mon Sep 17 00:00:00 2001 From: joey Date: Wed, 22 Nov 2006 02:28:42 +0000 Subject: * 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. --- IkiWiki/Plugin/inline.pm | 5 +++ IkiWiki/Plugin/nicebundle.pm | 29 ++++++++++++++ IkiWiki/Plugin/toggle.pm | 94 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 128 insertions(+) create mode 100644 IkiWiki/Plugin/nicebundle.pm create mode 100644 IkiWiki/Plugin/toggle.pm (limited to 'IkiWiki/Plugin') 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'; + +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 "$params{text}"; +} # }}} + +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
. + return "
\n\n$params{text}
"; +} # }}} + +sub format (@) { #{{{ + my %params=@_; + + if ($params{content}=~s!(
)
!$1!g) { + $params{content}=~s/
//g; + $params{content}=~s!^<\/body>!$javascript!m; + } + return $params{content}; +} # }}} + +1 -- cgit v1.2.3