Coding style change: Remove explcit vim folding markers.

master
Joey Hess 2008-12-17 15:22:16 -05:00
parent 985b229be6
commit bb93fccf06
175 changed files with 1776 additions and 1775 deletions

View File

@ -34,7 +34,7 @@ memoize("abs2rel");
memoize("pagespec_translate");
memoize("file_pruned");
sub getsetup () { #{{{
sub getsetup () {
wikiname => {
type => "string",
default => "wiki",
@ -431,9 +431,9 @@ sub getsetup () { #{{{
safe => 0,
rebuild => 0,
},
} #}}}
}
sub defaultconfig () { #{{{
sub defaultconfig () {
my %s=getsetup();
my @ret;
foreach my $key (keys %s) {
@ -441,9 +441,9 @@ sub defaultconfig () { #{{{
}
use Data::Dumper;
return @ret;
} #}}}
}
sub checkconfig () { #{{{
sub checkconfig () {
# locale stuff; avoid LC_ALL since it overrides everything
if (defined $ENV{LC_ALL}) {
$ENV{LANG} = $ENV{LC_ALL};
@ -490,9 +490,9 @@ sub checkconfig () { #{{{
run_hooks(checkconfig => sub { shift->() });
return 1;
} #}}}
}
sub listplugins () { #{{{
sub listplugins () {
my %ret;
foreach my $dir (@INC, $config{libdir}) {
@ -510,9 +510,9 @@ sub listplugins () { #{{{
}
return keys %ret;
} #}}}
}
sub loadplugins () { #{{{
sub loadplugins () {
if (defined $config{libdir} && length $config{libdir}) {
unshift @INC, possibly_foolish_untaint($config{libdir});
}
@ -539,9 +539,9 @@ sub loadplugins () { #{{{
}
return 1;
} #}}}
}
sub loadplugin ($) { #{{{
sub loadplugin ($) {
my $plugin=shift;
return if grep { $_ eq $plugin} @{$config{disable_plugins}};
@ -567,9 +567,9 @@ sub loadplugin ($) { #{{{
}
$loaded_plugins{$plugin}=1;
return 1;
} #}}}
}
sub error ($;$) { #{{{
sub error ($;$) {
my $message=shift;
my $cleaner=shift;
log_message('err' => $message) if $config{syslog};
@ -577,15 +577,15 @@ sub error ($;$) { #{{{
$cleaner->();
}
die $message."\n";
} #}}}
}
sub debug ($) { #{{{
sub debug ($) {
return unless $config{verbose};
return log_message(debug => @_);
} #}}}
}
my $log_open=0;
sub log_message ($$) { #{{{
sub log_message ($$) {
my $type=shift;
if ($config{syslog}) {
@ -605,44 +605,44 @@ sub log_message ($$) { #{{{
else {
return print STDERR "@_\n";
}
} #}}}
}
sub possibly_foolish_untaint ($) { #{{{
sub possibly_foolish_untaint ($) {
my $tainted=shift;
my ($untainted)=$tainted=~/(.*)/s;
return $untainted;
} #}}}
}
sub basename ($) { #{{{
sub basename ($) {
my $file=shift;
$file=~s!.*/+!!;
return $file;
} #}}}
}
sub dirname ($) { #{{{
sub dirname ($) {
my $file=shift;
$file=~s!/*[^/]+$!!;
return $file;
} #}}}
}
sub pagetype ($) { #{{{
sub pagetype ($) {
my $page=shift;
if ($page =~ /\.([^.]+)$/) {
return $1 if exists $hooks{htmlize}{$1};
}
return;
} #}}}
}
sub isinternal ($) { #{{{
sub isinternal ($) {
my $page=shift;
return exists $pagesources{$page} &&
$pagesources{$page} =~ /\._([^.]+)$/;
} #}}}
}
sub pagename ($) { #{{{
sub pagename ($) {
my $file=shift;
my $type=pagetype($file);
@ -652,9 +652,9 @@ sub pagename ($) { #{{{
$page=$1;
}
return $page;
} #}}}
}
sub newpagefile ($$) { #{{{
sub newpagefile ($$) {
my $page=shift;
my $type=shift;
@ -664,9 +664,9 @@ sub newpagefile ($$) { #{{{
else {
return $page."/index.".$type;
}
} #}}}
}
sub targetpage ($$;$) { #{{{
sub targetpage ($$;$) {
my $page=shift;
my $ext=shift;
my $filename=shift;
@ -680,15 +680,15 @@ sub targetpage ($$;$) { #{{{
else {
return $page."/index.".$ext;
}
} #}}}
}
sub htmlpage ($) { #{{{
sub htmlpage ($) {
my $page=shift;
return targetpage($page, $config{htmlext});
} #}}}
}
sub srcfile_stat { #{{{
sub srcfile_stat {
my $file=shift;
my $nothrow=shift;
@ -698,13 +698,13 @@ sub srcfile_stat { #{{{
}
error("internal error: $file cannot be found in $config{srcdir} or underlay") unless $nothrow;
return;
} #}}}
}
sub srcfile ($;$) { #{{{
sub srcfile ($;$) {
return (srcfile_stat(@_))[0];
} #}}}
}
sub add_underlay ($) { #{{{
sub add_underlay ($) {
my $dir=shift;
if ($dir !~ /^\//) {
@ -716,9 +716,9 @@ sub add_underlay ($) { #{{{
}
return 1;
} #}}}
}
sub readfile ($;$$) { #{{{
sub readfile ($;$$) {
my $file=shift;
my $binary=shift;
my $wantfd=shift;
@ -738,9 +738,9 @@ sub readfile ($;$$) { #{{{
}
close $in || error("failed to read $file: $!");
return $ret;
} #}}}
}
sub prep_writefile ($$) { #{{{
sub prep_writefile ($$) {
my $file=shift;
my $destdir=shift;
@ -764,9 +764,9 @@ sub prep_writefile ($$) { #{{{
}
return 1;
} #}}}
}
sub writefile ($$$;$$) { #{{{
sub writefile ($$$;$$) {
my $file=shift; # can include subdirs
my $destdir=shift; # directory to put file in
my $content=shift;
@ -794,10 +794,10 @@ sub writefile ($$$;$$) { #{{{
error("failed renaming $newfile to $destdir/$file: $!", $cleanup);
return 1;
} #}}}
}
my %cleared;
sub will_render ($$;$) { #{{{
sub will_render ($$;$) {
my $page=shift;
my $dest=shift;
my $clear=shift;
@ -821,9 +821,9 @@ sub will_render ($$;$) { #{{{
$destsources{$dest}=$page;
return 1;
} #}}}
}
sub bestlink ($$) { #{{{
sub bestlink ($$) {
my $page=shift;
my $link=shift;
@ -859,15 +859,15 @@ sub bestlink ($$) { #{{{
#print STDERR "warning: page $page, broken link: $link\n";
return "";
} #}}}
}
sub isinlinableimage ($) { #{{{
sub isinlinableimage ($) {
my $file=shift;
return $file =~ /\.(png|gif|jpg|jpeg)$/i;
} #}}}
}
sub pagetitle ($;$) { #{{{
sub pagetitle ($;$) {
my $page=shift;
my $unescaped=shift;
@ -879,31 +879,31 @@ sub pagetitle ($;$) { #{{{
}
return $page;
} #}}}
}
sub titlepage ($) { #{{{
sub titlepage ($) {
my $title=shift;
# support use w/o %config set
my $chars = defined $config{wiki_file_chars} ? $config{wiki_file_chars} : "-[:alnum:]+/.:_";
$title=~s/([^$chars]|_)/$1 eq ' ' ? '_' : "__".ord($1)."__"/eg;
return $title;
} #}}}
}
sub linkpage ($) { #{{{
sub linkpage ($) {
my $link=shift;
my $chars = defined $config{wiki_file_chars} ? $config{wiki_file_chars} : "-[:alnum:]+/.:_";
$link=~s/([^$chars])/$1 eq ' ' ? '_' : "__".ord($1)."__"/eg;
return $link;
} #}}}
}
sub cgiurl (@) { #{{{
sub cgiurl (@) {
my %params=@_;
return $config{cgiurl}."?".
join("&", map $_."=".uri_escape_utf8($params{$_}), keys %params);
} #}}}
}
sub baseurl (;$) { #{{{
sub baseurl (;$) {
my $page=shift;
return "$config{url}/" if ! defined $page;
@ -912,9 +912,9 @@ sub baseurl (;$) { #{{{
$page=~s/[^\/]+$//;
$page=~s/[^\/]+\//..\//g;
return $page;
} #}}}
}
sub abs2rel ($$) { #{{{
sub abs2rel ($$) {
# Work around very innefficient behavior in File::Spec if abs2rel
# is passed two relative paths. It's much faster if paths are
# absolute! (Debian bug #376658; fixed in debian unstable now)
@ -925,15 +925,15 @@ sub abs2rel ($$) { #{{{
my $ret=File::Spec->abs2rel($path, $base);
$ret=~s/^// if defined $ret;
return $ret;
} #}}}
}
sub displaytime ($;$) { #{{{
sub displaytime ($;$) {
# Plugins can override this function to mark up the time to
# display.
return '<span class="date">'.formattime(@_).'</span>';
} #}}}
}
sub formattime ($;$) { #{{{
sub formattime ($;$) {
# Plugins can override this function to format the time.
my $time=shift;
my $format=shift;
@ -944,9 +944,9 @@ sub formattime ($;$) { #{{{
# strftime doesn't know about encodings, so make sure
# its output is properly treated as utf8
return decode_utf8(POSIX::strftime($format, localtime($time)));
} #}}}
}
sub beautify_urlpath ($) { #{{{
sub beautify_urlpath ($) {
my $url=shift;
if ($config{usedirs}) {
@ -960,9 +960,9 @@ sub beautify_urlpath ($) { #{{{
}
return $url;
} #}}}
}
sub urlto ($$;$) { #{{{
sub urlto ($$;$) {
my $to=shift;
my $from=shift;
my $absolute=shift;
@ -982,9 +982,9 @@ sub urlto ($$;$) { #{{{
my $link = abs2rel($to, dirname(htmlpage($from)));
return beautify_urlpath($link);
} #}}}
}
sub htmllink ($$$;@) { #{{{
sub htmllink ($$$;@) {
my $lpage=shift; # the page doing the linking
my $page=shift; # the page that will contain the link (different for inline)
my $link=shift;
@ -1047,9 +1047,9 @@ sub htmllink ($$$;@) { #{{{
}
return "<a href=\"$bestlink\"@attrs>$linktext</a>";
} #}}}
}
sub userlink ($) { #{{{
sub userlink ($) {
my $user=shift;
my $oiduser=eval { openiduser($user) };
@ -1064,9 +1064,9 @@ sub userlink ($) { #{{{
length $config{userdir} ? $config{userdir}."/".$user : $user
), noimageinline => 1);
}
} #}}}
}
sub htmlize ($$$$) { #{{{
sub htmlize ($$$$) {
my $page=shift;
my $destpage=shift;
my $type=shift;
@ -1101,9 +1101,9 @@ sub htmlize ($$$$) { #{{{
}
return $content;
} #}}}
}
sub linkify ($$$) { #{{{
sub linkify ($$$) {
my $page=shift;
my $destpage=shift;
my $content=shift;
@ -1117,11 +1117,11 @@ sub linkify ($$$) { #{{{
});
return $content;
} #}}}
}
our %preprocessing;
our $preprocess_preview=0;
sub preprocess ($$$;$$) { #{{{
sub preprocess ($$$;$$) {
my $page=shift; # the page the data comes from
my $destpage=shift; # the page the data will appear in (different for inline)
my $content=shift;
@ -1274,9 +1274,9 @@ sub preprocess ($$$;$$) { #{{{
$content =~ s{$regex}{$handle->($1, $2, $3, $4)}eg;
return $content;
} #}}}
}
sub filter ($$$) { #{{{
sub filter ($$$) {
my $page=shift;
my $destpage=shift;
my $content=shift;
@ -1287,15 +1287,15 @@ sub filter ($$$) { #{{{
});
return $content;
} #}}}
}
sub indexlink () { #{{{
sub indexlink () {
return "<a href=\"$config{url}\">$config{wikiname}</a>";
} #}}}
}
my $wikilock;
sub lockwiki () { #{{{
sub lockwiki () {
# Take an exclusive lock on the wiki to prevent multiple concurrent
# run issues. The lock will be dropped on program exit.
if (! -d $config{wikistatedir}) {
@ -1307,17 +1307,17 @@ sub lockwiki () { #{{{
error("failed to get lock");
}
return 1;
} #}}}
}
sub unlockwiki () { #{{{
sub unlockwiki () {
POSIX::close($ENV{IKIWIKI_CGILOCK_FD}) if exists $ENV{IKIWIKI_CGILOCK_FD};
return close($wikilock) if $wikilock;
return;
} #}}}
}
my $commitlock;
sub commit_hook_enabled () { #{{{
sub commit_hook_enabled () {
open($commitlock, '+>', "$config{wikistatedir}/commitlock") ||
error("cannot write to $config{wikistatedir}/commitlock: $!");
if (! flock($commitlock, 1 | 4)) { # LOCK_SH | LOCK_NB to test
@ -1326,23 +1326,23 @@ sub commit_hook_enabled () { #{{{
}
close($commitlock) || error("failed closing commitlock: $!");
return 1;
} #}}}
}
sub disable_commit_hook () { #{{{
sub disable_commit_hook () {
open($commitlock, '>', "$config{wikistatedir}/commitlock") ||
error("cannot write to $config{wikistatedir}/commitlock: $!");
if (! flock($commitlock, 2)) { # LOCK_EX
error("failed to get commit lock");
}
return 1;
} #}}}
}
sub enable_commit_hook () { #{{{
sub enable_commit_hook () {
return close($commitlock) if $commitlock;
return;
} #}}}
}
sub loadindex () { #{{{
sub loadindex () {
%oldrenderedfiles=%pagectime=();
if (! $config{rebuild}) {
%pagesources=%pagemtime=%oldlinks=%links=%depends=
@ -1402,9 +1402,9 @@ sub loadindex () { #{{{
$destsources{$_}=$page foreach @{$renderedfiles{$page}};
}
return close($in);
} #}}}
}
sub saveindex () { #{{{
sub saveindex () {
run_hooks(savestate => sub { shift->() });
my %hookids;
@ -1460,18 +1460,18 @@ sub saveindex () { #{{{
error("failed renaming $newfile to $config{wikistatedir}/indexdb", $cleanup);
return 1;
} #}}}
}
sub template_file ($) { #{{{
sub template_file ($) {
my $template=shift;
foreach my $dir ($config{templatedir}, "$installdir/share/ikiwiki/templates") {
return "$dir/$template" if -e "$dir/$template";
}
return;
} #}}}
}
sub template_params (@) { #{{{
sub template_params (@) {
my $filename=template_file(shift);
if (! defined $filename) {
@ -1490,14 +1490,14 @@ sub template_params (@) { #{{{
@_
);
return wantarray ? @ret : {@ret};
} #}}}
}
sub template ($;@) { #{{{
sub template ($;@) {
require HTML::Template;
return HTML::Template->new(template_params(@_));
} #}}}
}
sub misctemplate ($$;@) { #{{{
sub misctemplate ($$;@) {
my $title=shift;
my $pagebody=shift;
@ -1514,9 +1514,9 @@ sub misctemplate ($$;@) { #{{{
shift->(page => "", destpage => "", template => $template);
});
return $template->output;
}#}}}
}
sub hook (@) { # {{{
sub hook (@) {
my %param=@_;
if (! exists $param{type} || ! ref $param{call} || ! exists $param{id}) {
@ -1527,9 +1527,9 @@ sub hook (@) { # {{{
$hooks{$param{type}}{$param{id}}=\%param;
return 1;
} # }}}
}
sub run_hooks ($$) { # {{{
sub run_hooks ($$) {
# Calls the given sub for each hook of the given type,
# passing it the hook function to call.
my $type=shift;
@ -1550,53 +1550,53 @@ sub run_hooks ($$) { # {{{
}
return 1;
} #}}}
}
sub rcs_update () { #{{{
sub rcs_update () {
$hooks{rcs}{rcs_update}{call}->(@_);
} #}}}
}
sub rcs_prepedit ($) { #{{{
sub rcs_prepedit ($) {
$hooks{rcs}{rcs_prepedit}{call}->(@_);
} #}}}
}
sub rcs_commit ($$$;$$) { #{{{
sub rcs_commit ($$$;$$) {
$hooks{rcs}{rcs_commit}{call}->(@_);
} #}}}
}
sub rcs_commit_staged ($$$) { #{{{
sub rcs_commit_staged ($$$) {
$hooks{rcs}{rcs_commit_staged}{call}->(@_);
} #}}}
}
sub rcs_add ($) { #{{{
sub rcs_add ($) {
$hooks{rcs}{rcs_add}{call}->(@_);
} #}}}
}
sub rcs_remove ($) { #{{{
sub rcs_remove ($) {
$hooks{rcs}{rcs_remove}{call}->(@_);
} #}}}
}
sub rcs_rename ($$) { #{{{
sub rcs_rename ($$) {
$hooks{rcs}{rcs_rename}{call}->(@_);
} #}}}
}
sub rcs_recentchanges ($) { #{{{
sub rcs_recentchanges ($) {
$hooks{rcs}{rcs_recentchanges}{call}->(@_);
} #}}}
}
sub rcs_diff ($) { #{{{
sub rcs_diff ($) {
$hooks{rcs}{rcs_diff}{call}->(@_);
} #}}}
}
sub rcs_getctime ($) { #{{{
sub rcs_getctime ($) {
$hooks{rcs}{rcs_getctime}{call}->(@_);
} #}}}
}
sub rcs_receive () { #{{{
sub rcs_receive () {
$hooks{rcs}{rcs_receive}{call}->();
} #}}}
}
sub globlist_to_pagespec ($) { #{{{
sub globlist_to_pagespec ($) {
my @globlist=split(' ', shift);
my (@spec, @skip);
@ -1620,20 +1620,20 @@ sub globlist_to_pagespec ($) { #{{{
}
}
return $spec;
} #}}}
}
sub is_globlist ($) { #{{{
sub is_globlist ($) {
my $s=shift;
return ( $s =~ /[^\s]+\s+([^\s]+)/ && $1 ne "and" && $1 ne "or" );
} #}}}
}
sub safequote ($) { #{{{
sub safequote ($) {
my $s=shift;
$s=~s/[{}]//g;
return "q{$s}";
} #}}}
}
sub add_depends ($$) { #{{{
sub add_depends ($$) {
my $page=shift;
my $pagespec=shift;
@ -1647,9 +1647,9 @@ sub add_depends ($$) { #{{{
}
return 1;
} # }}}
}
sub file_pruned ($$) { #{{{
sub file_pruned ($$) {
require File::Spec;
my $file=File::Spec->canonpath(shift);
my $base=File::Spec->canonpath(shift);
@ -1657,9 +1657,9 @@ sub file_pruned ($$) { #{{{
my $regexp='('.join('|', @{$config{wiki_file_prune_regexps}}).')';
return $file =~ m/$regexp/ && $file ne $base;
} #}}}
}
sub gettext { #{{{
sub gettext {
# Only use gettext in the rare cases it's needed.
if ((exists $ENV{LANG} && length $ENV{LANG}) ||
(exists $ENV{LC_ALL} && length $ENV{LC_ALL}) ||
@ -1680,15 +1680,15 @@ sub gettext { #{{{
else {
return shift;
}
} #}}}
}
sub yesno ($) { #{{{
sub yesno ($) {
my $val=shift;
return (defined $val && lc($val) eq gettext("yes"));
} #}}}
}
sub inject { #{{{
sub inject {
# Injects a new function into the symbol table to replace an
# exported function.
my %params=@_;
@ -1711,9 +1711,9 @@ sub inject { #{{{
}
use strict;
use warnings;
} #}}}
}
sub pagespec_merge ($$) { #{{{
sub pagespec_merge ($$) {
my $a=shift;
my $b=shift;
@ -1728,9 +1728,9 @@ sub pagespec_merge ($$) { #{{{
}
return "($a) or ($b)";
} #}}}
}
sub pagespec_translate ($) { #{{{
sub pagespec_translate ($) {
my $spec=shift;
# Support for old-style GlobLists.
@ -1784,9 +1784,9 @@ sub pagespec_translate ($) { #{{{
no warnings;
return eval 'sub { my $page=shift; '.$code.' }';
} #}}}
}
sub pagespec_match ($$;@) { #{{{
sub pagespec_match ($$;@) {
my $page=shift;
my $spec=shift;
my @params=@_;
@ -1799,55 +1799,55 @@ sub pagespec_match ($$;@) { #{{{
my $sub=pagespec_translate($spec);
return IkiWiki::FailReason->new("syntax error in pagespec \"$spec\"") if $@;
return $sub->($page, @params);
} #}}}
}
sub pagespec_valid ($) { #{{{
sub pagespec_valid ($) {
my $spec=shift;
my $sub=pagespec_translate($spec);
return ! $@;
} #}}}
}
sub glob2re ($) { #{{{
sub glob2re ($) {
my $re=quotemeta(shift);
$re=~s/\\\*/.*/g;
$re=~s/\\\?/./g;
return $re;
} #}}}
}
package IkiWiki::FailReason;
use overload ( #{{{
use overload (
'""' => sub { ${$_[0]} },
'0+' => sub { 0 },
'!' => sub { bless $_[0], 'IkiWiki::SuccessReason'},
fallback => 1,
); #}}}
);
sub new { #{{{
sub new {
my $class = shift;
my $value = shift;
return bless \$value, $class;
} #}}}
}
package IkiWiki::SuccessReason;
use overload ( #{{{
use overload (
'""' => sub { ${$_[0]} },
'0+' => sub { 1 },
'!' => sub { bless $_[0], 'IkiWiki::FailReason'},
fallback => 1,
); #}}}
);
sub new { #{{{
sub new {
my $class = shift;
my $value = shift;
return bless \$value, $class;
}; #}}}
};
package IkiWiki::PageSpec;
sub match_glob ($$;@) { #{{{
sub match_glob ($$;@) {
my $page=shift;
my $glob=shift;
my %params=@_;
@ -1873,13 +1873,13 @@ sub match_glob ($$;@) { #{{{
else {
return IkiWiki::FailReason->new("$glob does not match $page");
}
} #}}}
}
sub match_internal ($$;@) { #{{{
sub match_internal ($$;@) {
return match_glob($_[0], $_[1], @_, internal => 1)
} #}}}
}
sub match_link ($$;@) { #{{{
sub match_link ($$;@) {
my $page=shift;
my $link=lc(shift);
my %params=@_;
@ -1911,13 +1911,13 @@ sub match_link ($$;@) { #{{{
}
}
return IkiWiki::FailReason->new("$page does not link to $link");
} #}}}
}
sub match_backlink ($$;@) { #{{{
sub match_backlink ($$;@) {
return match_link($_[1], $_[0], @_);
} #}}}
}
sub match_created_before ($$;@) { #{{{
sub match_created_before ($$;@) {
my $page=shift;
my $testpage=shift;
@ -1932,9 +1932,9 @@ sub match_created_before ($$;@) { #{{{
else {
return IkiWiki::FailReason->new("$testpage has no ctime");
}
} #}}}
}
sub match_created_after ($$;@) { #{{{
sub match_created_after ($$;@) {
my $page=shift;
my $testpage=shift;
@ -1949,36 +1949,36 @@ sub match_created_after ($$;@) { #{{{
else {
return IkiWiki::FailReason->new("$testpage has no ctime");
}
} #}}}
}
sub match_creation_day ($$;@) { #{{{
sub match_creation_day ($$;@) {
if ((gmtime($IkiWiki::pagectime{shift()}))[3] == shift) {
return IkiWiki::SuccessReason->new('creation_day matched');
}
else {
return IkiWiki::FailReason->new('creation_day did not match');
}
} #}}}
}
sub match_creation_month ($$;@) { #{{{
sub match_creation_month ($$;@) {
if ((gmtime($IkiWiki::pagectime{shift()}))[4] + 1 == shift) {
return IkiWiki::SuccessReason->new('creation_month matched');
}
else {
return IkiWiki::FailReason->new('creation_month did not match');
}
} #}}}
}
sub match_creation_year ($$;@) { #{{{
sub match_creation_year ($$;@) {
if ((gmtime($IkiWiki::pagectime{shift()}))[5] + 1900 == shift) {
return IkiWiki::SuccessReason->new('creation_year matched');
}
else {
return IkiWiki::FailReason->new('creation_year did not match');
}
} #}}}
}
sub match_user ($$;@) { #{{{
sub match_user ($$;@) {
shift;
my $user=shift;
my %params=@_;
@ -1996,9 +1996,9 @@ sub match_user ($$;@) { #{{{
else {
return IkiWiki::FailReason->new("user is $params{user}, not $user");
}
} #}}}
}
sub match_admin ($$;@) { #{{{
sub match_admin ($$;@) {
shift;
shift;
my %params=@_;
@ -2016,9 +2016,9 @@ sub match_admin ($$;@) { #{{{
else {
return IkiWiki::FailReason->new("user is not an admin");
}
} #}}}
}
sub match_ip ($$;@) { #{{{
sub match_ip ($$;@) {
shift;
my $ip=shift;
my %params=@_;
@ -2033,6 +2033,6 @@ sub match_ip ($$;@) { #{{{
else {
return IkiWiki::FailReason->new("IP is $params{ip}, not $ip");
}
} #}}}
}
1

View File

@ -9,7 +9,7 @@ use IkiWiki::UserInfo;
use open qw{:utf8 :std};
use Encode;
sub printheader ($) { #{{{
sub printheader ($) {
my $session=shift;
if ($config{sslcookie}) {
@ -19,9 +19,9 @@ sub printheader ($) { #{{{
print $session->header(-charset => 'utf-8',
-cookie => $session->cookie(-httponly => 1));
}
} #}}}
}
sub showform ($$$$;@) { #{{{
sub showform ($$$$;@) {
my $form=shift;
my $buttons=shift;
my $session=shift;
@ -36,9 +36,9 @@ sub showform ($$$$;@) { #{{{
printheader($session);
print misctemplate($form->title, $form->render(submit => $buttons), @_);
} #}}}
}
sub redirect ($$) { #{{{
sub redirect ($$) {
my $q=shift;
my $url=shift;
if (! $config{w3mmode}) {
@ -48,9 +48,9 @@ sub redirect ($$) { #{{{
print "Content-type: text/plain\n";
print "W3m-control: GOTO $url\n\n";
}
} #}}}
}
sub decode_cgi_utf8 ($) { #{{{
sub decode_cgi_utf8 ($) {
# decode_form_utf8 method is needed for 5.10
if ($] < 5.01) {
my $cgi = shift;
@ -58,9 +58,9 @@ sub decode_cgi_utf8 ($) { #{{{
$cgi->param($f, map { decode_utf8 $_ } $cgi->param($f));
}
}
} #}}}
}
sub decode_form_utf8 ($) { #{{{
sub decode_form_utf8 ($) {
if ($] >= 5.01) {
my $form = shift;
foreach my $f ($form->field) {
@ -70,11 +70,11 @@ sub decode_form_utf8 ($) { #{{{
);
}
}
} #}}}
}
# Check if the user is signed in. If not, redirect to the signin form and
# save their place to return to later.
sub needsignin ($$) { #{{{
sub needsignin ($$) {
my $q=shift;
my $session=shift;
@ -85,9 +85,9 @@ sub needsignin ($$) { #{{{
cgi_savesession($session);
exit;
}
} #}}}
}
sub cgi_signin ($$) { #{{{
sub cgi_signin ($$) {
my $q=shift;
my $session=shift;
@ -127,9 +127,9 @@ sub cgi_signin ($$) { #{{{
}
showform($form, $buttons, $session, $q);
} #}}}
}
sub cgi_postsignin ($$) { #{{{
sub cgi_postsignin ($$) {
my $q=shift;
my $session=shift;
@ -144,9 +144,9 @@ sub cgi_postsignin ($$) { #{{{
else {
error(gettext("login failed, perhaps you need to turn on cookies?"));
}
} #}}}
}
sub cgi_prefs ($$) { #{{{
sub cgi_prefs ($$) {
my $q=shift;
my $session=shift;
@ -254,9 +254,9 @@ sub cgi_prefs ($$) { #{{{
}
showform($form, $buttons, $session, $q);
} #}}}
}
sub check_banned ($$) { #{{{
sub check_banned ($$) {
my $q=shift;
my $session=shift;
@ -273,9 +273,9 @@ sub check_banned ($$) { #{{{
exit;
}
}
} #}}}
}
sub cgi_getsession ($) { #{{{
sub cgi_getsession ($) {
my $q=shift;
eval q{use CGI::Session; use HTML::Entities};
@ -294,13 +294,13 @@ sub cgi_getsession ($) { #{{{
umask($oldmask);
return $session;
} #}}}
}
# To guard against CSRF, the user's session id (sid)
# can be stored on a form. This function will check
# (for logged in users) that the sid on the form matches
# the session id in the cookie.
sub checksessionexpiry ($$) { # {{{
sub checksessionexpiry ($$) {
my $q=shift;
my $session = shift;
@ -310,18 +310,18 @@ sub checksessionexpiry ($$) { # {{{
error(gettext("Your login session has expired."));
}
}
} # }}}
}
sub cgi_savesession ($) { #{{{
sub cgi_savesession ($) {
my $session=shift;
# Force session flush with safe umask.
my $oldmask=umask(077);
$session->flush;
umask($oldmask);
} #}}}
}
sub cgi (;$$) { #{{{
sub cgi (;$$) {
my $q=shift;
my $session=shift;
@ -391,16 +391,16 @@ sub cgi (;$$) { #{{{
else {
error("unknown do parameter");
}
} #}}}
}
# Does not need to be called directly; all errors will go through here.
sub cgierror ($) { #{{{
sub cgierror ($) {
my $message=shift;
print "Content-type: text/html\n\n";
print misctemplate(gettext("Error"),
"<p class=\"error\">".gettext("Error").": $message</p>");
die $@;
} #}}}
}
1

View File

@ -14,7 +14,7 @@ use open qw{:utf8 :std};
my %feeds;
my %guids;
sub import { #{{{
sub import {
hook(type => "getopt", id => "aggregate", call => \&getopt);
hook(type => "getsetup", id => "aggregate", call => \&getsetup);
hook(type => "checkconfig", id => "aggregate", call => \&checkconfig);
@ -26,9 +26,9 @@ sub import { #{{{
if (exists $config{aggregate_webtrigger} && $config{aggregate_webtrigger}) {
hook(type => "cgi", id => "aggregate", call => \&cgi);
}
} # }}}
}
sub getopt () { #{{{
sub getopt () {
eval q{use Getopt::Long};
error($@) if $@;
Getopt::Long::Configure('pass_through');
@ -36,9 +36,9 @@ sub getopt () { #{{{
"aggregate" => \$config{aggregate},
"aggregateinternal!" => \$config{aggregateinternal},
);
} #}}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
@ -58,16 +58,16 @@ sub getsetup () { #{{{
safe => 1,
rebuild => 0,
},
} #}}}
}
sub checkconfig () { #{{{
sub checkconfig () {
if ($config{aggregate} && ! ($config{post_commit} &&
IkiWiki::commit_hook_enabled())) {
launchaggregation();
}
} #}}}
}
sub cgi ($) { #{{{
sub cgi ($) {
my $cgi=shift;
if (defined $cgi->param('do') &&
@ -90,9 +90,9 @@ sub cgi ($) { #{{{
}
exit 0;
}
} #}}}
}
sub launchaggregation () { #{{{
sub launchaggregation () {
# See if any feeds need aggregation.
loadstate();
my @feeds=needsaggregate();
@ -135,16 +135,16 @@ sub launchaggregation () { #{{{
unlockaggregate();
return 1;
} #}}}
}
# Pages with extension _aggregated have plain html markup, pass through.
sub htmlize (@) { #{{{
sub htmlize (@) {
my %params=@_;
return $params{content};
} #}}}
}
# Used by ikiwiki-transition aggregateinternal.
sub migrate_to_internal { #{{{
sub migrate_to_internal {
if (! lockaggregate()) {
error("an aggregation process is currently running");
}
@ -190,9 +190,9 @@ sub migrate_to_internal { #{{{
IkiWiki::unlockwiki;
unlockaggregate();
} #}}}
}
sub needsbuild (@) { #{{{
sub needsbuild (@) {
my $needsbuild=shift;
loadstate();
@ -206,9 +206,9 @@ sub needsbuild (@) { #{{{
markunseen($feed->{sourcepage});
}
}
} # }}}
}
sub preprocess (@) { #{{{
sub preprocess (@) {
my %params=@_;
foreach my $required (qw{name url}) {
@ -265,9 +265,9 @@ sub preprocess (@) { #{{{
($feed->{newposts} ? "; ".$feed->{newposts}.
" ".gettext("new") : "").
")";
} # }}}
}
sub delete (@) { #{{{
sub delete (@) {
my @files=@_;
# Remove feed data for removed pages.
@ -275,9 +275,9 @@ sub delete (@) { #{{{
my $page=pagename($file);
markunseen($page);
}
} #}}}
}
sub markunseen ($) { #{{{
sub markunseen ($) {
my $page=shift;
foreach my $id (keys %feeds) {
@ -285,11 +285,11 @@ sub markunseen ($) { #{{{
$feeds{$id}->{unseen}=1;
}
}
} #}}}
}
my $state_loaded=0;
sub loadstate () { #{{{
sub loadstate () {
return if $state_loaded;
$state_loaded=1;
if (-e "$config{wikistatedir}/aggregate") {
@ -323,9 +323,9 @@ sub loadstate () { #{{{
close IN;
}
} #}}}
}
sub savestate () { #{{{
sub savestate () {
return unless $state_loaded;
garbage_collect();
my $newfile="$config{wikistatedir}/aggregate.new";
@ -350,9 +350,9 @@ sub savestate () { #{{{
close OUT || error("save $newfile: $!", $cleanup);
rename($newfile, "$config{wikistatedir}/aggregate") ||
error("rename $newfile: $!", $cleanup);
} #}}}
}
sub garbage_collect () { #{{{
sub garbage_collect () {
foreach my $name (keys %feeds) {
# remove any feeds that were not seen while building the pages
# that used to contain them
@ -375,9 +375,9 @@ sub garbage_collect () { #{{{
delete $guid->{md5};
}
}
} #}}}
}
sub mergestate () { #{{{
sub mergestate () {
# Load the current state in from disk, and merge into it
# values from the state in memory that might have changed
# during aggregation.
@ -407,15 +407,15 @@ sub mergestate () { #{{{
$guids{$guid}=$myguids{$guid};
}
}
} #}}}
}
sub clearstate () { #{{{
sub clearstate () {
%feeds=();
%guids=();
$state_loaded=0;
} #}}}
}
sub expire () { #{{{
sub expire () {
foreach my $feed (values %feeds) {
next unless $feed->{expireage} || $feed->{expirecount};
my $count=0;
@ -444,14 +444,14 @@ sub expire () { #{{{
}
}
}
} #}}}
}
sub needsaggregate () { #{{{
sub needsaggregate () {
return values %feeds if $config{rebuild};
return grep { time - $_->{lastupdate} >= $_->{updateinterval} } values %feeds;
} #}}}
}
sub aggregate (@) { #{{{
sub aggregate (@) {
eval q{use XML::Feed};
error($@) if $@;
eval q{use URI::Fetch};
@ -542,9 +542,9 @@ sub aggregate (@) { #{{{
);
}
}
} #}}}
}
sub add_page (@) { #{{{
sub add_page (@) {
my %params=@_;
my $feed=$params{feed};
@ -635,21 +635,21 @@ sub add_page (@) { #{{{
# Dummy value for expiry code.
$IkiWiki::pagectime{$guid->{page}}=time;
}
} #}}}
}
sub wikiescape ($) { #{{{
sub wikiescape ($) {
# escape accidental wikilinks and preprocessor stuff
return encode_entities(shift, '\[\]');
} #}}}
}
sub urlabs ($$) { #{{{
sub urlabs ($$) {
my $url=shift;
my $urlbase=shift;
URI->new_abs($url, $urlbase)->as_string;
} #}}}
}
sub htmlabs ($$) { #{{{
sub htmlabs ($$) {
# Convert links in html from relative to absolute.
# Note that this is a heuristic, which is not specified by the rss
# spec and may not be right for all feeds. Also, see Debian
@ -685,15 +685,15 @@ sub htmlabs ($$) { #{{{
$p->eof;
return $ret;
} #}}}
}
sub htmlfn ($) { #{{{
sub htmlfn ($) {
return shift().".".($config{aggregateinternal} ? "_aggregated" : $config{htmlext});
} #}}}
}
my $aggregatelock;
sub lockaggregate () { #{{{
sub lockaggregate () {
# Take an exclusive lock to prevent multiple concurrent aggregators.
# Returns true if the lock was aquired.
if (! -d $config{wikistatedir}) {
@ -706,11 +706,11 @@ sub lockaggregate () { #{{{
return 0;
}
return 1;
} #}}}
}
sub unlockaggregate () { #{{{
sub unlockaggregate () {
return close($aggregatelock) if $aggregatelock;
return;
} #}}}
}
1

View File

@ -16,13 +16,13 @@ BEGIN {
}
};
sub import { #{{{
sub import {
hook(type => "getopt", id => "amazon_s3", call => \&getopt);
hook(type => "getsetup", id => "amazon_s3", call => \&getsetup);
hook(type => "checkconfig", id => "amazon_s3", call => \&checkconfig);
} # }}}
}
sub getopt () { #{{{
sub getopt () {
eval q{use Getopt::Long};
error($@) if $@;
Getopt::Long::Configure('pass_through');
@ -38,9 +38,9 @@ sub getopt () { #{{{
debug(gettext("done"));
exit(0);
});
} #}}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 0,
@ -88,9 +88,9 @@ sub getsetup () { #{{{
safe => 1,
rebuild => 1,
},
} #}}}
}
sub checkconfig { #{{{
sub checkconfig {
foreach my $field (qw{amazon_s3_key_id amazon_s3_key_file
amazon_s3_bucket}) {
if (! exists $config{$field} || ! defined $config{$field}) {
@ -101,11 +101,11 @@ sub checkconfig { #{{{
! defined $config{amazon_s3_prefix}) {
$config{amazon_s3_prefix}="wiki/";
}
} #}}}
}
{
my $bucket;
sub getbucket { #{{{
sub getbucket {
return $bucket if defined $bucket;
open(IN, "<", $config{amazon_s3_key_file}) || error($config{amazon_s3_key_file}.": ".$!);
@ -138,11 +138,11 @@ sub getbucket { #{{{
}
return $bucket;
} #}}}
}
}
# Given a file, return any S3 keys associated with it.
sub file2keys ($) { #{{{
sub file2keys ($) {
my $file=shift;
my @keys;
@ -162,14 +162,14 @@ sub file2keys ($) { #{{{
}
}
return @keys;
} #}}}
}
package IkiWiki;
use File::MimeInfo;
use Encode;
# This is a wrapper around the real writefile.
sub writefile ($$$;$$) { #{{{
sub writefile ($$$;$$) {
my $file=shift;
my $destdir=shift;
my $content=shift;
@ -225,10 +225,10 @@ sub writefile ($$$;$$) { #{{{
}
return $ret;
} #}}}
}
# This is a wrapper around the real prune.
sub prune ($) { #{{{
sub prune ($) {
my $file=shift;
my @keys=IkiWiki::Plugin::amazon_s3::file2keys($file);
@ -247,6 +247,6 @@ sub prune ($) { #{{{
}
return $IkiWiki::Plugin::amazon_s3::subs{'IkiWiki::prune'}->($file);
} #}}}
}
1

View File

@ -5,12 +5,12 @@ use warnings;
use strict;
use IkiWiki 2.00;
sub import { #{{{
sub import {
hook(type => "getsetup", id => "anonok", call => \&getsetup);
hook(type => "canedit", id => "anonok", call => \&canedit);
} # }}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
@ -24,9 +24,9 @@ sub getsetup () { #{{{
safe => 1,
rebuild => 0,
},
} #}}}
}
sub canedit ($$$) { #{{{
sub canedit ($$$) {
my $page=shift;
my $cgi=shift;
my $session=shift;
@ -45,6 +45,6 @@ sub canedit ($$$) { #{{{
else {
return "";
}
} #}}}
}
1

View File

@ -5,16 +5,16 @@ use warnings;
use strict;
use IkiWiki 2.00;
sub import { #{{{
sub import {
add_underlay("javascript");
hook(type => "getsetup", id => "attachment", call => \&getsetup);
hook(type => "checkconfig", id => "attachment", call => \&checkconfig);
hook(type => "formbuilder_setup", id => "attachment", call => \&formbuilder_setup);
hook(type => "formbuilder", id => "attachment", call => \&formbuilder);
IkiWiki::loadplugin("filecheck");
} # }}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
@ -35,9 +35,9 @@ sub getsetup () { #{{{
safe => 0, # executed
rebuild => 0,
},
} #}}}
}
sub check_canattach ($$;$) { #{{{
sub check_canattach ($$;$) {
my $session=shift;
my $dest=shift; # where it's going to be put, under the srcdir
my $file=shift; # the path to the attachment currently
@ -84,13 +84,13 @@ sub check_canattach ($$;$) { #{{{
else {
return 1;
}
} #}}}
}
sub checkconfig () { #{{{
sub checkconfig () {
$config{cgi_disable_uploads}=0;
} #}}}
}
sub formbuilder_setup (@) { #{{{
sub formbuilder_setup (@) {
my %params=@_;
my $form=$params{form};
my $q=$params{cgi};
@ -153,9 +153,9 @@ sub formbuilder_setup (@) { #{{{
}
}
}
} #}}}
}
sub formbuilder (@) { #{{{
sub formbuilder (@) {
my %params=@_;
my $form=$params{form};
my $q=$params{cgi};
@ -253,9 +253,9 @@ sub formbuilder (@) { #{{{
# Generate the attachment list only after having added any new
# attachments.
$form->tmpl_param("attachment_list" => [attachment_list($form->field('page'))]);
} # }}}
}
sub attachment_location ($) { #{{{
sub attachment_location ($) {
my $page=shift;
# Put the attachment in a subdir of the page it's attached
@ -264,9 +264,9 @@ sub attachment_location ($) { #{{{
$page.="/" if length $page;
return $page;
} #}}}
}
sub attachment_list ($) { #{{{
sub attachment_list ($) {
my $page=shift;
my $loc=attachment_location($page);
@ -287,6 +287,6 @@ sub attachment_list ($) { #{{{
# Sort newer attachments to the top of the list, so a newly-added
# attachment appears just before the form used to add it.
return sort { $b->{mtime_raw} <=> $a->{mtime_raw} || $a->{link} cmp $b->{link} } @ret;
} #}}}
}
1

View File

@ -6,20 +6,20 @@ use strict;
use IkiWiki 2.00;
use Encode;
sub import { #{{{
sub import {
hook(type => "getsetup", id => "autoindex", call => \&getsetup);
hook(type => "refresh", id => "autoindex", call => \&refresh);
} # }}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
rebuild => 0,
},
} #}}}
}
sub genindex ($) { #{{{
sub genindex ($) {
my $page=shift;
my $file=newpagefile($page, $config{default_pageext});
my $template=template("autoindex.tmpl");
@ -28,9 +28,9 @@ sub genindex ($) { #{{{
if ($config{rcs}) {
IkiWiki::rcs_add($file);
}
} #}}}
}
sub refresh () { #{{{
sub refresh () {
eval q{use File::Find};
error($@) if $@;
@ -107,6 +107,6 @@ sub refresh () { #{{{
IkiWiki::enable_commit_hook();
}
}
} #}}}
}
1

View File

@ -6,20 +6,20 @@ use warnings;
use strict;
use IkiWiki 2.00;
sub import { #{{{
sub import {
hook(type => "getsetup", id => "brokenlinks", call => \&getsetup);
hook(type => "preprocess", id => "brokenlinks", call => \&preprocess);
} # }}}
}
sub getsetup { #{{{
sub getsetup {
return
plugin => {
safe => 1,
rebuild => undef,
},
} #}}}
}
sub preprocess (@) { #{{{
sub preprocess (@) {
my %params=@_;
$params{pages}="*" unless defined $params{pages};
@ -61,6 +61,6 @@ sub preprocess (@) { #{{{
}
sort @broken)
."</ul>\n";
} # }}}
}
1

View File

@ -7,7 +7,7 @@ use IkiWiki;
use Encode;
use open qw{:utf8 :std};
sub import { #{{{
sub import {
hook(type => "checkconfig", id => "bzr", call => \&checkconfig);
hook(type => "getsetup", id => "bzr", call => \&getsetup);
hook(type => "rcs", id => "rcs_update", call => \&rcs_update);
@ -20,18 +20,18 @@ sub import { #{{{
hook(type => "rcs", id => "rcs_recentchanges", call => \&rcs_recentchanges);
hook(type => "rcs", id => "rcs_diff", call => \&rcs_diff);
hook(type => "rcs", id => "rcs_getctime", call => \&rcs_getctime);
} #}}}
}
sub checkconfig () { #{{{
sub checkconfig () {
if (defined $config{bzr_wrapper} && length $config{bzr_wrapper}) {
push @{$config{wrappers}}, {
wrapper => $config{bzr_wrapper},
wrappermode => (defined $config{bzr_wrappermode} ? $config{bzr_wrappermode} : "06755"),
};
}
} #}}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 0, # rcs plugin
@ -65,9 +65,9 @@ sub getsetup () { #{{{
safe => 1,
rebuild => 1,
},
} #}}}
}
sub bzr_log ($) { #{{{
sub bzr_log ($) {
my $out = shift;
my @infos = ();
my $key = undef;
@ -99,20 +99,20 @@ sub bzr_log ($) { #{{{
close $out;
return @infos;
} #}}}
}
sub rcs_update () { #{{{
sub rcs_update () {
my @cmdline = ("bzr", "update", "--quiet", $config{srcdir});
if (system(@cmdline) != 0) {
warn "'@cmdline' failed: $!";
}
} #}}}
}
sub rcs_prepedit ($) { #{{{
sub rcs_prepedit ($) {
return "";
} #}}}
}
sub bzr_author ($$) { #{{{
sub bzr_author ($$) {
my ($user, $ipaddr) = @_;
if (defined $user) {
@ -124,9 +124,9 @@ sub bzr_author ($$) { #{{{
else {
return "Anonymous";
}
} #}}}
}
sub rcs_commit ($$$;$$) { #{{{
sub rcs_commit ($$$;$$) {
my ($file, $message, $rcstoken, $user, $ipaddr) = @_;
$user = bzr_author($user, $ipaddr);
@ -143,7 +143,7 @@ sub rcs_commit ($$$;$$) { #{{{
}
return undef; # success
} #}}}
}
sub rcs_commit_staged ($$$) {
# Commits all staged changes. Changes can be staged using rcs_add,
@ -164,27 +164,27 @@ sub rcs_commit_staged ($$$) {
}
return undef; # success
} #}}}
}
sub rcs_add ($) { # {{{
sub rcs_add ($) {
my ($file) = @_;
my @cmdline = ("bzr", "add", "--quiet", "$config{srcdir}/$file");
if (system(@cmdline) != 0) {
warn "'@cmdline' failed: $!";
}
} #}}}
}
sub rcs_remove ($) { # {{{
sub rcs_remove ($) {
my ($file) = @_;
my @cmdline = ("bzr", "rm", "--force", "--quiet", "$config{srcdir}/$file");
if (system(@cmdline) != 0) {
warn "'@cmdline' failed: $!";
}
} #}}}
}
sub rcs_rename ($$) { # {{{
sub rcs_rename ($$) {
my ($src, $dest) = @_;
my $parent = IkiWiki::dirname($dest);
@ -196,9 +196,9 @@ sub rcs_rename ($$) { # {{{
if (system(@cmdline) != 0) {
warn "'@cmdline' failed: $!";
}
} #}}}
}
sub rcs_recentchanges ($) { #{{{
sub rcs_recentchanges ($) {
my ($num) = @_;
my @cmdline = ("bzr", "log", "-v", "--show-ids", "--limit", $num,
@ -253,9 +253,9 @@ sub rcs_recentchanges ($) { #{{{
}
return @ret;
} #}}}
}
sub rcs_getctime ($) { #{{{
sub rcs_getctime ($) {
my ($file) = @_;
# XXX filename passes through the shell here, should try to avoid
@ -274,6 +274,6 @@ sub rcs_getctime ($) { #{{{
my $ctime = str2time($log[0]->{"timestamp"});
return $ctime;
} #}}}
}
1

View File

@ -29,13 +29,13 @@ my %linkcache;
my $time=time;
my @now=localtime($time);
sub import { #{{{
sub import {
hook(type => "getsetup", id => "calendar", call => \&getsetup);
hook(type => "needsbuild", id => "calendar", call => \&needsbuild);
hook(type => "preprocess", id => "calendar", call => \&preprocess);
} #}}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
@ -48,23 +48,23 @@ sub getsetup () { #{{{
safe => 1,
rebuild => 1,
},
} #}}}
}
sub is_leap_year (@) { #{{{
sub is_leap_year (@) {
my %params=@_;
return ($params{year} % 4 == 0 && (($params{year} % 100 != 0) || $params{year} % 400 == 0));
} #}}}
}
sub month_days { #{{{
sub month_days {
my %params=@_;
my $days_in_month = (31,28,31,30,31,30,31,31,30,31,30,31)[$params{month}-1];
if ($params{month} == 2 && is_leap_year(%params)) {
$days_in_month++;
}
return $days_in_month;
} #}}}
}
sub format_month (@) { #{{{
sub format_month (@) {
my %params=@_;
my $pagespec = $params{pages};
@ -215,9 +215,9 @@ EOF
add_depends($params{page}, join(" or ", @list));
return $calendar;
} #}}}
}
sub format_year (@) { #{{{
sub format_year (@) {
my %params=@_;
my $pagespec = $params{pages};
@ -318,9 +318,9 @@ EOF
EOF
return $calendar;
} #}}}
}
sub preprocess (@) { #{{{
sub preprocess (@) {
my %params=@_;
$params{pages} = "*" unless defined $params{pages};
$params{type} = "month" unless defined $params{type};
@ -397,7 +397,7 @@ sub preprocess (@) { #{{{
return "\n<div><div class=\"calendar\">$calendar</div></div>\n";
} #}}
sub needsbuild (@) { #{{{
sub needsbuild (@) {
my $needsbuild=shift;
foreach my $page (keys %pagestate) {
if (exists $pagestate{$page}{calendar}{nextchange}) {
@ -415,6 +415,6 @@ sub needsbuild (@) { #{{{
}
}
}
} # }}}
}
1

View File

@ -22,21 +22,21 @@ my $link_regexp=qr{
)
}x;
sub import { #{{{
sub import {
hook(type => "getsetup", id => "camelcase", call => \&getsetup);
hook(type => "linkify", id => "camelcase", call => \&linkify);
hook(type => "scan", id => "camelcase", call => \&scan);
} # }}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
rebuild => undef,
};
} #}}}
}
sub linkify (@) { #{{{
sub linkify (@) {
my %params=@_;
my $page=$params{page};
my $destpage=$params{destpage};
@ -46,9 +46,9 @@ sub linkify (@) { #{{{
}eg;
return $params{content};
} #}}}
}
sub scan (@) { #{{{
sub scan (@) {
my %params=@_;
my $page=$params{page};
my $content=$params{content};

View File

@ -7,12 +7,12 @@ use warnings;
use strict;
use IkiWiki 2.00;
sub import { #{{{
sub import {
hook(type => "preprocess", id => "color", call => \&preprocess);
hook(type => "format", id => "color", call => \&format);
} #}}}
}
sub preserve_style ($$$) { #{{{
sub preserve_style ($$$) {
my $foreground = shift;
my $background = shift;
my $text = shift;
@ -37,18 +37,18 @@ sub preserve_style ($$$) { #{{{
return $preserved;
} #}}}
}
sub replace_preserved_style ($) { #{{{
sub replace_preserved_style ($) {
my $content = shift;
$content =~ s!<span class="color">((color: ([a-z]+|\#[0-9a-f]{3,6})?)?((; )?(background-color: ([a-z]+|\#[0-9a-f]{3,6})?)?)?)</span>!<span class="color" style="$1">!g;
$content =~ s!<span class="colorend">!!g;
return $content;
} #}}}
}
sub preprocess (@) { #{{{
sub preprocess (@) {
my %params = @_;
# Preprocess the text to expand any preprocessor directives
@ -57,13 +57,13 @@ sub preprocess (@) { #{{{
IkiWiki::filter($params{page}, $params{destpage}, $params{text}));
return preserve_style($params{foreground}, $params{background}, $params{text});
} #}}}
}
sub format (@) { #{{{
sub format (@) {
my %params = @_;
$params{content} = replace_preserved_style($params{content});
return $params{content};
} #}}}
}
1

View File

@ -17,7 +17,7 @@ use constant CANCEL => "Cancel";
my $postcomment;
sub import { #{{{
sub import {
hook(type => "checkconfig", id => 'comments', call => \&checkconfig);
hook(type => "getsetup", id => 'comments', call => \&getsetup);
hook(type => "preprocess", id => '_comment', call => \&preprocess);
@ -26,9 +26,9 @@ sub import { #{{{
hook(type => "pagetemplate", id => "comments", call => \&pagetemplate);
hook(type => "cgi", id => "comments", call => \&linkcgi);
IkiWiki::loadplugin("inline");
} # }}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
@ -88,15 +88,15 @@ sub getsetup () { #{{{
safe => 0,
rebuild => 0,
},
} #}}}
}
sub htmlize { # {{{
sub htmlize {
my %params = @_;
return $params{content};
} # }}}
}
# FIXME: copied verbatim from meta
sub safeurl ($) { #{{{
sub safeurl ($) {
my $url=shift;
if (exists $IkiWiki::Plugin::htmlscrubber::{safe_url_regexp} &&
defined $IkiWiki::Plugin::htmlscrubber::safe_url_regexp) {
@ -105,9 +105,9 @@ sub safeurl ($) { #{{{
else {
return 1;
}
} #}}}
}
sub preprocess { # {{{
sub preprocess {
my %params = @_;
my $page = $params{page};
@ -206,16 +206,16 @@ sub preprocess { # {{{
# FIXME: hard-coded HTML (although it's just to set an ID)
return "<div id=\"$anchor\">$content</div>" if $anchor;
return $content;
} # }}}
}
sub checkconfig () { #{{{
sub checkconfig () {
$config{comments_commit} = 1 unless defined $config{comments_commit};
$config{comments_pagename} = 'comment_'
unless defined $config{comments_pagename};
} #}}}
}
# This is exactly the same as recentchanges_link :-(
sub linkcgi ($) { #{{{
sub linkcgi ($) {
my $cgi=shift;
if (defined $cgi->param('do') && $cgi->param('do') eq "commenter") {
@ -245,7 +245,7 @@ sub linkcgi ($) { #{{{
# FIXME: basically the same logic as recentchanges
# returns (author URL, pretty-printed version)
sub linkuser ($) { # {{{
sub linkuser ($) {
my $user = shift;
my $oiduser = eval { IkiWiki::openiduser($user) };
@ -262,10 +262,10 @@ sub linkuser ($) { # {{{
: "$user")
), $user);
}
} # }}}
}
# Mostly cargo-culted from IkiWiki::plugin::editpage
sub sessioncgi ($$) { #{{{
sub sessioncgi ($$) {
my $cgi=shift;
my $session=shift;
@ -512,9 +512,9 @@ sub sessioncgi ($$) { #{{{
}
exit;
} #}}}
}
sub pagetemplate (@) { #{{{
sub pagetemplate (@) {
my %params = @_;
my $page = $params{page};
@ -583,7 +583,7 @@ sub pagetemplate (@) { #{{{
$template->param(commentauthorurl =>
$pagestate{$page}{comments}{commentauthorurl});
}
} # }}}
}
package IkiWiki::PageSpec;

View File

@ -6,20 +6,20 @@ use strict;
use IkiWiki 2.00;
use UNIVERSAL;
sub import { #{{{
sub import {
hook(type => "getsetup", id => "conditional", call => \&getsetup);
hook(type => "preprocess", id => "if", call => \&preprocess_if);
} # }}}
}
sub getsetup { #{{{
sub getsetup {
return
plugin => {
safe => 1,
rebuild => undef,
},
} #}}}
}
sub preprocess_if (@) { #{{{
sub preprocess_if (@) {
my %params=@_;
foreach my $param (qw{test then}) {
@ -66,11 +66,11 @@ sub preprocess_if (@) { #{{{
}
return IkiWiki::preprocess($params{page}, $params{destpage},
IkiWiki::filter($params{page}, $params{destpage}, $ret));
} # }}}
}
package IkiWiki::PageSpec;
sub match_enabled ($$;@) { #{{{
sub match_enabled ($$;@) {
shift;
my $plugin=shift;
@ -81,9 +81,9 @@ sub match_enabled ($$;@) { #{{{
else {
return IkiWiki::FailReason->new("$plugin is not enabled");
}
} #}}}
}
sub match_sourcepage ($$;@) { #{{{
sub match_sourcepage ($$;@) {
shift;
my $glob=shift;
my %params=@_;
@ -95,9 +95,9 @@ sub match_sourcepage ($$;@) { #{{{
else {
return IkiWiki::FailReason->new("sourcepage does not match $glob");
}
} #}}}
}
sub match_destpage ($$;@) { #{{{
sub match_destpage ($$;@) {
shift;
my $glob=shift;
my %params=@_;
@ -109,9 +109,9 @@ sub match_destpage ($$;@) { #{{{
else {
return IkiWiki::FailReason->new("destpage does not match $glob");
}
} #}}}
}
sub match_included ($$;@) { #{{{
sub match_included ($$;@) {
shift;
shift;
my %params=@_;
@ -123,6 +123,6 @@ sub match_included ($$;@) { #{{{
else {
return IkiWiki::FailReason->new("page $params{sourcepage} is not included");
}
} #}}}
}
1

View File

@ -7,20 +7,20 @@ use warnings;
use strict;
use IkiWiki 2.00;
sub import { #{{{
sub import {
hook(type => "getsetup", id => "creole", call => \&getsetup);
hook(type => "htmlize", id => "creole", call => \&htmlize);
} # }}}
}
sub getsetup { #{{{
sub getsetup {
return
plugin => {
safe => 1,
rebuild => 1, # format plugin
},
} #}}}
}
sub htmlize (@) { #{{{
sub htmlize (@) {
my %params=@_;
my $content = $params{content};
@ -32,6 +32,6 @@ sub htmlize (@) { #{{{
creole_custombarelinks();
return creole_parse($content);
} # }}}
}
1

View File

@ -7,22 +7,22 @@ use IkiWiki 2.00;
my %savedtext;
sub import { #{{{
sub import {
hook(type => "getsetup", id => "cutpaste", call => \&getsetup);
hook(type => "preprocess", id => "cut", call => \&preprocess_cut, scan => 1);
hook(type => "preprocess", id => "copy", call => \&preprocess_copy, scan => 1);
hook(type => "preprocess", id => "paste", call => \&preprocess_paste);
} # }}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
rebuild => undef,
},
} #}}}
}
sub preprocess_cut (@) { #{{{
sub preprocess_cut (@) {
my %params=@_;
foreach my $param (qw{id text}) {
@ -35,9 +35,9 @@ sub preprocess_cut (@) { #{{{
$savedtext{$params{page}}->{$params{id}} = $params{text};
return "" if defined wantarray;
} # }}}
}
sub preprocess_copy (@) { #{{{
sub preprocess_copy (@) {
my %params=@_;
foreach my $param (qw{id text}) {
@ -51,9 +51,9 @@ sub preprocess_copy (@) { #{{{
return IkiWiki::preprocess($params{page}, $params{destpage},
IkiWiki::filter($params{page}, $params{destpage}, $params{text})) if defined wantarray;
} # }}}
}
sub preprocess_paste (@) { #{{{
sub preprocess_paste (@) {
my %params=@_;
foreach my $param (qw{id}) {
@ -71,6 +71,6 @@ sub preprocess_paste (@) { #{{{
return IkiWiki::preprocess($params{page}, $params{destpage},
IkiWiki::filter($params{page}, $params{destpage}, $savedtext{$params{page}}->{$params{id}}));
} # }}}
}
1;

View File

@ -5,19 +5,19 @@ package IkiWiki::Plugin::ddate;
use IkiWiki 2.00;
no warnings;
sub import { #{{{
sub import {
hook(type => "getsetup", id => "ddate", call => \&getsetup);
} # }}}
}
sub getsetup { #{{{
sub getsetup {
return
plugin => {
safe => 1,
rebuild => 1,
},
} #}}}
}
sub IkiWiki::formattime ($;$) { #{{{
sub IkiWiki::formattime ($;$) {
my $time=shift;
my $format=shift;
if (! defined $format) {
@ -36,6 +36,6 @@ sub IkiWiki::formattime ($;$) { #{{{
my $dt = DateTime->from_epoch(epoch => $time);
my $dd = DateTime::Calendar::Discordian->from_object(object => $dt);
return $dd->strftime($format);
} #}}}
}
5

View File

@ -8,21 +8,21 @@ use IkiWiki 2.00;
use HTML::Entities;
use IPC::Open2;
sub import { #{{{
sub import {
hook(type => "getsetup", id => "editdiff", call => \&getsetup);
hook(type => "formbuilder_setup", id => "editdiff",
call => \&formbuilder_setup);
} #}}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
rebuild => 0,
},
} #}}}
}
sub diff ($$) { #{{{
sub diff ($$) {
my $orig=shift;
my $content=shift;
@ -50,9 +50,9 @@ sub diff ($$) { #{{{
return "couldn't run diff\n" if $sigpipe;
return "<pre>".encode_entities($ret)."</pre>";
} #}}}
}
sub formbuilder_setup { #{{{
sub formbuilder_setup {
my %params=@_;
my $form=$params{form};
@ -72,6 +72,6 @@ sub formbuilder_setup { #{{{
my $diff = diff(srcfile($pagesources{$page}), $content);
$form->tmpl_param("page_preview", $diff);
}
} #}}}
}
1

View File

@ -6,19 +6,19 @@ use strict;
use IkiWiki;
use open qw{:utf8 :std};
sub import { #{{{
sub import {
hook(type => "getsetup", id => "editpage", call => \&getsetup);
hook(type => "refresh", id => "editpage", call => \&refresh);
hook(type => "sessioncgi", id => "editpage", call => \&IkiWiki::cgi_editpage);
} # }}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
rebuild => 1,
},
} #}}}
}
sub refresh () {
if (exists $wikistate{editpage} && exists $wikistate{editpage}{previews}) {
@ -54,7 +54,7 @@ sub refresh () {
# and other plugins use the functions below.
package IkiWiki;
sub check_canedit ($$$;$) { #{{{
sub check_canedit ($$$;$) {
my $page=shift;
my $q=shift;
my $session=shift;
@ -79,9 +79,9 @@ sub check_canedit ($$$;$) { #{{{
}
});
return $canedit;
} #}}}
}
sub cgi_editpage ($$) { #{{{
sub cgi_editpage ($$) {
my $q=shift;
my $session=shift;
@ -453,6 +453,6 @@ sub cgi_editpage ($$) { #{{{
}
exit;
} #}}}
}
1

View File

@ -7,7 +7,7 @@ use IkiWiki 2.00;
use HTML::Template;
use Encode;
sub import { #{{{
sub import {
hook(type => "getsetup", id => "edittemplate",
call => \&getsetup);
hook(type => "needsbuild", id => "edittemplate",
@ -16,17 +16,17 @@ sub import { #{{{
call => \&preprocess);
hook(type => "formbuilder", id => "edittemplate",
call => \&formbuilder);
} #}}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
rebuild => undef,
},
} #}}}
}
sub needsbuild (@) { #{{{
sub needsbuild (@) {
my $needsbuild=shift;
foreach my $page (keys %pagestate) {
@ -40,9 +40,9 @@ sub needsbuild (@) { #{{{
}
}
}
} #}}}
}
sub preprocess (@) { #{{{
sub preprocess (@) {
my %params=@_;
return "" if $params{page} ne $params{destpage};
@ -62,9 +62,9 @@ sub preprocess (@) { #{{{
return sprintf(gettext("edittemplate %s registered for %s"),
htmllink($params{page}, $params{destpage}, $link),
$params{match});
} # }}}
}
sub formbuilder (@) { #{{{
sub formbuilder (@) {
my %params=@_;
my $form=$params{form};
@ -103,9 +103,9 @@ sub formbuilder (@) { #{{{
}
}
}
} #}}}
}
sub filltemplate ($$) { #{{{
sub filltemplate ($$) {
my $template_page=shift;
my $page=shift;
@ -136,6 +136,6 @@ sub filltemplate ($$) { #{{{
$template->param(name => $page);
return $template->output;
} #}}}
}
1

View File

@ -43,35 +43,35 @@ my $safehtml=qr{(
my @embedded;
sub import { #{{{
sub import {
hook(type => "getsetup", id => "embed", call => \&getsetup);
hook(type => "filter", id => "embed", call => \&filter);
} # }}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
rebuild => undef,
},
} #}}}
}
sub embed ($) { #{{{
sub embed ($) {
hook(type => "format", id => "embed", call => \&format) unless @embedded;
push @embedded, shift;
return "<div class=\"embed$#embedded\"></div>";
} #}}}
}
sub filter (@) { #{{{
sub filter (@) {
my %params=@_;
$params{content} =~ s/$safehtml/embed($1)/eg;
return $params{content};
} # }}}
}
sub format (@) { #{{{
sub format (@) {
my %params=@_;
$params{content} =~ s/<div class="embed(\d+)"><\/div>/$embedded[$1]/eg;
return $params{content};
} # }}}
}
1

View File

@ -14,7 +14,7 @@ use IO::Handle;
my %plugins;
sub import { #{{{
sub import {
my $self=shift;
my $plugin=shift;
return unless defined $plugin;
@ -32,17 +32,17 @@ sub import { #{{{
$RPC::XML::ENCODING="utf-8";
rpc_call($plugins{$plugin}, "import");
} #}}}
}
sub rpc_write ($$) { #{{{
sub rpc_write ($$) {
my $fh=shift;
my $string=shift;
$fh->print($string."\n");
$fh->flush;
} #}}}
}
sub rpc_call ($$;@) { #{{{
sub rpc_call ($$;@) {
my $plugin=shift;
my $command=shift;
@ -131,12 +131,12 @@ sub rpc_call ($$;@) { #{{{
}
return undef;
} #}}}
}
package IkiWiki::RPC::XML;
use Memoize;
sub getvar ($$$) { #{{{
sub getvar ($$$) {
my $plugin=shift;
my $varname="IkiWiki::".shift;
my $key=shift;
@ -145,9 +145,9 @@ sub getvar ($$$) { #{{{
my $ret=$varname->{$key};
use strict 'refs';
return $ret;
} #}}}
}
sub setvar ($$$;@) { #{{{
sub setvar ($$$;@) {
my $plugin=shift;
my $varname="IkiWiki::".shift;
my $key=shift;
@ -157,18 +157,18 @@ sub setvar ($$$;@) { #{{{
my $ret=$varname->{$key}=$value;
use strict 'refs';
return $ret;
} #}}}
}
sub getstate ($$$$) { #{{{
sub getstate ($$$$) {
my $plugin=shift;
my $page=shift;
my $id=shift;
my $key=shift;
return $IkiWiki::pagestate{$page}{$id}{$key};
} #}}}
}
sub setstate ($$$$;@) { #{{{
sub setstate ($$$$;@) {
my $plugin=shift;
my $page=shift;
my $id=shift;
@ -176,22 +176,22 @@ sub setstate ($$$$;@) { #{{{
my $value=shift;
return $IkiWiki::pagestate{$page}{$id}{$key}=$value;
} #}}}
}
sub getargv ($) { #{{{
sub getargv ($) {
my $plugin=shift;
return \@ARGV;
} #}}}
}
sub setargv ($@) { #{{{
sub setargv ($@) {
my $plugin=shift;
my $array=shift;
@ARGV=@$array;
} #}}}
}
sub inject ($@) { #{{{
sub inject ($@) {
# Bind a given perl function name to a particular RPC request.
my $plugin=shift;
my %params=@_;
@ -213,9 +213,9 @@ sub inject ($@) { #{{{
# the injected version.
IkiWiki::inject(name => $params{name}, call => $sub);
return 1;
} #}}}
}
sub hook ($@) { #{{{
sub hook ($@) {
# the call parameter is a function name to call, since XML RPC
# cannot pass a function reference
my $plugin=shift;
@ -227,13 +227,13 @@ sub hook ($@) { #{{{
IkiWiki::hook(%params, call => sub {
IkiWiki::Plugin::external::rpc_call($plugin, $callback, @_);
});
} #}}}
}
sub pagespec_match ($@) { #{{{
sub pagespec_match ($@) {
# convert pagespec_match's return object into a XML RPC boolean
my $plugin=shift;
return RPC::XML::boolean->new(0 + IkiWiki::pagespec_march(@_));
} #}}}
}
1

View File

@ -7,20 +7,20 @@ use warnings;
use strict;
use IkiWiki 2.00;
sub import { #{{{
sub import {
hook(type => "getsetup", id => "favicon", call => \&getsetup);
hook(type => "pagetemplate", id => "favicon", call => \&pagetemplate);
} # }}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
rebuild => 1,
},
} #}}}
}
sub pagetemplate (@) { #{{{
sub pagetemplate (@) {
my %params=@_;
my $template=$params{template};
@ -28,6 +28,6 @@ sub pagetemplate (@) { #{{{
if ($template->query(name => "favicon")) {
$template->param(favicon => "favicon.ico");
}
} # }}}
}
1

View File

@ -37,9 +37,9 @@ my %units=( #{{{ # size in bytes
# ikiwiki, if you find you need larger data quantities, either modify
# yourself to add them, or travel back in time to 2008 and kill me.
# -- Joey
); #}}}
);
sub parsesize ($) { #{{{
sub parsesize ($) {
my $size=shift;
no warnings;
@ -51,10 +51,10 @@ sub parsesize ($) { #{{{
}
}
return $base;
} #}}}
}
# This is provided for other plugins that want to convert back the other way.
sub humansize ($) { #{{{
sub humansize ($) {
my $size=shift;
foreach my $unit (reverse sort { $units{$a} <=> $units{$b} || $b cmp $a } keys %units) {
@ -63,11 +63,11 @@ sub humansize ($) { #{{{
}
}
return $size; # near zero, or negative
} #}}}
}
package IkiWiki::PageSpec;
sub match_maxsize ($$;@) { #{{{
sub match_maxsize ($$;@) {
my $page=shift;
my $maxsize=eval{IkiWiki::Plugin::filecheck::parsesize(shift)};
if ($@) {
@ -86,9 +86,9 @@ sub match_maxsize ($$;@) { #{{{
else {
return IkiWiki::SuccessReason->new("file not too large");
}
} #}}}
}
sub match_minsize ($$;@) { #{{{
sub match_minsize ($$;@) {
my $page=shift;
my $minsize=eval{IkiWiki::Plugin::filecheck::parsesize(shift)};
if ($@) {
@ -107,9 +107,9 @@ sub match_minsize ($$;@) { #{{{
else {
return IkiWiki::SuccessReason->new("file not too small");
}
} #}}}
}
sub match_mimetype ($$;@) { #{{{
sub match_mimetype ($$;@) {
my $page=shift;
my $wanted=shift;
@ -140,9 +140,9 @@ sub match_mimetype ($$;@) { #{{{
else {
return IkiWiki::SuccessReason->new("file MIME type is $mimetype");
}
} #}}}
}
sub match_virusfree ($$;@) { #{{{
sub match_virusfree ($$;@) {
my $page=shift;
my $wanted=shift;
@ -182,9 +182,9 @@ sub match_virusfree ($$;@) { #{{{
else {
return IkiWiki::SuccessReason->new("file seems virusfree ($reason)");
}
} #}}}
}
sub match_ispage ($$;@) { #{{{
sub match_ispage ($$;@) {
my $filename=shift;
if (defined IkiWiki::pagetype($filename)) {
@ -193,4 +193,4 @@ sub match_ispage ($$;@) { #{{{
else {
return IkiWiki::FailReason->new("file is not a wiki page");
}
} #}}}
}

View File

@ -5,11 +5,11 @@ use warnings;
use strict;
use IkiWiki 2.00;
sub import { #{{{
sub import {
hook(type => "preprocess", id => "format", call => \&preprocess);
} #}}}
}
sub preprocess (@) { #{{{
sub preprocess (@) {
my $format=$_[0];
shift; shift;
my $text=$_[0];
@ -25,6 +25,6 @@ sub preprocess (@) { #{{{
return IkiWiki::htmlize($params{page}, $params{destpage}, $format,
IkiWiki::preprocess($params{page}, $params{destpage}, $text));
} #}}}
}
1

View File

@ -6,20 +6,20 @@ use warnings;
use strict;
use IkiWiki 2.00;
sub import { #{{{
sub import {
hook(type => "getsetup", id => "fortune", call => \&getsetup);
hook(type => "preprocess", id => "fortune", call => \&preprocess);
} # }}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
rebuild => undef,
},
} #}}}
}
sub preprocess (@) { #{{{
sub preprocess (@) {
$ENV{PATH}="$ENV{PATH}:/usr/games:/usr/local/games";
my $f = `fortune 2>/dev/null`;
@ -29,6 +29,6 @@ sub preprocess (@) { #{{{
else {
return "<pre>$f</pre>\n";
}
} # }}}
}
1

View File

@ -11,7 +11,7 @@ my $sha1_pattern = qr/[0-9a-fA-F]{40}/; # pattern to validate Git sha1sums
my $dummy_commit_msg = 'dummy commit'; # message to skip in recent changes
my $no_chdir=0;
sub import { #{{{
sub import {
hook(type => "checkconfig", id => "git", call => \&checkconfig);
hook(type => "getsetup", id => "git", call => \&getsetup);
hook(type => "rcs", id => "rcs_update", call => \&rcs_update);
@ -25,9 +25,9 @@ sub import { #{{{
hook(type => "rcs", id => "rcs_diff", call => \&rcs_diff);
hook(type => "rcs", id => "rcs_getctime", call => \&rcs_getctime);
hook(type => "rcs", id => "rcs_receive", call => \&rcs_receive);
} #}}}
}
sub checkconfig () { #{{{
sub checkconfig () {
if (! defined $config{gitorigin_branch}) {
$config{gitorigin_branch}="origin";
}
@ -49,9 +49,9 @@ sub checkconfig () { #{{{
wrappermode => (defined $config{git_wrappermode} ? $config{git_wrappermode} : "06755"),
};
}
} #}}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 0, # rcs plugin
@ -113,9 +113,9 @@ sub getsetup () { #{{{
safe => 0, # paranoia
rebuild => 0,
},
} #}}}
}
sub safe_git (&@) { #{{{
sub safe_git (&@) {
# Start a child process safely without resorting /bin/sh.
# Return command output or success state (in scalar context).
@ -152,9 +152,9 @@ sub safe_git (&@) { #{{{
sub run_or_die ($@) { safe_git(\&error, @_) }
sub run_or_cry ($@) { safe_git(sub { warn @_ }, @_) }
sub run_or_non ($@) { safe_git(undef, @_) }
#}}}
sub merge_past ($$$) { #{{{
sub merge_past ($$$) {
# Unlike with Subversion, Git cannot make a 'svn merge -rN:M file'.
# Git merge commands work with the committed changes, except in the
# implicit case of '-m' of git checkout(1). So we should invent a
@ -246,9 +246,9 @@ sub merge_past ($$$) { #{{{
error("Git merge failed!\n$failure\n") if $failure;
return $conflict;
} #}}}
}
sub parse_diff_tree ($@) { #{{{
sub parse_diff_tree ($@) {
# Parse the raw diff tree chunk and return the info hash.
# See git-diff-tree(1) for the syntax.
@ -358,9 +358,9 @@ sub parse_diff_tree ($@) { #{{{
}
return \%ci;
} #}}}
}
sub git_commit_info ($;$) { #{{{
sub git_commit_info ($;$) {
# Return an array of commit info hashes of num commits
# starting from the given sha1sum.
my ($sha1, $num) = @_;
@ -381,9 +381,9 @@ sub git_commit_info ($;$) { #{{{
warn "Cannot parse commit info for '$sha1' commit" if !@ci;
return wantarray ? @ci : $ci[0];
} #}}}
}
sub git_sha1 (;$) { #{{{
sub git_sha1 (;$) {
# Return head sha1sum (of given file).
my $file = shift || q{--};
@ -394,25 +394,25 @@ sub git_sha1 (;$) { #{{{
($sha1) = $sha1 =~ m/($sha1_pattern)/; # sha1 is untainted now
} else { debug("Empty sha1sum for '$file'.") }
return defined $sha1 ? $sha1 : q{};
} #}}}
}
sub rcs_update () { #{{{
sub rcs_update () {
# Update working directory.
if (length $config{gitorigin_branch}) {
run_or_cry('git', 'pull', $config{gitorigin_branch});
}
} #}}}
}
sub rcs_prepedit ($) { #{{{
sub rcs_prepedit ($) {
# Return the commit sha1sum of the file when editing begins.
# This will be later used in rcs_commit if a merge is required.
my ($file) = @_;
return git_sha1($file);
} #}}}
}
sub rcs_commit ($$$;$$) { #{{{
sub rcs_commit ($$$;$$) {
# Try to commit the page; returns undef on _success_ and
# a version of the page with the rcs's conflict markers on
# failure.
@ -431,7 +431,7 @@ sub rcs_commit ($$$;$$) { #{{{
rcs_add($file);
return rcs_commit_staged($message, $user, $ipaddr);
} #}}}
}
sub rcs_commit_staged ($$$) {
# Commits all staged changes. Changes can be staged using rcs_add,
@ -472,29 +472,29 @@ sub rcs_commit_staged ($$$) {
return undef; # success
}
sub rcs_add ($) { # {{{
sub rcs_add ($) {
# Add file to archive.
my ($file) = @_;
run_or_cry('git', 'add', $file);
} #}}}
}
sub rcs_remove ($) { # {{{
sub rcs_remove ($) {
# Remove file from archive.
my ($file) = @_;
run_or_cry('git', 'rm', '-f', $file);
} #}}}
}
sub rcs_rename ($$) { # {{{
sub rcs_rename ($$) {
my ($src, $dest) = @_;
run_or_cry('git', 'mv', '-f', $src, $dest);
} #}}}
}
sub rcs_recentchanges ($) { #{{{
sub rcs_recentchanges ($) {
# List of recent changes.
my ($num) = @_;
@ -562,9 +562,9 @@ sub rcs_recentchanges ($) { #{{{
}
return @rets;
} #}}}
}
sub rcs_diff ($) { #{{{
sub rcs_diff ($) {
my $rev=shift;
my ($sha1) = $rev =~ /^($sha1_pattern)$/; # untaint
my @lines;
@ -579,9 +579,9 @@ sub rcs_diff ($) { #{{{
else {
return join("", @lines);
}
} #}}}
}
sub rcs_getctime ($) { #{{{
sub rcs_getctime ($) {
my $file=shift;
# Remove srcdir prefix
$file =~ s/^\Q$config{srcdir}\E\/?//;
@ -592,9 +592,9 @@ sub rcs_getctime ($) { #{{{
debug("ctime for '$file': ". localtime($ctime));
return $ctime;
} #}}}
}
sub rcs_receive () { #{{{
sub rcs_receive () {
# The wiki may not be the only thing in the git repo.
# Determine if it is in a subdirectory by examining the srcdir,
# and its parents, looking for the .git directory.
@ -685,6 +685,6 @@ sub rcs_receive () { #{{{
}
return reverse @rets;
} #}}}
}
1

View File

@ -24,19 +24,19 @@ my @bundle=qw{
toggle
};
sub import { #{{{
sub import {
hook(type => "getsetup", id => "goodstuff", call => \&getsetup);
foreach my $plugin (@bundle) {
IkiWiki::loadplugin($plugin);
}
} # }}}
}
sub getsetup { #{{{
sub getsetup {
return
plugin => {
safe => 1,
rebuild => undef,
},
} #}}}
}
1

View File

@ -8,21 +8,21 @@ use URI;
my $host;
sub import { #{{{
sub import {
hook(type => "getsetup", id => "google", call => \&getsetup);
hook(type => "checkconfig", id => "google", call => \&checkconfig);
hook(type => "pagetemplate", id => "google", call => \&pagetemplate);
} # }}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
rebuild => 1,
},
} #}}}
}
sub checkconfig () { #{{{
sub checkconfig () {
if (! length $config{url}) {
error(sprintf(gettext("Must specify %s when using the google search plugin"), "url"));
}
@ -31,10 +31,10 @@ sub checkconfig () { #{{{
error(gettext("Failed to parse url, cannot determine domain name"));
}
$host=$uri->host;
} #}}}
}
my $form;
sub pagetemplate (@) { #{{{
sub pagetemplate (@) {
my %params=@_;
my $page=$params{page};
my $template=$params{template};
@ -49,6 +49,6 @@ sub pagetemplate (@) { #{{{
$template->param(searchform => $form);
}
} #}}}
}
1

View File

@ -5,24 +5,24 @@ use warnings;
use strict;
use IkiWiki 2.00;
sub import { #{{{
sub import {
hook(type => "getsetup", id => "googlecalendar",
call => \&getsetup);
hook(type => "preprocess", id => "googlecalendar",
call => \&preprocess);
hook(type => "format", id => "googlecalendar",
call => \&format);
} # }}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
rebuild => undef,
},
} #}}}
}
sub preprocess (@) { #{{{
sub preprocess (@) {
my %params=@_;
# Parse the html, looking for the url to embed for the calendar.
@ -35,21 +35,21 @@ sub preprocess (@) { #{{{
my ($width)=$params{html}=~m#width="(\d+)"#;
return "<div class=\"googlecalendar\" src=\"$url\" height=\"$height\" width=\"$width\"></div>";
} # }}}
}
sub format (@) { #{{{
sub format (@) {
my %params=@_;
$params{content}=~s/<div class=\"googlecalendar" src="([^"]+)" height="([^"]+)" width="([^"]+)"><\/div>/gencal($1,$2,$3)/eg;
return $params{content};
} # }}}
}
sub gencal ($$$) { #{{{
sub gencal ($$$) {
my $url=shift;
my $height=shift;
my $width=shift;
return qq{<iframe src="http://www.google.com/calendar/embed?$url" style=" border-width:0 " width="$width" frameborder="0" height="$height"></iframe>};
} #}}}
}
1

View File

@ -8,24 +8,24 @@ use strict;
use IkiWiki 2.00;
use IPC::Open2;
sub import { #{{{
sub import {
hook(type => "getsetup", id => "graphviz", call => \&getsetup);
hook(type => "preprocess", id => "graph", call => \&graph);
} # }}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
rebuild => undef,
},
} #}}}
}
my %graphviz_programs = (
"dot" => 1, "neato" => 1, "fdp" => 1, "twopi" => 1, "circo" => 1
);
sub render_graph (\%) { #{{{
sub render_graph (\%) {
my %params = %{(shift)};
my $src = "$params{type} g {\n";
@ -84,9 +84,9 @@ sub render_graph (\%) { #{{{
else {
return "<img src=\"".urlto($dest, $params{destpage})."\" />\n";
}
} #}}}
}
sub graph (@) { #{{{
sub graph (@) {
my %params=@_;
$params{src} = "" unless defined $params{src};
$params{type} = "digraph" unless defined $params{type};
@ -94,6 +94,6 @@ sub graph (@) { #{{{
error gettext("prog not a valid graphviz program") unless $graphviz_programs{$params{prog}};
return render_graph(%params);
} # }}}
}
1

View File

@ -6,20 +6,20 @@ use warnings;
use strict;
use IkiWiki 2.00;
sub import { #{{{
sub import {
hook(type => "getsetup", id => "haiku", call => \&getsetup);
hook(type => "preprocess", id => "haiku", call => \&preprocess);
} # }}}
}
sub getsetup { #{{{
sub getsetup {
return
plugin => {
safe => 1,
rebuild => undef,
},
} #}}}
}
sub preprocess (@) { #{{{
sub preprocess (@) {
my %params=@_;
my $haiku;
@ -54,6 +54,6 @@ sub preprocess (@) { #{{{
$haiku=~s/\n/<br \/>\n/mg;
return "\n\n<blockquote><p>$haiku</p></blockquote>\n\n";
} # }}}
}
1

View File

@ -13,20 +13,20 @@ use strict;
use IkiWiki 2.00;
use File::Temp qw(:mktemp);
sub import { #{{{
sub import {
hook(type => "getsetup", id => "hnb", call => \&getsetup);
hook(type => "htmlize", id => "hnb", call => \&htmlize);
} #}}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
rebuild => 1, # format plugin
},
} #}}}
}
sub htmlize (@) { #{{{
sub htmlize (@) {
my %params = @_;
# hnb outputs version number etc. every time to STDOUT, so
@ -52,6 +52,6 @@ sub htmlize (@) { #{{{
$ret =~ s/<body>.*//si;
return $ret;
} #}}}
}
1;

View File

@ -6,7 +6,7 @@ use warnings;
use strict;
use IkiWiki 2.00;
sub import { #{{{
sub import {
hook(type => "getsetup", id => "html", call => \&getsetup);
hook(type => "htmlize", id => "html", call => \&htmlize);
hook(type => "htmlize", id => "htm", call => \&htmlize);
@ -14,19 +14,19 @@ sub import { #{{{
# ikiwiki defaults to skipping .html files as a security measure;
# make it process them so this plugin can take effect
$config{wiki_file_prune_regexps} = [ grep { !m/\\\.x\?html\?\$/ } @{$config{wiki_file_prune_regexps}} ];
} # }}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
rebuild => 1, # format plugin
},
} #}}}
}
sub htmlize (@) { #{{{
sub htmlize (@) {
my %params=@_;
return $params{content};
} #}}}
}
1

View File

@ -13,20 +13,20 @@ use IkiWiki 2.00;
use HTML::TreeBuilder;
use HTML::Entities;
sub import { #{{{
sub import {
hook(type => "getsetup", id => "htmlbalance", call => \&getsetup);
hook(type => "sanitize", id => "htmlbalance", call => \&sanitize);
} # }}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
rebuild => undef,
},
} #}}}
}
sub sanitize (@) { #{{{
sub sanitize (@) {
my %params=@_;
my $ret = '';
@ -52,6 +52,6 @@ sub sanitize (@) { #{{{
}
$tree->delete();
return $ret;
} # }}}
}
1

View File

@ -9,7 +9,7 @@ use IkiWiki 2.00;
# Feel free to use it from other plugins.
our $safe_url_regexp;
sub import { #{{{
sub import {
hook(type => "getsetup", id => "htmlscrubber", call => \&getsetup);
hook(type => "sanitize", id => "htmlscrubber", call => \&sanitize);
@ -33,9 +33,9 @@ sub import { #{{{
# data is a special case. Allow data:image/*, but
# disallow data:text/javascript and everything else.
$safe_url_regexp=qr/^(?:(?:$uri_schemes):|data:image\/|[^:]+(?:$|\/))/i;
} # }}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
@ -49,9 +49,9 @@ sub getsetup () { #{{{
safe => 1,
rebuild => undef,
},
} #}}}
}
sub sanitize (@) { #{{{
sub sanitize (@) {
my %params=@_;
if (exists $config{htmlscrubber_skip} &&
@ -62,10 +62,10 @@ sub sanitize (@) { #{{{
}
return scrubber()->scrub($params{content});
} # }}}
}
my $_scrubber;
sub scrubber { #{{{
sub scrubber {
return $_scrubber if defined $_scrubber;
eval q{use HTML::Scrubber};
@ -111,6 +111,6 @@ sub scrubber { #{{{
}],
);
return $_scrubber;
} # }}}
}
1

View File

@ -12,20 +12,20 @@ use strict;
use IkiWiki 2.00;
use IPC::Open2;
sub import { #{{{
sub import {
hook(type => "getsetup", id => "tidy", call => \&getsetup);
hook(type => "sanitize", id => "tidy", call => \&sanitize);
} # }}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
rebuild => undef,
},
} #}}}
}
sub sanitize (@) { #{{{
sub sanitize (@) {
my %params=@_;
my $pid;
@ -49,6 +49,6 @@ sub sanitize (@) { #{{{
return "" if $sigpipe || ! defined $ret;
return $ret;
} # }}}
}
1

View File

@ -6,26 +6,26 @@ use warnings;
use strict;
use IkiWiki 2.00;
sub import { #{{{
sub import {
hook(type => "getsetup", id => "httpauth", call => \&getsetup);
hook(type => "auth", id => "httpauth", call => \&auth);
} # }}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
rebuild => 0,
},
} #}}}
}
sub auth ($$) { #{{{
sub auth ($$) {
my $cgi=shift;
my $session=shift;
if (defined $cgi->remote_user()) {
$session->param("name", $cgi->remote_user());
}
} #}}}
}
1

View File

@ -9,20 +9,20 @@ use IkiWiki 2.00;
my %imgdefaults;
sub import { #{{{
sub import {
hook(type => "getsetup", id => "img", call => \&getsetup);
hook(type => "preprocess", id => "img", call => \&preprocess, scan => 1);
} #}}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
rebuild => undef,
},
} #}}}
}
sub preprocess (@) { #{{{
sub preprocess (@) {
my ($image) = $_[0] =~ /$config{wiki_file_regexp}/; # untaint
my %params=@_;
@ -149,6 +149,6 @@ sub preprocess (@) { #{{{
else {
return $imgtag;
}
} #}}}
}
1

View File

@ -13,7 +13,7 @@ my %page_numfeeds;
my @inline;
my $nested=0;
sub import { #{{{
sub import {
hook(type => "getopt", id => "inline", call => \&getopt);
hook(type => "getsetup", id => "inline", call => \&getsetup);
hook(type => "checkconfig", id => "inline", call => \&checkconfig);
@ -27,9 +27,9 @@ sub import { #{{{
# This ensures each page only pings once and prevents slow
# pings interrupting page builds.
hook(type => "change", id => "inline", call => \&IkiWiki::pingurl);
} # }}}
}
sub getopt () { #{{{
sub getopt () {
eval q{use Getopt::Long};
error($@) if $@;
Getopt::Long::Configure('pass_through');
@ -42,9 +42,9 @@ sub getopt () { #{{{
push @{$config{pingurl}}, $_[1];
},
);
} #}}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
@ -85,9 +85,9 @@ sub getsetup () { #{{{
safe => 1,
rebuild => 0,
},
} #}}}
}
sub checkconfig () { #{{{
sub checkconfig () {
if (($config{rss} || $config{atom}) && ! length $config{url}) {
error(gettext("Must specify url to wiki with --url when using --rss or --atom"));
}
@ -100,9 +100,9 @@ sub checkconfig () { #{{{
if (! exists $config{pingurl}) {
$config{pingurl}=[];
}
} #}}}
}
sub format (@) { #{{{
sub format (@) {
my %params=@_;
# Fill in the inline content generated earlier. This is actually an
@ -111,9 +111,9 @@ sub format (@) { #{{{
delete @inline[$1,]
}eg;
return $params{content};
} #}}}
}
sub sessioncgi ($$) { #{{{
sub sessioncgi ($$) {
my $q=shift;
my $session=shift;
@ -148,7 +148,7 @@ package IkiWiki;
my %toping;
my %feedlinks;
sub preprocess_inline (@) { #{{{
sub preprocess_inline (@) {
my %params=@_;
if (! exists $params{pages}) {
@ -416,18 +416,18 @@ sub preprocess_inline (@) { #{{{
return $ret if $raw || $nested;
push @inline, $ret;
return "<div class=\"inline\" id=\"$#inline\"></div>\n\n";
} #}}}
}
sub pagetemplate_inline (@) { #{{{
sub pagetemplate_inline (@) {
my %params=@_;
my $page=$params{page};
my $template=$params{template};
$template->param(feedlinks => $feedlinks{$page})
if exists $feedlinks{$page} && $template->query(name => "feedlinks");
} #}}}
}
sub get_inline_content ($$) { #{{{
sub get_inline_content ($$) {
my $page=shift;
my $destpage=shift;
@ -446,9 +446,9 @@ sub get_inline_content ($$) { #{{{
else {
return "";
}
} #}}}
}
sub date_822 ($) { #{{{
sub date_822 ($) {
my $time=shift;
my $lc_time=POSIX::setlocale(&POSIX::LC_TIME);
@ -456,9 +456,9 @@ sub date_822 ($) { #{{{
my $ret=POSIX::strftime("%a, %d %b %Y %H:%M:%S %z", localtime($time));
POSIX::setlocale(&POSIX::LC_TIME, $lc_time);
return $ret;
} #}}}
}
sub date_3339 ($) { #{{{
sub date_3339 ($) {
my $time=shift;
my $lc_time=POSIX::setlocale(&POSIX::LC_TIME);
@ -466,9 +466,9 @@ sub date_3339 ($) { #{{{
my $ret=POSIX::strftime("%Y-%m-%dT%H:%M:%SZ", gmtime($time));
POSIX::setlocale(&POSIX::LC_TIME, $lc_time);
return $ret;
} #}}}
}
sub absolute_urls ($$) { #{{{
sub absolute_urls ($$) {
# sucky sub because rss sucks
my $content=shift;
my $baseurl=shift;
@ -489,9 +489,9 @@ sub absolute_urls ($$) { #{{{
$content=~s/(<a(?:\s+(?:class|id)\s*="?\w+"?)?)\s+href=\s*"(?!\w+:)(\/[^"]*)"/$1 href="$urltop$2"/mig;
$content=~s/(<img(?:\s+(?:class|id|width|height)\s*="?\w+"?)*)\s+src=\s*"(?!\w+:)(\/[^"]*)"/$1 src="$urltop$2"/mig;
return $content;
} #}}}
}
sub genfeed ($$$$$@) { #{{{
sub genfeed ($$$$$@) {
my $feedtype=shift;
my $feedurl=shift;
my $feeddesc=shift;
@ -576,9 +576,9 @@ sub genfeed ($$$$$@) { #{{{
});
return $template->output;
} #}}}
}
sub pingurl (@) { #{{{
sub pingurl (@) {
return unless @{$config{pingurl}} && %toping;
eval q{require RPC::XML::Client};
@ -624,6 +624,6 @@ sub pingurl (@) { #{{{
}
exit 0; # daemon done
} #}}}
}
1

View File

@ -7,23 +7,23 @@ use IkiWiki 2.00;
my $link_regexp;
sub import { #{{{
sub import {
hook(type => "getsetup", id => "link", call => \&getsetup);
hook(type => "checkconfig", id => "link", call => \&checkconfig);
hook(type => "linkify", id => "link", call => \&linkify);
hook(type => "scan", id => "link", call => \&scan);
hook(type => "renamepage", id => "link", call => \&renamepage);
} # }}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
rebuild => 1,
},
} #}}}
}
sub checkconfig () { #{{{
sub checkconfig () {
if ($config{prefix_directives}) {
$link_regexp = qr{
\[\[(?=[^!]) # beginning of link
@ -58,9 +58,9 @@ sub checkconfig () { #{{{
\]\] # end of link
}x,
}
} #}}}
}
sub linkify (@) { #{{{
sub linkify (@) {
my %params=@_;
my $page=$params{page};
my $destpage=$params{destpage};
@ -78,9 +78,9 @@ sub linkify (@) { #{{{
}eg;
return $params{content};
} #}}}
}
sub scan (@) { #{{{
sub scan (@) {
my %params=@_;
my $page=$params{page};
my $content=$params{content};
@ -88,9 +88,9 @@ sub scan (@) { #{{{
while ($content =~ /(?<!\\)$link_regexp/g) {
push @{$links{$page}}, linkpage($2);
}
} # }}}
}
sub renamepage (@) { #{{{
sub renamepage (@) {
my %params=@_;
my $page=$params{page};
my $old=$params{oldpage};
@ -118,6 +118,6 @@ sub renamepage (@) { #{{{
}eg;
return $params{content};
} #}}}
}
1

View File

@ -6,24 +6,24 @@ use strict;
use IkiWiki 2.00;
use IPC::Open2;
sub import { #{{{
sub import {
hook(type => "getsetup", id => "linkmap", call => \&getsetup);
hook(type => "preprocess", id => "linkmap", call => \&preprocess);
hook(type => "format", id => "linkmap", call => \&format);
} # }}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
rebuild => undef,
},
} #}}}
}
my $mapnum=0;
my %maps;
sub preprocess (@) { #{{{
sub preprocess (@) {
my %params=@_;
$params{pages}="*" unless defined $params{pages};
@ -39,17 +39,17 @@ sub preprocess (@) { #{{{
$mapnum++;
$maps{$mapnum}=\%params;
return "<div class=\"linkmap$mapnum\"></div>";
} # }}}
}
sub format (@) { #{{{
sub format (@) {
my %params=@_;
$params{content}=~s/<div class=\"linkmap(\d+)"><\/div>/genmap($1)/eg;
return $params{content};
} # }}}
}
sub genmap ($) { #{{{
sub genmap ($) {
my $mapnum=shift;
return "" unless exists $maps{$mapnum};
my %params=%{$maps{$mapnum}};
@ -106,6 +106,6 @@ sub genmap ($) { #{{{
error gettext("failed to run dot") if $sigpipe;
return $ret;
} #}}}
}
1

View File

@ -6,15 +6,15 @@ use warnings;
use strict;
use IkiWiki 2.00;
sub import { #{{{
sub import {
add_underlay("directives");
hook(type => "getsetup", id => "listdirectives", call => \&getsetup);
hook(type => "checkconfig", id => "listdirectives", call => \&checkconfig);
hook(type => "needsbuild", id => "listdirectives", call => \&needsbuild);
hook(type => "preprocess", id => "listdirectives", call => \&preprocess);
} # }}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
@ -27,22 +27,22 @@ sub getsetup () { #{{{
safe => 1,
rebuild => 1,
},
} #}}}
}
my @fulllist;
my @shortlist;
my $pluginstring;
sub checkconfig () { #{{{
sub checkconfig () {
if (! defined $config{directive_description_dir}) {
$config{directive_description_dir} = "ikiwiki/directive";
}
else {
$config{directive_description_dir} =~ s/\/+$//;
}
} #}}}
}
sub needsbuild (@) { #{{{
sub needsbuild (@) {
my $needsbuild=shift;
@fulllist = sort keys %{$IkiWiki::hooks{preprocess}};
@ -63,9 +63,9 @@ sub needsbuild (@) { #{{{
}
}
}
} # }}}
}
sub preprocess (@) { #{{{
sub preprocess (@) {
my %params=@_;
$pagestate{$params{destpage}}{listdirectives}{shown}=$pluginstring;
@ -92,6 +92,6 @@ sub preprocess (@) { #{{{
$result .= "</ul>";
return $result;
} # }}}
}
1

View File

@ -5,14 +5,14 @@ use warnings;
use strict;
use IkiWiki 2.00;
sub import { #{{{
sub import {
hook(type => "getsetup", id => "lockedit", call => \&getsetup);
hook(type => "canedit", id => "lockedit", call => \&canedit);
hook(type => "formbuilder_setup", id => "lockedit",
call => \&formbuilder_setup);
} # }}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
@ -26,9 +26,9 @@ sub getsetup () { #{{{
safe => 1,
rebuild => 0,
},
} #}}}
}
sub canedit ($$) { #{{{
sub canedit ($$) {
my $page=shift;
my $cgi=shift;
my $session=shift;
@ -70,9 +70,9 @@ sub canedit ($$) { #{{{
}
return undef;
} #}}}
}
sub formbuilder_setup (@) { #{{{
sub formbuilder_setup (@) {
my %params=@_;
# XXX deprecated, should be removed eventually
@ -109,6 +109,6 @@ sub formbuilder_setup (@) { #{{{
}
}
}
} #}}}
}
1

View File

@ -11,20 +11,20 @@ use warnings;
use strict;
use IkiWiki 2.00;
sub import { #{{{
sub import {
hook(type => "getsetup", id => "map", call => \&getsetup);
hook(type => "preprocess", id => "map", call => \&preprocess);
} # }}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
rebuild => undef,
},
} #}}}
}
sub preprocess (@) { #{{{
sub preprocess (@) {
my %params=@_;
$params{pages}="*" unless defined $params{pages};
@ -144,6 +144,6 @@ sub preprocess (@) { #{{{
}
$map .= "</div>\n";
return $map;
} # }}}
}
1

View File

@ -6,12 +6,12 @@ use warnings;
use strict;
use IkiWiki 2.00;
sub import { #{{{
sub import {
hook(type => "getsetup", id => "mdwn", call => \&getsetup);
hook(type => "htmlize", id => "mdwn", call => \&htmlize);
} # }}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
@ -24,10 +24,10 @@ sub getsetup () { #{{{
safe => 1,
rebuild => 1,
},
} #}}}
}
my $markdown_sub;
sub htmlize (@) { #{{{
sub htmlize (@) {
my %params=@_;
my $content = $params{content};
@ -83,6 +83,6 @@ sub htmlize (@) { #{{{
$content=Encode::decode_utf8($content);
return $content;
} # }}}
}
1

View File

@ -7,7 +7,7 @@ use IkiWiki;
use Encode;
use open qw{:utf8 :std};
sub import { #{{{
sub import {
hook(type => "checkconfig", id => "mercurial", call => \&checkconfig);
hook(type => "getsetup", id => "mercurial", call => \&getsetup);
hook(type => "rcs", id => "rcs_update", call => \&rcs_update);
@ -20,18 +20,18 @@ sub import { #{{{
hook(type => "rcs", id => "rcs_recentchanges", call => \&rcs_recentchanges);
hook(type => "rcs", id => "rcs_diff", call => \&rcs_diff);
hook(type => "rcs", id => "rcs_getctime", call => \&rcs_getctime);
} #}}}
}
sub checkconfig () { #{{{
sub checkconfig () {
if (exists $config{mercurial_wrapper} && length $config{mercurial_wrapper}) {
push @{$config{wrappers}}, {
wrapper => $config{mercurial_wrapper},
wrappermode => (defined $config{mercurial_wrappermode} ? $config{mercurial_wrappermode} : "06755"),
};
}
} #}}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 0, # rcs plugin
@ -65,9 +65,9 @@ sub getsetup () { #{{{
safe => 1,
rebuild => 1,
},
} #}}}
}
sub mercurial_log ($) { #{{{
sub mercurial_log ($) {
my $out = shift;
my @infos;
@ -111,20 +111,20 @@ sub mercurial_log ($) { #{{{
close $out;
return @infos;
} #}}}
}
sub rcs_update () { #{{{
sub rcs_update () {
my @cmdline = ("hg", "-q", "-R", "$config{srcdir}", "update");
if (system(@cmdline) != 0) {
warn "'@cmdline' failed: $!";
}
} #}}}
}
sub rcs_prepedit ($) { #{{{
sub rcs_prepedit ($) {
return "";
} #}}}
}
sub rcs_commit ($$$;$$) { #{{{
sub rcs_commit ($$$;$$) {
my ($file, $message, $rcstoken, $user, $ipaddr) = @_;
if (defined $user) {
@ -149,7 +149,7 @@ sub rcs_commit ($$$;$$) { #{{{
}
return undef; # success
} #}}}
}
sub rcs_commit_staged ($$$) {
# Commits all staged changes. Changes can be staged using rcs_add,
@ -159,28 +159,28 @@ sub rcs_commit_staged ($$$) {
error("rcs_commit_staged not implemented for mercurial"); # TODO
}
sub rcs_add ($) { # {{{
sub rcs_add ($) {
my ($file) = @_;
my @cmdline = ("hg", "-q", "-R", "$config{srcdir}", "add", "$config{srcdir}/$file");
if (system(@cmdline) != 0) {
warn "'@cmdline' failed: $!";
}
} #}}}
}
sub rcs_remove ($) { # {{{
sub rcs_remove ($) {
my ($file) = @_;
error("rcs_remove not implemented for mercurial"); # TODO
} #}}}
}
sub rcs_rename ($$) { # {{{
sub rcs_rename ($$) {
my ($src, $dest) = @_;
error("rcs_rename not implemented for mercurial"); # TODO
} #}}}
}
sub rcs_recentchanges ($) { #{{{
sub rcs_recentchanges ($) {
my ($num) = @_;
my @cmdline = ("hg", "-R", $config{srcdir}, "log", "-v", "-l", $num,
@ -225,13 +225,13 @@ sub rcs_recentchanges ($) { #{{{
}
return @ret;
} #}}}
}
sub rcs_diff ($) { #{{{
sub rcs_diff ($) {
# TODO
} #}}}
}
sub rcs_getctime ($) { #{{{
sub rcs_getctime ($) {
my ($file) = @_;
# XXX filename passes through the shell here, should try to avoid
@ -251,6 +251,6 @@ sub rcs_getctime ($) { #{{{
my $ctime = str2time($log[0]->{"date"});
return $ctime;
} #}}}
}
1

View File

@ -8,22 +8,22 @@ use IkiWiki 2.00;
my %metaheaders;
sub import { #{{{
sub import {
hook(type => "getsetup", id => "meta", call => \&getsetup);
hook(type => "needsbuild", id => "meta", call => \&needsbuild);
hook(type => "preprocess", id => "meta", call => \&preprocess, scan => 1);
hook(type => "pagetemplate", id => "meta", call => \&pagetemplate);
} # }}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
rebuild => undef,
},
} #}}}
}
sub needsbuild (@) { #{{{
sub needsbuild (@) {
my $needsbuild=shift;
foreach my $page (keys %pagestate) {
if (exists $pagestate{$page}{meta}) {
@ -38,7 +38,7 @@ sub needsbuild (@) { #{{{
}
}
sub scrub ($$) { #{{{
sub scrub ($$) {
if (IkiWiki::Plugin::htmlscrubber->can("sanitize")) {
return IkiWiki::Plugin::htmlscrubber::sanitize(
content => shift, destpage => shift);
@ -46,9 +46,9 @@ sub scrub ($$) { #{{{
else {
return shift;
}
} #}}}
}
sub safeurl ($) { #{{{
sub safeurl ($) {
my $url=shift;
if (exists $IkiWiki::Plugin::htmlscrubber::{safe_url_regexp} &&
defined $IkiWiki::Plugin::htmlscrubber::safe_url_regexp) {
@ -57,9 +57,9 @@ sub safeurl ($) { #{{{
else {
return 1;
}
} #}}}
}
sub htmlize ($$$) { #{{{
sub htmlize ($$$) {
my $page = shift;
my $destpage = shift;
@ -68,7 +68,7 @@ sub htmlize ($$$) { #{{{
IkiWiki::preprocess($page, $destpage, shift)));
}
sub preprocess (@) { #{{{
sub preprocess (@) {
return "" unless @_;
my %params=@_;
my $key=shift;
@ -230,9 +230,9 @@ sub preprocess (@) { #{{{
}
return "";
} # }}}
}
sub pagetemplate (@) { #{{{
sub pagetemplate (@) {
my %params=@_;
my $page=$params{page};
my $destpage=$params{destpage};
@ -260,9 +260,9 @@ sub pagetemplate (@) { #{{{
$template->param($field => htmlize($page, $destpage, $pagestate{$page}{meta}{$field}));
}
}
} # }}}
}
sub match { #{{{
sub match {
my $field=shift;
my $page=shift;
@ -288,28 +288,28 @@ sub match { #{{{
else {
return IkiWiki::FailReason->new("$page does not have a $field");
}
} #}}}
}
package IkiWiki::PageSpec;
sub match_title ($$;@) { #{{{
sub match_title ($$;@) {
IkiWiki::Plugin::meta::match("title", @_);
} #}}}
}
sub match_author ($$;@) { #{{{
sub match_author ($$;@) {
IkiWiki::Plugin::meta::match("author", @_);
} #}}}
}
sub match_authorurl ($$;@) { #{{{
sub match_authorurl ($$;@) {
IkiWiki::Plugin::meta::match("authorurl", @_);
} #}}}
}
sub match_license ($$;@) { #{{{
sub match_license ($$;@) {
IkiWiki::Plugin::meta::match("license", @_);
} #}}}
}
sub match_copyright ($$;@) { #{{{
sub match_copyright ($$;@) {
IkiWiki::Plugin::meta::match("copyright", @_);
} #}}}
}
1

View File

@ -5,12 +5,12 @@ use warnings;
use strict;
use IkiWiki 2.00;
sub import { #{{{
sub import {
hook(type => "getsetup", id => "mirrorlist", call => \&getsetup);
hook(type => "pagetemplate", id => "mirrorlist", call => \&pagetemplate);
} # }}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
@ -23,9 +23,9 @@ sub getsetup () { #{{{
safe => 1,
rebuild => 1,
},
} #}}}
}
sub pagetemplate (@) { #{{{
sub pagetemplate (@) {
my %params=@_;
my $template=$params{template};
@ -34,9 +34,9 @@ sub pagetemplate (@) { #{{{
$value.=mirrorlist($params{page});
$template->param(extrafooter => $value);
}
} # }}}
}
sub mirrorlist ($) { #{{{
sub mirrorlist ($) {
my $page=shift;
return "<p>".
(keys %{$config{mirrorlist}} > 1 ? gettext("Mirrors") : gettext("Mirror")).
@ -49,6 +49,6 @@ sub mirrorlist ($) { #{{{
} keys %{$config{mirrorlist}}
).
"</p>";
} # }}}
}
1

View File

@ -10,7 +10,7 @@ use Date::Format qw(time2str);
my $sha1_pattern = qr/[0-9a-fA-F]{40}/; # pattern to validate sha1sums
sub import { #{{{
sub import {
hook(type => "checkconfig", id => "monotone", call => \&checkconfig);
hook(type => "getsetup", id => "monotone", call => \&getsetup);
hook(type => "rcs", id => "rcs_update", call => \&rcs_update);
@ -23,9 +23,9 @@ sub import { #{{{
hook(type => "rcs", id => "rcs_recentchanges", call => \&rcs_recentchanges);
hook(type => "rcs", id => "rcs_diff", call => \&rcs_diff);
hook(type => "rcs", id => "rcs_getctime", call => \&rcs_getctime);
} #}}}
}
sub checkconfig () { #{{{
sub checkconfig () {
if (!defined($config{mtnrootdir})) {
$config{mtnrootdir} = $config{srcdir};
}
@ -61,9 +61,9 @@ sub checkconfig () { #{{{
wrappermode => (defined $config{mtn_wrappermode} ? $config{mtn_wrappermode} : "06755"),
};
}
} #}}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 0, # rcs plugin
@ -117,9 +117,9 @@ sub getsetup () { #{{{
safe => 0, # path
rebuild => 0,
},
} #}}}
}
sub get_rev () { #{{{
sub get_rev () {
my $sha1 = `mtn --root=$config{mtnrootdir} automate get_base_revision_id`;
($sha1) = $sha1 =~ m/($sha1_pattern)/; # sha1 is untainted now
@ -128,9 +128,9 @@ sub get_rev () { #{{{
}
return $sha1;
} #}}}
}
sub get_rev_auto ($) { #{{{
sub get_rev_auto ($) {
my $automator=shift;
my @results = $automator->call("get_base_revision_id");
@ -142,9 +142,9 @@ sub get_rev_auto ($) { #{{{
}
return $sha1;
} #}}}
}
sub mtn_merge ($$$$) { #{{{
sub mtn_merge ($$$$) {
my $leftRev=shift;
my $rightRev=shift;
my $branch=shift;
@ -172,9 +172,9 @@ sub mtn_merge ($$$$) { #{{{
debug("merged $leftRev, $rightRev to make $mergeRev");
return $mergeRev;
} #}}}
}
sub commit_file_to_new_rev ($$$$$$$$) { #{{{
sub commit_file_to_new_rev ($$$$$$$$) {
my $automator=shift;
my $wsfilename=shift;
my $oldFileID=shift;
@ -219,9 +219,9 @@ sub commit_file_to_new_rev ($$$$$$$$) { #{{{
debug("Added certs for rev: $newRevID");
return $newRevID;
} #}}}
}
sub read_certs ($$) { #{{{
sub read_certs ($$) {
my $automator=shift;
my $rev=shift;
my @results = $automator->call("certs", $rev);
@ -239,9 +239,9 @@ sub read_certs ($$) { #{{{
}
return @ret;
} #}}}
}
sub get_changed_files ($$) { #{{{
sub get_changed_files ($$) {
my $automator=shift;
my $rev=shift;
@ -261,9 +261,9 @@ sub get_changed_files ($$) { #{{{
}
return @ret;
} #}}}
}
sub rcs_update () { #{{{
sub rcs_update () {
chdir $config{srcdir}
or error("Cannot chdir to $config{srcdir}: $!");
@ -278,9 +278,9 @@ sub rcs_update () { #{{{
if (system("mtn", "--root=$config{mtnrootdir}", "update", "--quiet") != 0) {
debug("monotone update failed");
}
} #}}}
}
sub rcs_prepedit ($) { #{{{
sub rcs_prepedit ($) {
my $file=shift;
chdir $config{srcdir}
@ -289,9 +289,9 @@ sub rcs_prepedit ($) { #{{{
# For monotone, return the revision of the file when
# editing begins.
return get_rev();
} #}}}
}
sub rcs_commit ($$$;$$) { #{{{
sub rcs_commit ($$$;$$) {
# Tries to commit the page; returns undef on _success_ and
# a version of the page with the rcs's conflict markers on failure.
# The file is relative to the srcdir.
@ -434,7 +434,7 @@ sub rcs_commit ($$$;$$) { #{{{
}
return undef # success
} #}}}
}
sub rcs_commit_staged ($$$) {
# Commits all staged changes. Changes can be staged using rcs_add,
@ -466,7 +466,7 @@ sub rcs_commit_staged ($$$) {
}
}
sub rcs_add ($) { #{{{
sub rcs_add ($) {
my $file=shift;
chdir $config{srcdir}
@ -476,9 +476,9 @@ sub rcs_add ($) { #{{{
$file) != 0) {
error("Monotone add failed");
}
} #}}}
}
sub rcs_remove ($) { # {{{
sub rcs_remove ($) {
my $file = shift;
chdir $config{srcdir}
@ -495,9 +495,9 @@ sub rcs_remove ($) { # {{{
$file) != 0) {
error("Monotone remove failed");
}
} #}}}
}
sub rcs_rename ($$) { # {{{
sub rcs_rename ($$) {
my ($src, $dest) = @_;
chdir $config{srcdir}
@ -507,9 +507,9 @@ sub rcs_rename ($$) { # {{{
$src, $dest) != 0) {
error("Monotone rename failed");
}
} #}}}
}
sub rcs_recentchanges ($) { #{{{
sub rcs_recentchanges ($) {
my $num=shift;
my @ret;
@ -614,9 +614,9 @@ sub rcs_recentchanges ($) { #{{{
$automator->close();
return @ret;
} #}}}
}
sub rcs_diff ($) { #{{{
sub rcs_diff ($) {
my $rev=shift;
my ($sha1) = $rev =~ /^($sha1_pattern)$/; # untaint
@ -638,9 +638,9 @@ sub rcs_diff ($) { #{{{
else {
return join("", @lines);
}
} #}}}
}
sub rcs_getctime ($) { #{{{
sub rcs_getctime ($) {
my $file=shift;
chdir $config{srcdir}
@ -690,6 +690,6 @@ sub rcs_getctime ($) { #{{{
$date=str2time($date, 'UTC');
debug("found ctime ".localtime($date)." for $file");
return $date;
} #}}}
}
1

View File

@ -7,20 +7,20 @@ use IkiWiki 2.00;
my $linktext = gettext("more");
sub import { #{{{
sub import {
hook(type => "getsetup", id => "more", call => \&getsetup);
hook(type => "preprocess", id => "more", call => \&preprocess);
} # }}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
rebuild => undef,
},
} #}}}
}
sub preprocess (@) { #{{{
sub preprocess (@) {
my %params=@_;
$params{linktext} = $linktext unless defined $params{linktext};

View File

@ -6,7 +6,7 @@ use warnings;
use strict;
use IkiWiki;
sub import { #{{{
sub import {
hook(type => "getsetup", id => "norcs", call => \&getsetup);
hook(type => "rcs", id => "rcs_update", call => \&rcs_update);
hook(type => "rcs", id => "rcs_prepedit", call => \&rcs_prepedit);
@ -18,51 +18,51 @@ sub import { #{{{
hook(type => "rcs", id => "rcs_recentchanges", call => \&rcs_recentchanges);
hook(type => "rcs", id => "rcs_diff", call => \&rcs_diff);
hook(type => "rcs", id => "rcs_getctime", call => \&rcs_getctime);
} #}}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 0, # rcs plugin
rebuild => 0,
},
} #}}}
}
sub rcs_update () { #{{{
} #}}}
sub rcs_update () {
}
sub rcs_prepedit ($) { #{{{
sub rcs_prepedit ($) {
return ""
} #}}}
}
sub rcs_commit ($$$;$$) { #{{{
sub rcs_commit ($$$;$$) {
my ($file, $message, $rcstoken, $user, $ipaddr) = @_;
return undef # success
} #}}}
}
sub rcs_commit_staged ($$$) { #{{{
sub rcs_commit_staged ($$$) {
my ($message, $user, $ipaddr)=@_;
return undef # success
} #}}}
}
sub rcs_add ($) { #{{{
} #}}}
sub rcs_add ($) {
}
sub rcs_remove ($) { #{{{
} #}}}
sub rcs_remove ($) {
}
sub rcs_rename ($$) { #{{{
} #}}}
sub rcs_rename ($$) {
}
sub rcs_recentchanges ($) { #{{{
} #}}}
sub rcs_recentchanges ($) {
}
sub rcs_diff ($) { #{{{
} #}}}
sub rcs_diff ($) {
}
sub rcs_getctime ($) { #{{{
sub rcs_getctime ($) {
error gettext("getctime not implemented");
} #}}}
}
1

View File

@ -5,20 +5,20 @@ use warnings;
use strict;
use IkiWiki 2.00;
sub import { #{{{
sub import {
hook(type => "getsetup", id => "opendiscussion", call => \&getsetup);
hook(type => "canedit", id => "opendiscussion", call => \&canedit);
} # }}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
rebuild => 0,
},
} #}}}
}
sub canedit ($$) { #{{{
sub canedit ($$) {
my $page=shift;
my $cgi=shift;
my $session=shift;
@ -26,6 +26,6 @@ sub canedit ($$) { #{{{
my $discussion=gettext("discussion");
return "" if $page=~/(\/|^)\Q$discussion\E$/;
return undef;
} #}}}
}
1

View File

@ -6,22 +6,22 @@ use warnings;
use strict;
use IkiWiki 2.00;
sub import { #{{{
sub import {
hook(type => "getopt", id => "openid", call => \&getopt);
hook(type => "getsetup", id => "openid", call => \&getsetup);
hook(type => "auth", id => "openid", call => \&auth);
hook(type => "formbuilder_setup", id => "openid",
call => \&formbuilder_setup, last => 1);
} # }}}
}
sub getopt () { #{{{
sub getopt () {
eval q{use Getopt::Long};
error($@) if $@;
Getopt::Long::Configure('pass_through');
GetOptions("openidsignup=s" => \$config{openidsignup});
} #}}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
@ -34,9 +34,9 @@ sub getsetup () { #{{{
safe => 1,
rebuild => 0,
},
} #}}}
}
sub formbuilder_setup (@) { #{{{
sub formbuilder_setup (@) {
my %params=@_;
my $form=$params{form};
@ -92,7 +92,7 @@ sub formbuilder_setup (@) { #{{{
}
}
sub validate ($$$;$) { #{{{
sub validate ($$$;$) {
my $q=shift;
my $session=shift;
my $openid_url=shift;
@ -121,9 +121,9 @@ sub validate ($$$;$) { #{{{
# eventually bounce them back to auth()
IkiWiki::redirect($q, $check_url);
exit 0;
} #}}}
}
sub auth ($$) { #{{{
sub auth ($$) {
my $q=shift;
my $session=shift;
@ -147,9 +147,9 @@ sub auth ($$) { #{{{
# myopenid.com affiliate support
validate($q, $session, $q->param('openid_identifier'));
}
} #}}}
}
sub getobj ($$) { #{{{
sub getobj ($$) {
my $q=shift;
my $session=shift;
@ -178,13 +178,13 @@ sub getobj ($$) { #{{{
consumer_secret => sub { return shift()+$secret },
required_root => $config{cgiurl},
);
} #}}}
}
package IkiWiki;
# This is not used by this plugin, but this seems the best place to put it.
# Used elsewhere to pretty-display the name of an openid user.
sub openiduser ($) { #{{{
sub openiduser ($) {
my $user=shift;
if ($user =~ m!^https?://! &&

View File

@ -6,20 +6,20 @@ use warnings;
use strict;
use IkiWiki 2.00;
sub import { #{{{
sub import {
hook(type => "getsetup", id => "orphans", call => \&getsetup);
hook(type => "preprocess", id => "orphans", call => \&preprocess);
} # }}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
rebuild => undef,
},
} #}}}
}
sub preprocess (@) { #{{{
sub preprocess (@) {
my %params=@_;
$params{pages}="*" unless defined $params{pages};
@ -58,6 +58,6 @@ sub preprocess (@) { #{{{
"</li>"
} sort @orphans).
"</ul>\n";
} # }}}
}
1

View File

@ -7,22 +7,22 @@ use strict;
use IkiWiki 2.00;
use open qw{:utf8 :std};
sub import { #{{{
sub import {
hook(type => "getsetup", id => "otl", call => \&getsetup);
hook(type => "filter", id => "otl", call => \&filter);
hook(type => "htmlize", id => "otl", call => \&htmlize);
} # }}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
rebuild => 1, # format plugin
},
} #}}}
}
sub filter (@) { #{{{
sub filter (@) {
my %params=@_;
# Munge up check boxes to look a little bit better. This is a hack.
@ -34,9 +34,9 @@ sub filter (@) { #{{{
$params{content}=~s/^(\s*)\[_\]\s/${1}$unchecked /mg;
return $params{content};
} # }}}
}
sub htmlize (@) { #{{{
sub htmlize (@) {
my %params=@_;
# Can't use open2 since otl2html doesn't play nice with buffering.
@ -95,6 +95,6 @@ sub htmlize (@) { #{{{
$ret=~s/<body>.*//s;
$ret=~s/<div class="Footer">.*//s;
return $ret;
} # }}}
}
1

View File

@ -5,20 +5,20 @@ use warnings;
use strict;
use IkiWiki 2.00;
sub import { #{{{
sub import {
hook(type => "getsetup", id => "pagecount", call => \&getsetup);
hook(type => "preprocess", id => "pagecount", call => \&preprocess);
} # }}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
rebuild => undef,
},
} #}}}
}
sub preprocess (@) { #{{{
sub preprocess (@) {
my %params=@_;
$params{pages}="*" unless defined $params{pages};
@ -33,6 +33,6 @@ sub preprocess (@) { #{{{
$count++ if pagespec_match($page, $params{pages}, location => $params{page});
}
return $count;
} # }}}
}
1

View File

@ -17,20 +17,20 @@ use IkiWiki 2.00;
# Names of the HTML classes to use for the tag cloud
our @classes = ('smallestPC', 'smallPC', 'normalPC', 'bigPC', 'biggestPC' );
sub import { #{{{
sub import {
hook(type => "getsetup", id => "pagestats", call => \&getsetup);
hook(type => "preprocess", id => "pagestats", call => \&preprocess);
} # }}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
rebuild => undef,
},
} #}}}
}
sub preprocess (@) { #{{{
sub preprocess (@) {
my %params=@_;
$params{pages}="*" unless defined $params{pages};
my $style = ($params{style} or 'cloud');
@ -73,6 +73,6 @@ sub preprocess (@) { #{{{
return $res;
}
} # }}}
}
1

View File

@ -7,21 +7,21 @@ use IkiWiki 2.00;
my %templates;
sub import { #{{{
sub import {
hook(type => "getsetup", id => "pagetemplate", call => \&getsetup);
hook(type => "preprocess", id => "pagetemplate", call => \&preprocess);
hook(type => "templatefile", id => "pagetemplate", call => \&templatefile);
} # }}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
rebuild => undef,
},
} #}}}
}
sub preprocess (@) { #{{{
sub preprocess (@) {
my %params=@_;
if (! exists $params{template} ||
@ -35,9 +35,9 @@ sub preprocess (@) { #{{{
}
return "";
} # }}}
}
sub templatefile (@) { #{{{
sub templatefile (@) {
my %params=@_;
if (exists $templates{$params{page}}) {
@ -45,6 +45,6 @@ sub templatefile (@) { #{{{
}
return undef;
} # }}}
}
1

View File

@ -6,20 +6,20 @@ use warnings;
use strict;
use IkiWiki 2.00;
sub import { #{{{
sub import {
hook(type => "parentlinks", id => "parentlinks", call => \&parentlinks);
hook(type => "pagetemplate", id => "parentlinks", call => \&pagetemplate);
} # }}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
rebuild => 1,
},
} #}}}
}
sub parentlinks ($) { #{{{
sub parentlinks ($) {
my $page=shift;
my @ret;
@ -48,9 +48,9 @@ sub parentlinks ($) { #{{{
$i++;
}
return @ret;
} #}}}
}
sub pagetemplate (@) { #{{{
sub pagetemplate (@) {
my %params=@_;
my $page=$params{page};
my $template=$params{template};
@ -58,6 +58,6 @@ sub pagetemplate (@) { #{{{
if ($template->query(name => "parentlinks")) {
$template->param(parentlinks => [parentlinks($page)]);
}
} # }}}
}
1

View File

@ -6,14 +6,14 @@ use warnings;
use strict;
use IkiWiki 2.00;
sub import { #{{{
sub import {
hook(type => "getsetup", id => "passwordauth", "call" => \&getsetup);
hook(type => "formbuilder_setup", id => "passwordauth", call => \&formbuilder_setup);
hook(type => "formbuilder", id => "passwordauth", call => \&formbuilder);
hook(type => "sessioncgi", id => "passwordauth", call => \&sessioncgi);
} # }}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
@ -33,10 +33,10 @@ sub getsetup () { #{{{
safe => 1,
rebuild => 0,
},
} #}}}
}
# Checks if a string matches a user's password, and returns true or false.
sub checkpassword ($$;$) { #{{{
sub checkpassword ($$;$) {
my $user=shift;
my $password=shift;
my $field=shift || "password";
@ -74,9 +74,9 @@ sub checkpassword ($$;$) { #{{{
}
return $ret;
} #}}}
}
sub setpassword ($$;$) { #{{{
sub setpassword ($$;$) {
my $user=shift;
my $password=shift;
my $field=shift || "password";
@ -94,9 +94,9 @@ sub setpassword ($$;$) { #{{{
else {
IkiWiki::userinfo_set($user, $field, $password);
}
} #}}}
}
sub formbuilder_setup (@) { #{{{
sub formbuilder_setup (@) {
my %params=@_;
my $form=$params{form};
@ -222,7 +222,7 @@ sub formbuilder_setup (@) { #{{{
}
}
sub formbuilder (@) { #{{{
sub formbuilder (@) {
my %params=@_;
my $form=$params{form};
@ -313,9 +313,9 @@ sub formbuilder (@) { #{{{
}
}
}
} #}}}
}
sub sessioncgi ($$) { #{{{
sub sessioncgi ($$) {
my $q=shift;
my $session=shift;
@ -335,6 +335,6 @@ sub sessioncgi ($$) { #{{{
IkiWiki::cgi_prefs($q, $session);
exit;
}
} #}}}
}
1

View File

@ -5,20 +5,20 @@ use warnings;
use strict;
use IkiWiki 2.00;
sub import { #{{{
sub import {
hook(type => "getsetup", id => "pingee", call => \&getsetup);
hook(type => "cgi", id => "pingee", call => \&cgi);
} # }}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
rebuild => undef,
},
} #}}}
}
sub cgi ($) { #{{{
sub cgi ($) {
my $cgi=shift;
if (defined $cgi->param('do') && $cgi->param("do") eq "ping") {
@ -37,6 +37,6 @@ sub cgi ($) { #{{{
IkiWiki::saveindex();
exit 0;
}
} #}}}
}
1

View File

@ -8,15 +8,15 @@ use IkiWiki 2.00;
my %pages;
my $pinged=0;
sub import { #{{{
sub import {
hook(type => "getsetup", id => "pinger", call => \&getsetup);
hook(type => "needsbuild", id => "pinger", call => \&needsbuild);
hook(type => "preprocess", id => "ping", call => \&preprocess);
hook(type => "delete", id => "pinger", call => \&ping);
hook(type => "change", id => "pinger", call => \&ping);
} # }}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
@ -29,9 +29,9 @@ sub getsetup () { #{{{
safe => 1,
rebuild => 0,
},
} #}}}
}
sub needsbuild (@) { #{{{
sub needsbuild (@) {
my $needsbuild=shift;
foreach my $page (keys %pagestate) {
if (exists $pagestate{$page}{pinger}) {
@ -45,9 +45,9 @@ sub needsbuild (@) { #{{{
}
}
}
} # }}}
}
sub preprocess (@) { #{{{
sub preprocess (@) {
my %params=@_;
if (! exists $params{from} || ! exists $params{to}) {
error gettext("requires 'from' and 'to' parameters");
@ -60,7 +60,7 @@ sub preprocess (@) { #{{{
else {
return sprintf(gettext("Ignoring ping directive for wiki %s (this wiki is %s)"), $params{from}, $config{url});
}
} # }}}
}
sub ping {
if (! $pinged && %pages) {

View File

@ -6,22 +6,22 @@ use strict;
use IkiWiki 2.00;
use Encode;
sub import { #{{{
sub import {
hook(type => "getsetup", id => "poll", call => \&getsetup);
hook(type => "preprocess", id => "poll", call => \&preprocess);
hook(type => "sessioncgi", id => "poll", call => \&sessioncgi);
} # }}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
rebuild => undef,
},
} #}}}
}
my %pagenum;
sub preprocess (@) { #{{{
sub preprocess (@) {
my %params=(open => "yes", total => "yes", percent => "yes", @_);
my $open=IkiWiki::yesno($params{open});
@ -77,9 +77,9 @@ sub preprocess (@) { #{{{
$ret.="<span>".gettext("Total votes:")." $total</span>\n";
}
return "<div class=poll>$ret</div>";
} # }}}
}
sub sessioncgi ($$) { #{{{
sub sessioncgi ($$) {
my $cgi=shift;
my $session=shift;
if (defined $cgi->param('do') && $cgi->param('do') eq "poll") {
@ -152,6 +152,6 @@ sub sessioncgi ($$) { #{{{
-url => urlto($page, undef, 1));
exit;
}
} #}}}
}
1

View File

@ -10,20 +10,20 @@ use strict;
use IkiWiki 2.00;
use File::Find;
sub import { #{{{
sub import {
hook(type => "getsetup", id => "polygen", call => \&getsetup);
hook(type => "preprocess", id => "polygen", call => \&preprocess);
} # }}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
rebuild => undef,
},
} #}}}
}
sub preprocess (@) { #{{{
sub preprocess (@) {
my %params=@_;
my $grammar = ($params{grammar} or 'polygen');
my $symbol = ($params{symbol} or undef);
@ -64,6 +64,6 @@ sub preprocess (@) { #{{{
# markdown text
$res =~ s/\s*$//;
return $res;
} # }}}
}
1

View File

@ -5,21 +5,21 @@ use warnings;
use strict;
use IkiWiki 2.00;
sub import { #{{{
sub import {
IkiWiki::loadplugin('sparkline');
hook(type => "getsetup", id => "postsparkline", call => \&getsetup);
hook(type => "preprocess", id => "postsparkline", call => \&preprocess);
} # }}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
rebuild => undef,
},
} #}}}
}
sub preprocess (@) { #{{{
sub preprocess (@) {
my %params=@_;
if (! exists $params{max}) {
@ -78,7 +78,7 @@ sub preprocess (@) { #{{{
delete $params{color};
return IkiWiki::Plugin::sparkline::preprocess(%params,
map { $_.$color => "" } reverse @data);
} # }}}
}
sub perfoo ($@) {
my $sub=shift;

View File

@ -39,12 +39,12 @@ sub default_timetable {
];
}
sub import { #{{{
sub import {
hook(type => "getsetup", id => "prettydate", call => \&getsetup);
hook(type => "checkconfig", id => "prettydate", call => \&checkconfig);
} # }}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
@ -64,9 +64,9 @@ sub getsetup () { #{{{
safe => 1,
rebuild => 1,
},
} #}}}
}
sub checkconfig () { #{{{
sub checkconfig () {
if (! defined $config{prettydateformat} ||
$config{prettydateformat} eq '%c') {
$config{prettydateformat}='%X, %B %o, %Y';
@ -82,9 +82,9 @@ sub checkconfig () { #{{{
$config{timetable}[$h] = $config{timetable}[$h - 1];
}
}
} #}}}
}
sub IkiWiki::formattime ($;$) { #{{{
sub IkiWiki::formattime ($;$) {
my $time=shift;
my $format=shift;
if (! defined $format) {
@ -122,6 +122,6 @@ sub IkiWiki::formattime ($;$) { #{{{
$format=~s/\%X/$t/g;
return strftime($format, \@t);
} #}}}
}
1

View File

@ -7,21 +7,21 @@ use IkiWiki 2.00;
my $percentage_pattern = qr/[0-9]+\%?/; # pattern to validate percentages
sub import { #{{{
sub import {
hook(type => "getsetup", id => "progress", call => \&getsetup);
hook(type => "preprocess", id => "progress", call => \&preprocess);
hook(type => "format", id => "progress", call => \&format);
} # }}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
rebuild => undef,
},
} #}}}
}
sub preprocess (@) { #{{{
sub preprocess (@) {
my %params=@_;
my $fill;
@ -64,9 +64,9 @@ sub preprocess (@) { #{{{
<div class="progress-done" style="width: $fill">$fill</div>
</div>
EODIV
} # }}}
}
sub format(@) { #{{{
sub format(@) {
my %params = @_;
# If HTMLScrubber has removed the style attribute, then bring it back
@ -74,6 +74,6 @@ sub format(@) { #{{{
$params{content} =~ s!<div class="progress-done">($percentage_pattern)</div>!<div class="progress-done" style="width: $1">$1</div>!g;
return $params{content};
} #}}}
}
1

View File

@ -6,17 +6,17 @@ use warnings;
use strict;
use IkiWiki 2.00;
sub import { #{{{
sub import {
hook(type => "getsetup", id => "rawhtml", call => \&getsetup);
$config{wiki_file_prune_regexps} = [ grep { !m/\\\.x\?html\?\$/ } @{$config{wiki_file_prune_regexps}} ];
} # }}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
rebuild => 1, # changes file types
},
} #}}}
}
1

View File

@ -7,16 +7,16 @@ use IkiWiki 2.00;
use Encode;
use HTML::Entities;
sub import { #{{{
sub import {
hook(type => "getsetup", id => "recentchanges", call => \&getsetup);
hook(type => "checkconfig", id => "recentchanges", call => \&checkconfig);
hook(type => "refresh", id => "recentchanges", call => \&refresh);
hook(type => "pagetemplate", id => "recentchanges", call => \&pagetemplate);
hook(type => "htmlize", id => "_change", call => \&htmlize);
hook(type => "cgi", id => "recentchanges", call => \&cgi);
} #}}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
@ -36,14 +36,14 @@ sub getsetup () { #{{{
safe => 1,
rebuild => 0,
},
} #}}}
}
sub checkconfig () { #{{{
sub checkconfig () {
$config{recentchangespage}='recentchanges' unless defined $config{recentchangespage};
$config{recentchangesnum}=100 unless defined $config{recentchangesnum};
} #}}}
}
sub refresh ($) { #{{{
sub refresh ($) {
my %seen;
# add new changes
@ -57,10 +57,10 @@ sub refresh ($) { #{{{
unlink($config{srcdir}.'/'.$pagesources{$page});
}
}
} #}}}
}
# Enable the recentchanges link on wiki pages.
sub pagetemplate (@) { #{{{
sub pagetemplate (@) {
my %params=@_;
my $template=$params{template};
my $page=$params{page};
@ -71,15 +71,15 @@ sub pagetemplate (@) { #{{{
$template->param(recentchangesurl => urlto($config{recentchangespage}, $page));
$template->param(have_actions => 1);
}
} #}}}
}
# Pages with extension _change have plain html markup, pass through.
sub htmlize (@) { #{{{
sub htmlize (@) {
my %params=@_;
return $params{content};
} #}}}
}
sub cgi ($) { #{{{
sub cgi ($) {
my $cgi=shift;
if (defined $cgi->param('do') && $cgi->param('do') eq "recentchanges_link") {
# This is a link from a change page to some
@ -112,7 +112,7 @@ sub cgi ($) { #{{{
}
}
sub store ($$$) { #{{{
sub store ($$$) {
my $change=shift;
my $page="$config{recentchangespage}/change_".titlepage($change->{rev});
@ -192,6 +192,6 @@ sub store ($$$) { #{{{
utime $change->{when}, $change->{when}, "$config{srcdir}/$file";
return $page;
} #}}}
}
1

View File

@ -8,22 +8,22 @@ use HTML::Entities;
my $maxlines=200;
sub import { #{{{
sub import {
hook(type => "getsetup", id => "recentchangesdiff",
call => \&getsetup);
hook(type => "pagetemplate", id => "recentchangesdiff",
call => \&pagetemplate);
} #}}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
rebuild => 1,
},
} #}}}
}
sub pagetemplate (@) { #{{{
sub pagetemplate (@) {
my %params=@_;
my $template=$params{template};
if ($config{rcs} && exists $params{rev} && length $params{rev} &&
@ -46,6 +46,6 @@ sub pagetemplate (@) { #{{{
$template->param(diff => $diff);
}
}
} #}}}
}
1

View File

@ -8,22 +8,22 @@ use IkiWiki 2.00;
use POSIX;
use Encode;
sub import { #{{{
sub import {
add_underlay("javascript");
hook(type => "getsetup", id => "relativedate", call => \&getsetup);
hook(type => "format", id => "relativedate", call => \&format);
inject(name => "IkiWiki::displaytime", call => \&mydisplaytime);
} # }}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
rebuild => 1,
},
} #}}}
}
sub format (@) { #{{{
sub format (@) {
my %params=@_;
if (! ($params{content}=~s!^(<body>)!$1.include_javascript($params{page})!em)) {
@ -31,9 +31,9 @@ sub format (@) { #{{{
$params{content}=include_javascript($params{page}, 1).$params{content};
}
return $params{content};
} # }}}
}
sub include_javascript ($;$) { #{{{
sub include_javascript ($;$) {
my $page=shift;
my $absolute=shift;
@ -41,9 +41,9 @@ sub include_javascript ($;$) { #{{{
'" type="text/javascript" charset="utf-8"></script>'."\n".
'<script src="'.urlto("relativedate.js", $page, $absolute).
'" type="text/javascript" charset="utf-8"></script>';
} #}}}
}
sub mydisplaytime ($;$) { #{{{
sub mydisplaytime ($;$) {
my $time=shift;
my $format=shift;
@ -55,6 +55,6 @@ sub mydisplaytime ($;$) { #{{{
return '<span class="relativedate" title="'.$gmtime.'">'.
IkiWiki::formattime($time, $format).'</span>';
} #}}}
}
1

View File

@ -5,23 +5,23 @@ use warnings;
use strict;
use IkiWiki 2.00;
sub import { #{{{
sub import {
hook(type => "getsetup", id => "remove", call => \&getsetup);
hook(type => "formbuilder_setup", id => "remove", call => \&formbuilder_setup);
hook(type => "formbuilder", id => "remove", call => \&formbuilder);
hook(type => "sessioncgi", id => "remove", call => \&sessioncgi);
} # }}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
rebuild => 0,
},
} #}}}
}
sub check_canremove ($$$) { #{{{
sub check_canremove ($$$) {
my $page=shift;
my $q=shift;
my $session=shift;
@ -54,9 +54,9 @@ sub check_canremove ($$$) { #{{{
error("renaming of attachments is not allowed");
}
}
} #}}}
}
sub formbuilder_setup (@) { #{{{
sub formbuilder_setup (@) {
my %params=@_;
my $form=$params{form};
my $q=$params{cgi};
@ -67,9 +67,9 @@ sub formbuilder_setup (@) { #{{{
push @{$params{buttons}}, "Remove" if $form->field("do") eq "edit";
$form->tmpl_param("field-remove" => '<input name="_submit" type="submit" value="Remove Attachments" />');
}
} #}}}
}
sub confirmation_form ($$) { #{{{
sub confirmation_form ($$) {
my $q=shift;
my $session=shift;
@ -90,9 +90,9 @@ sub confirmation_form ($$) { #{{{
$f->field(name => "do", type => "hidden", value => "remove", force => 1);
return $f, ["Remove", "Cancel"];
} #}}}
}
sub removal_confirm ($$@) { #{{{
sub removal_confirm ($$@) {
my $q=shift;
my $session=shift;
my $attachment=shift;
@ -122,9 +122,9 @@ sub removal_confirm ($$@) { #{{{
IkiWiki::showform($f, $buttons, $session, $q);
exit 0;
} #}}}
}
sub postremove ($) { #{{{
sub postremove ($) {
my $session=shift;
# Load saved form state and return to edit form.
@ -132,9 +132,9 @@ sub postremove ($) { #{{{
$session->clear("postremove");
IkiWiki::cgi_savesession($session);
IkiWiki::cgi($postremove, $session);
} #}}}
}
sub formbuilder (@) { #{{{
sub formbuilder (@) {
my %params=@_;
my $form=$params{form};
@ -154,9 +154,9 @@ sub formbuilder (@) { #{{{
removal_confirm($q, $session, 1, @selected);
}
}
} #}}}
}
sub sessioncgi ($$) { #{{{
sub sessioncgi ($$) {
my $q=shift;
if ($q->param("do") eq 'remove') {

View File

@ -5,23 +5,23 @@ use warnings;
use strict;
use IkiWiki 2.00;
sub import { #{{{
sub import {
hook(type => "getsetup", id => "rename", call => \&getsetup);
hook(type => "formbuilder_setup", id => "rename", call => \&formbuilder_setup);
hook(type => "formbuilder", id => "rename", call => \&formbuilder);
hook(type => "sessioncgi", id => "rename", call => \&sessioncgi);
} # }}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
rebuild => 0,
},
} #}}}
}
sub check_canrename ($$$$$$) { #{{{
sub check_canrename ($$$$$$) {
my $src=shift;
my $srcfile=shift;
my $dest=shift;
@ -87,9 +87,9 @@ sub check_canrename ($$$$$$) { #{{{
IkiWiki::Plugin::attachment::check_canattach($session, $dest, $srcfile);
}
}
} #}}}
}
sub rename_form ($$$) { #{{{
sub rename_form ($$$) {
my $q=shift;
my $session=shift;
my $page=shift;
@ -145,9 +145,9 @@ sub rename_form ($$$) { #{{{
$f->field(name => "attachment", type => "hidden");
return $f, ["Rename", "Cancel"];
} #}}}
}
sub rename_start ($$$$) { #{{{
sub rename_start ($$$$) {
my $q=shift;
my $session=shift;
my $attachment=shift;
@ -171,9 +171,9 @@ sub rename_start ($$$$) { #{{{
my ($f, $buttons)=rename_form($q, $session, $page);
IkiWiki::showform($f, $buttons, $session, $q);
exit 0;
} #}}}
}
sub postrename ($;$$$) { #{{{
sub postrename ($;$$$) {
my $session=shift;
my $src=shift;
my $dest=shift;
@ -204,9 +204,9 @@ sub postrename ($;$$$) { #{{{
}
IkiWiki::cgi_editpage($postrename, $session);
} #}}}
}
sub formbuilder (@) { #{{{
sub formbuilder (@) {
my %params=@_;
my $form=$params{form};
@ -229,11 +229,11 @@ sub formbuilder (@) { #{{{
rename_start($q, $session, 1, $selected[0]);
}
}
} #}}}
}
my $renamesummary;
sub formbuilder_setup (@) { #{{{
sub formbuilder_setup (@) {
my %params=@_;
my $form=$params{form};
my $q=$params{cgi};
@ -248,9 +248,9 @@ sub formbuilder_setup (@) { #{{{
$form->tmpl_param(message => $renamesummary);
}
}
} #}}}
}
sub sessioncgi ($$) { #{{{
sub sessioncgi ($$) {
my $q=shift;
if ($q->param("do") eq 'rename') {
@ -418,9 +418,9 @@ sub sessioncgi ($$) { #{{{
exit 0;
}
} #}}}
}
sub renamepage_hook ($$$$) { #{{{
sub renamepage_hook ($$$$) {
my ($page, $src, $dest, $content)=@_;
IkiWiki::run_hooks(renamepage => sub {
@ -433,9 +433,9 @@ sub renamepage_hook ($$$$) { #{{{
});
return $content;
}# }}}
}
sub do_rename ($$$) { #{{{
sub do_rename ($$$) {
my $rename=shift;
my $q=shift;
my $session=shift;
@ -460,9 +460,9 @@ sub do_rename ($$$) { #{{{
}
}
} # }}}
}
sub fixlinks ($$$) { #{{{
sub fixlinks ($$$) {
my $rename=shift;
my $session=shift;
@ -498,6 +498,6 @@ sub fixlinks ($$$) { #{{{
}
return @fixedlinks;
} #}}}
}
1

View File

@ -6,16 +6,16 @@ use warnings;
use strict;
use IkiWiki 2.00;
sub import { #{{{
sub import {
hook(type => "getsetup", id => "search", call => \&getsetup);
hook(type => "checkconfig", id => "search", call => \&checkconfig);
hook(type => "pagetemplate", id => "search", call => \&pagetemplate);
hook(type => "postscan", id => "search", call => \&index);
hook(type => "delete", id => "search", call => \&delete);
hook(type => "cgi", id => "search", call => \&cgi);
} # }}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
@ -28,9 +28,9 @@ sub getsetup () { #{{{
safe => 0, # external program
rebuild => 0,
},
} #}}}
}
sub checkconfig () { #{{{
sub checkconfig () {
foreach my $required (qw(url cgiurl)) {
if (! length $config{$required}) {
error(sprintf(gettext("Must specify %s when using the search plugin"), $required));
@ -40,10 +40,10 @@ sub checkconfig () { #{{{
if (! defined $config{omega_cgi}) {
$config{omega_cgi}="/usr/lib/cgi-bin/omega/omega";
}
} #}}}
}
my $form;
sub pagetemplate (@) { #{{{
sub pagetemplate (@) {
my %params=@_;
my $page=$params{page};
my $template=$params{template};
@ -58,11 +58,11 @@ sub pagetemplate (@) { #{{{
$template->param(searchform => $form);
}
} #}}}
}
my $scrubber;
my $stemmer;
sub index (@) { #{{{
sub index (@) {
my %params=@_;
setupfiles();
@ -146,17 +146,17 @@ sub index (@) { #{{{
$doc->add_term($pageterm);
$db->replace_document_by_term($pageterm, $doc);
} #}}}
}
sub delete (@) { #{{{
sub delete (@) {
my $db=xapiandb();
foreach my $page (@_) {
my $pageterm=pageterm(pagename($page));
$db->delete_document_by_term($pageterm) if defined $pageterm;
}
} #}}}
}
sub cgi ($) { #{{{
sub cgi ($) {
my $cgi=shift;
if (defined $cgi->param('P')) {
@ -169,9 +169,9 @@ sub cgi ($) { #{{{
noimageinline => 1, linktext => "Help");
exec($config{omega_cgi}) || error("$config{omega_cgi} failed: $!");
}
} #}}}
}
sub pageterm ($) { #{{{
sub pageterm ($) {
my $page=shift;
# 240 is the number used by omindex to decide when to hash an
@ -190,10 +190,10 @@ sub pageterm ($) { #{{{
else {
return "U:".$page;
}
} #}}}
}
my $db;
sub xapiandb () { #{{{
sub xapiandb () {
if (! defined $db) {
eval q{
use Search::Xapian;
@ -204,11 +204,11 @@ sub xapiandb () { #{{{
Search::Xapian::DB_CREATE_OR_OPEN());
}
return $db;
} #}}}
}
{
my $setup=0;
sub setupfiles () { #{{{
sub setupfiles () {
if (! $setup and (! -e $config{wikistatedir}."/xapian" || $config{rebuild})) {
writefile("omega.conf", $config{wikistatedir}."/xapian",
"database_dir .\n".
@ -218,7 +218,7 @@ sub setupfiles () { #{{{
readfile(IkiWiki::template_file("searchquery.tmpl"))));
$setup=1;
}
} #}}}
}
}
1

View File

@ -5,21 +5,21 @@ use warnings;
use strict;
use IkiWiki 2.00;
sub import { #{{{
sub import {
hook(type => "getsetup", id => "shortcut", call => \&getsetup);
hook(type => "checkconfig", id => "shortcut", call => \&checkconfig);
hook(type => "preprocess", id => "shortcut", call => \&preprocess_shortcut);
} #}}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
rebuild => undef,
},
} #}}}
}
sub checkconfig () { #{{{
sub checkconfig () {
if (defined $config{srcdir}) {
# Preprocess the shortcuts page to get all the available shortcuts
# defined before other pages are rendered.
@ -29,9 +29,9 @@ sub checkconfig () { #{{{
}
IkiWiki::preprocess("shortcuts", "shortcuts", readfile($srcfile));
}
} # }}}
}
sub preprocess_shortcut (@) { #{{{
sub preprocess_shortcut (@) {
my %params=@_;
if (! defined $params{name} || ! defined $params{url}) {
@ -46,9 +46,9 @@ sub preprocess_shortcut (@) { #{{{
#translators: First parameter is the name of the shortcut, the second
#translators: is an URL.
return sprintf(gettext("shortcut %s points to <i>%s</i>"), $params{name}, $params{url});
} # }}}
}
sub shortcut_expand ($$@) { #{{{
sub shortcut_expand ($$@) {
my $url=shift;
my $desc=shift;
my %params=@_;
@ -85,6 +85,6 @@ sub shortcut_expand ($$@) { #{{{
}
return "<a href=\"$url\">$desc</a>";
} #}}}
}
1

View File

@ -8,20 +8,20 @@ use warnings;
use strict;
use IkiWiki 2.00;
sub import { #{{{
sub import {
hook(type => "getsetup", id => "sidebar", call => \&getsetup);
hook(type => "pagetemplate", id => "sidebar", call => \&pagetemplate);
} # }}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
rebuild => 1,
},
} #}}}
}
sub sidebar_content ($) { #{{{
sub sidebar_content ($) {
my $page=shift;
my $sidebar_page=bestlink($page, "sidebar") || return;
@ -42,9 +42,9 @@ sub sidebar_content ($) { #{{{
IkiWiki::filter($sidebar_page, $page, $content))));
}
} # }}}
}
sub pagetemplate (@) { #{{{
sub pagetemplate (@) {
my %params=@_;
my $page=$params{page};
@ -56,6 +56,6 @@ sub pagetemplate (@) { #{{{
$template->param(sidebar => $content);
}
}
} # }}}
}
1

View File

@ -5,21 +5,21 @@ use warnings;
use strict;
use IkiWiki 2.00;
sub import { #{{{
sub import {
hook(type => "getsetup", id => "signinedit", call => \&getsetup);
hook(type => "canedit", id => "signinedit", call => \&canedit,
last => 1);
} # }}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
rebuild => 0,
},
} #}}}
}
sub canedit ($$$) { #{{{
sub canedit ($$$) {
my $page=shift;
my $cgi=shift;
my $session=shift;
@ -34,6 +34,6 @@ sub canedit ($$$) { #{{{
else {
return "";
}
} #}}}
}
1

View File

@ -8,7 +8,7 @@ use warnings;
use strict;
use IkiWiki 2.00;
sub import { #{{{
sub import {
hook(type => "getopt", id => "skeleton", call => \&getopt);
hook(type => "getsetup", id => "skeleton", call => \&getsetup);
hook(type => "checkconfig", id => "skeleton", call => \&checkconfig);
@ -34,13 +34,13 @@ sub import { #{{{
hook(type => "formbuilder_setup", id => "skeleton", call => \&formbuilder_setup);
hook(type => "formbuilder", id => "skeleton", call => \&formbuilder);
hook(type => "savestate", id => "skeleton", call => \&savestate);
} # }}}
}
sub getopt () { #{{{
sub getopt () {
debug("skeleton plugin getopt");
} #}}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
@ -53,155 +53,155 @@ sub getsetup () { #{{{
safe => 0,
rebuild => 0,
},
} #}}}
}
sub checkconfig () { #{{{
sub checkconfig () {
debug("skeleton plugin checkconfig");
} #}}}
}
sub refresh () { #{{{
sub refresh () {
debug("skeleton plugin refresh");
} #}}}
}
sub needsbuild () { #{{{
sub needsbuild () {
debug("skeleton plugin needsbuild");
} #}}}
}
sub preprocess (@) { #{{{
sub preprocess (@) {
my %params=@_;
return "skeleton plugin result";
} # }}}
}
sub filter (@) { #{{{
sub filter (@) {
my %params=@_;
debug("skeleton plugin running as filter");
return $params{content};
} # }}}
}
sub linkify (@) { #{{{
sub linkify (@) {
my %params=@_;
debug("skeleton plugin running as linkify");
return $params{content};
} # }}}
}
sub scan (@) { #{{{a
my %params=@_;
debug("skeleton plugin running as scan");
} # }}}
}
sub htmlize (@) { #{{{
sub htmlize (@) {
my %params=@_;
debug("skeleton plugin running as htmlize");
return $params{content};
} # }}}
}
sub sanitize (@) { #{{{
sub sanitize (@) {
my %params=@_;
debug("skeleton plugin running as a sanitizer");
return $params{content};
} # }}}
}
sub postscan (@) { #{{{
sub postscan (@) {
my %params=@_;
debug("skeleton plugin running as postscan");
} # }}}
}
sub format (@) { #{{{
sub format (@) {
my %params=@_;
debug("skeleton plugin running as a formatter");
return $params{content};
} # }}}
}
sub pagetemplate (@) { #{{{
sub pagetemplate (@) {
my %params=@_;
my $page=$params{page};
my $template=$params{template};
debug("skeleton plugin running as a pagetemplate hook");
} # }}}
}
sub templatefile (@) { #{{{
sub templatefile (@) {
my %params=@_;
my $page=$params{page};
debug("skeleton plugin running as a templatefile hook");
} # }}}
}
sub delete (@) { #{{{
sub delete (@) {
my @files=@_;
debug("skeleton plugin told that files were deleted: @files");
} #}}}
}
sub change (@) { #{{{
sub change (@) {
my @files=@_;
debug("skeleton plugin told that changed files were rendered: @files");
} #}}}
}
sub cgi ($) { #{{{
sub cgi ($) {
my $cgi=shift;
debug("skeleton plugin running in cgi");
} #}}}
}
sub auth ($$) { #{{{
sub auth ($$) {
my $cgi=shift;
my $session=shift;
debug("skeleton plugin running in auth");
} #}}}
}
sub sessioncgi ($$) { #{{{
sub sessioncgi ($$) {
my $cgi=shift;
my $session=shift;
debug("skeleton plugin running in sessioncgi");
} #}}}
}
sub canedit ($$$) { #{{{
sub canedit ($$$) {
my $page=shift;
my $cgi=shift;
my $session=shift;
debug("skeleton plugin running in canedit");
} #}}}
}
sub editcontent ($$$) { #{{{
sub editcontent ($$$) {
my %params=@_;
debug("skeleton plugin running in editcontent");
return $params{content};
} #}}}
}
sub formbuilder_setup (@) { #{{{
sub formbuilder_setup (@) {
my %params=@_;
debug("skeleton plugin running in formbuilder_setup");
} # }}}
}
sub formbuilder (@) { #{{{
sub formbuilder (@) {
my %params=@_;
debug("skeleton plugin running in formbuilder");
} # }}}
}
sub savestate () { #{{{
sub savestate () {
debug("skeleton plugin running in savestate");
} #}}}
}
1

View File

@ -8,13 +8,13 @@ use IkiWiki 2.00;
my %smileys;
my $smiley_regexp;
sub import { #{{{
sub import {
add_underlay("smiley");
hook(type => "getsetup", id => "smiley", call => \&getsetup);
hook(type => "sanitize", id => "smiley", call => \&sanitize);
} # }}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
@ -22,9 +22,9 @@ sub getsetup () { #{{{
# removes the smileys, which would break links
rebuild => 1,
},
} #}}}
}
sub build_regexp () { #{{{
sub build_regexp () {
my $list=readfile(srcfile("smileys.mdwn"));
while ($list =~ m/^\s*\*\s+\\\\([^\s]+)\s+\[\[([^]]+)\]\]/mg) {
my $smiley=$1;
@ -50,9 +50,9 @@ sub build_regexp () { #{{{
$smiley_regexp='('.join('|', map { quotemeta }
reverse sort keys %smileys).')';
#debug($smiley_regexp);
} #}}}
}
sub sanitize (@) { #{{{
sub sanitize (@) {
my %params=@_;
build_regexp() unless defined $smiley_regexp;
@ -95,6 +95,6 @@ MATCH: while (m{(?:^|(?<=\s|>))(\\?)$smiley_regexp(?:(?=\s|<)|$)}g) {
}
return $_;
} # }}}
}
1

View File

@ -14,20 +14,20 @@ my %locmap=(
left => 'TEXT_LEFT',
);
sub import { #{{{
sub import {
hook(type => "getsetup", id => "sparkline", call => \&getsetup);
hook(type => "preprocess", id => "sparkline", call => \&preprocess);
} # }}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
rebuild => undef,
},
} #}}}
}
sub preprocess (@) { #{{{
sub preprocess (@) {
my %params=@_;
my $php;
@ -166,6 +166,6 @@ sub preprocess (@) { #{{{
}
return '<img src="'.urlto($fn, $params{destpage}).'" alt="graph" />';
} # }}}
}
1

View File

@ -6,7 +6,7 @@ use strict;
use IkiWiki;
use POSIX qw(setlocale LC_CTYPE);
sub import { #{{{
sub import {
hook(type => "checkconfig", id => "svn", call => \&checkconfig);
hook(type => "getsetup", id => "svn", call => \&getsetup);
hook(type => "rcs", id => "rcs_update", call => \&rcs_update);
@ -19,9 +19,9 @@ sub import { #{{{
hook(type => "rcs", id => "rcs_recentchanges", call => \&rcs_recentchanges);
hook(type => "rcs", id => "rcs_diff", call => \&rcs_diff);
hook(type => "rcs", id => "rcs_getctime", call => \&rcs_getctime);
} #}}}
}
sub checkconfig () { #{{{
sub checkconfig () {
if (! defined $config{svnpath}) {
$config{svnpath}="trunk";
}
@ -37,9 +37,9 @@ sub checkconfig () { #{{{
wrappermode => (defined $config{svn_wrappermode} ? $config{svn_wrappermode} : "04755"),
};
}
} #}}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 0, # rcs plugin
@ -87,7 +87,7 @@ sub getsetup () { #{{{
safe => 1,
rebuild => 1,
},
} #}}}
}
# svn needs LC_CTYPE set to a UTF-8 locale, so try to find one. Any will do.
sub find_lc_ctype() {
@ -107,27 +107,27 @@ sub find_lc_ctype() {
# fallback to the current locale
return $current;
} # }}}
}
$ENV{LC_CTYPE} = $ENV{LC_CTYPE} || find_lc_ctype();
sub svn_info ($$) { #{{{
sub svn_info ($$) {
my $field=shift;
my $file=shift;
my $info=`LANG=C svn info $file`;
my ($ret)=$info=~/^$field: (.*)$/m;
return $ret;
} #}}}
}
sub rcs_update () { #{{{
sub rcs_update () {
if (-d "$config{srcdir}/.svn") {
if (system("svn", "update", "--quiet", $config{srcdir}) != 0) {
warn("svn update failed\n");
}
}
} #}}}
}
sub rcs_prepedit ($) { #{{{
sub rcs_prepedit ($) {
# Prepares to edit a file under revision control. Returns a token
# that must be passed into rcs_commit when the file is ready
# for committing.
@ -140,9 +140,9 @@ sub rcs_prepedit ($) { #{{{
my $rev=svn_info("Revision", "$config{srcdir}/$file");
return defined $rev ? $rev : "";
}
} #}}}
}
sub rcs_commit ($$$;$$) { #{{{
sub rcs_commit ($$$;$$) {
# Tries to commit the page; returns undef on _success_ and
# a version of the page with the rcs's conflict markers on failure.
# The file is relative to the srcdir.
@ -185,7 +185,7 @@ sub rcs_commit ($$$;$$) { #{{{
}
}
return undef # success
} #}}}
}
sub rcs_commit_staged ($$$) {
# Commits all staged changes. Changes can be staged using rcs_add,
@ -209,7 +209,7 @@ sub rcs_commit_staged ($$$) {
return undef # success
}
sub rcs_add ($) { #{{{
sub rcs_add ($) {
# filename is relative to the root of the srcdir
my $file=shift;
@ -224,9 +224,9 @@ sub rcs_add ($) { #{{{
warn("svn add failed\n");
}
}
} #}}}
}
sub rcs_remove ($) { #{{{
sub rcs_remove ($) {
# filename is relative to the root of the srcdir
my $file=shift;
@ -235,9 +235,9 @@ sub rcs_remove ($) { #{{{
warn("svn rm failed\n");
}
}
} #}}}
}
sub rcs_rename ($$) { #{{{
sub rcs_rename ($$) {
# filenames relative to the root of the srcdir
my ($src, $dest)=@_;
@ -258,9 +258,9 @@ sub rcs_rename ($$) { #{{{
warn("svn rename failed\n");
}
}
} #}}}
}
sub rcs_recentchanges ($) { #{{{
sub rcs_recentchanges ($) {
my $num=shift;
my @ret;
@ -341,14 +341,14 @@ sub rcs_recentchanges ($) { #{{{
}
return @ret;
} #}}}
}
sub rcs_diff ($) { #{{{
sub rcs_diff ($) {
my $rev=IkiWiki::possibly_foolish_untaint(int(shift));
return `svnlook diff $config{svnrepo} -r$rev --no-diff-deleted`;
} #}}}
}
sub rcs_getctime ($) { #{{{
sub rcs_getctime ($) {
my $file=shift;
my $svn_log_infoline=qr/^r\d+\s+\|\s+[^\s]+\s+\|\s+(\d+-\d+-\d+\s+\d+:\d+:\d+\s+[-+]?\d+).*/;
@ -376,6 +376,6 @@ sub rcs_getctime ($) { #{{{
$date=str2time($date);
debug("found ctime ".localtime($date)." for $file");
return $date;
} #}}}
}
1

View File

@ -6,20 +6,20 @@ use strict;
use Encode;
use IkiWiki 2.00;
sub import { #{{{
sub import {
hook(type => "getsetup", id => "table", call => \&getsetup);
hook(type => "preprocess", id => "table", call => \&preprocess);
} # }}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
rebuild => undef,
},
} #}}}
}
sub preprocess (@) { #{{{
sub preprocess (@) {
my %params =(
format => 'auto',
header => 'row',
@ -102,16 +102,16 @@ sub preprocess (@) { #{{{
else {
return $html;
}
} #}}}
}
sub is_dsv_data ($) { #{{{
sub is_dsv_data ($) {
my $text = shift;
my ($line) = split(/\n/, $text);
return $line =~ m{.+\|};
}
sub split_csv ($$) { #{{{
sub split_csv ($$) {
my @text_lines = split(/\n/, shift);
my $delimiter = shift;
@ -137,9 +137,9 @@ sub split_csv ($$) { #{{{
}
return @data;
} #}}}
}
sub split_dsv ($$) { #{{{
sub split_dsv ($$) {
my @text_lines = split(/\n/, shift);
my $delimiter = shift;
$delimiter="|" unless defined $delimiter;
@ -150,9 +150,9 @@ sub split_dsv ($$) { #{{{
}
return @data;
} #}}}
}
sub genrow ($@) { #{{{
sub genrow ($@) {
my %params=%{shift()};
my $elt = shift;
my @data = @_;
@ -190,6 +190,6 @@ sub genrow ($@) { #{{{
push @ret, "\t\t</tr>";
return @ret;
} #}}}
}
1

View File

@ -8,22 +8,22 @@ use IkiWiki 2.00;
my %tags;
sub import { #{{{
sub import {
hook(type => "getopt", id => "tag", call => \&getopt);
hook(type => "getsetup", id => "tag", call => \&getsetup);
hook(type => "preprocess", id => "tag", call => \&preprocess_tag, scan => 1);
hook(type => "preprocess", id => "taglink", call => \&preprocess_taglink, scan => 1);
hook(type => "pagetemplate", id => "tag", call => \&pagetemplate);
} # }}}
}
sub getopt () { #{{{
sub getopt () {
eval q{use Getopt::Long};
error($@) if $@;
Getopt::Long::Configure('pass_through');
GetOptions("tagbase=s" => \$config{tagbase});
} #}}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
@ -36,9 +36,9 @@ sub getsetup () { #{{{
safe => 1,
rebuild => 1,
},
} #}}}
}
sub tagpage ($) { #{{{
sub tagpage ($) {
my $tag=shift;
if ($tag !~ m{^\.?/} &&
@ -48,18 +48,18 @@ sub tagpage ($) { #{{{
}
return $tag;
} #}}}
}
sub taglink ($$$;@) { #{{{
sub taglink ($$$;@) {
my $page=shift;
my $destpage=shift;
my $tag=shift;
my %opts=@_;
return htmllink($page, $destpage, tagpage($tag), %opts);
} #}}}
}
sub preprocess_tag (@) { #{{{
sub preprocess_tag (@) {
if (! @_) {
return "";
}
@ -77,9 +77,9 @@ sub preprocess_tag (@) { #{{{
}
return "";
} # }}}
}
sub preprocess_taglink (@) { #{{{
sub preprocess_taglink (@) {
if (! @_) {
return "";
}
@ -102,9 +102,9 @@ sub preprocess_taglink (@) { #{{{
grep {
$_ ne 'page' && $_ ne 'destpage' && $_ ne 'preview'
} keys %params);
} # }}}
}
sub pagetemplate (@) { #{{{
sub pagetemplate (@) {
my %params=@_;
my $page=$params{page};
my $destpage=$params{destpage};
@ -123,6 +123,6 @@ sub pagetemplate (@) { #{{{
sort keys %{$tags{$page}}]);
}
}
} # }}}
}
1

View File

@ -8,20 +8,20 @@ use IkiWiki 2.00;
use HTML::Template;
use Encode;
sub import { #{{{
sub import {
hook(type => "getsetup", id => "template", call => \&getsetup);
hook(type => "preprocess", id => "template", call => \&preprocess);
} # }}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
rebuild => undef,
},
} #}}}
}
sub preprocess (@) { #{{{
sub preprocess (@) {
my %params=@_;
if (! exists $params{id}) {
@ -71,6 +71,6 @@ sub preprocess (@) { #{{{
return IkiWiki::preprocess($params{page}, $params{destpage},
IkiWiki::filter($params{page}, $params{destpage},
$template->output));
} # }}}
}
1

View File

@ -5,20 +5,20 @@ use warnings;
use strict;
use IkiWiki 2.00;
sub import { #{{{
sub import {
hook(type => "getsetup", id => "testpagespec", call => \&getsetup);
hook(type => "preprocess", id => "testpagespec", call => \&preprocess);
} # }}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
rebuild => undef,
},
} #}}}
}
sub preprocess (@) { #{{{
sub preprocess (@) {
my %params=@_;
foreach my $param (qw{match pagespec}) {
@ -37,6 +37,6 @@ sub preprocess (@) { #{{{
else {
return "no match: $ret";
}
} # }}}
}
1

View File

@ -21,12 +21,12 @@ EOPREFIX
my $default_postfix = '\\end{document}';
sub import { #{{{
sub import {
hook(type => "getsetup", id => "teximg", call => \&getsetup);
hook(type => "preprocess", id => "teximg", call => \&preprocess);
} #}}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
@ -52,9 +52,9 @@ sub getsetup () { #{{{
safe => 0, # Not sure how secure LaTeX is...
rebuild => 1,
},
} #}}}
}
sub preprocess (@) { #{{{
sub preprocess (@) {
my %params = @_;
my $height = $params{height};
@ -76,9 +76,9 @@ sub preprocess (@) { #{{{
else {
error gettext("code includes disallowed latex commands")
}
} #}}}
}
sub check_height ($) { #{{{
sub check_height ($) {
# Since latex doesn't support unlimited scaling this function
# returns the closest supported size.
my $height =shift;
@ -95,9 +95,9 @@ sub check_height ($) { #{{{
}
}
return $ret;
} #}}}
}
sub create ($$$) { #{{{
sub create ($$$) {
# This function calls the image generating function and returns
# the <img .. /> for the generated image.
my $code = shift;
@ -127,9 +127,9 @@ sub create ($$$) { #{{{
else {
error qq{<a href="$logurl">}.gettext("failed to generate image from code")."</a>";
}
} #}}}
}
sub gen_image ($$$$) { #{{{
sub gen_image ($$$$) {
# Actually creates the image.
my $code = shift;
my $height = shift;
@ -180,18 +180,18 @@ sub gen_image ($$$$) { #{{{
return 0;
}
} #}}}
}
sub create_tmp_dir ($) { #{{{
sub create_tmp_dir ($) {
# Create a temp directory, it will be removed when ikiwiki exits.
my $base = shift;
my $template = $base.".XXXXXXXXXX";
my $tmpdir = tempdir($template, TMPDIR => 1, CLEANUP => 1);
return $tmpdir;
} #}}}
}
sub check ($) { #{{{
sub check ($) {
# Check if the code is ok
my $code = shift;
@ -219,6 +219,6 @@ sub check ($) { #{{{
}
}
return 1;
} #}}}
}
1

View File

@ -9,26 +9,26 @@ use strict;
use IkiWiki 2.00;
use Encode;
sub import { #{{{
sub import {
hook(type => "getsetup", id => "textile", call => \&getsetup);
hook(type => "htmlize", id => "txtl", call => \&htmlize);
} # }}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
rebuild => 1, # format plugin
},
} #}}}
}
sub htmlize (@) { #{{{
sub htmlize (@) {
my %params=@_;
my $content = decode_utf8(encode_utf8($params{content}));
eval q{use Text::Textile};
return $content if $@;
return Text::Textile::textile($content);
} # }}}
}
1

View File

@ -5,7 +5,7 @@ use warnings;
use strict;
use IkiWiki;
sub import { #{{{
sub import {
hook(type => "checkconfig", id => "tla", call => \&checkconfig);
hook(type => "getsetup", id => "tla", call => \&getsetup);
hook(type => "rcs", id => "rcs_update", call => \&rcs_update);
@ -18,18 +18,18 @@ sub import { #{{{
hook(type => "rcs", id => "rcs_recentchanges", call => \&rcs_recentchanges);
hook(type => "rcs", id => "rcs_diff", call => \&rcs_diff);
hook(type => "rcs", id => "rcs_getctime", call => \&rcs_getctime);
} #}}}
}
sub checkconfig () { #{{{
sub checkconfig () {
if (defined $config{tla_wrapper} && length $config{tla_wrapper}) {
push @{$config{wrappers}}, {
wrapper => $config{tla_wrapper},
wrappermode => (defined $config{tla_wrappermode} ? $config{tla_wrappermode} : "06755"),
};
}
} #}}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 0, # rcs plugin
@ -63,9 +63,9 @@ sub getsetup () { #{{{
safe => 1,
rebuild => 1,
},
} #}}}
}
sub quiet_system (@) { #{{{
sub quiet_system (@) {
# See Debian bug #385939.
open (SAVEOUT, ">&STDOUT");
close STDOUT;
@ -75,17 +75,17 @@ sub quiet_system (@) { #{{{
open (STDOUT, ">&SAVEOUT");
close SAVEOUT;
return $ret;
} #}}}
}
sub rcs_update () { #{{{
sub rcs_update () {
if (-d "$config{srcdir}/{arch}") {
if (quiet_system("tla", "replay", "-d", $config{srcdir}) != 0) {
warn("tla replay failed\n");
}
}
} #}}}
}
sub rcs_prepedit ($) { #{{{
sub rcs_prepedit ($) {
my $file=shift;
if (-d "$config{srcdir}/{arch}") {
@ -94,9 +94,9 @@ sub rcs_prepedit ($) { #{{{
my $rev=`tla tree-id $config{srcdir}`;
return defined $rev ? $rev : "";
}
} #}}}
}
sub rcs_commit ($$$;$$) { #{{{
sub rcs_commit ($$$;$$) {
my $file=shift;
my $message=shift;
my $rcstoken=shift;
@ -135,7 +135,7 @@ sub rcs_commit ($$$;$$) { #{{{
}
}
return undef # success
} #}}}
}
sub rcs_commit_staged ($$$) {
# Commits all staged changes. Changes can be staged using rcs_add,
@ -145,7 +145,7 @@ sub rcs_commit_staged ($$$) {
error("rcs_commit_staged not implemented for tla"); # TODO
}
sub rcs_add ($) { #{{{
sub rcs_add ($) {
my $file=shift;
if (-d "$config{srcdir}/{arch}") {
@ -153,19 +153,19 @@ sub rcs_add ($) { #{{{
warn("tla add failed\n");
}
}
} #}}}
}
sub rcs_remove ($) { # {{{
sub rcs_remove ($) {
my $file = shift;
error("rcs_remove not implemented for tla"); # TODO
} #}}}
}
sub rcs_rename ($$) { # {{{a
my ($src, $dest) = @_;
error("rcs_rename not implemented for tla"); # TODO
} #}}}
}
sub rcs_recentchanges ($) {
my $num=shift;
@ -239,7 +239,7 @@ sub rcs_recentchanges ($) {
return @ret;
}
sub rcs_diff ($) { #{{{
sub rcs_diff ($) {
my $rev=shift;
my $logs = `tla logs -d $config{srcdir}`;
my @changesets = reverse split(/\n/, $logs);
@ -251,9 +251,9 @@ sub rcs_diff ($) { #{{{
my $revminusone = $changesets[$i+1];
return `tla diff -d $config{srcdir} $revminusone`;
} #}}}
}
sub rcs_getctime ($) { #{{{
sub rcs_getctime ($) {
my $file=shift;
eval q{use Date::Parse};
error($@) if $@;
@ -281,6 +281,6 @@ sub rcs_getctime ($) { #{{{
my $date=str2time($sdate, 'UTC');
debug("found ctime ".localtime($date)." for $file");
return $date;
} #}}}
}
1

View File

@ -7,23 +7,23 @@ use strict;
use IkiWiki 2.00;
use HTML::Parser;
sub import { #{{{
sub import {
hook(type => "getsetup", id => "toc", call => \&getsetup);
hook(type => "preprocess", id => "toc", call => \&preprocess);
hook(type => "format", id => "toc", call => \&format);
} # }}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
rebuild => undef,
},
} #}}}
}
my %tocpages;
sub preprocess (@) { #{{{
sub preprocess (@) {
my %params=@_;
if ($params{page} eq $params{destpage}) {
@ -40,9 +40,9 @@ sub preprocess (@) { #{{{
# right.
return "";
}
} # }}}
}
sub format (@) { #{{{
sub format (@) {
my %params=@_;
my $content=$params{content};

View File

@ -5,7 +5,7 @@ use warnings;
use strict;
use IkiWiki 2.00;
sub import { #{{{
sub import {
add_underlay("javascript");
hook(type => "getsetup", id => "toggle", call => \&getsetup);
hook(type => "preprocess", id => "toggle",
@ -13,17 +13,17 @@ sub import { #{{{
hook(type => "preprocess", id => "toggleable",
call => \&preprocess_toggleable);
hook(type => "format", id => "toggle", call => \&format);
} # }}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
rebuild => undef,
},
} #}}}
}
sub genid ($$) { #{{{
sub genid ($$) {
my $page=shift;
my $id=shift;
@ -35,16 +35,16 @@ sub genid ($$) { #{{{
$id="id$id";
}
return $id;
} #}}}
}
sub preprocess_toggle (@) { #{{{
sub preprocess_toggle (@) {
my %params=(id => "default", text => "more", @_);
my $id=genid($params{page}, $params{id});
return "<a class=\"toggle\" href=\"#$id\">$params{text}</a>";
} # }}}
}
sub preprocess_toggleable (@) { #{{{
sub preprocess_toggleable (@) {
my %params=(id => "default", text => "", open => "no", @_);
# Preprocess the text to expand any preprocessor directives
@ -61,9 +61,9 @@ sub preprocess_toggleable (@) { #{{{
my ($indent)=$params{text}=~/( +)$/;
$indent="" unless defined $indent;
return "<div class=\"$class\" id=\"$id\"></div>\n\n$params{text}\n$indent<div class=\"toggleableend\"></div>";
} # }}}
}
sub format (@) { #{{{
sub format (@) {
my %params=@_;
if ($params{content}=~s!(<div class="toggleable(?:-open)?" id="[^"]+">\s*)</div>!$1!g) {
@ -74,9 +74,9 @@ sub format (@) { #{{{
}
}
return $params{content};
} # }}}
}
sub include_javascript ($;$) { #{{{
sub include_javascript ($;$) {
my $page=shift;
my $absolute=shift;
@ -84,6 +84,6 @@ sub include_javascript ($;$) { #{{{
'" type="text/javascript" charset="utf-8"></script>'."\n".
'<script src="'.urlto("toggle.js", $page, $absolute).
'" type="text/javascript" charset="utf-8"></script>';
} #}}}
}
1

View File

@ -24,13 +24,13 @@ sub import {
}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
rebuild => 1, # format plugin
},
} #}}}
}
# We use filter to convert raw text to HTML
# (htmlize is called after other plugins insert HTML)

View File

@ -6,20 +6,20 @@ use warnings;
use strict;
use IkiWiki 2.00;
sub import { #{{{
sub import {
hook(type => "getopt", id => "typography", call => \&getopt);
hook(type => "getsetup", id => "typography", call => \&getsetup);
IkiWiki::hook(type => "sanitize", id => "typography", call => \&sanitize);
} # }}}
}
sub getopt () { #{{{
sub getopt () {
eval q{use Getopt::Long};
error($@) if $@;
Getopt::Long::Configure('pass_through');
GetOptions("typographyattributes=s" => \$config{typographyattributes});
} #}}}
}
sub getsetup () { #{{{
sub getsetup () {
eval q{use Text::Typography};
error($@) if $@;
@ -36,9 +36,9 @@ sub getsetup () { #{{{
safe => 1,
rebuild => 1,
},
} #}}}
}
sub sanitize (@) { #{{{
sub sanitize (@) {
my %params=@_;
eval q{use Text::Typography};
@ -46,6 +46,6 @@ sub sanitize (@) { #{{{
my $attributes=defined $config{typographyattributes} ? $config{typographyattributes} : '3';
return Text::Typography::typography($params{content}, $attributes);
} # }}}
}
1

View File

@ -6,21 +6,21 @@ use warnings;
use strict;
use IkiWiki 2.00;
sub import { #{{{
sub import {
hook(type => "getsetup", id => "version", call => \&getsetup);
hook(type => "needsbuild", id => "version", call => \&needsbuild);
hook(type => "preprocess", id => "version", call => \&preprocess);
} # }}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
rebuild => undef,
},
} #}}}
}
sub needsbuild (@) { #{{{
sub needsbuild (@) {
my $needsbuild=shift;
foreach my $page (keys %pagestate) {
if (exists $pagestate{$page}{version}{shown}) {
@ -36,11 +36,11 @@ sub needsbuild (@) { #{{{
}
}
}
} # }}}
}
sub preprocess (@) { #{{{
sub preprocess (@) {
my %params=@_;
$pagestate{$params{destpage}}{version}{shown}=$IkiWiki::version;
} # }}}
}
1

View File

@ -5,15 +5,15 @@ use warnings;
use strict;
use IkiWiki 2.00;
sub import { #{{{
sub import {
hook(type => "getsetup", id => "websetup", call => \&getsetup);
hook(type => "checkconfig", id => "websetup", call => \&checkconfig);
hook(type => "sessioncgi", id => "websetup", call => \&sessioncgi);
hook(type => "formbuilder_setup", id => "websetup",
call => \&formbuilder_setup);
} # }}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 1,
@ -33,15 +33,15 @@ sub getsetup () { #{{{
safe => 0,
rebuild => 0,
},
} #}}}
}
sub checkconfig () { #{{{
sub checkconfig () {
if (! exists $config{websetup_show_unsafe}) {
$config{websetup_show_unsafe}=1;
}
} #}}}
}
sub formatexample ($$) { #{{{
sub formatexample ($$) {
my $example=shift;
my $value=shift;
@ -54,9 +54,9 @@ sub formatexample ($$) { #{{{
else {
return "";
}
} #}}}
}
sub showfields ($$$@) { #{{{
sub showfields ($$$@) {
my $form=shift;
my $plugin=shift;
my $enabled=shift;
@ -207,16 +207,16 @@ sub showfields ($$$@) { #{{{
}
return %enabledfields;
} #}}}
}
sub enable_plugin ($) { #{{{
sub enable_plugin ($) {
my $plugin=shift;
$config{disable_plugins}=[grep { $_ ne $plugin } @{$config{disable_plugins}}];
push @{$config{add_plugins}}, $plugin;
}
sub disable_plugin ($) { #{{{
sub disable_plugin ($) {
my $plugin=shift;
if (grep { $_ eq $plugin } @{$config{add_plugins}}) {
@ -227,7 +227,7 @@ sub disable_plugin ($) { #{{{
}
}
sub showform ($$) { #{{{
sub showform ($$) {
my $cgi=shift;
my $session=shift;
@ -441,9 +441,9 @@ sub showform ($$) { #{{{
}
IkiWiki::showform($form, $buttons, $session, $cgi);
} #}}}
}
sub sessioncgi ($$) { #{{{
sub sessioncgi ($$) {
my $cgi=shift;
my $session=shift;
@ -451,9 +451,9 @@ sub sessioncgi ($$) { #{{{
showform($cgi, $session);
exit;
}
} #}}}
}
sub formbuilder_setup (@) { #{{{
sub formbuilder_setup (@) {
my %params=@_;
my $form=$params{form};
@ -464,6 +464,6 @@ sub formbuilder_setup (@) { #{{{
exit;
}
}
} #}}}
}
1

View File

@ -6,27 +6,27 @@ use warnings;
use strict;
use IkiWiki 2.00;
sub import { #{{{
sub import {
hook(type => "getsetup", id => "wiki", call => \&getsetup);
hook(type => "htmlize", id => "wiki", call => \&htmlize);
} # }}}
}
sub getsetup () { #{{{
sub getsetup () {
return
plugin => {
safe => 0, # format plugin
rebuild => undef,
},
} #}}}
}
sub htmlize (@) { #{{{
sub htmlize (@) {
my %params=@_;
my $content = $params{content};
eval q{use Text::WikiFormat};
return $content if $@;
return Text::WikiFormat::format($content, undef, { implicit_links => 0 });
} # }}}
}
1

View File

@ -6,21 +6,21 @@ use warnings;
use strict;
use IkiWiki;
sub getuser () { #{{{
sub getuser () {
my $user=(getpwuid(exists $ENV{CALLER_UID} ? $ENV{CALLER_UID} : $<))[0];
if (! defined $user) {
error("cannot determine username for $<");
}
return $user;
} #}}}
}
sub trusted () { #{{{
sub trusted () {
my $user=getuser();
return ! ref $config{untrusted_committers} ||
! grep { $_ eq $user } @{$config{untrusted_committers}};
} #}}}
}
sub gen_wrapper () { #{{{
sub gen_wrapper () {
# Test for commits from untrusted committers in the wrapper, to
# avoid loading ikiwiki at all for trusted commits.
@ -43,9 +43,9 @@ EOF
}
EOF
return $ret;
} #}}}
}
sub test () { #{{{
sub test () {
exit 0 if trusted();
IkiWiki::lockwiki();
@ -130,6 +130,6 @@ sub test () { #{{{
}
exit 0;
} #}}}
}
1

View File

@ -10,7 +10,7 @@ use Encode;
my %backlinks;
my $backlinks_calculated=0;
sub calculate_backlinks () { #{{{
sub calculate_backlinks () {
return if $backlinks_calculated;
%backlinks=();
foreach my $page (keys %links) {
@ -22,9 +22,9 @@ sub calculate_backlinks () { #{{{
}
}
$backlinks_calculated=1;
} #}}}
}
sub backlinks ($) { #{{{
sub backlinks ($) {
my $page=shift;
calculate_backlinks();
@ -45,9 +45,9 @@ sub backlinks ($) { #{{{
push @links, { url => $href, page => pagetitle($p_trimmed) };
}
return @links;
} #}}}
}
sub genpage ($$) { #{{{
sub genpage ($$) {
my $page=shift;
my $content=shift;
@ -131,9 +131,9 @@ sub genpage ($$) { #{{{
});
return $content;
} #}}}
}
sub scan ($) { #{{{
sub scan ($) {
my $file=shift;
my $type=pagetype($file);
@ -165,9 +165,9 @@ sub scan ($) { #{{{
else {
will_render($file, $file, 1);
}
} #}}}
}
sub fast_file_copy (@) { #{{{
sub fast_file_copy (@) {
my $srcfile=shift;
my $destfile=shift;
my $srcfd=shift;
@ -191,7 +191,7 @@ sub fast_file_copy (@) { #{{{
}
}
sub render ($) { #{{{
sub render ($) {
my $file=shift;
my $type=pagetype($file);
@ -233,9 +233,9 @@ sub render ($) { #{{{
fast_file_copy($srcfile, $file, $srcfd, @_);
});
}
} #}}}
}
sub prune ($) { #{{{
sub prune ($) {
my $file=shift;
unlink($file);
@ -243,9 +243,9 @@ sub prune ($) { #{{{
while (rmdir($dir)) {
$dir=dirname($dir);
}
} #}}}
}
sub refresh () { #{{{
sub refresh () {
# security check, avoid following symlinks in the srcdir path by default
my $test=$config{srcdir};
while (length $test) {
@ -507,9 +507,9 @@ sub refresh () { #{{{
if (%rendered) {
run_hooks(change => sub { shift->(keys %rendered) });
}
} #}}}
}
sub commandline_render () { #{{{
sub commandline_render () {
lockwiki();
loadindex();
unlockwiki();
@ -532,6 +532,6 @@ sub commandline_render () { #{{{
print genpage($page, $content);
exit 0;
} #}}}
}
1

View File

@ -10,7 +10,7 @@ use IkiWiki;
use open qw{:utf8 :std};
use File::Spec;
sub load ($) { # {{{
sub load ($) {
my $setup=IkiWiki::possibly_foolish_untaint(shift);
$config{setupfile}=File::Spec->rel2abs($setup);
@ -27,7 +27,7 @@ sub load ($) { # {{{
eval $code;
error("$setup: ".$@) if $@;
} #}}}
}
sub merge ($) {
# Merge setup into existing config and untaint.
@ -71,9 +71,9 @@ sub merge ($) {
wrappermode => (defined $config{cgi_wrappermode} ? $config{cgi_wrappermode} : "06755"),
};
}
} #}}}
}
sub getsetup () { #{{{
sub getsetup () {
# Gets all available setup data from all plugins. Returns an
# ordered list of [plugin, setup] pairs.
my @ret;
@ -105,9 +105,9 @@ sub getsetup () { #{{{
$config{syslog}=$syslog;
return @ret;
} #}}}
}
sub dump ($) { #{{{
sub dump ($) {
my $file=IkiWiki::possibly_foolish_untaint(shift);
require IkiWiki::Setup::Standard;

View File

@ -10,20 +10,20 @@ use IkiWiki::UserInfo;
use Term::ReadLine;
use File::Path;
sub ask ($$) { #{{{
sub ask ($$) {
my ($question, $default)=@_;
my $r=Term::ReadLine->new("ikiwiki");
$r->readline($question." ", $default);
} #}}}
}
sub prettydir ($) { #{{{
sub prettydir ($) {
my $dir=shift;
$dir=~s/^\Q$ENV{HOME}\E\//~\//;
return $dir;
} #}}}
}
sub import (@) { #{{{
sub import (@) {
my $this=shift;
IkiWiki::Setup::merge({@_});
@ -142,6 +142,6 @@ sub import (@) { #{{{
print "To modify settings, edit ".prettydir($config{dumpsetup})." and then run:\n";
print " ikiwiki -setup ".prettydir($config{dumpsetup})."\n";
exit 0;
} #}}}
}
1

Some files were not shown because too many files have changed in this diff Show More