* 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.master
parent
538a7a487b
commit
a405b46c3b
19
IkiWiki.pm
19
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";
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
|
@ -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
|
|
@ -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
|
||||
}
|
||||
} #}}}
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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}],
|
||||
|
||||
|
|
|
@ -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.
|
|
@ -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
|
||||
|
|
|
@ -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.
|
|
@ -0,0 +1 @@
|
|||
These plugins enable whole bundles of other plugins.
|
Loading…
Reference in New Issue