From 5e52bfb2e743138fb365cb6a63c98d836883f287 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 20 Oct 2008 15:25:45 -0400 Subject: inline: Only the last feed link was put on the page, fix this to include all feed links. So rss will be included along with atom, and pages with multiple feeds will get links added for all feeds. --- IkiWiki/Plugin/inline.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'IkiWiki/Plugin') diff --git a/IkiWiki/Plugin/inline.pm b/IkiWiki/Plugin/inline.pm index 6d88c2f15..1b1ca2ce2 100644 --- a/IkiWiki/Plugin/inline.pm +++ b/IkiWiki/Plugin/inline.pm @@ -376,7 +376,7 @@ sub preprocess_inline (@) { #{{{ genfeed("rss", $config{url}."/".$rssp, $desc, $params{guid}, $params{destpage}, @feedlist)); $toping{$params{destpage}}=1 unless $config{rebuild}; - $feedlinks{$params{destpage}}=qq{}; + $feedlinks{$params{destpage}}.=qq{}; } } if ($atom) { @@ -386,7 +386,7 @@ sub preprocess_inline (@) { #{{{ writefile($atomp, $config{destdir}, genfeed("atom", $config{url}."/".$atomp, $desc, $params{guid}, $params{destpage}, @feedlist)); $toping{$params{destpage}}=1 unless $config{rebuild}; - $feedlinks{$params{destpage}}=qq{}; + $feedlinks{$params{destpage}}.=qq{}; } } } -- cgit v1.2.3 From a2839de9362187b67b0e3a564461e272e64fd9b4 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 20 Oct 2008 18:17:03 -0400 Subject: tag: When tagpage is set, force the links created by tagging to point at the toplevel tagpage, and not closer subpages. The html links already went there, but internally the links were not recorded as absolute, which could cause confusing backlinks etc. For example, with tagbase=tags, if blog/tags/bar existed and blog/foo was tagged bar, it would link to /tags/bar. But, the link would be recorded simply as a link to tags/bar, and so later blog/tags/bar would appear to have the backlink. --- IkiWiki/Plugin/tag.pm | 2 +- debian/changelog | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) (limited to 'IkiWiki/Plugin') diff --git a/IkiWiki/Plugin/tag.pm b/IkiWiki/Plugin/tag.pm index 158657507..c4a175677 100644 --- a/IkiWiki/Plugin/tag.pm +++ b/IkiWiki/Plugin/tag.pm @@ -43,7 +43,7 @@ sub tagpage ($) { #{{{ if ($tag !~ m{^\.?/} && defined $config{tagbase}) { - $tag=$config{tagbase}."/".$tag; + $tag="/".$config{tagbase}."/".$tag; } return $tag; diff --git a/debian/changelog b/debian/changelog index 42c8a52e9..928cd8666 100644 --- a/debian/changelog +++ b/debian/changelog @@ -20,6 +20,10 @@ ikiwiki (2.68) UNRELEASED; urgency=low * inline: Only the last feed link was put on the page, fix this to include all feed links. So rss will be included along with atom, and pages with multiple feeds will get links added for all feeds. + * tag: When tagpage is set, force the links created by tagging to point at + the toplevel tagpage, and not closer subpages. The html links already went + there, but internally the links were not recorded as absolute, which could + cause confusing backlinks etc. -- Joey Hess Fri, 17 Oct 2008 20:11:02 -0400 -- cgit v1.2.3 From ee1ccfa863b9d56cf7ec987f7fee89c98c484b0b Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 20 Oct 2008 19:22:22 -0400 Subject: use relativedate as the css class for dates that should display relative --- IkiWiki/Plugin/relativedate.pm | 2 +- doc/plugins/relativedate.mdwn | 6 +++--- underlays/javascript/relativedate.js | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) (limited to 'IkiWiki/Plugin') diff --git a/IkiWiki/Plugin/relativedate.pm b/IkiWiki/Plugin/relativedate.pm index d9d8f7776..f4dba61a4 100644 --- a/IkiWiki/Plugin/relativedate.pm +++ b/IkiWiki/Plugin/relativedate.pm @@ -53,7 +53,7 @@ sub display ($;$) { #{{{ my $gmtime=decode_utf8(POSIX::strftime("%a, %d %b %Y %H:%M:%S %z", localtime($time))); - return ''. + return ''. IkiWiki::formattime($time, $format).''; } #}}} diff --git a/doc/plugins/relativedate.mdwn b/doc/plugins/relativedate.mdwn index 121bce477..32f8c798b 100644 --- a/doc/plugins/relativedate.mdwn +++ b/doc/plugins/relativedate.mdwn @@ -10,7 +10,7 @@ show the absolute date instead. Also, this plugin can be used with other plugins like [[prettydate]] that change how the absolute date is displayed. If this plugin is enabled, you may also add relative dates to pages in the -wiki, by using html elements in the "date" class. For example, this will -display as a relative date: +wiki, by using html elements in the "relativedate" class. For example, this +will display as a relative date: - Fri Oct 17 18:36:13 EDT 2008 + Fri Oct 17 18:36:13 EDT 2008 diff --git a/underlays/javascript/relativedate.js b/underlays/javascript/relativedate.js index c5e62b3cc..8e05d4065 100644 --- a/underlays/javascript/relativedate.js +++ b/underlays/javascript/relativedate.js @@ -1,4 +1,4 @@ -// Causes html elements in the 'date' and 'pagedate' classes to be displayed +// Causes html elements in the 'relativedate' class to be displayed // as relative dates. The date is parsed from the title attribute, or from // the element content. @@ -7,7 +7,7 @@ var dateElements; hook("onload", getDates); function getDates() { - dateElements = getElementsByClass('date'); + dateElements = getElementsByClass('relativedate'); for (var i = 0; i < dateElements.length; i++) { var elt = dateElements[i]; var title = elt.attributes.title; -- cgit v1.2.3 From 327adadf0443db5d240253f375e72657b6a88cfa Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 21 Oct 2008 17:03:08 -0400 Subject: disable warnings when redefining functions --- IkiWiki/Plugin/external.pm | 2 ++ 1 file changed, 2 insertions(+) (limited to 'IkiWiki/Plugin') diff --git a/IkiWiki/Plugin/external.pm b/IkiWiki/Plugin/external.pm index ba6c7d8b9..287e118f1 100644 --- a/IkiWiki/Plugin/external.pm +++ b/IkiWiki/Plugin/external.pm @@ -202,7 +202,9 @@ sub inject ($@) { #{{{ my $sub = sub { IkiWiki::Plugin::external::rpc_call($plugin, $params{call}, @_) }; + no warnings; eval qq{*$params{name}=\$sub}; + use warnings; memoize($params{name}) if $params{memoize}; return 1; } #}}} -- cgit v1.2.3 From e75818572fff5256d16221a2b065b214d8cb9f5d Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 21 Oct 2008 17:57:19 -0400 Subject: function injection overhaul Add an inject function, that can be used by plugins that want to replace one of ikiwiki's functions with their own version. (This is a scary thing that grubs through the symbol table, and replaces all exported occurances of a function with the injected version.) external: RPC functions can be injected to replace exported functions. Removed the stupid displaytime hook, and use injection instead. --- IkiWiki.pm | 46 +++++++++++++++++++++++++------------- IkiWiki/Plugin/external.pm | 8 ++++++- IkiWiki/Plugin/relativedate.pm | 4 ++-- debian/changelog | 5 +++++ doc/plugins/contrib/po.mdwn | 5 +++++ doc/plugins/write.mdwn | 50 ++++++++++++++++++++++++++++++++++++++++++ plugins/externaldemo | 10 ++++----- po/ikiwiki.pot | 14 ++++++------ 8 files changed, 111 insertions(+), 31 deletions(-) (limited to 'IkiWiki/Plugin') diff --git a/IkiWiki.pm b/IkiWiki.pm index 207ca87fb..e0454963d 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -21,6 +21,7 @@ our @EXPORT = qw(hook debug error template htmlpage add_depends pagespec_match bestlink htmllink readfile writefile pagetype srcfile pagename displaytime will_render gettext urlto targetpage add_underlay pagetitle titlepage linkpage newpagefile + inject %config %links %pagestate %wikistate %renderedfiles %pagesources %destsources); our $VERSION = 2.00; # plugin interface version, next is ikiwiki version @@ -898,23 +899,13 @@ sub abs2rel ($$) { #{{{ } #}}} sub displaytime ($;$) { #{{{ - my $time=shift; - my $format=shift; - if (exists $hooks{displaytime}) { - my $ret; - run_hooks(displaytime => sub { - $ret=shift->($time, $format) - }); - return $ret; - } - else { - return formattime($time, $format); - } + # Plugins can override this function to mark up the time to + # display. + return ''.formattime(@_).''; } #}}} sub formattime ($;$) { #{{{ - # Plugins can override this function to mark up the time for - # display. + # Plugins can override this function to format the time. my $time=shift; my $format=shift; if (! defined $format) { @@ -1676,6 +1667,31 @@ sub yesno ($) { #{{{ return (defined $val && lc($val) eq gettext("yes")); } #}}} +sub inject { #{{{ + # Injects a new function into the symbol table to replace an + # exported function. + my %params=@_; + + # This is deep ugly perl foo, beware. + no strict; + no warnings; + if (! defined $params{parent}) { + $params{parent}='::'; + $params{old}=\&{$params{name}}; + $params{name}=~s/.*:://; + } + my $parent=$params{parent}; + foreach my $ns (grep /^\w+::/, keys %{$parent}) { + $ns = $params{parent} . $ns; + inject(%params, parent => $ns) unless $ns eq '::main::'; + *{$ns . $params{name}} = $params{call} + if exists ${$ns}{$params{name}} && + \&{${$ns}{$params{name}}} == $params{old}; + } + use strict; + use warnings; +} #}}} + sub pagespec_merge ($$) { #{{{ my $a=shift; my $b=shift; @@ -1770,7 +1786,7 @@ sub pagespec_valid ($) { #{{{ my $sub=pagespec_translate($spec); return ! $@; } #}}} - + sub glob2re ($) { #{{{ my $re=quotemeta(shift); $re=~s/\\\*/.*/g; diff --git a/IkiWiki/Plugin/external.pm b/IkiWiki/Plugin/external.pm index 287e118f1..4ce9c8bab 100644 --- a/IkiWiki/Plugin/external.pm +++ b/IkiWiki/Plugin/external.pm @@ -202,10 +202,16 @@ sub inject ($@) { #{{{ my $sub = sub { IkiWiki::Plugin::external::rpc_call($plugin, $params{call}, @_) }; + $sub=memoize($sub) if $params{memoize}; + + # This will add it to the symbol table even if not present. no warnings; eval qq{*$params{name}=\$sub}; use warnings; - memoize($params{name}) if $params{memoize}; + + # This will ensure that everywhere it was exported to sees + # the injected version. + IkiWiki::inject(name => $params{name}, call => $sub); return 1; } #}}} diff --git a/IkiWiki/Plugin/relativedate.pm b/IkiWiki/Plugin/relativedate.pm index f4dba61a4..dc8f7d538 100644 --- a/IkiWiki/Plugin/relativedate.pm +++ b/IkiWiki/Plugin/relativedate.pm @@ -12,7 +12,7 @@ sub import { #{{{ add_underlay("javascript"); hook(type => "getsetup", id => "relativedate", call => \&getsetup); hook(type => "format", id => "relativedate", call => \&format); - hook(type => "displaytime", id => "relativedate", call => \&display); + inject(name => "IkiWiki::displaytime", call => \&mydisplaytime); } # }}} sub getsetup () { #{{{ @@ -43,7 +43,7 @@ sub include_javascript ($;$) { #{{{ '" type="text/javascript" charset="utf-8">'; } #}}} -sub display ($;$) { #{{{ +sub mydisplaytime ($;$) { #{{{ my $time=shift; my $format=shift; diff --git a/debian/changelog b/debian/changelog index 928cd8666..e1baea8ce 100644 --- a/debian/changelog +++ b/debian/changelog @@ -24,6 +24,11 @@ ikiwiki (2.68) UNRELEASED; urgency=low the toplevel tagpage, and not closer subpages. The html links already went there, but internally the links were not recorded as absolute, which could cause confusing backlinks etc. + * Add an inject function, that can be used by plugins that want to + replace one of ikiwiki's functions with their own version. + (This is a scary thing that grubs through the symbol table, and replaces + all exported occurances of a function with the injected version.) + * external: RPC functions can be injected to replace exported functions. -- Joey Hess Fri, 17 Oct 2008 20:11:02 -0400 diff --git a/doc/plugins/contrib/po.mdwn b/doc/plugins/contrib/po.mdwn index 30ede95a6..c4b7f9ee9 100644 --- a/doc/plugins/contrib/po.mdwn +++ b/doc/plugins/contrib/po.mdwn @@ -47,6 +47,11 @@ Any thoughts on this? >>> `targetpage`, `bestlink`, and `beautify_urlpath`. But, I noticed >>> the other day that such wrappers around exported functions are only visible by >>> plugins loaded after the plugin that defines them. +>>> +>>> Update: Take a look at the new "Function overriding" section of +>>> [[plugins/write]]. I think you can just inject wrappers about a few ikiwiki +>>> functions, rather than adding hooks. The `inject` function is pretty +>>> insane^Wlow level, but seems to work great. --[[Joey]] >> >> The Discussion pages issue is something I am not sure about yet. But I will >> probably decide that "slave" pages, being only translations, don't deserve diff --git a/doc/plugins/write.mdwn b/doc/plugins/write.mdwn index 856b34ba1..2e11e6234 100644 --- a/doc/plugins/write.mdwn +++ b/doc/plugins/write.mdwn @@ -854,6 +854,56 @@ By the way, to parse a ikiwiki setup file and populate `%config`, a program just needs to do something like: `use IkiWiki::Setup; IkiWiki::Setup::load($filename)` +### Function overriding + +Sometimes using ikiwiki's pre-defined hooks is not enough. Your plugin +may need to replace one of ikiwiki's own functions with a modified version, +or wrap one of the functions. + +For example, your plugin might want to override `displaytime`, to change +the html markup used when displaying a date. Or it might want to override +`IkiWiki::formattime`, to change how a date is formatted. Or perhaps you +want to override `bestlink` and change how ikiwiki deals with WikiLinks. + +By venturing into this territory, your plugin is becoming tightly tied to +ikiwiki's internals. And it might break if those internals change. But +don't let that stop you, if you're brave. + +Ikiwiki provides an `inject()` function, that is a powerful way to replace +any function with one of your own. This even allows you to inject a +replacement for an exported function, like `bestlink`. Everything that +imports that function will get your version instead. Pass it the name of +the function to replace, and a new function to call. + +For example, here's how to replace `displaytime` with a version using HTML 5 +markup: + + inject(name => 'IkiWiki::displaytime', call => sub { + return ""; + }); + +Here's how to wrap `bestlink` with a version that tries to handle +plural words: + + my $origbestlink=\&bestlink; + inject(name => 'IkiWiki::bestlink', call => \&mybestlink); + + sub deplural ($) { + my $word=shift; + $word =~ s/e?s$//; # just an example :-) + return $word; + } + + sub mybestlink ($$) { + my $page=shift; + my $link=shift; + my $ret=$origbestlink->($page, $link); + if (! length $ret) { + $ret=$origbestlink->($page, deplural($link)); + } + return $ret; + } + ### Javascript Some plugins use javascript to make ikiwiki look a bit more web-2.0-ish. diff --git a/plugins/externaldemo b/plugins/externaldemo index 4d13f2444..be7aba8b9 100755 --- a/plugins/externaldemo +++ b/plugins/externaldemo @@ -106,9 +106,8 @@ sub import { rpc_call("getvar", "config", "url")."\n"; # Here's an example of how to inject an arbitrary function into - # ikiwiki, replacing a core function. - # Note use of automatic memoization. - rpc_call("inject", name => "IkiWiki::formattime", + # ikiwiki. Note use of automatic memoization. + rpc_call("inject", name => "IkiWiki::bob", call => "formattime", memoize => 1); print STDERR "externaldemo plugin successfully imported\n"; @@ -126,9 +125,8 @@ sub preprocess { return "externaldemo plugin preprocessing on $title!"; } -sub formattime { - print STDERR "externaldemo plugin's formattime called via RPC"; - return scalar "formatted time: ".localtime(shift); +sub bob { + print STDERR "externaldemo plugin's bob called via RPC"; } # Now all that's left to do is loop and handle each incoming RPC request. diff --git a/po/ikiwiki.pot b/po/ikiwiki.pot index 335575f02..4452ea8dc 100644 --- a/po/ikiwiki.pot +++ b/po/ikiwiki.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2008-10-19 20:06-0400\n" +"POT-Creation-Date: 2008-10-21 17:51-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -48,7 +48,7 @@ msgstr "" msgid "You are banned." msgstr "" -#: ../IkiWiki/CGI.pm:385 ../IkiWiki/CGI.pm:386 ../IkiWiki.pm:1182 +#: ../IkiWiki/CGI.pm:385 ../IkiWiki/CGI.pm:386 ../IkiWiki.pm:1175 msgid "Error" msgstr "" @@ -913,25 +913,25 @@ msgstr "" msgid "refreshing wiki.." msgstr "" -#: ../IkiWiki.pm:458 +#: ../IkiWiki.pm:459 msgid "Must specify url to wiki with --url when using --cgi" msgstr "" -#: ../IkiWiki.pm:504 +#: ../IkiWiki.pm:505 msgid "cannot use multiple rcs plugins" msgstr "" -#: ../IkiWiki.pm:533 +#: ../IkiWiki.pm:534 #, perl-format msgid "failed to load external plugin needed for %s plugin: %s" msgstr "" -#: ../IkiWiki.pm:1165 +#: ../IkiWiki.pm:1158 #, perl-format msgid "preprocessing loop detected on %s at depth %i" msgstr "" -#: ../IkiWiki.pm:1674 +#: ../IkiWiki.pm:1667 msgid "yes" msgstr "" -- cgit v1.2.3 From 094af3d113f375f7faf2abf283615582a9977a65 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 22 Oct 2008 20:52:34 -0400 Subject: initial support for git repos with untrusted committers Still need to wire up the calls to check_* , but it's cold out here and my hands are going numb, so enough for now. --- IkiWiki.pm | 11 +++++ IkiWiki/Plugin/git.pm | 115 ++++++++++++++++++++++++++++++++++++++++++++----- doc/plugins/write.mdwn | 9 ++++ doc/rcs/details.mdwn | 3 ++ doc/rcs/git.mdwn | 27 ++++++++++++ ikiwiki.in | 3 ++ 6 files changed, 158 insertions(+), 10 deletions(-) (limited to 'IkiWiki/Plugin') diff --git a/IkiWiki.pm b/IkiWiki.pm index e0454963d..245eaafba 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -382,6 +382,13 @@ sub getsetup () { #{{{ safe => 0, rebuild => 0, }, + test_receive => { + type => "internal", + default => 0, + description => "running in receive test mode", + safe => 0, + rebuild => 0, + }, getctime => { type => "internal", default => 0, @@ -1575,6 +1582,10 @@ sub rcs_getctime ($) { #{{{ $hooks{rcs}{rcs_getctime}{call}->(@_); } #}}} +sub rcs_test_receive ($) { #{{{ + $hooks{rcs}{rcs_test_receive}{call}->(@_); +} #}}} + sub globlist_to_pagespec ($) { #{{{ my @globlist=split(' ', shift); diff --git a/IkiWiki/Plugin/git.pm b/IkiWiki/Plugin/git.pm index 14b0ab285..1facb14c0 100644 --- a/IkiWiki/Plugin/git.pm +++ b/IkiWiki/Plugin/git.pm @@ -23,6 +23,7 @@ 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); + hook(type => "rcs", id => "rcs_test_receive", call => \&rcs_test_receive); } #}}} sub checkconfig () { #{{{ @@ -32,12 +33,21 @@ sub checkconfig () { #{{{ if (! defined $config{gitmaster_branch}) { $config{gitmaster_branch}="master"; } - if (defined $config{git_wrapper} && length $config{git_wrapper}) { + if (defined $config{git_wrapper} && + length $config{git_wrapper}) { push @{$config{wrappers}}, { wrapper => $config{git_wrapper}, wrappermode => (defined $config{git_wrappermode} ? $config{git_wrappermode} : "06755"), }; } + if (defined $config{git_test_receive_wrapper} && + length $config{git_test_receive_wrapper}) { + push @{$config{wrappers}}, { + test_receive => 1, + wrapper => $config{git_test_receive_wrapper}, + wrappermode => "0755", + }; + } } #}}} sub getsetup () { #{{{ @@ -60,6 +70,20 @@ sub getsetup () { #{{{ safe => 0, rebuild => 0, }, + git_test_receive_wrapper => { + type => "string", + example => "/git/wiki.git/hooks/pre-receive", + description => "git pre-receive hook to generate", + safe => 0, # file + rebuild => 0, + }, + git_untrusted_committers => { + type => "string", + example => [], + description => "unix users whose commits should be checked by the pre-receive hook", + safe => 0, + rebuild => 0, + }, historyurl => { type => "string", example => "http://git.example.com/gitweb.cgi?p=wiki.git;a=history;f=[[file]]", @@ -320,6 +344,9 @@ sub parse_diff_tree ($@) { #{{{ 'file' => decode("utf8", $file), 'sha1_from' => $sha1_from[0], 'sha1_to' => $sha1_to, + 'mode_from' => $mode_from[0], + 'mode_to' => $mode_to, + 'status' => $status, }; } next; @@ -331,14 +358,12 @@ sub parse_diff_tree ($@) { #{{{ } #}}} sub git_commit_info ($;$) { #{{{ - # Return an array of commit info hashes of num commits (default: 1) + # Return an array of commit info hashes of num commits # starting from the given sha1sum. - my ($sha1, $num) = @_; - $num ||= 1; - - my @raw_lines = run_or_die('git', 'log', "--max-count=$num", + my @raw_lines = run_or_die('git', 'log', + (defined $num ? "--max-count=$num" : ""), '--pretty=raw', '--raw', '--abbrev=40', '--always', '-c', '-r', $sha1, '--', '.'); my ($prefix) = run_or_die('git', 'rev-parse', '--show-prefix'); @@ -355,7 +380,6 @@ sub git_commit_info ($;$) { #{{{ sub git_sha1 (;$) { #{{{ # Return head sha1sum (of given file). - my $file = shift || q{--}; # Ignore error since a non-existing file might be given. @@ -378,7 +402,6 @@ sub rcs_update () { #{{{ 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); @@ -475,7 +498,7 @@ sub rcs_recentchanges ($) { #{{{ error($@) if $@; my @rets; - foreach my $ci (git_commit_info('HEAD', $num)) { + foreach my $ci (git_commit_info('HEAD', $num || 1)) { # Skip redundant commits. next if ($ci->{'comment'} && @{$ci->{'comment'}}[0] eq $dummy_commit_msg); @@ -558,11 +581,83 @@ sub rcs_getctime ($) { #{{{ $file =~ s/^\Q$config{srcdir}\E\/?//; my $sha1 = git_sha1($file); - my $ci = git_commit_info($sha1); + my $ci = git_commit_info($sha1, 1); my $ctime = $ci->{'author_epoch'}; debug("ctime for '$file': ". localtime($ctime)); return $ctime; } #}}} +sub rcs_test_receive () { #{{{ + # quick success if the user is trusted + my $committer=(getpwuid($<))[0]; + if (! defined $committer) { + error("cannot determine username for $<"); + } + exit 0 if ! ref $config{git_untrusted_committers} || + ! grep { $_ eq $committer } @{$config{git_untrusted_committers}}; + + # 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. + my $subdir=""; + my $dir=$config{srcdir}; + while (! -d "$dir/.git") { + $subdir=IkiWiki::basename($dir)."/".$subdir; + $dir=IkiWiki::dirname($dir); + if (! length $dir) { + error("cannot determine root of git repo"); + } + } + + my @errors; + while (<>) { + chomp; + my ($oldrev, $newrev, $refname) = split(' ', $_, 3); + + # only allow changes to gitmaster_branch + if ($refname !~ /^refs\/heads\/\Q$config{gitmaster_branch}\E$/) { + push @errors, sprintf(gettext("you are not allowed to change %s"), $refname); + } + + foreach my $ci (git_commit_info($oldrev."..".$newrev)) { + foreach my $detail (@{ $ci->{'details'} }) { + my $file = $detail->{'file'}; + + # check that all changed files are in the subdir + if (length $subdir && + ! ($file =~ s/^\Q$subdir\E//)) { + push @errors, sprintf(gettext("you are not allowed to change %s"), $file); + next; + } + + if ($detail->{'mode_from'} ne $detail->{'mode_to'}) { + push @errors, gettext("you are not allowed to change file modes"); + } + + if ($detail->{'status'} =~ /^D+\d*/) { + # TODO check_canremove + } + elsif ($detail->{'status'} !~ /^[MA]+\d*$/) { + push @errors, "unknown status ".$detail->{'status'}; + } + else { + # TODO check_canedit + # TODO check_canattach + } + } + } + } + + if (@errors) { + # TODO clean up objects from failed push + + print STDERR "$_\n" foreach @errors; + exit 1; + } + else { + exit 0; + } +} #}}} + 1 diff --git a/doc/plugins/write.mdwn b/doc/plugins/write.mdwn index 0d244e1f5..5a5db6be0 100644 --- a/doc/plugins/write.mdwn +++ b/doc/plugins/write.mdwn @@ -820,6 +820,15 @@ it up in the history. It's ok if this is not implemented, and throws an error. +#### `rcs_test_receive()` + +This is used to test if changes pushed into the RCS should be accepted. +Ikiwiki will be running as a pre-receive hook (or equivilant) and should +examine the incoming changes, decide if they are allowed, and communicate +that to the RCS. + +This is optional, and doesn't make sense for all RCSs. + ### PageSpec plugins It's also possible to write plugins that add new functions to diff --git a/doc/rcs/details.mdwn b/doc/rcs/details.mdwn index e62f3ef49..089221cab 100644 --- a/doc/rcs/details.mdwn +++ b/doc/rcs/details.mdwn @@ -280,6 +280,9 @@ Here is a how a commit from a remote repository works: * git-commit in the remote repository * git-push, pushes the commit to the master repo on the server +* (Optionally, the master repo's pre-receive hook runs, and checks that the + update only modifies files that the pushing user is allowed to update. + If not, it aborts the receive.) * the master repo's post-update hook notices this update, and runs ikiwiki * ikiwiki notices the modifies page source, and compiles it diff --git a/doc/rcs/git.mdwn b/doc/rcs/git.mdwn index b210af825..2a6feecf5 100644 --- a/doc/rcs/git.mdwn +++ b/doc/rcs/git.mdwn @@ -100,6 +100,33 @@ repository, should only be writable by the wiki's admin, and *not* by the group. Take care that ikiwiki uses a umask that does not cause files in the srcdir to become group writable. (umask 022 will work.) +## git repository with untrusted committers + +By default, anyone who can commit to the git repository can modify any file +on the wiki however they like. A `pre-receive` hook can be set up to limit +incoming commits from untrusted users. Then the same limits that are placed +on edits via the web will be in effect for commits to git for the users. +They will not be allowed to edit locked pages, they will only be able to +delete pages that the [[plugins/remove]] configuration allows them to +remove, and they will only be allowed to add non-page attachments that the +[[plugins/attachment]] configuration allows. + +To enable this, you need to set up the git repository to have multiple +committers. Trusted committers, including the user that ikiwiki runs as, +will not have their commits checked by the `pre-receive` hook. Untrusted +committers will have their commits checked. The configuration settings to +enable are `git_test_receive_wrapper`, which enables generation of a +`pre-receive` hook, and `git_untrusted_committers`, which is a list of +usernames of the untrusted committers. + +Note that when the `pre-receive` hook is checking incoming changes, it +ignores the git authorship information, and uses the username of the unix +user who made the commit. Then tests including the `locked_pages` [[PageSpec]] +are checked to see if that user can edit the pages in the commit. + +You can even set up an anonymous user, to allow anyone to push +changes in via git rather than using the web interface. + ## Optionally using a local wiki to preview changes When working on the "working clones" to add content to your wiki, diff --git a/ikiwiki.in b/ikiwiki.in index 4f24cfc2e..873bde0df 100755 --- a/ikiwiki.in +++ b/ikiwiki.in @@ -183,6 +183,9 @@ sub main () { #{{{ elsif ($config{post_commit} && ! commit_hook_enabled()) { # do nothing } + elsif ($config{test_receive}) { + rcs_test_receive(); + } else { if ($config{rebuild}) { debug(gettext("rebuilding wiki..")); -- cgit v1.2.3 From 4669eab596c8d90de0cf9f9d359ad8dd8f48edb5 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 23 Oct 2008 16:29:50 -0400 Subject: more work on untrusted committers Wired up check_canedit and check_canremove, still need to deal with check_canattach, and test. --- IkiWiki.pm | 4 +- IkiWiki/Plugin/editpage.pm | 2 +- IkiWiki/Plugin/git.pm | 70 ++++++++++++++++--------------- IkiWiki/Plugin/remove.pm | 2 +- IkiWiki/Receive.pm | 101 +++++++++++++++++++++++++++++++++++++++++++++ doc/plugins/write.mdwn | 24 ++++++++--- doc/rcs/git.mdwn | 2 +- ikiwiki.in | 10 ++++- 8 files changed, 168 insertions(+), 47 deletions(-) create mode 100644 IkiWiki/Receive.pm (limited to 'IkiWiki/Plugin') diff --git a/IkiWiki.pm b/IkiWiki.pm index 245eaafba..698244187 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -1582,8 +1582,8 @@ sub rcs_getctime ($) { #{{{ $hooks{rcs}{rcs_getctime}{call}->(@_); } #}}} -sub rcs_test_receive ($) { #{{{ - $hooks{rcs}{rcs_test_receive}{call}->(@_); +sub rcs_receive ($) { #{{{ + $hooks{rcs}{rcs_receive}{call}->(@_); } #}}} sub globlist_to_pagespec ($) { #{{{ diff --git a/IkiWiki/Plugin/editpage.pm b/IkiWiki/Plugin/editpage.pm index 30c93df20..fe2864bac 100644 --- a/IkiWiki/Plugin/editpage.pm +++ b/IkiWiki/Plugin/editpage.pm @@ -122,7 +122,7 @@ sub cgi_editpage ($$) { #{{{ my $absolute=($page =~ s#^/+##); if (! defined $page || ! length $page || file_pruned($page, $config{srcdir})) { - error("bad page name"); + error(gettext("bad page name")); } my $baseurl = urlto($page, undef, 1); diff --git a/IkiWiki/Plugin/git.pm b/IkiWiki/Plugin/git.pm index 1facb14c0..234e7af2e 100644 --- a/IkiWiki/Plugin/git.pm +++ b/IkiWiki/Plugin/git.pm @@ -23,7 +23,7 @@ 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); - hook(type => "rcs", id => "rcs_test_receive", call => \&rcs_test_receive); + hook(type => "rcs", id => "rcs_receive", call => \&rcs_receive); } #}}} sub checkconfig () { #{{{ @@ -77,7 +77,7 @@ sub getsetup () { #{{{ safe => 0, # file rebuild => 0, }, - git_untrusted_committers => { + untrusted_committers => { type => "string", example => [], description => "unix users whose commits should be checked by the pre-receive hook", @@ -588,15 +588,7 @@ sub rcs_getctime ($) { #{{{ return $ctime; } #}}} -sub rcs_test_receive () { #{{{ - # quick success if the user is trusted - my $committer=(getpwuid($<))[0]; - if (! defined $committer) { - error("cannot determine username for $<"); - } - exit 0 if ! ref $config{git_untrusted_committers} || - ! grep { $_ eq $committer } @{$config{git_untrusted_committers}}; - +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. @@ -610,54 +602,64 @@ sub rcs_test_receive () { #{{{ } } - my @errors; + my @rets; while (<>) { chomp; my ($oldrev, $newrev, $refname) = split(' ', $_, 3); # only allow changes to gitmaster_branch if ($refname !~ /^refs\/heads\/\Q$config{gitmaster_branch}\E$/) { - push @errors, sprintf(gettext("you are not allowed to change %s"), $refname); + error sprintf(gettext("you are not allowed to change %s"), $refname); } foreach my $ci (git_commit_info($oldrev."..".$newrev)) { foreach my $detail (@{ $ci->{'details'} }) { my $file = $detail->{'file'}; - # check that all changed files are in the subdir + # check that all changed files are in the + # subdir if (length $subdir && ! ($file =~ s/^\Q$subdir\E//)) { - push @errors, sprintf(gettext("you are not allowed to change %s"), $file); - next; + error sprintf(gettext("you are not allowed to change %s"), $file); } - if ($detail->{'mode_from'} ne $detail->{'mode_to'}) { - push @errors, gettext("you are not allowed to change file modes"); + my $action; + my $mode; + if ($detail->{'status'} =~ /^[M]+\d*$/) { + $action="change"; + $mode=$detail->{'mode_to'}; } - - if ($detail->{'status'} =~ /^D+\d*/) { - # TODO check_canremove + elsif ($detail->{'status'} =~ /^[AM]+\d*$/) { + $action="add"; + $mode=$detail->{'mode_to'}; } - elsif ($detail->{'status'} !~ /^[MA]+\d*$/) { - push @errors, "unknown status ".$detail->{'status'}; + elsif ($detail->{'status'} =~ /^[DAM]+\d*/) { + $action="remove"; + $mode=$detail->{'mode_from'}; } else { - # TODO check_canedit - # TODO check_canattach + error "unknown status ".$detail->{'status'}; } + + # test that the file mode is ok + if ($mode !~ /^100[64][64][64]$/) { + error sprintf(gettext("you cannot act on a file with mode %s"), $mode); + } + if ($action eq "change") { + if ($detail->{'mode_from'} ne $detail->{'mode_to'}) { + error gettext("you are not allowed to change file modes"); + } + } + + push @rets, { + file => $file, + action => $action, + }; } } } - if (@errors) { - # TODO clean up objects from failed push - - print STDERR "$_\n" foreach @errors; - exit 1; - } - else { - exit 0; - } + return @rets; } #}}} 1 diff --git a/IkiWiki/Plugin/remove.pm b/IkiWiki/Plugin/remove.pm index 68bf9d1ee..c512b3b97 100644 --- a/IkiWiki/Plugin/remove.pm +++ b/IkiWiki/Plugin/remove.pm @@ -41,7 +41,7 @@ sub check_canremove ($$$) { #{{{ error(sprintf(gettext("%s is not a file"), $file)); } - # Must be editiable. + # Must be editable. IkiWiki::check_canedit($page, $q, $session); # If a user can't upload an attachment, don't let them delete it. diff --git a/IkiWiki/Receive.pm b/IkiWiki/Receive.pm new file mode 100644 index 000000000..63944bb81 --- /dev/null +++ b/IkiWiki/Receive.pm @@ -0,0 +1,101 @@ +#!/usr/bin/perl + +package IkiWiki::Receive; + +use warnings; +use strict; +use IkiWiki; + +sub getuser () { #{{{ + my $user=(getpwuid($<))[0]; + if (! defined $user) { + error("cannot determine username for $<"); + } + return $user; +} #}}} + +sub trusted () { #{{{ + my $user=getuser(); + return ! ref $config{untrusted_committers} || + ! grep { $_ eq $user } @{$config{untrusted_committers}}; +} #}}} + +sub test () { #{{{ + exit 0 if trusted(); + IkiWiki::rcs_test_receive(); + + # Dummy up a cgi environment to use when calling check_canedit + # and friends. + eval q{use CGI}; + error($@) if $@; + my $cgi=CGI->new; + require IkiWiki::CGI; + my $session=IkiWiki::cgi_getsession($cgi); + my $user=getuser(); + $session->param("name", $user); + $ENV{REMOTE_ADDR}='unknown' unless exists $ENV{REMOTE_ADDR}; + + lockwiki(); + loadindex(); + + my %newfiles; + + foreach my $change (IkiWiki::rcs_receive()) { + # This untaint is safe because we check file_pruned and + # wiki_file_regexp. + my $file=$change->{file}=~/$config{wiki_file_regexp}/; + $file=possibly_foolish_untaint($file); + if (! defined $file || ! length $file || + IkiWiki::file_pruned($file, $config{srcdir})) { + error(gettext("bad file name")); + } + + my $type=pagetype($file); + my $page=pagename($file) if defined $type; + + if ($change->{action} eq 'add') { + $newfiles{$file}=1; + } + + if ($change->{action} eq 'change' || + $change->{action} eq 'add') { + if (defined $page) { + if (IkiWiki->can("check_canedit") && + IkiWiki::check_canedit($page, $cgi, $session)) { + next; + } + } + else { + # TODO + #if (IkiWiki::Plugin::attachment->can("check_canattach") && + # IkiWiki::Plugin::attachment::check_canattach($session, $file, $path)) { + # next; + #} + } + } + elsif ($change->{action} eq 'remove') { + # check_canremove tests to see if the file is present + # on disk. This will fail is a single commit adds a + # file and then removes it again. Avoid the problem + # by not testing the removal in such pairs of changes. + # (The add is still tested, just to make sure that + # no data is added to the repo that a web edit + # could add.) + next if $newfiles{$file}; + + if (IkiWiki::Plugin::remove->can("check_canremove") && + IkiWiki::Plugin::remove::check_canremove(defined $page ? $page : $file, $cgi, $session)) { + next; + } + } + else { + error "unknown action ".$change->{action}; + } + + error sprintf(gettext("you are not allowed to change %s"), $file); + } + + exit 0; +} #}}} + +1 diff --git a/doc/plugins/write.mdwn b/doc/plugins/write.mdwn index 5a5db6be0..9f096e4f7 100644 --- a/doc/plugins/write.mdwn +++ b/doc/plugins/write.mdwn @@ -820,14 +820,26 @@ it up in the history. It's ok if this is not implemented, and throws an error. -#### `rcs_test_receive()` +#### `rcs_receive()` -This is used to test if changes pushed into the RCS should be accepted. -Ikiwiki will be running as a pre-receive hook (or equivilant) and should -examine the incoming changes, decide if they are allowed, and communicate -that to the RCS. +This is called when ikiwiki is running as a pre-receive hook (or +equivilant), and is testing if changes pushed into the RCS from an +untrusted user should be accepted. This is optional, and doesn't make +sense to implement for all RCSs. -This is optional, and doesn't make sense for all RCSs. +It should examine the incoming changes, and do any sanity +checks that are appropriate for the RCS to limit changes to safe file adds, +removes, and renames. If something bad is found, it should exit +nonzero, to abort the push. Otherwise, it should return a list of +files that were changed, in the form: + + { + file => # name of file that was changed + action => # either "add", "change", or "remove" + } + +The list will then be checked to make sure that each change is one that +is allowed to be made via the web interface. ### PageSpec plugins diff --git a/doc/rcs/git.mdwn b/doc/rcs/git.mdwn index 2a6feecf5..6ba0da894 100644 --- a/doc/rcs/git.mdwn +++ b/doc/rcs/git.mdwn @@ -116,7 +116,7 @@ committers. Trusted committers, including the user that ikiwiki runs as, will not have their commits checked by the `pre-receive` hook. Untrusted committers will have their commits checked. The configuration settings to enable are `git_test_receive_wrapper`, which enables generation of a -`pre-receive` hook, and `git_untrusted_committers`, which is a list of +`pre-receive` hook, and `untrusted_committers`, which is a list of usernames of the untrusted committers. Note that when the `pre-receive` hook is checking incoming changes, it diff --git a/ikiwiki.in b/ikiwiki.in index 22addb463..60663bc89 100755 --- a/ikiwiki.in +++ b/ikiwiki.in @@ -119,10 +119,15 @@ sub getconfig () { #{{{ } delete $ENV{WRAPPED_OPTIONS}; - # optimisation for no-op post_commit if ($config{post_commit} && ! commit_hook_enabled()) { + # optimisation for no-op post_commit exit 0; } + elsif ($config{test_receive}) { + # quick success if the user is trusted + require IkiWiki::Receive; + exit 0 if IkiWiki::Receive::trusted(); + } loadplugins(); checkconfig(); @@ -190,7 +195,8 @@ sub main () { #{{{ # do nothing } elsif ($config{test_receive}) { - rcs_test_receive(); + require IkiWiki::Receive; + IkiWiki::Receive::test(); } else { if ($config{rebuild}) { -- cgit v1.2.3 From ad9e443f22a139c71f0cd05885cda3e418f27567 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 23 Oct 2008 16:56:40 -0400 Subject: check_canattach hooked up --- IkiWiki/Plugin/git.pm | 33 ++++++++++++++++++++++++++------- IkiWiki/Receive.pm | 9 ++++----- doc/plugins/write.mdwn | 5 ++++- 3 files changed, 34 insertions(+), 13 deletions(-) (limited to 'IkiWiki/Plugin') diff --git a/IkiWiki/Plugin/git.pm b/IkiWiki/Plugin/git.pm index 234e7af2e..bdac6f7a1 100644 --- a/IkiWiki/Plugin/git.pm +++ b/IkiWiki/Plugin/git.pm @@ -9,6 +9,7 @@ use open qw{:utf8 :std}; 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 { #{{{ hook(type => "checkconfig", id => "git", call => \&checkconfig); @@ -127,8 +128,10 @@ sub safe_git (&@) { #{{{ if (!$pid) { # In child. # Git commands want to be in wc. - chdir $config{srcdir} - or error("Cannot chdir to $config{srcdir}: $!"); + if (! $no_chdir) { + chdir $config{srcdir} + or error("Cannot chdir to $config{srcdir}: $!"); + } exec @cmdline or error("Cannot exec '@cmdline': $!"); } # In parent. @@ -606,13 +609,20 @@ sub rcs_receive () { #{{{ while (<>) { chomp; my ($oldrev, $newrev, $refname) = split(' ', $_, 3); - + # only allow changes to gitmaster_branch if ($refname !~ /^refs\/heads\/\Q$config{gitmaster_branch}\E$/) { error sprintf(gettext("you are not allowed to change %s"), $refname); } - - foreach my $ci (git_commit_info($oldrev."..".$newrev)) { + + # Avoid chdir when running git here, because the changes + # are in the master git repo, not the srcdir repo. + # The pre-recieve hook already puts us in the right place. + $no_chdir=1; + my @changes=git_commit_info($oldrev."..".$newrev); + $no_chdir=0; + + foreach my $ci (@changes) { foreach my $detail (@{ $ci->{'details'} }) { my $file = $detail->{'file'}; @@ -623,8 +633,7 @@ sub rcs_receive () { #{{{ error sprintf(gettext("you are not allowed to change %s"), $file); } - my $action; - my $mode; + my ($action, $mode, $path); if ($detail->{'status'} =~ /^[M]+\d*$/) { $action="change"; $mode=$detail->{'mode_to'}; @@ -632,6 +641,15 @@ sub rcs_receive () { #{{{ elsif ($detail->{'status'} =~ /^[AM]+\d*$/) { $action="add"; $mode=$detail->{'mode_to'}; + if (! pagetype($file)) { + eval q{use File::Temp}; + die $@ if $@; + my $fh; + ($fh, $path)=tempfile("XXXXXXXXXX", UNLINK => 1); + if (system("git show ".$detail->{sha1_to}." > '$path'") != 0) { + error("failed writing temp file"); + } + } } elsif ($detail->{'status'} =~ /^[DAM]+\d*/) { $action="remove"; @@ -654,6 +672,7 @@ sub rcs_receive () { #{{{ push @rets, { file => $file, action => $action, + path => $path, }; } } diff --git a/IkiWiki/Receive.pm b/IkiWiki/Receive.pm index 63944bb81..4d437cf78 100644 --- a/IkiWiki/Receive.pm +++ b/IkiWiki/Receive.pm @@ -66,11 +66,10 @@ sub test () { #{{{ } } else { - # TODO - #if (IkiWiki::Plugin::attachment->can("check_canattach") && - # IkiWiki::Plugin::attachment::check_canattach($session, $file, $path)) { - # next; - #} + if (IkiWiki::Plugin::attachment->can("check_canattach") && + IkiWiki::Plugin::attachment::check_canattach($session, $file, $change->{path})) { + next; + } } } elsif ($change->{action} eq 'remove') { diff --git a/doc/plugins/write.mdwn b/doc/plugins/write.mdwn index 9f096e4f7..7fbe4bd57 100644 --- a/doc/plugins/write.mdwn +++ b/doc/plugins/write.mdwn @@ -829,13 +829,16 @@ sense to implement for all RCSs. It should examine the incoming changes, and do any sanity checks that are appropriate for the RCS to limit changes to safe file adds, -removes, and renames. If something bad is found, it should exit +removes, and changes. If something bad is found, it should exit nonzero, to abort the push. Otherwise, it should return a list of files that were changed, in the form: { file => # name of file that was changed action => # either "add", "change", or "remove" + path => # temp file containing the new file content, only + # needed for "add", and only if the file is an + # attachment, not a page } The list will then be checked to make sure that each change is one that -- cgit v1.2.3 From 85f4b99710fa94b9b67cee061c37eaf49be36b25 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 23 Oct 2008 18:05:57 -0400 Subject: untrusted committers code seems to be fully working Still need to investigate possible races, and test some more. --- IkiWiki.pm | 4 ++-- IkiWiki/Plugin/git.pm | 10 ++++++---- debian/changelog | 2 ++ ikiwiki.in | 3 ++- 4 files changed, 12 insertions(+), 7 deletions(-) (limited to 'IkiWiki/Plugin') diff --git a/IkiWiki.pm b/IkiWiki.pm index 698244187..1a55945a8 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -1582,8 +1582,8 @@ sub rcs_getctime ($) { #{{{ $hooks{rcs}{rcs_getctime}{call}->(@_); } #}}} -sub rcs_receive ($) { #{{{ - $hooks{rcs}{rcs_receive}{call}->(@_); +sub rcs_receive () { #{{{ + $hooks{rcs}{rcs_receive}{call}->(); } #}}} sub globlist_to_pagespec ($) { #{{{ diff --git a/IkiWiki/Plugin/git.pm b/IkiWiki/Plugin/git.pm index bdac6f7a1..e565f6369 100644 --- a/IkiWiki/Plugin/git.pm +++ b/IkiWiki/Plugin/git.pm @@ -365,8 +365,10 @@ sub git_commit_info ($;$) { #{{{ # starting from the given sha1sum. my ($sha1, $num) = @_; - my @raw_lines = run_or_die('git', 'log', - (defined $num ? "--max-count=$num" : ""), + my @opts; + push @opts, "--max-count=$num" if defined $num; + + my @raw_lines = run_or_die('git', 'log', @opts, '--pretty=raw', '--raw', '--abbrev=40', '--always', '-c', '-r', $sha1, '--', '.'); my ($prefix) = run_or_die('git', 'rev-parse', '--show-prefix'); @@ -645,7 +647,7 @@ sub rcs_receive () { #{{{ eval q{use File::Temp}; die $@ if $@; my $fh; - ($fh, $path)=tempfile("XXXXXXXXXX", UNLINK => 1); + ($fh, $path)=File::Temp::tempfile("XXXXXXXXXX", UNLINK => 1); if (system("git show ".$detail->{sha1_to}." > '$path'") != 0) { error("failed writing temp file"); } @@ -678,7 +680,7 @@ sub rcs_receive () { #{{{ } } - return @rets; + return reverse @rets; } #}}} 1 diff --git a/debian/changelog b/debian/changelog index 49bd85447..d8e26e4c9 100644 --- a/debian/changelog +++ b/debian/changelog @@ -33,6 +33,8 @@ ikiwiki (2.68) UNRELEASED; urgency=low * Updated Danish translation from Jonas Smedegaard. Closes: #503117 * Optimise the no-op post-commit hook in the web edit case by skipping loading plugins. (Particularly a win when using external plugins.) + * Add support for checking pushes from untrusted git committers. This can be + used to set up anonymous git pushes, and other similar things. -- Joey Hess Fri, 17 Oct 2008 20:11:02 -0400 diff --git a/ikiwiki.in b/ikiwiki.in index 60663bc89..d601d2739 100755 --- a/ikiwiki.in +++ b/ikiwiki.in @@ -156,7 +156,8 @@ sub main () { #{{{ if exists $config{setupsyslog}; delete @config{qw(setupsyslog setupverbose wrappers genwrappers rebuild)}; checkconfig(); - if (! $config{cgi} && ! $config{post_commit}) { + if (! $config{cgi} && ! $config{post_commit} && + ! $config{test_receive}) { $config{post_commit}=1; } gen_wrapper(); -- cgit v1.2.3 From 0196e1f9fcfebbf904e59c029e494cb2186793e6 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 24 Oct 2008 13:29:41 -0400 Subject: updates --- IkiWiki/Plugin/git.pm | 2 +- doc/plugins/pingee.mdwn | 2 +- doc/users/xma/discussion.mdwn | 2 ++ 3 files changed, 4 insertions(+), 2 deletions(-) (limited to 'IkiWiki/Plugin') diff --git a/IkiWiki/Plugin/git.pm b/IkiWiki/Plugin/git.pm index e565f6369..3a8476e7d 100644 --- a/IkiWiki/Plugin/git.pm +++ b/IkiWiki/Plugin/git.pm @@ -619,7 +619,7 @@ sub rcs_receive () { #{{{ # Avoid chdir when running git here, because the changes # are in the master git repo, not the srcdir repo. - # The pre-recieve hook already puts us in the right place. + # The pre-receive hook already puts us in the right place. $no_chdir=1; my @changes=git_commit_info($oldrev."..".$newrev); $no_chdir=0; diff --git a/doc/plugins/pingee.mdwn b/doc/plugins/pingee.mdwn index d012004f9..6156c235f 100644 --- a/doc/plugins/pingee.mdwn +++ b/doc/plugins/pingee.mdwn @@ -3,7 +3,7 @@ This plugin causes ikiwiki to listen for pings, typically delivered from another ikiwiki instance using the [[pinger]] plugin. When a ping is -recieved, ikiwiki will update the wiki, the same as if `ikiwiki --refresh` +received, ikiwiki will update the wiki, the same as if `ikiwiki --refresh` were ran at the command line. An url such as the following is used to trigger a ping: diff --git a/doc/users/xma/discussion.mdwn b/doc/users/xma/discussion.mdwn index c2bb62062..34adbf821 100644 --- a/doc/users/xma/discussion.mdwn +++ b/doc/users/xma/discussion.mdwn @@ -14,3 +14,5 @@ How do you edit this wiki (I mean [ikiwiki]) without the web browser ? Is there > for ikiwiki. --[[Joey]] > > I'll think about it. It may solve some of my offline-being issues. --[[intrigeri]] + +>>>> Now developed! --[[Joey]] -- cgit v1.2.3 From 1a883b3c504a543c8f4a5b5bb9687e7770f28a4f Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 24 Oct 2008 13:44:03 -0400 Subject: include temp file for attachment change too --- IkiWiki/Plugin/git.pm | 23 +++++++++++++---------- IkiWiki/Receive.pm | 2 +- doc/plugins/write.mdwn | 4 ++-- 3 files changed, 16 insertions(+), 13 deletions(-) (limited to 'IkiWiki/Plugin') diff --git a/IkiWiki/Plugin/git.pm b/IkiWiki/Plugin/git.pm index 3a8476e7d..84df56181 100644 --- a/IkiWiki/Plugin/git.pm +++ b/IkiWiki/Plugin/git.pm @@ -619,7 +619,7 @@ sub rcs_receive () { #{{{ # Avoid chdir when running git here, because the changes # are in the master git repo, not the srcdir repo. - # The pre-receive hook already puts us in the right place. + # The pre-recieve hook already puts us in the right place. $no_chdir=1; my @changes=git_commit_info($oldrev."..".$newrev); $no_chdir=0; @@ -643,15 +643,6 @@ sub rcs_receive () { #{{{ elsif ($detail->{'status'} =~ /^[AM]+\d*$/) { $action="add"; $mode=$detail->{'mode_to'}; - if (! pagetype($file)) { - eval q{use File::Temp}; - die $@ if $@; - my $fh; - ($fh, $path)=File::Temp::tempfile("XXXXXXXXXX", UNLINK => 1); - if (system("git show ".$detail->{sha1_to}." > '$path'") != 0) { - error("failed writing temp file"); - } - } } elsif ($detail->{'status'} =~ /^[DAM]+\d*/) { $action="remove"; @@ -670,6 +661,18 @@ sub rcs_receive () { #{{{ error gettext("you are not allowed to change file modes"); } } + + # extract attachment to temp file + if (($action eq 'add' || $action eq 'change') && + ! pagetype($file)) { + eval q{use File::Temp}; + die $@ if $@; + my $fh; + ($fh, $path)=File::Temp::tempfile("XXXXXXXXXX", UNLINK => 1); + if (system("git show ".$detail->{sha1_to}." > '$path'") != 0) { + error("failed writing temp file"); + } + } push @rets, { file => $file, diff --git a/IkiWiki/Receive.pm b/IkiWiki/Receive.pm index c69911a7c..9a672abc9 100644 --- a/IkiWiki/Receive.pm +++ b/IkiWiki/Receive.pm @@ -45,7 +45,7 @@ sub test () { #{{{ $file=IkiWiki::possibly_foolish_untaint($file); if (! defined $file || ! length $file || IkiWiki::file_pruned($file, $config{srcdir})) { - error(gettext("bad file name")); + error(gettext("bad file name %s"), $file); } my $type=pagetype($file); diff --git a/doc/plugins/write.mdwn b/doc/plugins/write.mdwn index 5ee4acb53..abcabbdc3 100644 --- a/doc/plugins/write.mdwn +++ b/doc/plugins/write.mdwn @@ -837,8 +837,8 @@ files that were changed, in the form: file => # name of file that was changed action => # either "add", "change", or "remove" path => # temp file containing the new file content, only - # needed for "add", and only if the file is an - # attachment, not a page + # needed for "add"/"change", and only if the file + # is an attachment, not a page } The list will then be checked to make sure that each change is one that -- cgit v1.2.3 From 146192d5b01329bd8e5dfbf4045efded467151e0 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 24 Oct 2008 15:47:42 -0400 Subject: the pre-receive wrapper needs to be suid after all It needs to write to the user db. --- IkiWiki/Plugin/git.pm | 2 +- IkiWiki/Receive.pm | 26 +++++++++++++++++++------- 2 files changed, 20 insertions(+), 8 deletions(-) (limited to 'IkiWiki/Plugin') diff --git a/IkiWiki/Plugin/git.pm b/IkiWiki/Plugin/git.pm index 84df56181..5bef92856 100644 --- a/IkiWiki/Plugin/git.pm +++ b/IkiWiki/Plugin/git.pm @@ -46,7 +46,7 @@ sub checkconfig () { #{{{ push @{$config{wrappers}}, { test_receive => 1, wrapper => $config{git_test_receive_wrapper}, - wrappermode => "0755", + wrappermode => (defined $config{git_wrappermode} ? $config{git_wrappermode} : "06755"), }; } } #}}} diff --git a/IkiWiki/Receive.pm b/IkiWiki/Receive.pm index 81b67d9b4..451a3fe8e 100644 --- a/IkiWiki/Receive.pm +++ b/IkiWiki/Receive.pm @@ -7,7 +7,8 @@ use strict; use IkiWiki; sub getuser () { #{{{ - my $user=(getpwuid($<))[0]; + # CALLER_UID is set by the suid wrapper, to the original uid + my $user=(getpwuid(exists $ENV{CALLER_UID} ? $ENV{CALLER_UID} : $<))[0]; if (! defined $user) { error("cannot determine username for $<"); } @@ -23,20 +24,31 @@ sub trusted () { #{{{ sub test () { #{{{ exit 0 if trusted(); + IkiWiki::lockwiki(); + IkiWiki::loadindex(); + # Dummy up a cgi environment to use when calling check_canedit # and friends. eval q{use CGI}; error($@) if $@; my $cgi=CGI->new; + $ENV{REMOTE_ADDR}='unknown' unless exists $ENV{REMOTE_ADDR}; + + # And dummy up a session object. require IkiWiki::CGI; my $session=IkiWiki::cgi_getsession($cgi); $session->param("name", getuser()); - $ENV{REMOTE_ADDR}='unknown' unless exists $ENV{REMOTE_ADDR}; - - # Wiki is not locked because we lack permission to do so. - # So, relying on atomic index file updates to avoid trouble. - IkiWiki::loadindex(); - + # Make sure whatever user was authed is in the + # userinfo db. + require IkiWiki::UserInfo; + if (! IkiWiki::userinfo_get($session->param("name"), "regdate")) { + IkiWiki::userinfo_setall($session->param("name"), { + email => "", + password => "", + regdate => time, + }) || error("failed adding user"); + } + my %newfiles; foreach my $change (IkiWiki::rcs_receive()) { -- cgit v1.2.3 From 8530e827b01a6eed8b8c933e758e152a1dc32035 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 27 Oct 2008 14:45:54 -0400 Subject: git: Allow [[sha1_commit]] to be used in the diffurl, to support cgit. --- IkiWiki/Plugin/git.pm | 3 ++- debian/changelog | 1 + doc/todo/provide_sha1_for_git_diffurl.mdwn | 4 +++- po/ikiwiki.pot | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) (limited to 'IkiWiki/Plugin') diff --git a/IkiWiki/Plugin/git.pm b/IkiWiki/Plugin/git.pm index 5bef92856..1a39d87e5 100644 --- a/IkiWiki/Plugin/git.pm +++ b/IkiWiki/Plugin/git.pm @@ -95,7 +95,7 @@ sub getsetup () { #{{{ diffurl => { type => "string", example => "http://git.example.com/gitweb.cgi?p=wiki.git;a=blobdiff;h=[[sha1_to]];hp=[[sha1_from]];hb=[[sha1_parent]];f=[[file]]", - description => "gitweb url to show a diff ([[sha1_to]], [[sha1_from]], [[sha1_parent]], and [[file]] substituted)", + description => "gitweb url to show a diff ([[sha1_to]], [[sha1_from]], [[sha1_parent]], [[sha1_commit]] and [[file]] substituted)", safe => 1, rebuild => 1, }, @@ -521,6 +521,7 @@ sub rcs_recentchanges ($) { #{{{ $diffurl =~ s/\[\[sha1_parent\]\]/$ci->{'parent'}/go; $diffurl =~ s/\[\[sha1_from\]\]/$detail->{'sha1_from'}/go; $diffurl =~ s/\[\[sha1_to\]\]/$detail->{'sha1_to'}/go; + $diffurl =~ s/\[\[sha1_commit\]\]/$sha1/go; push @pages, { page => pagename($file), diff --git a/debian/changelog b/debian/changelog index 63556c941..299cf1af2 100644 --- a/debian/changelog +++ b/debian/changelog @@ -35,6 +35,7 @@ ikiwiki (2.68) UNRELEASED; urgency=low of a second. * Add support for checking pushes from untrusted git committers. This can be used to set up anonymous git pushes, and other similar things. + * git: Allow [[sha1_commit]] to be used in the diffurl, to support cgit. -- Joey Hess Fri, 17 Oct 2008 20:11:02 -0400 diff --git a/doc/todo/provide_sha1_for_git_diffurl.mdwn b/doc/todo/provide_sha1_for_git_diffurl.mdwn index af785c3e6..dfd848058 100644 --- a/doc/todo/provide_sha1_for_git_diffurl.mdwn +++ b/doc/todo/provide_sha1_for_git_diffurl.mdwn @@ -18,4 +18,6 @@ diffurls of the following form: $diffurl =~ s/\[\[sha1_parent\]\]/$ci->{'parent'}/go; $diffurl =~ s/\[\[sha1_from\]\]/$detail->{'sha1_from'}/go; $diffurl =~ s/\[\[sha1_to\]\]/$detail->{'sha1_to'}/go; - + +> [[done]], but I called it `sha1_commit` since I think that's what it's +> actually a sha1 of. --[[Joey]] diff --git a/po/ikiwiki.pot b/po/ikiwiki.pot index cbae46752..7a2891ea5 100644 --- a/po/ikiwiki.pot +++ b/po/ikiwiki.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2008-10-26 15:03-0400\n" +"POT-Creation-Date: 2008-10-26 20:44-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" -- cgit v1.2.3 From 33a0e84ddbb9fe9c068cb40641ccec8554514151 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 29 Oct 2008 14:20:31 -0400 Subject: fix preview of shortcuts Move shortcut processing back to checkconfig, and avoid it failing if the srcdir is not defined. --- IkiWiki/Plugin/shortcut.pm | 18 ++++++++++-------- debian/changelog | 1 + doc/bugs/cannot_preview_shortcuts.mdwn | 2 ++ 3 files changed, 13 insertions(+), 8 deletions(-) (limited to 'IkiWiki/Plugin') diff --git a/IkiWiki/Plugin/shortcut.pm b/IkiWiki/Plugin/shortcut.pm index 7bfce586f..77131edb0 100644 --- a/IkiWiki/Plugin/shortcut.pm +++ b/IkiWiki/Plugin/shortcut.pm @@ -7,7 +7,7 @@ use IkiWiki 2.00; sub import { #{{{ hook(type => "getsetup", id => "shortcut", call => \&getsetup); - hook(type => "refresh", id => "shortcut", call => \&refresh); + hook(type => "checkconfig", id => "shortcut", call => \&checkconfig); hook(type => "preprocess", id => "shortcut", call => \&preprocess_shortcut); } #}}} @@ -19,14 +19,16 @@ sub getsetup () { #{{{ }, } #}}} -sub refresh () { #{{{ - # Preprocess the shortcuts page to get all the available shortcuts - # defined before other pages are rendered. - my $srcfile=srcfile("shortcuts.mdwn", 1); - if (! defined $srcfile) { - error(gettext("shortcut plugin will not work without a shortcuts.mdwn")); +sub checkconfig () { #{{{ + if (defined $config{srcdir}) { + # Preprocess the shortcuts page to get all the available shortcuts + # defined before other pages are rendered. + my $srcfile=srcfile("shortcuts.mdwn", 1); + if (! defined $srcfile) { + error(gettext("shortcut plugin will not work without a shortcuts.mdwn")); + } + IkiWiki::preprocess("shortcuts", "shortcuts", readfile($srcfile)); } - IkiWiki::preprocess("shortcuts", "shortcuts", readfile($srcfile)); } # }}} sub preprocess_shortcut (@) { #{{{ diff --git a/debian/changelog b/debian/changelog index 299cf1af2..4547cda3d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -36,6 +36,7 @@ ikiwiki (2.68) UNRELEASED; urgency=low * Add support for checking pushes from untrusted git committers. This can be used to set up anonymous git pushes, and other similar things. * git: Allow [[sha1_commit]] to be used in the diffurl, to support cgit. + * shortcut: Fix display of shortcuts while previewing. -- Joey Hess Fri, 17 Oct 2008 20:11:02 -0400 diff --git a/doc/bugs/cannot_preview_shortcuts.mdwn b/doc/bugs/cannot_preview_shortcuts.mdwn index a2fd3533a..2e7ef13b7 100644 --- a/doc/bugs/cannot_preview_shortcuts.mdwn +++ b/doc/bugs/cannot_preview_shortcuts.mdwn @@ -1,2 +1,4 @@ Shortcuts such as \[[!google foo]] do not work when previewing pages. --[[JasonBlevins]] + +> Broken during the setup dumping changes, now fixed. --[[Joey]] [[done]] -- cgit v1.2.3 From 354d22e27b4d9cb8207e038de4f342545435d2c6 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 30 Oct 2008 13:41:19 -0400 Subject: don't rely on plugin load order when determining generated directives Instead, shortcuts will explicitly be marked as such when registered, and listdirectives can filter them out. --- IkiWiki/Plugin/listdirectives.pm | 9 ++++----- IkiWiki/Plugin/shortcut.pm | 1 + doc/bugs/cannot_preview_shortcuts.mdwn | 7 +++++++ 3 files changed, 12 insertions(+), 5 deletions(-) (limited to 'IkiWiki/Plugin') diff --git a/IkiWiki/Plugin/listdirectives.pm b/IkiWiki/Plugin/listdirectives.pm index fc8927ccb..2ab3e4665 100644 --- a/IkiWiki/Plugin/listdirectives.pm +++ b/IkiWiki/Plugin/listdirectives.pm @@ -30,7 +30,7 @@ sub getsetup () { #{{{ } #}}} my @fulllist; -my @earlylist; +my @shortlist; my $pluginstring; sub checkconfig () { #{{{ @@ -40,15 +40,14 @@ sub checkconfig () { #{{{ else { $config{directive_description_dir} =~ s/\/+$//; } - - @earlylist = sort keys %{$IkiWiki::hooks{preprocess}}; } #}}} sub needsbuild (@) { #{{{ my $needsbuild=shift; @fulllist = sort keys %{$IkiWiki::hooks{preprocess}}; - $pluginstring = join(' ', @earlylist) . " : " . join(' ', @fulllist); + @shortlist = grep { ! $IkiWiki::hooks{preprocess}{$_}{shortcut} } @fulllist; + $pluginstring = join(' ', @shortlist) . " : " . join(' ', @fulllist); foreach my $page (keys %pagestate) { if (exists $pagestate{$page}{listdirectives}{shown}) { @@ -77,7 +76,7 @@ sub preprocess (@) { #{{{ @pluginlist = @fulllist; } else { - @pluginlist = @earlylist; + @pluginlist = @shortlist; } my $result = '
    '; diff --git a/IkiWiki/Plugin/shortcut.pm b/IkiWiki/Plugin/shortcut.pm index 77131edb0..dec8afdb5 100644 --- a/IkiWiki/Plugin/shortcut.pm +++ b/IkiWiki/Plugin/shortcut.pm @@ -39,6 +39,7 @@ sub preprocess_shortcut (@) { #{{{ } hook(type => "preprocess", no_override => 1, id => $params{name}, + shortcut => 1, call => sub { shortcut_expand($params{url}, $params{desc}, @_) }); #translators: This is used to display what shortcuts are defined. diff --git a/doc/bugs/cannot_preview_shortcuts.mdwn b/doc/bugs/cannot_preview_shortcuts.mdwn index 7c830898d..d7045b2dc 100644 --- a/doc/bugs/cannot_preview_shortcuts.mdwn +++ b/doc/bugs/cannot_preview_shortcuts.mdwn @@ -8,3 +8,10 @@ Shortcuts such as \[[!google foo]] do not work when previewing pages. >> still works, but it relies on the fact that the `listdirectives` `checkconfig` >> hook is called before the `shortcut` `checkconfig` hook. >> -- [[Will]] + +>> The order plugins are loaded is effectively random. (`keys %hooks`). +>> So I've made shortcuts pass a 'shortcut' parameter when registering +>> them, which listdirectives can grep out of the full list of directives. +>> That may not be the best name to give it, especially if other plugins +>> generate directives too. Seemed better than forcing shortcut's +>> checkconfig hook to run last tho. --[[Joey]] -- cgit v1.2.3 From bb841f94f47d865e4c78bd4f27c5f9cc04dc1557 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 31 Oct 2008 16:42:20 -0400 Subject: format: New plugin, allows embedding differntly formatted text inside a page (ie, otl inside a mdwn page, or syntax highlighted code inside a page). --- IkiWiki/Plugin/format.pm | 29 +++++++++++++++++++++++++++++ debian/changelog | 3 +++ doc/ikiwiki/directive/format.mdwn | 21 +++++++++++++++++++++ doc/plugins/format.mdwn | 9 +++++++++ doc/todo/syntax_highlighting.mdwn | 4 ++-- po/bg.po | 29 +++++++++++++++++++---------- po/cs.po | 29 +++++++++++++++++++---------- po/da.po | 29 +++++++++++++++++++---------- po/de.po | 29 +++++++++++++++++++---------- po/es.po | 29 +++++++++++++++++++---------- po/fr.po | 29 +++++++++++++++++++---------- po/gu.po | 29 +++++++++++++++++++---------- po/ikiwiki.pot | 13 +++++++++++-- po/pl.po | 29 +++++++++++++++++++---------- po/sv.po | 29 +++++++++++++++++++---------- po/vi.po | 29 +++++++++++++++++++---------- 16 files changed, 265 insertions(+), 104 deletions(-) create mode 100644 IkiWiki/Plugin/format.pm create mode 100644 doc/ikiwiki/directive/format.mdwn create mode 100644 doc/plugins/format.mdwn (limited to 'IkiWiki/Plugin') diff --git a/IkiWiki/Plugin/format.pm b/IkiWiki/Plugin/format.pm new file mode 100644 index 000000000..a219190e8 --- /dev/null +++ b/IkiWiki/Plugin/format.pm @@ -0,0 +1,29 @@ +#!/usr/bin/perl +package IkiWiki::Plugin::format; + +use warnings; +use strict; +use IkiWiki 2.00; + +sub import { #{{{ + hook(type => "preprocess", id => "format", call => \&preprocess); +} #}}} + +sub preprocess (@) { #{{{ + my $format=$_[0]; + shift; shift; + my $text=$_[0]; + shift; shift; + my %params=@_; + + if (! defined $format || ! defined $text) { + error(gettext("must specify format and text")); + } + elsif (! exists $IkiWiki::hooks{htmlize}{$format}) { + error(sprintf(gettext("unsupported page format %s"), $format)); + } + + return IkiWiki::htmlize($params{page}, $params{destpage}, $format, $text); +} #}}} + +1 diff --git a/debian/changelog b/debian/changelog index 0c3fded41..ca0433d10 100644 --- a/debian/changelog +++ b/debian/changelog @@ -39,6 +39,9 @@ ikiwiki (2.68) UNRELEASED; urgency=low * shortcut: Fix display of shortcuts while previewing. * Preserve syslog setting when doing `ikiwiki -setup foo -dumpsetup bar` * Several fixes to --render mode. + * format: New plugin, allows embedding differntly formatted text inside a + page (ie, otl inside a mdwn page, or syntax highlighted code inside a + page). -- Joey Hess Fri, 17 Oct 2008 20:11:02 -0400 diff --git a/doc/ikiwiki/directive/format.mdwn b/doc/ikiwiki/directive/format.mdwn new file mode 100644 index 000000000..94cf1b04f --- /dev/null +++ b/doc/ikiwiki/directive/format.mdwn @@ -0,0 +1,21 @@ +The `format` directive is supplied by the [[!iki plugins/format desc=format]] +plugin. + +The directive allows formatting a chunk of text using any available page +format. It takes two parameters. First is the type of format to use, +ie the extension that would be used for a standalone file of this type. +Second is the text to format. + +For example, this will embed an otl outline inside a page using mdwn or +some other format: + + \[[!format otl """ + foo + 1 + 2 + bar + 3 + 4 + """]] + +[[!meta robots="noindex, follow"]] diff --git a/doc/plugins/format.mdwn b/doc/plugins/format.mdwn new file mode 100644 index 000000000..91e707fcf --- /dev/null +++ b/doc/plugins/format.mdwn @@ -0,0 +1,9 @@ +[[!template id=plugin name=format core=0 author="[[Joey]]"]] +[[!tag type/format]] + +This plugin allows mixing different page formats together, by embedding +text formatted one way inside a page formatted another way. This is done +using the [[ikiwiki/directive/format]] [[ikiwiki/directive]]. + +For example, it could be used to embed an [[otl]] outline inside a page +that is formatted as [[mdwn]]. diff --git a/doc/todo/syntax_highlighting.mdwn b/doc/todo/syntax_highlighting.mdwn index 43878437f..bb1c84f02 100644 --- a/doc/todo/syntax_highlighting.mdwn +++ b/doc/todo/syntax_highlighting.mdwn @@ -73,8 +73,8 @@ That would run the text through the pl htmlizer, from the syntax hightligh plugin. OTOH, if "rst" were given, it would run the text through the rst htmlizer. So, more generic, allows mixing different types of markup on one page, as well as syntax highlighting. Does require specifying the type of -format, instead of allows it to be guessed (which some syntax highlighters -can do). +format, instead of allowing it to be guessed (which some syntax highlighters +can do). (This directive is now implemented..) Hmm, this would also allow comments inside source files to have mdwn embedded in them, without making the use of mdwn a special case, or needing diff --git a/po/bg.po b/po/bg.po index 471e03119..19b0fff50 100644 --- a/po/bg.po +++ b/po/bg.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: ikiwiki-bg\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2008-10-26 15:03-0400\n" +"POT-Creation-Date: 2008-10-31 16:37-0400\n" "PO-Revision-Date: 2007-01-12 01:19+0200\n" "Last-Translator: Damyan Ivanov \n" "Language-Team: Bulgarian \n" @@ -131,7 +131,7 @@ msgstr "създаване на нова страницa „%s”" msgid "deleting bucket.." msgstr "" -#: ../IkiWiki/Plugin/amazon_s3.pm:38 ../ikiwiki.in:205 +#: ../IkiWiki/Plugin/amazon_s3.pm:38 ../ikiwiki.in:206 msgid "done" msgstr "готово" @@ -253,22 +253,31 @@ msgstr "" msgid "failed to process" msgstr "грешка при обработване на шаблона" +#: ../IkiWiki/Plugin/format.pm:22 +msgid "must specify format and text" +msgstr "" + +#: ../IkiWiki/Plugin/format.pm:25 +#, perl-format +msgid "unsupported page format %s" +msgstr "" + #: ../IkiWiki/Plugin/fortune.pm:27 msgid "fortune failed" msgstr "грешшка в приставката „fortune”" -#: ../IkiWiki/Plugin/git.pm:617 ../IkiWiki/Plugin/git.pm:635 +#: ../IkiWiki/Plugin/git.pm:618 ../IkiWiki/Plugin/git.pm:636 #: ../IkiWiki/Receive.pm:129 #, perl-format msgid "you are not allowed to change %s" msgstr "" -#: ../IkiWiki/Plugin/git.pm:657 +#: ../IkiWiki/Plugin/git.pm:658 #, perl-format msgid "you cannot act on a file with mode %s" msgstr "" -#: ../IkiWiki/Plugin/git.pm:661 +#: ../IkiWiki/Plugin/git.pm:662 msgid "you are not allowed to change file modes" msgstr "" @@ -686,11 +695,11 @@ msgstr "" msgid "search" msgstr "" -#: ../IkiWiki/Plugin/shortcut.pm:27 +#: ../IkiWiki/Plugin/shortcut.pm:28 msgid "shortcut plugin will not work without a shortcuts.mdwn" msgstr "" -#: ../IkiWiki/Plugin/shortcut.pm:36 +#: ../IkiWiki/Plugin/shortcut.pm:38 #, fuzzy msgid "missing name or url parameter" msgstr "препратката няма указани параметрите „name” или „url”" @@ -698,7 +707,7 @@ msgstr "препратката няма указани параметрите #. translators: This is used to display what shortcuts are defined. #. translators: First parameter is the name of the shortcut, the second #. translators: is an URL. -#: ../IkiWiki/Plugin/shortcut.pm:45 +#: ../IkiWiki/Plugin/shortcut.pm:48 #, fuzzy, perl-format msgid "shortcut %s points to %s" msgstr "препратката „%s” сочи към „%s”" @@ -970,11 +979,11 @@ msgstr "" msgid "generating wrappers.." msgstr "генериране на обвивки..." -#: ../ikiwiki.in:194 +#: ../ikiwiki.in:195 msgid "rebuilding wiki.." msgstr "обновяване на уики..." -#: ../ikiwiki.in:197 +#: ../ikiwiki.in:198 msgid "refreshing wiki.." msgstr "осъвременяване на уики..." diff --git a/po/cs.po b/po/cs.po index ece992c47..6cbb0c596 100644 --- a/po/cs.po +++ b/po/cs.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: ikiwiki\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2008-10-26 15:03-0400\n" +"POT-Creation-Date: 2008-10-31 16:37-0400\n" "PO-Revision-Date: 2007-05-09 21:21+0200\n" "Last-Translator: Miroslav Kure \n" "Language-Team: Czech \n" @@ -128,7 +128,7 @@ msgstr "vytvářím novou stránku %s" msgid "deleting bucket.." msgstr "" -#: ../IkiWiki/Plugin/amazon_s3.pm:38 ../ikiwiki.in:205 +#: ../IkiWiki/Plugin/amazon_s3.pm:38 ../ikiwiki.in:206 msgid "done" msgstr "hotovo" @@ -250,22 +250,31 @@ msgstr "" msgid "failed to process" msgstr "nepodařilo se zpracovat:" +#: ../IkiWiki/Plugin/format.pm:22 +msgid "must specify format and text" +msgstr "" + +#: ../IkiWiki/Plugin/format.pm:25 +#, perl-format +msgid "unsupported page format %s" +msgstr "" + #: ../IkiWiki/Plugin/fortune.pm:27 msgid "fortune failed" msgstr "fortune selhal" -#: ../IkiWiki/Plugin/git.pm:617 ../IkiWiki/Plugin/git.pm:635 +#: ../IkiWiki/Plugin/git.pm:618 ../IkiWiki/Plugin/git.pm:636 #: ../IkiWiki/Receive.pm:129 #, perl-format msgid "you are not allowed to change %s" msgstr "" -#: ../IkiWiki/Plugin/git.pm:657 +#: ../IkiWiki/Plugin/git.pm:658 #, perl-format msgid "you cannot act on a file with mode %s" msgstr "" -#: ../IkiWiki/Plugin/git.pm:661 +#: ../IkiWiki/Plugin/git.pm:662 msgid "you are not allowed to change file modes" msgstr "" @@ -674,18 +683,18 @@ msgstr "" msgid "search" msgstr "" -#: ../IkiWiki/Plugin/shortcut.pm:27 +#: ../IkiWiki/Plugin/shortcut.pm:28 msgid "shortcut plugin will not work without a shortcuts.mdwn" msgstr "" -#: ../IkiWiki/Plugin/shortcut.pm:36 +#: ../IkiWiki/Plugin/shortcut.pm:38 msgid "missing name or url parameter" msgstr "chybí parametr jméno nebo url" #. translators: This is used to display what shortcuts are defined. #. translators: First parameter is the name of the shortcut, the second #. translators: is an URL. -#: ../IkiWiki/Plugin/shortcut.pm:45 +#: ../IkiWiki/Plugin/shortcut.pm:48 #, perl-format msgid "shortcut %s points to %s" msgstr "zkratka %s odkazuje na %s" @@ -951,11 +960,11 @@ msgstr "" msgid "generating wrappers.." msgstr "generuji obaly..." -#: ../ikiwiki.in:194 +#: ../ikiwiki.in:195 msgid "rebuilding wiki.." msgstr "znovu vytvářím wiki..." -#: ../ikiwiki.in:197 +#: ../ikiwiki.in:198 msgid "refreshing wiki.." msgstr "obnovuji wiki..." diff --git a/po/da.po b/po/da.po index 3d0deca8a..6c3ed3e53 100644 --- a/po/da.po +++ b/po/da.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: ikiwiki\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2008-10-26 15:03-0400\n" +"POT-Creation-Date: 2008-10-31 16:37-0400\n" "PO-Revision-Date: 2008-10-22 19:13+0100\n" "Last-Translator: Jonas Smedegaard \n" "Language-Team: None\n" @@ -132,7 +132,7 @@ msgstr "opretter ny side %s" msgid "deleting bucket.." msgstr "sletter bundt.." -#: ../IkiWiki/Plugin/amazon_s3.pm:38 ../ikiwiki.in:205 +#: ../IkiWiki/Plugin/amazon_s3.pm:38 ../ikiwiki.in:206 msgid "done" msgstr "færdig" @@ -250,22 +250,31 @@ msgstr "redigeringsskabelon %s registreret for %s" msgid "failed to process" msgstr "dannelsen mislykkedes" +#: ../IkiWiki/Plugin/format.pm:22 +msgid "must specify format and text" +msgstr "" + +#: ../IkiWiki/Plugin/format.pm:25 +#, fuzzy, perl-format +msgid "unsupported page format %s" +msgstr "revisionskontrolsystem %s ikke understøttet" + #: ../IkiWiki/Plugin/fortune.pm:27 msgid "fortune failed" msgstr "spådom (fortune) fejlede" -#: ../IkiWiki/Plugin/git.pm:617 ../IkiWiki/Plugin/git.pm:635 +#: ../IkiWiki/Plugin/git.pm:618 ../IkiWiki/Plugin/git.pm:636 #: ../IkiWiki/Receive.pm:129 #, fuzzy, perl-format msgid "you are not allowed to change %s" msgstr "du er ikke logget på som en administrator" -#: ../IkiWiki/Plugin/git.pm:657 +#: ../IkiWiki/Plugin/git.pm:658 #, perl-format msgid "you cannot act on a file with mode %s" msgstr "" -#: ../IkiWiki/Plugin/git.pm:661 +#: ../IkiWiki/Plugin/git.pm:662 #, fuzzy msgid "you are not allowed to change file modes" msgstr "du er ikke logget på som en administrator" @@ -669,18 +678,18 @@ msgstr "behøver Digest::SHA1 til indeks %s" msgid "search" msgstr "søg" -#: ../IkiWiki/Plugin/shortcut.pm:27 +#: ../IkiWiki/Plugin/shortcut.pm:28 msgid "shortcut plugin will not work without a shortcuts.mdwn" msgstr "genvejsudvidelsen vil ikke fungere uden en shortcuts.mdwn" -#: ../IkiWiki/Plugin/shortcut.pm:36 +#: ../IkiWiki/Plugin/shortcut.pm:38 msgid "missing name or url parameter" msgstr "manglende navn eller url parameter" #. translators: This is used to display what shortcuts are defined. #. translators: First parameter is the name of the shortcut, the second #. translators: is an URL. -#: ../IkiWiki/Plugin/shortcut.pm:45 +#: ../IkiWiki/Plugin/shortcut.pm:48 #, perl-format msgid "shortcut %s points to %s" msgstr "genvej %s viser til %s" @@ -949,11 +958,11 @@ msgstr "brug: --set var=værdi" msgid "generating wrappers.." msgstr "bygger wrappers.." -#: ../ikiwiki.in:194 +#: ../ikiwiki.in:195 msgid "rebuilding wiki.." msgstr "genopbygger wiki..." -#: ../ikiwiki.in:197 +#: ../ikiwiki.in:198 msgid "refreshing wiki.." msgstr "genopfrisker wiki..." diff --git a/po/de.po b/po/de.po index bef54ad89..022fbfef1 100644 --- a/po/de.po +++ b/po/de.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: ikiwiki 2.40\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2008-10-26 15:03-0400\n" +"POT-Creation-Date: 2008-10-31 16:37-0400\n" "PO-Revision-Date: 2008-03-03 21:22+0100\n" "Last-Translator: Kai Wasserbäch \n" "Language-Team: German \n" @@ -128,7 +128,7 @@ msgstr "erstelle neue Seite %s" msgid "deleting bucket.." msgstr "" -#: ../IkiWiki/Plugin/amazon_s3.pm:38 ../ikiwiki.in:205 +#: ../IkiWiki/Plugin/amazon_s3.pm:38 ../ikiwiki.in:206 msgid "done" msgstr "fertig" @@ -247,22 +247,31 @@ msgstr "»edittemplate« %s registriert für %s" msgid "failed to process" msgstr "Bearbeitung fehlgeschlagen" +#: ../IkiWiki/Plugin/format.pm:22 +msgid "must specify format and text" +msgstr "" + +#: ../IkiWiki/Plugin/format.pm:25 +#, perl-format +msgid "unsupported page format %s" +msgstr "" + #: ../IkiWiki/Plugin/fortune.pm:27 msgid "fortune failed" msgstr "»fortune« fehlgeschlagen" -#: ../IkiWiki/Plugin/git.pm:617 ../IkiWiki/Plugin/git.pm:635 +#: ../IkiWiki/Plugin/git.pm:618 ../IkiWiki/Plugin/git.pm:636 #: ../IkiWiki/Receive.pm:129 #, perl-format msgid "you are not allowed to change %s" msgstr "" -#: ../IkiWiki/Plugin/git.pm:657 +#: ../IkiWiki/Plugin/git.pm:658 #, perl-format msgid "you cannot act on a file with mode %s" msgstr "" -#: ../IkiWiki/Plugin/git.pm:661 +#: ../IkiWiki/Plugin/git.pm:662 msgid "you are not allowed to change file modes" msgstr "" @@ -671,18 +680,18 @@ msgstr "" msgid "search" msgstr "" -#: ../IkiWiki/Plugin/shortcut.pm:27 +#: ../IkiWiki/Plugin/shortcut.pm:28 msgid "shortcut plugin will not work without a shortcuts.mdwn" msgstr "das »shortcut«-Plugin funktioniert nicht ohne eine »shortcuts.mdwn«" -#: ../IkiWiki/Plugin/shortcut.pm:36 +#: ../IkiWiki/Plugin/shortcut.pm:38 msgid "missing name or url parameter" msgstr "fehlender Name oder URL-Parameter" #. translators: This is used to display what shortcuts are defined. #. translators: First parameter is the name of the shortcut, the second #. translators: is an URL. -#: ../IkiWiki/Plugin/shortcut.pm:45 +#: ../IkiWiki/Plugin/shortcut.pm:48 #, perl-format msgid "shortcut %s points to %s" msgstr "Shortcut %s zeigt auf %s" @@ -946,11 +955,11 @@ msgstr "Benutzung: --set Variable=Wert" msgid "generating wrappers.." msgstr "erzeuge Wrapper.." -#: ../ikiwiki.in:194 +#: ../ikiwiki.in:195 msgid "rebuilding wiki.." msgstr "erzeuge Wiki neu.." -#: ../ikiwiki.in:197 +#: ../ikiwiki.in:198 msgid "refreshing wiki.." msgstr "aktualisiere Wiki.." diff --git a/po/es.po b/po/es.po index 7afb45c14..8dce2940f 100644 --- a/po/es.po +++ b/po/es.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: es\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2008-10-26 15:03-0400\n" +"POT-Creation-Date: 2008-10-31 16:37-0400\n" "PO-Revision-Date: 2008-10-22 13:54+0200\n" "Last-Translator: Víctor Moral \n" "Language-Team: Spanish \n" @@ -130,7 +130,7 @@ msgstr "creando nueva página %s" msgid "deleting bucket.." msgstr "borrando el directorio.." -#: ../IkiWiki/Plugin/amazon_s3.pm:38 ../ikiwiki.in:205 +#: ../IkiWiki/Plugin/amazon_s3.pm:38 ../ikiwiki.in:206 msgid "done" msgstr "completado" @@ -248,22 +248,31 @@ msgstr "plantilla de edición %s registrada para %s" msgid "failed to process" msgstr "fallo en el proceso" +#: ../IkiWiki/Plugin/format.pm:22 +msgid "must specify format and text" +msgstr "" + +#: ../IkiWiki/Plugin/format.pm:25 +#, fuzzy, perl-format +msgid "unsupported page format %s" +msgstr "el sistema de control de versiones %s no está soportado" + #: ../IkiWiki/Plugin/fortune.pm:27 msgid "fortune failed" msgstr "el programa fortune ha fallado" -#: ../IkiWiki/Plugin/git.pm:617 ../IkiWiki/Plugin/git.pm:635 +#: ../IkiWiki/Plugin/git.pm:618 ../IkiWiki/Plugin/git.pm:636 #: ../IkiWiki/Receive.pm:129 #, fuzzy, perl-format msgid "you are not allowed to change %s" msgstr "No está registrado como un administrador" -#: ../IkiWiki/Plugin/git.pm:657 +#: ../IkiWiki/Plugin/git.pm:658 #, perl-format msgid "you cannot act on a file with mode %s" msgstr "" -#: ../IkiWiki/Plugin/git.pm:661 +#: ../IkiWiki/Plugin/git.pm:662 #, fuzzy msgid "you are not allowed to change file modes" msgstr "No está registrado como un administrador" @@ -676,18 +685,18 @@ msgstr "se necesita la instalación de Digest::SHA1 para indexar %s" msgid "search" msgstr "buscar" -#: ../IkiWiki/Plugin/shortcut.pm:27 +#: ../IkiWiki/Plugin/shortcut.pm:28 msgid "shortcut plugin will not work without a shortcuts.mdwn" msgstr "el complemento shortcut no funciona sin una página shortcuts.mdwn" -#: ../IkiWiki/Plugin/shortcut.pm:36 +#: ../IkiWiki/Plugin/shortcut.pm:38 msgid "missing name or url parameter" msgstr "shortcut necesita el parámetro 'name' ó el parámetro 'url'" #. translators: This is used to display what shortcuts are defined. #. translators: First parameter is the name of the shortcut, the second #. translators: is an URL. -#: ../IkiWiki/Plugin/shortcut.pm:45 +#: ../IkiWiki/Plugin/shortcut.pm:48 #, perl-format msgid "shortcut %s points to %s" msgstr "El atajo %s apunta a %s" @@ -959,11 +968,11 @@ msgstr "uso: --set variable=valor" msgid "generating wrappers.." msgstr "generando programas auxiliares.." -#: ../ikiwiki.in:194 +#: ../ikiwiki.in:195 msgid "rebuilding wiki.." msgstr "reconstruyendo el wiki.." -#: ../ikiwiki.in:197 +#: ../ikiwiki.in:198 msgid "refreshing wiki.." msgstr "actualizando el wiki.." diff --git a/po/fr.po b/po/fr.po index c0c96c476..53095c5e1 100644 --- a/po/fr.po +++ b/po/fr.po @@ -9,7 +9,7 @@ msgid "" msgstr "" "Project-Id-Version: \n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2008-10-26 15:03-0400\n" +"POT-Creation-Date: 2008-10-31 16:37-0400\n" "PO-Revision-Date: 2008-10-11 10:34+0200\n" "Last-Translator: Julien Patriarca \n" "Language-Team: French \n" @@ -133,7 +133,7 @@ msgstr "Création de la nouvelle page %s" msgid "deleting bucket.." msgstr "suppression du compartiment (« bucket »)..." -#: ../IkiWiki/Plugin/amazon_s3.pm:38 ../ikiwiki.in:205 +#: ../IkiWiki/Plugin/amazon_s3.pm:38 ../ikiwiki.in:206 msgid "done" msgstr "Terminé" @@ -255,22 +255,31 @@ msgstr "edittemplate %s enregistré pour %s" msgid "failed to process" msgstr "Échec du traitement" +#: ../IkiWiki/Plugin/format.pm:22 +msgid "must specify format and text" +msgstr "" + +#: ../IkiWiki/Plugin/format.pm:25 +#, fuzzy, perl-format +msgid "unsupported page format %s" +msgstr "Système de contrôle de version non reconnu" + #: ../IkiWiki/Plugin/fortune.pm:27 msgid "fortune failed" msgstr "Échec du lancement de « fortune »" -#: ../IkiWiki/Plugin/git.pm:617 ../IkiWiki/Plugin/git.pm:635 +#: ../IkiWiki/Plugin/git.pm:618 ../IkiWiki/Plugin/git.pm:636 #: ../IkiWiki/Receive.pm:129 #, fuzzy, perl-format msgid "you are not allowed to change %s" msgstr "vous n'êtes pas authentifié comme administrateur" -#: ../IkiWiki/Plugin/git.pm:657 +#: ../IkiWiki/Plugin/git.pm:658 #, perl-format msgid "you cannot act on a file with mode %s" msgstr "" -#: ../IkiWiki/Plugin/git.pm:661 +#: ../IkiWiki/Plugin/git.pm:662 #, fuzzy msgid "you are not allowed to change file modes" msgstr "vous n'êtes pas authentifié comme administrateur" @@ -683,18 +692,18 @@ msgstr "Digest::SHA1 est nécessaire pour indexer %s" msgid "search" msgstr "recherche" -#: ../IkiWiki/Plugin/shortcut.pm:27 +#: ../IkiWiki/Plugin/shortcut.pm:28 msgid "shortcut plugin will not work without a shortcuts.mdwn" msgstr "Le greffon « shortcut » ne fonctionnera pas sans shortcuts.mdwn" -#: ../IkiWiki/Plugin/shortcut.pm:36 +#: ../IkiWiki/Plugin/shortcut.pm:38 msgid "missing name or url parameter" msgstr "Il manque le paramètre nom ou URL." #. translators: This is used to display what shortcuts are defined. #. translators: First parameter is the name of the shortcut, the second #. translators: is an URL. -#: ../IkiWiki/Plugin/shortcut.pm:45 +#: ../IkiWiki/Plugin/shortcut.pm:48 #, perl-format msgid "shortcut %s points to %s" msgstr "Le raccourci %s pointe vers %s" @@ -967,11 +976,11 @@ msgstr "Syntaxe : -- set var=valeur" msgid "generating wrappers.." msgstr "Création des fichiers CGI..." -#: ../ikiwiki.in:194 +#: ../ikiwiki.in:195 msgid "rebuilding wiki.." msgstr "Reconstruction du wiki..." -#: ../ikiwiki.in:197 +#: ../ikiwiki.in:198 msgid "refreshing wiki.." msgstr "Rafraîchissement du wiki..." diff --git a/po/gu.po b/po/gu.po index c48985eb5..13c68afc9 100644 --- a/po/gu.po +++ b/po/gu.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: ikiwiki-gu\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2008-10-26 15:03-0400\n" +"POT-Creation-Date: 2008-10-31 16:37-0400\n" "PO-Revision-Date: 2007-01-11 16:05+0530\n" "Last-Translator: Kartik Mistry \n" "Language-Team: Gujarati \n" @@ -129,7 +129,7 @@ msgstr "નવું પાનું %s બનાવે છે" msgid "deleting bucket.." msgstr "" -#: ../IkiWiki/Plugin/amazon_s3.pm:38 ../ikiwiki.in:205 +#: ../IkiWiki/Plugin/amazon_s3.pm:38 ../ikiwiki.in:206 msgid "done" msgstr "સંપૂર્ણ" @@ -251,22 +251,31 @@ msgstr "" msgid "failed to process" msgstr "ક્રિયા કરવામાં નિષ્ફળ:" +#: ../IkiWiki/Plugin/format.pm:22 +msgid "must specify format and text" +msgstr "" + +#: ../IkiWiki/Plugin/format.pm:25 +#, perl-format +msgid "unsupported page format %s" +msgstr "" + #: ../IkiWiki/Plugin/fortune.pm:27 msgid "fortune failed" msgstr "ભવિષ્ય નિષ્ફળ" -#: ../IkiWiki/Plugin/git.pm:617 ../IkiWiki/Plugin/git.pm:635 +#: ../IkiWiki/Plugin/git.pm:618 ../IkiWiki/Plugin/git.pm:636 #: ../IkiWiki/Receive.pm:129 #, perl-format msgid "you are not allowed to change %s" msgstr "" -#: ../IkiWiki/Plugin/git.pm:657 +#: ../IkiWiki/Plugin/git.pm:658 #, perl-format msgid "you cannot act on a file with mode %s" msgstr "" -#: ../IkiWiki/Plugin/git.pm:661 +#: ../IkiWiki/Plugin/git.pm:662 msgid "you are not allowed to change file modes" msgstr "" @@ -675,18 +684,18 @@ msgstr "" msgid "search" msgstr "" -#: ../IkiWiki/Plugin/shortcut.pm:27 +#: ../IkiWiki/Plugin/shortcut.pm:28 msgid "shortcut plugin will not work without a shortcuts.mdwn" msgstr "" -#: ../IkiWiki/Plugin/shortcut.pm:36 +#: ../IkiWiki/Plugin/shortcut.pm:38 msgid "missing name or url parameter" msgstr "ખોવાયેલ નામ અથવા યુઆરએલ વિકલ્પ" #. translators: This is used to display what shortcuts are defined. #. translators: First parameter is the name of the shortcut, the second #. translators: is an URL. -#: ../IkiWiki/Plugin/shortcut.pm:45 +#: ../IkiWiki/Plugin/shortcut.pm:48 #, perl-format msgid "shortcut %s points to %s" msgstr "ટુંકોરસ્તો %s એ %s નો નિર્દેશ કરે છે" @@ -951,11 +960,11 @@ msgstr "" msgid "generating wrappers.." msgstr "આવરણ બનાવે છે.." -#: ../ikiwiki.in:194 +#: ../ikiwiki.in:195 msgid "rebuilding wiki.." msgstr "વીકી ફરીથી બનાવે છે.." -#: ../ikiwiki.in:197 +#: ../ikiwiki.in:198 msgid "refreshing wiki.." msgstr "વીકીને તાજી કરે છે.." diff --git a/po/ikiwiki.pot b/po/ikiwiki.pot index ab28f956c..f3eb0eb55 100644 --- a/po/ikiwiki.pot +++ b/po/ikiwiki.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2008-10-29 17:42-0400\n" +"POT-Creation-Date: 2008-10-31 16:38-0400\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -246,6 +246,15 @@ msgstr "" msgid "failed to process" msgstr "" +#: ../IkiWiki/Plugin/format.pm:22 +msgid "must specify format and text" +msgstr "" + +#: ../IkiWiki/Plugin/format.pm:25 +#, perl-format +msgid "unsupported page format %s" +msgstr "" + #: ../IkiWiki/Plugin/fortune.pm:27 msgid "fortune failed" msgstr "" @@ -671,7 +680,7 @@ msgstr "" #. translators: This is used to display what shortcuts are defined. #. translators: First parameter is the name of the shortcut, the second #. translators: is an URL. -#: ../IkiWiki/Plugin/shortcut.pm:47 +#: ../IkiWiki/Plugin/shortcut.pm:48 #, perl-format msgid "shortcut %s points to %s" msgstr "" diff --git a/po/pl.po b/po/pl.po index 6f262a2be..6f582c71f 100644 --- a/po/pl.po +++ b/po/pl.po @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: ikiwiki 1.51\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2008-10-26 15:03-0400\n" +"POT-Creation-Date: 2008-10-31 16:37-0400\n" "PO-Revision-Date: 2007-04-27 22:05+0200\n" "Last-Translator: Pawel Tecza \n" "Language-Team: Debian L10n Polish \n" @@ -133,7 +133,7 @@ msgstr "tworzenie nowej strony %s" msgid "deleting bucket.." msgstr "" -#: ../IkiWiki/Plugin/amazon_s3.pm:38 ../ikiwiki.in:205 +#: ../IkiWiki/Plugin/amazon_s3.pm:38 ../ikiwiki.in:206 msgid "done" msgstr "gotowe" @@ -255,22 +255,31 @@ msgstr "" msgid "failed to process" msgstr "awaria w trakcie przetwarzania:" +#: ../IkiWiki/Plugin/format.pm:22 +msgid "must specify format and text" +msgstr "" + +#: ../IkiWiki/Plugin/format.pm:25 +#, perl-format +msgid "unsupported page format %s" +msgstr "" + #: ../IkiWiki/Plugin/fortune.pm:27 msgid "fortune failed" msgstr "awaria fortunki" -#: ../IkiWiki/Plugin/git.pm:617 ../IkiWiki/Plugin/git.pm:635 +#: ../IkiWiki/Plugin/git.pm:618 ../IkiWiki/Plugin/git.pm:636 #: ../IkiWiki/Receive.pm:129 #, perl-format msgid "you are not allowed to change %s" msgstr "" -#: ../IkiWiki/Plugin/git.pm:657 +#: ../IkiWiki/Plugin/git.pm:658 #, perl-format msgid "you cannot act on a file with mode %s" msgstr "" -#: ../IkiWiki/Plugin/git.pm:661 +#: ../IkiWiki/Plugin/git.pm:662 msgid "you are not allowed to change file modes" msgstr "" @@ -691,11 +700,11 @@ msgstr "" msgid "search" msgstr "" -#: ../IkiWiki/Plugin/shortcut.pm:27 +#: ../IkiWiki/Plugin/shortcut.pm:28 msgid "shortcut plugin will not work without a shortcuts.mdwn" msgstr "" -#: ../IkiWiki/Plugin/shortcut.pm:36 +#: ../IkiWiki/Plugin/shortcut.pm:38 #, fuzzy msgid "missing name or url parameter" msgstr "brakujący parametr name lub url" @@ -703,7 +712,7 @@ msgstr "brakujący parametr name lub url" #. translators: This is used to display what shortcuts are defined. #. translators: First parameter is the name of the shortcut, the second #. translators: is an URL. -#: ../IkiWiki/Plugin/shortcut.pm:45 +#: ../IkiWiki/Plugin/shortcut.pm:48 #, fuzzy, perl-format msgid "shortcut %s points to %s" msgstr "skrót %s wskazuje na adres %s" @@ -976,11 +985,11 @@ msgstr "" msgid "generating wrappers.." msgstr "tworzenie osłon..." -#: ../ikiwiki.in:194 +#: ../ikiwiki.in:195 msgid "rebuilding wiki.." msgstr "przebudowywanie wiki..." -#: ../ikiwiki.in:197 +#: ../ikiwiki.in:198 msgid "refreshing wiki.." msgstr "odświeżanie wiki..." diff --git a/po/sv.po b/po/sv.po index cc83869cf..6d3e263ee 100644 --- a/po/sv.po +++ b/po/sv.po @@ -7,7 +7,7 @@ msgid "" msgstr "" "Project-Id-Version: ikiwiki\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2008-10-26 15:03-0400\n" +"POT-Creation-Date: 2008-10-31 16:37-0400\n" "PO-Revision-Date: 2007-01-10 23:47+0100\n" "Last-Translator: Daniel Nylander \n" "Language-Team: Swedish \n" @@ -130,7 +130,7 @@ msgstr "skapar nya sidan %s" msgid "deleting bucket.." msgstr "" -#: ../IkiWiki/Plugin/amazon_s3.pm:38 ../ikiwiki.in:205 +#: ../IkiWiki/Plugin/amazon_s3.pm:38 ../ikiwiki.in:206 msgid "done" msgstr "klar" @@ -252,22 +252,31 @@ msgstr "" msgid "failed to process" msgstr "misslyckades med att behandla mall:" +#: ../IkiWiki/Plugin/format.pm:22 +msgid "must specify format and text" +msgstr "" + +#: ../IkiWiki/Plugin/format.pm:25 +#, perl-format +msgid "unsupported page format %s" +msgstr "" + #: ../IkiWiki/Plugin/fortune.pm:27 msgid "fortune failed" msgstr "fortune misslyckades" -#: ../IkiWiki/Plugin/git.pm:617 ../IkiWiki/Plugin/git.pm:635 +#: ../IkiWiki/Plugin/git.pm:618 ../IkiWiki/Plugin/git.pm:636 #: ../IkiWiki/Receive.pm:129 #, perl-format msgid "you are not allowed to change %s" msgstr "" -#: ../IkiWiki/Plugin/git.pm:657 +#: ../IkiWiki/Plugin/git.pm:658 #, perl-format msgid "you cannot act on a file with mode %s" msgstr "" -#: ../IkiWiki/Plugin/git.pm:661 +#: ../IkiWiki/Plugin/git.pm:662 msgid "you are not allowed to change file modes" msgstr "" @@ -681,11 +690,11 @@ msgstr "" msgid "search" msgstr "" -#: ../IkiWiki/Plugin/shortcut.pm:27 +#: ../IkiWiki/Plugin/shortcut.pm:28 msgid "shortcut plugin will not work without a shortcuts.mdwn" msgstr "" -#: ../IkiWiki/Plugin/shortcut.pm:36 +#: ../IkiWiki/Plugin/shortcut.pm:38 #, fuzzy msgid "missing name or url parameter" msgstr "genväg saknar parameter för namn eller url" @@ -693,7 +702,7 @@ msgstr "genväg saknar parameter för namn eller url" #. translators: This is used to display what shortcuts are defined. #. translators: First parameter is the name of the shortcut, the second #. translators: is an URL. -#: ../IkiWiki/Plugin/shortcut.pm:45 +#: ../IkiWiki/Plugin/shortcut.pm:48 #, fuzzy, perl-format msgid "shortcut %s points to %s" msgstr "genvägen %s pekar på %s" @@ -965,11 +974,11 @@ msgstr "" msgid "generating wrappers.." msgstr "genererar wrappers.." -#: ../ikiwiki.in:194 +#: ../ikiwiki.in:195 msgid "rebuilding wiki.." msgstr "bygger om wiki.." -#: ../ikiwiki.in:197 +#: ../ikiwiki.in:198 msgid "refreshing wiki.." msgstr "uppdaterar wiki.." diff --git a/po/vi.po b/po/vi.po index 13d695880..4cc16e1d8 100644 --- a/po/vi.po +++ b/po/vi.po @@ -6,7 +6,7 @@ msgid "" msgstr "" "Project-Id-Version: ikiwiki\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2008-10-26 15:03-0400\n" +"POT-Creation-Date: 2008-10-31 16:37-0400\n" "PO-Revision-Date: 2007-01-13 15:31+1030\n" "Last-Translator: Clytie Siddall \n" "Language-Team: Vietnamese \n" @@ -131,7 +131,7 @@ msgstr "đang tạo trang mới %s" msgid "deleting bucket.." msgstr "" -#: ../IkiWiki/Plugin/amazon_s3.pm:38 ../ikiwiki.in:205 +#: ../IkiWiki/Plugin/amazon_s3.pm:38 ../ikiwiki.in:206 msgid "done" msgstr "xong" @@ -253,22 +253,31 @@ msgstr "" msgid "failed to process" msgstr "mẫu không xử lý được:" +#: ../IkiWiki/Plugin/format.pm:22 +msgid "must specify format and text" +msgstr "" + +#: ../IkiWiki/Plugin/format.pm:25 +#, perl-format +msgid "unsupported page format %s" +msgstr "" + #: ../IkiWiki/Plugin/fortune.pm:27 msgid "fortune failed" msgstr "fortune bị lỗi" -#: ../IkiWiki/Plugin/git.pm:617 ../IkiWiki/Plugin/git.pm:635 +#: ../IkiWiki/Plugin/git.pm:618 ../IkiWiki/Plugin/git.pm:636 #: ../IkiWiki/Receive.pm:129 #, perl-format msgid "you are not allowed to change %s" msgstr "" -#: ../IkiWiki/Plugin/git.pm:657 +#: ../IkiWiki/Plugin/git.pm:658 #, perl-format msgid "you cannot act on a file with mode %s" msgstr "" -#: ../IkiWiki/Plugin/git.pm:661 +#: ../IkiWiki/Plugin/git.pm:662 msgid "you are not allowed to change file modes" msgstr "" @@ -682,11 +691,11 @@ msgstr "" msgid "search" msgstr "" -#: ../IkiWiki/Plugin/shortcut.pm:27 +#: ../IkiWiki/Plugin/shortcut.pm:28 msgid "shortcut plugin will not work without a shortcuts.mdwn" msgstr "" -#: ../IkiWiki/Plugin/shortcut.pm:36 +#: ../IkiWiki/Plugin/shortcut.pm:38 #, fuzzy msgid "missing name or url parameter" msgstr "lối tắt thiếu tên hay tham số url" @@ -694,7 +703,7 @@ msgstr "lối tắt thiếu tên hay tham số url" #. translators: This is used to display what shortcuts are defined. #. translators: First parameter is the name of the shortcut, the second #. translators: is an URL. -#: ../IkiWiki/Plugin/shortcut.pm:45 +#: ../IkiWiki/Plugin/shortcut.pm:48 #, fuzzy, perl-format msgid "shortcut %s points to %s" msgstr "lối tắt %s chỉ tới %s" @@ -966,11 +975,11 @@ msgstr "" msgid "generating wrappers.." msgstr "đang tạo ra các bộ bao bọc.." -#: ../ikiwiki.in:194 +#: ../ikiwiki.in:195 msgid "rebuilding wiki.." msgstr "đang xây dựng lại wiki.." -#: ../ikiwiki.in:197 +#: ../ikiwiki.in:198 msgid "refreshing wiki.." msgstr "đang làm tươi wiki.." -- cgit v1.2.3 From fafa98ea96c0e28818ffcf47b7202c4130615c68 Mon Sep 17 00:00:00 2001 From: intrigeri Date: Sun, 2 Nov 2008 16:44:42 +0100 Subject: disable istranslatable memoization It makes some test cases cry once every two tries; this may be related to the artificial way the testsuite is run, or not. In the meantime, stop memoizing this function. Signed-off-by: intrigeri --- IkiWiki/Plugin/po.pm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'IkiWiki/Plugin') diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm index f535ebd39..a1f7476a3 100644 --- a/IkiWiki/Plugin/po.pm +++ b/IkiWiki/Plugin/po.pm @@ -18,7 +18,9 @@ use Memoize; my %translations; our %filtered; -memoize("istranslatable"); +## FIXME: makes some test cases cry once every two tries; this may be +## related to the artificial way the testsuite is run, or not. +# memoize("istranslatable"); memoize("_istranslation"); memoize("percenttranslated"); -- cgit v1.2.3 From 502a3433c410369eca4eb36b8fb8be5bc4a34a2d Mon Sep 17 00:00:00 2001 From: intrigeri Date: Sun, 2 Nov 2008 17:56:15 +0100 Subject: po plugin: replace tweakbestlink hook with a wrapper function ... thanks to the new inject() feature. Signed-off-by: intrigeri --- IkiWiki/Plugin/po.pm | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) (limited to 'IkiWiki/Plugin') diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm index a1f7476a3..fa250f3a4 100644 --- a/IkiWiki/Plugin/po.pm +++ b/IkiWiki/Plugin/po.pm @@ -18,6 +18,7 @@ use Memoize; my %translations; our %filtered; +my $origbestlink=\&bestlink; ## FIXME: makes some test cases cry once every two tries; this may be ## related to the artificial way the testsuite is run, or not. # memoize("istranslatable"); @@ -30,10 +31,10 @@ sub import { hook(type => "needsbuild", id => "po", call => \&needsbuild); hook(type => "targetpage", id => "po", call => \&targetpage); hook(type => "tweakurlpath", id => "po", call => \&tweakurlpath); - hook(type => "tweakbestlink", id => "po", call => \&tweakbestlink); hook(type => "filter", id => "po", call => \&filter); hook(type => "htmlize", id => "po", call => \&htmlize); hook(type => "pagetemplate", id => "po", call => \&pagetemplate); + inject(name => "IkiWiki::bestlink", call => \&mybestlink); } sub getsetup () { #{{{ @@ -246,17 +247,22 @@ sub tweakurlpath ($) { #{{{ return $url; } #}}} -sub tweakbestlink ($$) { #{{{ - my %params = @_; - my $page=$params{page}; - my $link=$params{link}; - if ($config{po_link_to} eq "current" - && istranslatable($link) - && istranslation($page)) { - my ($masterpage, $curlang) = ($page =~ /(.*)[.]([a-z]{2})$/); - return $link . "." . $curlang; +sub mybestlink ($$) { #{{{ + my $page=shift; + my $link=shift; + my $res=$origbestlink->($page, $link); + if (length $res) { + if ($config{po_link_to} eq "current" + && istranslatable($res) + && istranslation($page)) { + my ($masterpage, $curlang) = ($page =~ /(.*)[.]([a-z]{2})$/); + return $res . "." . $curlang; + } + else { + return $res; + } } - return $link; + return ""; } #}}} # We use filter to convert PO to the master page's type, -- cgit v1.2.3 From 7c173aca3e87d13fdd044cb79dac80ad83d64a38 Mon Sep 17 00:00:00 2001 From: intrigeri Date: Sun, 2 Nov 2008 18:08:50 +0100 Subject: Revert "added hook urlpath" and "rename urlpath hook into tweakurlpath..." This reverts commits d9b9022c13af3aa6c469df05beaa293fcf33cafc and 39d44d443d2271ec8787e6192b8b5811bee41ebf. This functionality should now be achieved using the new inject() function. Signed-off-by: intrigeri --- IkiWiki.pm | 4 ---- IkiWiki/Plugin/skeleton.pm.example | 5 ----- doc/plugins/write.mdwn | 10 ---------- 3 files changed, 19 deletions(-) (limited to 'IkiWiki/Plugin') diff --git a/IkiWiki.pm b/IkiWiki.pm index ba1847093..8b3a91114 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -942,10 +942,6 @@ sub beautify_urlpath ($) { #{{{ $url =~ s!/index.$config{htmlext}$!/!; } - run_hooks(tweakurlpath => sub { - $url=shift->(url => $url); - }); - # Ensure url is not an empty link, and # if it's relative, make that explicit to avoid colon confusion. if ($url !~ /^\//) { diff --git a/IkiWiki/Plugin/skeleton.pm.example b/IkiWiki/Plugin/skeleton.pm.example index ecf2a2407..af22b3406 100644 --- a/IkiWiki/Plugin/skeleton.pm.example +++ b/IkiWiki/Plugin/skeleton.pm.example @@ -35,7 +35,6 @@ sub import { #{{{ hook(type => "formbuilder", id => "skeleton", call => \&formbuilder); hook(type => "savestate", id => "skeleton", call => \&savestate); hook(type => "targetpage", id => "skeleton", call => \&targetpage); - hook(type => "urlpath", id => "skeleton", call => \&urlpath); } # }}} sub getopt () { #{{{ @@ -210,8 +209,4 @@ sub targetpage () { #{{{ debug("skeleton plugin running in targetpage"); } #}}} -sub urlpath () { #{{{ - debug("skeleton plugin running in urlpath"); -} #}}} - 1 diff --git a/doc/plugins/write.mdwn b/doc/plugins/write.mdwn index 82b377820..e8ac9614b 100644 --- a/doc/plugins/write.mdwn +++ b/doc/plugins/write.mdwn @@ -436,16 +436,6 @@ be compiled into. It should return the target filename. -### tweakurlpath - - hook(type => "tweakurlpath", id => "foo", call => \&tweakurlpath); - -This hook can be used to modify the internal urls generated by -ikiwiki; it is run just after ikiwiki has removed the trailing -`index.html`, in case `usedirs` is enabled. - -It should return the modified url. - ## Plugin interface To import the ikiwiki plugin interface: -- cgit v1.2.3 From 307d11541a80a4fed897ef51087c35546506aa70 Mon Sep 17 00:00:00 2001 From: intrigeri Date: Sun, 2 Nov 2008 18:29:23 +0100 Subject: po plugin: replace tweakurlpath hook with a wrapper function Signed-off-by: intrigeri --- IkiWiki/Plugin/po.pm | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) (limited to 'IkiWiki/Plugin') diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm index fa250f3a4..9b5652561 100644 --- a/IkiWiki/Plugin/po.pm +++ b/IkiWiki/Plugin/po.pm @@ -18,13 +18,18 @@ use Memoize; my %translations; our %filtered; -my $origbestlink=\&bestlink; + ## FIXME: makes some test cases cry once every two tries; this may be ## related to the artificial way the testsuite is run, or not. # memoize("istranslatable"); memoize("_istranslation"); memoize("percenttranslated"); +# backup references to subs that will be overriden +my %origsubs; +$origsubs{'bestlink'}=\&IkiWiki::bestlink; +$origsubs{'beautify_urlpath'}=\&IkiWiki::beautify_urlpath; + sub import { hook(type => "getsetup", id => "po", call => \&getsetup); hook(type => "checkconfig", id => "po", call => \&checkconfig); @@ -35,6 +40,7 @@ sub import { hook(type => "htmlize", id => "po", call => \&htmlize); hook(type => "pagetemplate", id => "po", call => \&pagetemplate); inject(name => "IkiWiki::bestlink", call => \&mybestlink); + inject(name => "IkiWiki::beautify_urlpath", call => \&mybeautify_urlpath); } sub getsetup () { #{{{ @@ -238,19 +244,19 @@ sub targetpage (@) { #{{{ return; } #}}} -sub tweakurlpath ($) { #{{{ - my %params = @_; - my $url=$params{url}; +sub mybeautify_urlpath ($) { #{{{ + my $url=shift; + my $res=$origsubs{'beautify_urlpath'}->($url); if ($config{po_link_to} eq "negotiated") { - $url =~ s!/index.$config{po_master_language}{code}.$config{htmlext}$!/!; + $res =~ s!/index.$config{po_master_language}{code}.$config{htmlext}$!/!; } - return $url; + return $res; } #}}} sub mybestlink ($$) { #{{{ my $page=shift; my $link=shift; - my $res=$origbestlink->($page, $link); + my $res=$origsubs{'bestlink'}->($page, $link); if (length $res) { if ($config{po_link_to} eq "current" && istranslatable($res) -- cgit v1.2.3 From 439a2d3c443a032b26ce2455c6f15352a7e606be Mon Sep 17 00:00:00 2001 From: intrigeri Date: Sun, 2 Nov 2008 18:34:10 +0100 Subject: Revert "added the targetpage hook" This reverts commit fc299df955879bf958aa78338ba64d56a7df17a9. Such functionality can now be achieved using the inject() function. Signed-off-by: intrigeri --- IkiWiki.pm | 15 ++------------- IkiWiki/Plugin/skeleton.pm.example | 5 ----- doc/plugins/write.mdwn | 9 --------- 3 files changed, 2 insertions(+), 27 deletions(-) (limited to 'IkiWiki/Plugin') diff --git a/IkiWiki.pm b/IkiWiki.pm index 8b3a91114..bab7b707a 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -655,19 +655,8 @@ sub newpagefile ($$) { #{{{ sub targetpage ($$) { #{{{ my $page=shift; my $ext=shift; - - my $targetpage=''; - run_hooks(targetpage => sub { - $targetpage=shift->( - page => $page, - ext => $ext, - ); - }); - - if (defined $targetpage && (length($targetpage) > 0)) { - return $targetpage; - } - elsif (! $config{usedirs} || $page eq 'index') { + + if (! $config{usedirs} || $page eq 'index') { return $page.".".$ext; } else { diff --git a/IkiWiki/Plugin/skeleton.pm.example b/IkiWiki/Plugin/skeleton.pm.example index af22b3406..f844ddb91 100644 --- a/IkiWiki/Plugin/skeleton.pm.example +++ b/IkiWiki/Plugin/skeleton.pm.example @@ -34,7 +34,6 @@ 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); - hook(type => "targetpage", id => "skeleton", call => \&targetpage); } # }}} sub getopt () { #{{{ @@ -205,8 +204,4 @@ sub savestate () { #{{{ debug("skeleton plugin running in savestate"); } #}}} -sub targetpage () { #{{{ - debug("skeleton plugin running in targetpage"); -} #}}} - 1 diff --git a/doc/plugins/write.mdwn b/doc/plugins/write.mdwn index e8ac9614b..abcabbdc3 100644 --- a/doc/plugins/write.mdwn +++ b/doc/plugins/write.mdwn @@ -427,15 +427,6 @@ describes the plugin as a whole. For example: and undef if a rebuild could be needed in some circumstances, but is not strictly required. -### targetpage - - hook(type => "targetpage", id => "foo", call => \&targetpage); - -This hook can be used to override the name of the file a page should -be compiled into. - -It should return the target filename. - ## Plugin interface To import the ikiwiki plugin interface: -- cgit v1.2.3 From 950c29679df8f8f2f20e150896dc7ec686f123e8 Mon Sep 17 00:00:00 2001 From: intrigeri Date: Sun, 2 Nov 2008 18:48:56 +0100 Subject: po plugin: replace targetpage hook with wrapper function Signed-off-by: intrigeri --- IkiWiki/Plugin/po.pm | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'IkiWiki/Plugin') diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm index 9b5652561..127d6d47f 100644 --- a/IkiWiki/Plugin/po.pm +++ b/IkiWiki/Plugin/po.pm @@ -29,18 +29,19 @@ memoize("percenttranslated"); my %origsubs; $origsubs{'bestlink'}=\&IkiWiki::bestlink; $origsubs{'beautify_urlpath'}=\&IkiWiki::beautify_urlpath; +$origsubs{'targetpage'}=\&IkiWiki::targetpage; sub import { hook(type => "getsetup", id => "po", call => \&getsetup); hook(type => "checkconfig", id => "po", call => \&checkconfig); hook(type => "needsbuild", id => "po", call => \&needsbuild); - hook(type => "targetpage", id => "po", call => \&targetpage); hook(type => "tweakurlpath", id => "po", call => \&tweakurlpath); hook(type => "filter", id => "po", call => \&filter); hook(type => "htmlize", id => "po", call => \&htmlize); hook(type => "pagetemplate", id => "po", call => \&pagetemplate); inject(name => "IkiWiki::bestlink", call => \&mybestlink); inject(name => "IkiWiki::beautify_urlpath", call => \&mybeautify_urlpath); + inject(name => "IkiWiki::targetpage", call => \&mytargetpage); } sub getsetup () { #{{{ @@ -219,10 +220,9 @@ sub needsbuild () { #{{{ } } #}}} -sub targetpage (@) { #{{{ - my %params = @_; - my $page=$params{page}; - my $ext=$params{ext}; +sub mytargetpage ($$) { #{{{ + my $page=shift; + my $ext=shift; if (istranslation($page)) { my ($masterpage, $lang) = ($page =~ /(.*)[.]([a-z]{2})$/); @@ -241,7 +241,7 @@ sub targetpage (@) { #{{{ return $page . "/index." . $config{po_master_language}{code} . "." . $ext; } } - return; + return $origsubs{'targetpage'}->($page, $ext); } #}}} sub mybeautify_urlpath ($) { #{{{ -- cgit v1.2.3 From 439ba4490acbeafe6206d8723901e16ddcfc611a Mon Sep 17 00:00:00 2001 From: intrigeri Date: Sun, 2 Nov 2008 18:51:00 +0100 Subject: po plugin: removed last (?) bit of deprecated custom hook Signed-off-by: intrigeri --- IkiWiki/Plugin/po.pm | 1 - 1 file changed, 1 deletion(-) (limited to 'IkiWiki/Plugin') diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm index 127d6d47f..4608f59c7 100644 --- a/IkiWiki/Plugin/po.pm +++ b/IkiWiki/Plugin/po.pm @@ -35,7 +35,6 @@ sub import { hook(type => "getsetup", id => "po", call => \&getsetup); hook(type => "checkconfig", id => "po", call => \&checkconfig); hook(type => "needsbuild", id => "po", call => \&needsbuild); - hook(type => "tweakurlpath", id => "po", call => \&tweakurlpath); hook(type => "filter", id => "po", call => \&filter); hook(type => "htmlize", id => "po", call => \&htmlize); hook(type => "pagetemplate", id => "po", call => \&pagetemplate); -- cgit v1.2.3 From 37a9e642910628b021f0dd3cf9203f7f76f3a7cd Mon Sep 17 00:00:00 2001 From: intrigeri Date: Sun, 2 Nov 2008 18:54:53 +0100 Subject: po plugin: fix targetpage for home page's translations Signed-off-by: intrigeri --- IkiWiki/Plugin/po.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'IkiWiki/Plugin') diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm index 4608f59c7..88f8194fb 100644 --- a/IkiWiki/Plugin/po.pm +++ b/IkiWiki/Plugin/po.pm @@ -225,7 +225,7 @@ sub mytargetpage ($$) { #{{{ if (istranslation($page)) { my ($masterpage, $lang) = ($page =~ /(.*)[.]([a-z]{2})$/); - if (! $config{usedirs} || $page eq 'index') { + if (! $config{usedirs} || $masterpage eq 'index') { return $masterpage . "." . $lang . "." . $ext; } else { -- cgit v1.2.3 From 2ebc0bb82dd907b6c0eaa39441378cb3bd8152d5 Mon Sep 17 00:00:00 2001 From: intrigeri Date: Sun, 2 Nov 2008 20:08:38 +0100 Subject: po plugin: fix linking from a translation to its master page Signed-off-by: intrigeri --- IkiWiki/Plugin/po.pm | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'IkiWiki/Plugin') diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm index 88f8194fb..0902322e3 100644 --- a/IkiWiki/Plugin/po.pm +++ b/IkiWiki/Plugin/po.pm @@ -252,6 +252,17 @@ sub mybeautify_urlpath ($) { #{{{ return $res; } #}}} +sub urlto_with_orig_beautiful_urlpath($$) { #{{{ + my $to=shift; + my $from=shift; + + inject(name => "IkiWiki::beautify_urlpath", call => $origsubs{'beautify_urlpath'}); + my $res=urlto($to, $from); + inject(name => "IkiWiki::beautify_urlpath", call => \&mybeautify_urlpath); + + return $res; +} #}}} + sub mybestlink ($$) { #{{{ my $page=shift; my $link=shift; @@ -359,7 +370,7 @@ sub otherlanguages ($) { #{{{ elsif (istranslation($page)) { my ($masterpage, $curlang) = ($page =~ /(.*)[.]([a-z]{2})$/); push @ret, { - url => urlto($masterpage, $page), + url => urlto_with_orig_beautiful_urlpath($masterpage, $page), code => $config{po_master_language}{code}, language => $config{po_master_language}{name}, master => 1, -- cgit v1.2.3