From 7ab84dcfe52a37b93e6faa49895ae963a3b5d0d1 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 30 Aug 2010 13:15:49 -0400 Subject: highlight: Make location of highlight's files configurable in setup file to allow for nonstandard installations. --- IkiWiki/Plugin/highlight.pm | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/highlight.pm b/IkiWiki/Plugin/highlight.pm index e517ac5c0..d4ade0a7b 100644 --- a/IkiWiki/Plugin/highlight.pm +++ b/IkiWiki/Plugin/highlight.pm @@ -6,10 +6,6 @@ use strict; use IkiWiki 3.00; use Encode; -# locations of highlight's files -my $filetypes="/etc/highlight/filetypes.conf"; -my $langdefdir="/usr/share/highlight/langDefs"; - sub import { hook(type => "getsetup", id => "highlight", call => \&getsetup); hook(type => "checkconfig", id => "highlight", call => \&checkconfig); @@ -32,9 +28,29 @@ sub getsetup () { safe => 1, rebuild => 1, }, + filetypes_conf => { + type => "string", + example => "/etc/highlight/filetypes.conf", + description => "location of highlight's filetypes.conf", + safe => 0, + rebuild => undef, + }, + langdefdir => { + type => "string", + example => "/usr/share/highlight/langDefs", + description => "location of highlight's langDefs directory", + safe => 0, + rebuild => undef, + }, } sub checkconfig () { + if (! exists $config{filetypes_conf}) { + $config{filetypes_conf}="/etc/highlight/filetypes.conf"; + } + if (! exists $config{langdefdir}) { + $config{langdefdir}="/usr/share/highlight/langDefs"; + } if (exists $config{tohighlight}) { foreach my $file (split ' ', $config{tohighlight}) { my @opts = $file=~s/^\.// ? @@ -80,7 +96,7 @@ my %highlighters; # Parse highlight's config file to get extension => language mappings. sub read_filetypes () { - open (IN, $filetypes) || error("$filetypes: $!"); + open (IN, $config{filetypes_conf}) || error("$config{filetypes_conf}: $!"); while () { chomp; if (/^\$ext\((.*)\)=(.*)$/) { @@ -97,12 +113,12 @@ sub read_filetypes () { sub ext2langfile ($) { my $ext=shift; - my $langfile="$langdefdir/$ext.lang"; + my $langfile="$config{langdefdir}/$ext.lang"; return $langfile if exists $highlighters{$langfile}; read_filetypes() unless $filetypes_read; if (exists $ext2lang{$ext}) { - return "$langdefdir/$ext2lang{$ext}.lang"; + return "$config{langdefdir}/$ext2lang{$ext}.lang"; } # If a language only has one common extension, it will not # be listed in filetypes, so check the langfile. -- cgit v1.2.3 From 4e14c5e793178eda34042e027bb01e963f1dae7b Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 30 Aug 2010 15:06:58 -0400 Subject: call preprocess in scan mode hooks before scan hooks Following along with change in Render.pm --- IkiWiki/Plugin/table.pm | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/table.pm b/IkiWiki/Plugin/table.pm index 2edd1eacd..f3c425a37 100644 --- a/IkiWiki/Plugin/table.pm +++ b/IkiWiki/Plugin/table.pm @@ -40,6 +40,9 @@ sub preprocess (@) { # scan that file too. return unless exists $params{file}; + # Preprocess in scan-only mode. + IkiWiki::preprocess($params{page}, $params{page}, $params{data}, 1); + IkiWiki::run_hooks(scan => sub { shift->( page => $params{page}, @@ -47,9 +50,6 @@ sub preprocess (@) { ); }); - # Preprocess in scan-only mode. - IkiWiki::preprocess($params{page}, $params{page}, $params{data}, 1); - return; } -- cgit v1.2.3 From 69fc0f427e82c24613a33b005e5fe2422516c001 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 30 Aug 2010 15:44:55 -0400 Subject: remove obsolete check to see if check_canedit is available The function moved from the editpage plugin into IkiWiki core some time ago. --- IkiWiki/Receive.pm | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Receive.pm b/IkiWiki/Receive.pm index fdd463025..d116049c4 100644 --- a/IkiWiki/Receive.pm +++ b/IkiWiki/Receive.pm @@ -95,10 +95,8 @@ sub test () { if ($change->{action} eq 'change' || $change->{action} eq 'add') { if (defined $page) { - if (IkiWiki->can("check_canedit")) { - IkiWiki::check_canedit($page, $cgi, $session); - next; - } + IkiWiki::check_canedit($page, $cgi, $session); + next; } else { if (IkiWiki::Plugin::attachment->can("check_canattach")) { -- cgit v1.2.3 From 7784e0b7b89d2330f507e04fd15dc04027f1eeaf Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 30 Aug 2010 15:57:10 -0400 Subject: don't run check_canedit in nonfatal mode --- IkiWiki/Plugin/attachment.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/attachment.pm b/IkiWiki/Plugin/attachment.pm index ee105a170..f73e355ee 100644 --- a/IkiWiki/Plugin/attachment.pm +++ b/IkiWiki/Plugin/attachment.pm @@ -146,7 +146,7 @@ sub formbuilder (@) { # Check that the user is allowed to edit a page with the # name of the attachment. - IkiWiki::check_canedit($filename, $q, $session, 1); + IkiWiki::check_canedit($filename, $q, $session); # And that the attachment itself is acceptable. check_canattach($session, $filename, $tempfile); -- cgit v1.2.3 From 75382bd3747f4c293a5fee5715bfbebe0ff04187 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 30 Aug 2010 15:58:42 -0400 Subject: factor out check_canedit calls from check_canremove --- IkiWiki/Plugin/remove.pm | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/remove.pm b/IkiWiki/Plugin/remove.pm index 95f148183..4b527993b 100644 --- a/IkiWiki/Plugin/remove.pm +++ b/IkiWiki/Plugin/remove.pm @@ -42,9 +42,6 @@ sub check_canremove ($$$) { error(sprintf(gettext("%s is not a file"), $file)); } - # Must be editable. - IkiWiki::check_canedit($page, $q, $session); - # If a user can't upload an attachment, don't let them delete it. # This is sorta overkill, but better safe than sorry. if (! defined pagetype($pagesources{$page})) { @@ -121,6 +118,7 @@ sub removal_confirm ($$@) { my @pages=@_; foreach my $page (@pages) { + IkiWiki::check_canedit($page, $q, $session); check_canremove($page, $q, $session); } @@ -198,6 +196,7 @@ sub sessioncgi ($$) { # and that the user is allowed to edit(/remove) it. my @files; foreach my $page (@pages) { + IkiWiki::check_canedit($page, $q, $session); check_canremove($page, $q, $session); # This untaint is safe because of the -- cgit v1.2.3 From a330b1ee743f093a03ff23b2d4bff42df7def8b9 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 30 Aug 2010 16:05:15 -0400 Subject: Avoid trying to log the user in when receiving anonymous pushes from git and a plugin like httpauth returns a login function. Just use check_canedit in nonfatal mode. --- IkiWiki/Receive.pm | 3 +-- debian/changelog | 2 ++ doc/bugs/httpauth_conflicts_with_git_anon_push.mdwn | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Receive.pm b/IkiWiki/Receive.pm index d116049c4..14936f8cd 100644 --- a/IkiWiki/Receive.pm +++ b/IkiWiki/Receive.pm @@ -95,8 +95,7 @@ sub test () { if ($change->{action} eq 'change' || $change->{action} eq 'add') { if (defined $page) { - IkiWiki::check_canedit($page, $cgi, $session); - next; + next if IkiWiki::check_canedit($page, $cgi, $session, 1); } else { if (IkiWiki::Plugin::attachment->can("check_canattach")) { diff --git a/debian/changelog b/debian/changelog index df74e35d1..a1ef33b22 100644 --- a/debian/changelog +++ b/debian/changelog @@ -23,6 +23,8 @@ ikiwiki (3.20100816) UNRELEASED; urgency=low setup. (intrigeri) * t/bazaar.t: Work around bzr 2.2.0's new requirement to configure bzr whoami before committing. + * Avoid trying to log the user in when receiving anonymous pushes + from git and a plugin like httpauth returns a login function. -- Joey Hess Sun, 15 Aug 2010 11:45:48 -0400 diff --git a/doc/bugs/httpauth_conflicts_with_git_anon_push.mdwn b/doc/bugs/httpauth_conflicts_with_git_anon_push.mdwn index 3e496fef4..91507f57a 100644 --- a/doc/bugs/httpauth_conflicts_with_git_anon_push.mdwn +++ b/doc/bugs/httpauth_conflicts_with_git_anon_push.mdwn @@ -22,4 +22,4 @@ Analysis: So, all these calls need to avoid running the error handler functions returned by canedit hooks, and just return error -messages. +messages. [[done]] --[[Joey]] -- cgit v1.2.3 From 3b84ea2f535e46f3d510f05a0b8970d6c94f5104 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 30 Aug 2010 16:17:33 -0400 Subject: add explicit check_canedit calls when checking canattach or canremove --- IkiWiki/Receive.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Receive.pm b/IkiWiki/Receive.pm index 14936f8cd..2952480b4 100644 --- a/IkiWiki/Receive.pm +++ b/IkiWiki/Receive.pm @@ -100,7 +100,7 @@ sub test () { else { if (IkiWiki::Plugin::attachment->can("check_canattach")) { IkiWiki::Plugin::attachment::check_canattach($session, $file, $change->{path}); - next; + next if IkiWiki::check_canedit($file, $cgi, $session, 1); } } } @@ -116,7 +116,7 @@ sub test () { if (IkiWiki::Plugin::remove->can("check_canremove")) { IkiWiki::Plugin::remove::check_canremove(defined $page ? $page : $file, $cgi, $session); - next; + next if IkiWiki::check_canedit(defined $page ? $page : $file, $cgi, $session, 1); } } else { -- cgit v1.2.3 From 426b3ad747b2fb2b3d7626788ae0967a9497e854 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 30 Aug 2010 16:26:01 -0400 Subject: minor typo --- IkiWiki/Receive.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Receive.pm b/IkiWiki/Receive.pm index 2952480b4..cd746c95f 100644 --- a/IkiWiki/Receive.pm +++ b/IkiWiki/Receive.pm @@ -106,7 +106,7 @@ sub test () { } 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 + # on disk. This will fail when 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 -- cgit v1.2.3 From 8135d2a9ebc8090452a5b2841a1146ba52880a65 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 30 Aug 2010 17:38:00 -0400 Subject: remove dead code --- IkiWiki/Plugin/httpauth.pm | 7 ------- 1 file changed, 7 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/httpauth.pm b/IkiWiki/Plugin/httpauth.pm index 478f67446..868862f4f 100644 --- a/IkiWiki/Plugin/httpauth.pm +++ b/IkiWiki/Plugin/httpauth.pm @@ -78,13 +78,6 @@ sub formbuilder_setup (@) { } } -sub test_httpauth_pagespec ($) { - my $page=shift; - - return ( - ); -} - sub canedit ($$$) { my $page=shift; my $cgi=shift; -- cgit v1.2.3 From 8030ecac02a743e930e480650e8c14413f26d9a2 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 30 Aug 2010 17:58:00 -0400 Subject: Receive: avoid hiding check_canedit error messages Avoid the generic "you are not allowed to change" message, and instead allow check_canedit to propigate out useful error messages. Went back to calling check_canedit in fatal mode, but added a parameter to avoid calling the troublesome subs that might cause a login attempt. --- IkiWiki.pm | 4 +++- IkiWiki/Receive.pm | 8 +++----- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki.pm b/IkiWiki.pm index 6da281999..d114c9a69 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -1455,11 +1455,12 @@ sub filter ($$$) { return $content; } -sub check_canedit ($$$;$) { +sub check_canedit ($$$;$$) { my $page=shift; my $q=shift; my $session=shift; my $nonfatal=shift; + my $nosubs=shift; my $canedit; run_hooks(canedit => sub { @@ -1470,6 +1471,7 @@ sub check_canedit ($$$;$) { $canedit=1; } elsif (ref $ret eq 'CODE') { + error(sprintf(gettext("you are not allowed to change %s"), $page)) if $nosubs && ! $nonfatal; $ret->() unless $nonfatal; $canedit=0; } diff --git a/IkiWiki/Receive.pm b/IkiWiki/Receive.pm index cd746c95f..3a5f91758 100644 --- a/IkiWiki/Receive.pm +++ b/IkiWiki/Receive.pm @@ -95,12 +95,12 @@ sub test () { if ($change->{action} eq 'change' || $change->{action} eq 'add') { if (defined $page) { - next if IkiWiki::check_canedit($page, $cgi, $session, 1); + IkiWiki::check_canedit($page, $cgi, $session, 0, 1); } else { if (IkiWiki::Plugin::attachment->can("check_canattach")) { IkiWiki::Plugin::attachment::check_canattach($session, $file, $change->{path}); - next if IkiWiki::check_canedit($file, $cgi, $session, 1); + IkiWiki::check_canedit($file, $cgi, $session, 0, 1); } } } @@ -116,14 +116,12 @@ sub test () { if (IkiWiki::Plugin::remove->can("check_canremove")) { IkiWiki::Plugin::remove::check_canremove(defined $page ? $page : $file, $cgi, $session); - next if IkiWiki::check_canedit(defined $page ? $page : $file, $cgi, $session, 1); + IkiWiki::check_canedit(defined $page ? $page : $file, $cgi, $session, 0, 1); } } else { error "unknown action ".$change->{action}; } - - error sprintf(gettext("you are not allowed to change %s"), $file); } exit 0; -- cgit v1.2.3 From 70db57134a73cde5cafac0f02a3858a22d44ed26 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 30 Aug 2010 18:20:34 -0400 Subject: correct logic on error fallthrough --- IkiWiki/Receive.pm | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'IkiWiki') diff --git a/IkiWiki/Receive.pm b/IkiWiki/Receive.pm index 3a5f91758..972e3578d 100644 --- a/IkiWiki/Receive.pm +++ b/IkiWiki/Receive.pm @@ -96,11 +96,13 @@ sub test () { $change->{action} eq 'add') { if (defined $page) { IkiWiki::check_canedit($page, $cgi, $session, 0, 1); + next; } else { if (IkiWiki::Plugin::attachment->can("check_canattach")) { IkiWiki::Plugin::attachment::check_canattach($session, $file, $change->{path}); IkiWiki::check_canedit($file, $cgi, $session, 0, 1); + next; } } } @@ -117,11 +119,14 @@ sub test () { if (IkiWiki::Plugin::remove->can("check_canremove")) { IkiWiki::Plugin::remove::check_canremove(defined $page ? $page : $file, $cgi, $session); IkiWiki::check_canedit(defined $page ? $page : $file, $cgi, $session, 0, 1); + next; } } else { error "unknown action ".$change->{action}; } + + error sprintf(gettext("you are not allowed to change %s"), $file); } exit 0; -- cgit v1.2.3 From 2df0999e4033278a6cc8f6e2d00449224aa09efa Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 30 Aug 2010 18:31:56 -0400 Subject: revert check_canedit nosubs thing Abstraction violation. I now think the problem should be treated as a bug in httpauth. --- IkiWiki.pm | 4 +--- IkiWiki/Receive.pm | 6 +++--- 2 files changed, 4 insertions(+), 6 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki.pm b/IkiWiki.pm index d114c9a69..6da281999 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -1455,12 +1455,11 @@ sub filter ($$$) { return $content; } -sub check_canedit ($$$;$$) { +sub check_canedit ($$$;$) { my $page=shift; my $q=shift; my $session=shift; my $nonfatal=shift; - my $nosubs=shift; my $canedit; run_hooks(canedit => sub { @@ -1471,7 +1470,6 @@ sub check_canedit ($$$;$$) { $canedit=1; } elsif (ref $ret eq 'CODE') { - error(sprintf(gettext("you are not allowed to change %s"), $page)) if $nosubs && ! $nonfatal; $ret->() unless $nonfatal; $canedit=0; } diff --git a/IkiWiki/Receive.pm b/IkiWiki/Receive.pm index 972e3578d..e77c477a9 100644 --- a/IkiWiki/Receive.pm +++ b/IkiWiki/Receive.pm @@ -95,13 +95,13 @@ sub test () { if ($change->{action} eq 'change' || $change->{action} eq 'add') { if (defined $page) { - IkiWiki::check_canedit($page, $cgi, $session, 0, 1); + IkiWiki::check_canedit($page, $cgi, $session); next; } else { if (IkiWiki::Plugin::attachment->can("check_canattach")) { IkiWiki::Plugin::attachment::check_canattach($session, $file, $change->{path}); - IkiWiki::check_canedit($file, $cgi, $session, 0, 1); + IkiWiki::check_canedit($file, $cgi, $session); next; } } @@ -118,7 +118,7 @@ sub test () { if (IkiWiki::Plugin::remove->can("check_canremove")) { IkiWiki::Plugin::remove::check_canremove(defined $page ? $page : $file, $cgi, $session); - IkiWiki::check_canedit(defined $page ? $page : $file, $cgi, $session, 0, 1); + IkiWiki::check_canedit(defined $page ? $page : $file, $cgi, $session); next; } } -- cgit v1.2.3 From f55c7d13966ff1cd90ddf50e05829f6bb3eda557 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 30 Aug 2010 18:32:32 -0400 Subject: httpauth: Avoid redirecting the user to the cgiauthurl if they already have a login session. --- IkiWiki/Plugin/httpauth.pm | 2 ++ debian/changelog | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/httpauth.pm b/IkiWiki/Plugin/httpauth.pm index 868862f4f..cb488449d 100644 --- a/IkiWiki/Plugin/httpauth.pm +++ b/IkiWiki/Plugin/httpauth.pm @@ -84,6 +84,8 @@ sub canedit ($$$) { my $session=shift; if (! defined $cgi->remote_user() && + (! defined $session->param("name") || + ! IkiWiki::userinfo_get($session->param("name"), "regdate")) && defined $config{httpauth_pagespec} && length $config{httpauth_pagespec} && defined $config{cgiauthurl} && diff --git a/debian/changelog b/debian/changelog index a1ef33b22..44b54b123 100644 --- a/debian/changelog +++ b/debian/changelog @@ -23,8 +23,8 @@ ikiwiki (3.20100816) UNRELEASED; urgency=low setup. (intrigeri) * t/bazaar.t: Work around bzr 2.2.0's new requirement to configure bzr whoami before committing. - * Avoid trying to log the user in when receiving anonymous pushes - from git and a plugin like httpauth returns a login function. + * httpauth: Avoid redirecting the user to the cgiauthurl if + they already have a login session. -- Joey Hess Sun, 15 Aug 2010 11:45:48 -0400 -- cgit v1.2.3 From d3d3bbbb17be3b2004e730e2a5d394e23cdff116 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 30 Aug 2010 18:48:38 -0400 Subject: saner return codes for check_can{remove,rename} These return codes are not currently used, but might be later. --- IkiWiki/Plugin/remove.pm | 1 + IkiWiki/Plugin/rename.pm | 1 + 2 files changed, 2 insertions(+) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/remove.pm b/IkiWiki/Plugin/remove.pm index 4b527993b..1717c8cf3 100644 --- a/IkiWiki/Plugin/remove.pm +++ b/IkiWiki/Plugin/remove.pm @@ -71,6 +71,7 @@ sub check_canremove ($$$) { } } }); + return defined $canremove ? $canremove : 1; } sub formbuilder_setup (@) { diff --git a/IkiWiki/Plugin/rename.pm b/IkiWiki/Plugin/rename.pm index 61d39d4b5..ad5e72645 100644 --- a/IkiWiki/Plugin/rename.pm +++ b/IkiWiki/Plugin/rename.pm @@ -108,6 +108,7 @@ sub check_canrename ($$$$$$) { } } }); + return defined $canrename ? $canrename : 1; } sub rename_form ($$$) { -- cgit v1.2.3 From 8a6f4a7e50c247c061fd74b535d0f292aca6bda7 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 7 Sep 2010 12:08:59 -0400 Subject: needsbuild hook interface changed; the hooks should now return the modified array of things that need built. (Backwards compatability code keeps plugins using the old interface working.) --- IkiWiki/Plugin/aggregate.pm | 2 ++ IkiWiki/Plugin/calendar.pm | 1 + IkiWiki/Plugin/edittemplate.pm | 2 ++ IkiWiki/Plugin/listdirectives.pm | 2 ++ IkiWiki/Plugin/meta.pm | 1 + IkiWiki/Plugin/pinger.pm | 1 + IkiWiki/Plugin/po.pm | 2 ++ IkiWiki/Plugin/skeleton.pm.example | 4 ++++ IkiWiki/Plugin/theme.pm | 1 + IkiWiki/Plugin/version.pm | 1 + IkiWiki/Render.pm | 5 ++++- debian/changelog | 8 ++++++++ doc/plugins/write.mdwn | 4 ++-- 13 files changed, 31 insertions(+), 3 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/aggregate.pm b/IkiWiki/Plugin/aggregate.pm index 7789c4c2a..fe53d868d 100644 --- a/IkiWiki/Plugin/aggregate.pm +++ b/IkiWiki/Plugin/aggregate.pm @@ -210,6 +210,8 @@ sub needsbuild (@) { markunseen($feed->{sourcepage}); } } + + return $needsbuild; } sub preprocess (@) { diff --git a/IkiWiki/Plugin/calendar.pm b/IkiWiki/Plugin/calendar.pm index bb995d499..c7d2b7c01 100644 --- a/IkiWiki/Plugin/calendar.pm +++ b/IkiWiki/Plugin/calendar.pm @@ -491,6 +491,7 @@ sub needsbuild (@) { } } } + return $needsbuild; } 1 diff --git a/IkiWiki/Plugin/edittemplate.pm b/IkiWiki/Plugin/edittemplate.pm index 226f83bb4..4f07866e4 100644 --- a/IkiWiki/Plugin/edittemplate.pm +++ b/IkiWiki/Plugin/edittemplate.pm @@ -41,6 +41,8 @@ sub needsbuild (@) { } } } + + return $needsbuild; } sub preprocess (@) { diff --git a/IkiWiki/Plugin/listdirectives.pm b/IkiWiki/Plugin/listdirectives.pm index 8a67f7160..835e25388 100644 --- a/IkiWiki/Plugin/listdirectives.pm +++ b/IkiWiki/Plugin/listdirectives.pm @@ -64,6 +64,8 @@ sub needsbuild (@) { } } } + + return $needsbuild; } sub preprocess (@) { diff --git a/IkiWiki/Plugin/meta.pm b/IkiWiki/Plugin/meta.pm index d18585d3d..5941e3f3f 100644 --- a/IkiWiki/Plugin/meta.pm +++ b/IkiWiki/Plugin/meta.pm @@ -37,6 +37,7 @@ sub needsbuild (@) { } } } + return $needsbuild; } sub scrub ($$) { diff --git a/IkiWiki/Plugin/pinger.pm b/IkiWiki/Plugin/pinger.pm index c20ecb5d4..cc9f52d2b 100644 --- a/IkiWiki/Plugin/pinger.pm +++ b/IkiWiki/Plugin/pinger.pm @@ -45,6 +45,7 @@ sub needsbuild (@) { } } } + return $needsbuild; } sub preprocess (@) { diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm index f3530faf3..7b62092e1 100644 --- a/IkiWiki/Plugin/po.pm +++ b/IkiWiki/Plugin/po.pm @@ -221,6 +221,8 @@ sub needsbuild () { foreach my $master (keys %translations) { map add_depends($_, $master), values %{otherlanguages_pages($master)}; } + + return $needsbuild; } sub scan (@) { diff --git a/IkiWiki/Plugin/skeleton.pm.example b/IkiWiki/Plugin/skeleton.pm.example index 341d67867..7974d5e53 100644 --- a/IkiWiki/Plugin/skeleton.pm.example +++ b/IkiWiki/Plugin/skeleton.pm.example @@ -73,7 +73,11 @@ sub refresh () { } sub needsbuild ($) { + my $needsbuild=shift; + debug("skeleton plugin needsbuild"); + + return $needsbuild; } sub preprocess (@) { diff --git a/IkiWiki/Plugin/theme.pm b/IkiWiki/Plugin/theme.pm index 03b0816ed..ee94547e9 100644 --- a/IkiWiki/Plugin/theme.pm +++ b/IkiWiki/Plugin/theme.pm @@ -60,6 +60,7 @@ sub needsbuild ($) { $wikistate{theme}{currenttheme}=$config{theme}; } + return $needsbuild; } 1 diff --git a/IkiWiki/Plugin/version.pm b/IkiWiki/Plugin/version.pm index c13643478..fc265526c 100644 --- a/IkiWiki/Plugin/version.pm +++ b/IkiWiki/Plugin/version.pm @@ -37,6 +37,7 @@ sub needsbuild (@) { } } } + return $needsbuild; } sub preprocess (@) { diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm index 9921915b4..0dbe9611a 100644 --- a/IkiWiki/Render.pm +++ b/IkiWiki/Render.pm @@ -759,7 +759,10 @@ sub refresh () { my ($new, $internal_new)=find_new_files($files); my ($del, $internal_del)=find_del_files($pages); my ($changed, $internal_changed)=find_changed($files); - run_hooks(needsbuild => sub { shift->($changed) }); + run_hooks(needsbuild => sub { + my $ret=shift->($changed); + $changed=$ret if ref $ret eq 'ARRAY'; + }); my $oldlink_targets=calculate_old_links($changed, $del); foreach my $file (@$changed) { diff --git a/debian/changelog b/debian/changelog index 81bd99a71..430bd302c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,11 @@ +ikiwiki (3.20100832) UNRELEASED; urgency=low + + * needsbuild hook interface changed; the hooks should now return + the modified array of things that need built. (Backwards compatability + code keeps plugins using the old interface working.) + + -- Joey Hess Tue, 07 Sep 2010 12:08:05 -0400 + ikiwiki (3.20100831) unstable; urgency=low * filecheck: Fall back to using the file command if the freedesktop diff --git a/doc/plugins/write.mdwn b/doc/plugins/write.mdwn index 10b4df835..31bb64e68 100644 --- a/doc/plugins/write.mdwn +++ b/doc/plugins/write.mdwn @@ -179,8 +179,8 @@ function is passed no values. This allows a plugin to manipulate the list of files that need to be built when the wiki is refreshed. The function is passed a reference to an -array of files that will be rebuilt, and can modify the array, either -adding or removing files from it. +array of files that will be rebuilt. It should return an array reference +that is a modified version of its input. It can add or remove files from it. ### scan -- cgit v1.2.3 From 7415aee9cc1558316ab50d4e38e0408ae3fa53f5 Mon Sep 17 00:00:00 2001 From: Paul Menzel Date: Wed, 8 Sep 2010 15:34:41 +0200 Subject: teximg: Use Unicode UTF-8 encoding by default. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If I am not mistaking all source files in ikiwiki are encoded in Unicode UTF-8. Adding `\usepackage[utf8]{inputenc}` enables LaTeX to deal with the encoding. As a consequence some special characters like umlauts can be used in the source code which is useful for foreign languages. [[!teximg code="a = b \text{ für alle } b \neq 2"]] But for example »≠« cannot be used in LaTeX right now. One has to use other TeX systems like XeTeX or LuaTeX featuring native UTF-8 support or use additional nonstandard packages like uniinput [1]. I used the package `inputenc` (`texdoc inputenc`) and not `inputenx` (`texdoc inputenx`), because I have not used `inputenx` that much and using the option `math` is not supported in Debian (and I guess other distributions too) since `inpmath` is not included in CTAN. [1] http://wiki.neo-layout.org/browser/latex/Standard-LaTeX Signed-off-by: Paul Menzel --- IkiWiki/Plugin/teximg.pm | 1 + 1 file changed, 1 insertion(+) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/teximg.pm b/IkiWiki/Plugin/teximg.pm index 521af499f..195792aca 100644 --- a/IkiWiki/Plugin/teximg.pm +++ b/IkiWiki/Plugin/teximg.pm @@ -13,6 +13,7 @@ use IkiWiki 3.00; my $default_prefix = < Date: Fri, 10 Sep 2010 11:45:59 -0400 Subject: po: Allow enabling via web setup. The only unsafe thing should be that enabling it with some languages will generate po files. --- IkiWiki/Plugin/po.pm | 4 ++-- debian/changelog | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm index 7b62092e1..651c98ed7 100644 --- a/IkiWiki/Plugin/po.pm +++ b/IkiWiki/Plugin/po.pm @@ -89,7 +89,7 @@ sub import { sub getsetup () { return plugin => { - safe => 0, + safe => 1, rebuild => 1, # format plugin section => "format", }, @@ -110,7 +110,7 @@ sub getsetup () { 'es|Español', 'de|Deutsch' ], - description => "slave languages (PO files)", + description => "slave languages (translated via PO files) format: ll|Langname", safe => 1, rebuild => 1, }, diff --git a/debian/changelog b/debian/changelog index a89485f79..ebccf4698 100644 --- a/debian/changelog +++ b/debian/changelog @@ -7,6 +7,7 @@ ikiwiki (3.20100832) UNRELEASED; urgency=low perl taint checking happy, but taint checking is disabled. * teximg: Use Unicode UTF-8 encoding by default. Closes: #596067 Thanks, Paul Menzel. + * po: Allow enabling via web setup. -- Joey Hess Tue, 07 Sep 2010 12:08:05 -0400 -- cgit v1.2.3 From fbfda5ccfce40d3f0b5a6076ef02f07e9e5b8fd6 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 10 Sep 2010 13:13:00 -0400 Subject: po: Make the po_master_language use a langpair like "en|English", so it can be configured via the web. --- IkiWiki/Plugin/po.pm | 81 ++++++++++++++++++++++++++++++++-------------------- debian/changelog | 2 ++ doc/plugins/po.mdwn | 2 +- 3 files changed, 53 insertions(+), 32 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm index 651c98ed7..a233fb5af 100644 --- a/IkiWiki/Plugin/po.pm +++ b/IkiWiki/Plugin/po.pm @@ -25,6 +25,7 @@ use File::Temp; use Memoize; use UNIVERSAL; +my ($master_language_code, $master_language_name); my %translations; my @origneedsbuild; my %origsubs; @@ -95,10 +96,7 @@ sub getsetup () { }, po_master_language => { type => "string", - example => { - 'code' => 'en', - 'name' => 'English' - }, + example => "en|English", description => "master language (non-PO files)", safe => 1, rebuild => 1, @@ -132,24 +130,31 @@ sub getsetup () { } sub checkconfig () { - foreach my $field (qw{po_master_language}) { - if (! exists $config{$field} || ! defined $config{$field}) { - error(sprintf(gettext("Must specify %s when using the %s plugin"), - $field, 'po')); + if (exists $config{po_master_language}) { + if (! ref $config{po_master_language}) { + ($master_language_code, $master_language_name)= + splitlangpair($config{po_master_language}); } + else { + $master_language_code=$config{po_master_language}{code}; + $master_language_name=$config{po_master_language}{name}; + } + } + if (! defined $master_language_code) { + $master_language_code='en'; + } + if (! defined $master_language_name) { + $master_language_name='English'; } if (ref $config{po_slave_languages} eq 'ARRAY') { my %slaves; foreach my $pair (@{$config{po_slave_languages}}) { - my ($code, $name) = ( $pair =~ /^([a-z]{2})\|(.+)$/ ); - if (!defined $code || !defined $name) { - error(sprintf(gettext("%s has invalid syntax: must use CODE|NAME"), - $pair)); + my ($code, $name)=splitlangpair($pair); + if (defined $code) { + push @slavelanguages, $code; + $slaves{$code} = $name; } - $slaves{$code} = $name; - push @slavelanguages, $code; - } $config{po_slave_languages} = \%slaves; } @@ -159,12 +164,12 @@ sub checkconfig () { } keys %{$config{po_slave_languages}}; } - delete $config{po_slave_languages}{$config{po_master_language}{code}};; + delete $config{po_slave_languages}{$master_language_code}; map { islanguagecode($_) or error(sprintf(gettext("%s is not a valid language code"), $_)); - } ($config{po_master_language}{code}, @slavelanguages); + } ($master_language_code, @slavelanguages); if (! exists $config{po_translatable_pages} || ! defined $config{po_translatable_pages}) { @@ -198,11 +203,11 @@ sub checkconfig () { if -d "$config{underlaydirbase}/po/$ll/$underlay"; } - if ($config{po_master_language}{code} ne 'en') { + if ($master_language_code ne 'en') { # Add underlay containing translated source files # for the master language. - add_underlay("locale/$config{po_master_language}{code}/$underlay") - if -d "$config{underlaydirbase}/locale/$config{po_master_language}{code}/$underlay"; + add_underlay("locale/$master_language_code/$underlay") + if -d "$config{underlaydirbase}/locale/$master_language_code/$underlay"; } } } @@ -512,7 +517,7 @@ sub formbuilder_setup (@) { if ($form->field("do") eq "create") { # Warn the user: new pages must be written in master language. my $template=template("pocreatepage.tmpl"); - $template->param(LANG => $config{po_master_language}{name}); + $template->param(LANG => $master_language_name); $form->tmpl_param(message => $template->output); } elsif ($form->field("do") eq "edit") { @@ -601,7 +606,7 @@ sub mybeautify_urlpath ($) { my $res=$origsubs{'beautify_urlpath'}->($url); if (defined $config{po_link_to} && $config{po_link_to} eq "negotiated") { - $res =~ s!/\Qindex.$config{po_master_language}{code}.$config{htmlext}\E$!/!; + $res =~ s!/\Qindex.$master_language_code.$config{htmlext}\E$!/!; $res =~ s!/\Qindex.$config{htmlext}\E$!/!; map { $res =~ s!/\Qindex.$_.$config{htmlext}\E$!/!; @@ -824,7 +829,7 @@ sub lang ($) { if (1 < (my ($masterpage, $lang) = _istranslation($page))) { return $lang; } - return $config{po_master_language}{code}; + return $master_language_code; } sub islanguagecode ($) { @@ -837,7 +842,7 @@ sub otherlanguage_page ($$) { my $page=shift; my $code=shift; - return masterpage($page) if $code eq $config{po_master_language}{code}; + return masterpage($page) if $code eq $master_language_code; return masterpage($page) . '.' . $code; } @@ -851,9 +856,9 @@ sub otherlanguages_codes ($) { return \@ret unless istranslation($page) || istranslatable($page); my $curlang=lang($page); foreach my $lang - ($config{po_master_language}{code}, @slavelanguages) { + ($master_language_code, @slavelanguages) { next if $lang eq $curlang; - if ($lang eq $config{po_master_language}{code} || + if ($lang eq $master_language_code || istranslatedto(masterpage($page), $lang)) { push @ret, $lang; } @@ -1008,8 +1013,8 @@ sub percenttranslated ($) { sub languagename ($) { my $code=shift; - return $config{po_master_language}{name} - if $code eq $config{po_master_language}{code}; + return $master_language_name + if $code eq $master_language_code; return $config{po_slave_languages}{$code} if defined $config{po_slave_languages}{$code}; return; @@ -1022,13 +1027,13 @@ sub otherlanguagesloop ($) { if (istranslation($page)) { push @ret, { url => urlto_with_orig_beautiful_urlpath(masterpage($page), $page), - code => $config{po_master_language}{code}, - language => $config{po_master_language}{name}, + code => $master_language_code, + language => $master_language_name, master => 1, }; } foreach my $lang (@{otherlanguages_codes($page)}) { - next if $lang eq $config{po_master_language}{code}; + next if $lang eq $master_language_code; my $otherpage = otherlanguage_page($page, $lang); push @ret, { url => urlto_with_orig_beautiful_urlpath($otherpage, $page), @@ -1233,6 +1238,20 @@ sub po4a_options($) { return %options; } +sub splitlangpair ($) { + my $pair=shift; + + my ($code, $name) = ( $pair =~ /^([a-z]{2})\|(.+)$/ ); + if (! defined $code || ! defined $name || + ! length $code || ! length $name) { + # not a fatal error to avoid breaking if used with web setup + print STDERR sprintf(gettext("%s has invalid syntax: must use CODE|NAME"), + $pair)."\n"; + } + + return $code, $name; +} + # ,---- # | PageSpecs # `---- diff --git a/debian/changelog b/debian/changelog index ebccf4698..72b220a4f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -7,6 +7,8 @@ ikiwiki (3.20100832) UNRELEASED; urgency=low perl taint checking happy, but taint checking is disabled. * teximg: Use Unicode UTF-8 encoding by default. Closes: #596067 Thanks, Paul Menzel. + * po: Make the po_master_language use a langpair like "en|English", + so it can be configured via the web. * po: Allow enabling via web setup. -- Joey Hess Tue, 07 Sep 2010 12:08:05 -0400 diff --git a/doc/plugins/po.mdwn b/doc/plugins/po.mdwn index da58a9f49..2acbc366a 100644 --- a/doc/plugins/po.mdwn +++ b/doc/plugins/po.mdwn @@ -49,7 +49,7 @@ Supported languages `po_master_language` is used to set the "master" language in `ikiwiki.setup`, such as: - po_master_language => { 'code' => 'en', 'name' => 'English' } + po_master_language => 'en|English' `po_slave_languages` is used to set the list of supported "slave" languages, such as: -- cgit v1.2.3 From 23f88690092f4434335f0ae4df90fafbf58100eb Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 10 Sep 2010 14:04:43 -0400 Subject: po: Auto-upgrade old format settings to new formats when writing setup file. --- IkiWiki/Plugin/po.pm | 27 +++++++++++++++++++-------- debian/changelog | 2 ++ 2 files changed, 21 insertions(+), 8 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm index a233fb5af..d920d3648 100644 --- a/IkiWiki/Plugin/po.pm +++ b/IkiWiki/Plugin/po.pm @@ -30,6 +30,7 @@ my %translations; my @origneedsbuild; my %origsubs; my @slavelanguages; # language codes ordered as in config po_slave_languages +my %slavelanguages; # language code to name lookup memoize("istranslatable"); memoize("_istranslation"); @@ -138,6 +139,7 @@ sub checkconfig () { else { $master_language_code=$config{po_master_language}{code}; $master_language_name=$config{po_master_language}{name}; + $config{po_master_language}=joinlangpair($master_language_code, $master_language_name); } } if (! defined $master_language_code) { @@ -148,23 +150,25 @@ sub checkconfig () { } if (ref $config{po_slave_languages} eq 'ARRAY') { - my %slaves; foreach my $pair (@{$config{po_slave_languages}}) { my ($code, $name)=splitlangpair($pair); if (defined $code) { push @slavelanguages, $code; - $slaves{$code} = $name; + $slavelanguages{$code} = $name; } } - $config{po_slave_languages} = \%slaves; } elsif (ref $config{po_slave_languages} eq 'HASH') { + %slavelanguages=%{$config{po_slave_languages}}; @slavelanguages = sort { $config{po_slave_languages}->{$a} cmp $config{po_slave_languages}->{$b}; - } keys %{$config{po_slave_languages}}; + } keys %slavelanguages; + $config{po_slave_languages}=[ + map { joinlangpair($_, $slavelanguages{$_}) } @slavelanguages + ] } - delete $config{po_slave_languages}{$master_language_code}; + delete $slavelanguages{$master_language_code}; map { islanguagecode($_) @@ -797,7 +801,7 @@ sub _istranslation ($) { return 0 unless defined $masterpage && defined $lang && length $masterpage && length $lang && defined $pagesources{$masterpage} - && defined $config{po_slave_languages}{$lang}; + && defined $slavelanguages{$lang}; return (maybe_add_leading_slash($masterpage, $hasleadingslash), $lang) if istranslatable($masterpage); @@ -1015,8 +1019,8 @@ sub languagename ($) { return $master_language_name if $code eq $master_language_code; - return $config{po_slave_languages}{$code} - if defined $config{po_slave_languages}{$code}; + return $slavelanguages{$code} + if defined $slavelanguages{$code}; return; } @@ -1252,6 +1256,13 @@ sub splitlangpair ($) { return $code, $name; } +sub joinlangpair ($$) { + my $code=shift; + my $name=shift; + + return "$code|$name"; +} + # ,---- # | PageSpecs # `---- diff --git a/debian/changelog b/debian/changelog index 72b220a4f..4b61a12b0 100644 --- a/debian/changelog +++ b/debian/changelog @@ -10,6 +10,8 @@ ikiwiki (3.20100832) UNRELEASED; urgency=low * po: Make the po_master_language use a langpair like "en|English", so it can be configured via the web. * po: Allow enabling via web setup. + * po: Auto-upgrade old format settings to new formats when writing + setup file. -- Joey Hess Tue, 07 Sep 2010 12:08:05 -0400 -- cgit v1.2.3 From 8c1a3595d49760ecedd7e56b6f2f2c5f2271b85d Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 10 Sep 2010 14:12:59 -0400 Subject: avoid dups getting into @slavelanguages This could happen if checkconfig was run twice, I think. --- IkiWiki/Plugin/po.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm index d920d3648..ab39cca12 100644 --- a/IkiWiki/Plugin/po.pm +++ b/IkiWiki/Plugin/po.pm @@ -152,7 +152,7 @@ sub checkconfig () { if (ref $config{po_slave_languages} eq 'ARRAY') { foreach my $pair (@{$config{po_slave_languages}}) { my ($code, $name)=splitlangpair($pair); - if (defined $code) { + if (defined $code && ! exists $slavelanguages{$code}) { push @slavelanguages, $code; $slavelanguages{$code} = $name; } -- cgit v1.2.3 From 163fc34db7f29bc75a05c54b83c2a00c5ad899c2 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 10 Sep 2010 14:20:53 -0400 Subject: use warn --- IkiWiki/Plugin/po.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm index ab39cca12..a79e7d7f0 100644 --- a/IkiWiki/Plugin/po.pm +++ b/IkiWiki/Plugin/po.pm @@ -1249,8 +1249,8 @@ sub splitlangpair ($) { if (! defined $code || ! defined $name || ! length $code || ! length $name) { # not a fatal error to avoid breaking if used with web setup - print STDERR sprintf(gettext("%s has invalid syntax: must use CODE|NAME"), - $pair)."\n"; + warn sprintf(gettext("%s has invalid syntax: must use CODE|NAME"), + $pair); } return $code, $name; -- cgit v1.2.3 From c4ebdd6f467f3361b1f444d9462e10acdbcf9322 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 10 Sep 2010 17:17:08 -0400 Subject: Pass array of names of files that have been deleted to needsbuild hook as second parameter, to allow for plugins that needs access to this information earlier than the delete hook. --- IkiWiki/Plugin/inline.pm | 5 +++-- IkiWiki/Render.pm | 2 +- debian/changelog | 3 +++ doc/plugins/write.mdwn | 13 +++++++++---- 4 files changed, 16 insertions(+), 7 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/inline.pm b/IkiWiki/Plugin/inline.pm index 715a3d652..20c5f3bdd 100644 --- a/IkiWiki/Plugin/inline.pm +++ b/IkiWiki/Plugin/inline.pm @@ -570,9 +570,9 @@ sub genfeed ($$$$$@) { } } + my $file=$pagesources{$p}; + my $type=pagetype($file); if ($itemtemplate->query(name => "enclosure")) { - my $file=$pagesources{$p}; - my $type=pagetype($file); if (defined $type) { $itemtemplate->param(content => $pcontent); } @@ -591,6 +591,7 @@ sub genfeed ($$$$$@) { } } else { + next unless defined $type; $itemtemplate->param(content => $pcontent); } diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm index 0dbe9611a..7ea919abc 100644 --- a/IkiWiki/Render.pm +++ b/IkiWiki/Render.pm @@ -760,7 +760,7 @@ sub refresh () { my ($del, $internal_del)=find_del_files($pages); my ($changed, $internal_changed)=find_changed($files); run_hooks(needsbuild => sub { - my $ret=shift->($changed); + my $ret=shift->($changed, [@$del, @$internal_del]); $changed=$ret if ref $ret eq 'ARRAY'; }); my $oldlink_targets=calculate_old_links($changed, $del); diff --git a/debian/changelog b/debian/changelog index 4b61a12b0..bf294b6d4 100644 --- a/debian/changelog +++ b/debian/changelog @@ -12,6 +12,9 @@ ikiwiki (3.20100832) UNRELEASED; urgency=low * po: Allow enabling via web setup. * po: Auto-upgrade old format settings to new formats when writing setup file. + * Pass array of names of files that have been deleted to needsbuild hook + as second parameter, to allow for plugins that needs access to this + information earlier than the delete hook. -- Joey Hess Tue, 07 Sep 2010 12:08:05 -0400 diff --git a/doc/plugins/write.mdwn b/doc/plugins/write.mdwn index 31bb64e68..e60314485 100644 --- a/doc/plugins/write.mdwn +++ b/doc/plugins/write.mdwn @@ -177,10 +177,15 @@ function is passed no values. hook(type => "needsbuild", id => "foo", call => \&needsbuild); -This allows a plugin to manipulate the list of files that need to be -built when the wiki is refreshed. The function is passed a reference to an -array of files that will be rebuilt. It should return an array reference -that is a modified version of its input. It can add or remove files from it. +This allows a plugin to observe or even manipulate the list of files that +need to be built when the wiki is refreshed. + +As its first parameter, the function is passed a reference to an array of +files that will be built. It should return an array reference that is a +modified version of its input. It can add or remove files from it. + +The second parameter passed to the function is a reference to an array of +files that have been deleted. ### scan -- cgit v1.2.3 From 24ff4a9e5f365854ebef59ca2ef99552fdc5b4a6 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 13 Sep 2010 12:49:31 -0400 Subject: revert accidentially committed change --- IkiWiki/Plugin/inline.pm | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/inline.pm b/IkiWiki/Plugin/inline.pm index 20c5f3bdd..715a3d652 100644 --- a/IkiWiki/Plugin/inline.pm +++ b/IkiWiki/Plugin/inline.pm @@ -570,9 +570,9 @@ sub genfeed ($$$$$@) { } } - my $file=$pagesources{$p}; - my $type=pagetype($file); if ($itemtemplate->query(name => "enclosure")) { + my $file=$pagesources{$p}; + my $type=pagetype($file); if (defined $type) { $itemtemplate->param(content => $pcontent); } @@ -591,7 +591,6 @@ sub genfeed ($$$$$@) { } } else { - next unless defined $type; $itemtemplate->param(content => $pcontent); } -- cgit v1.2.3 From e0898ae1a8e64a12c4e47b3f922d6cf1fad4f31c Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 14 Sep 2010 15:23:16 -0400 Subject: blogspam: Fix crash when content contained utf-8. I also tried setting RPC::XML::ENCODING but that did not prevent the crash, and it seems that blogspam.net doesn't like getting xml encoded in unicode, since it mis-flagged comments as spammy that way that are normally allowed through. --- IkiWiki/Plugin/blogspam.pm | 12 +++++++----- debian/changelog | 1 + .../blog_spam_plugin_not_allowing_non-ASCII_chars__63__.mdwn | 5 +++++ 3 files changed, 13 insertions(+), 5 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/blogspam.pm b/IkiWiki/Plugin/blogspam.pm index 8db3780e8..f0b6cb2a2 100644 --- a/IkiWiki/Plugin/blogspam.pm +++ b/IkiWiki/Plugin/blogspam.pm @@ -4,6 +4,7 @@ package IkiWiki::Plugin::blogspam; use warnings; use strict; use IkiWiki 3.00; +use Encode; my $defaulturl='http://test.blogspam.net:8888/'; @@ -68,6 +69,7 @@ sub checkcontent (@) { my $url=$defaulturl; $url = $config{blogspam_server} if exists $config{blogspam_server}; + my $client = RPC::XML::Client->new($url); my @options = split(",", $config{blogspam_options}) @@ -90,12 +92,12 @@ sub checkcontent (@) { my %req=( ip => $session->remote_addr(), - comment => defined $params{diff} ? $params{diff} : $params{content}, - subject => defined $params{subject} ? $params{subject} : "", - name => defined $params{author} ? $params{author} : "", - link => exists $params{url} ? $params{url} : "", + comment => encode_utf8(defined $params{diff} ? $params{diff} : $params{content}), + subject => encode_utf8(defined $params{subject} ? $params{subject} : ""), + name => encode_utf8(defined $params{author} ? $params{author} : ""), + link => encode_utf8(exists $params{url} ? $params{url} : ""), options => join(",", @options), - site => $config{url}, + site => encode_utf8($config{url}), version => "ikiwiki ".$IkiWiki::version, ); my $res = $client->send_request('testComment', \%req); diff --git a/debian/changelog b/debian/changelog index 8b127b574..0eb5810d0 100644 --- a/debian/changelog +++ b/debian/changelog @@ -18,6 +18,7 @@ ikiwiki (3.20100832) UNRELEASED; urgency=low * actiontabs: Improve tab padding. * blueview: Fix display of links to translated pages in the page header. * Set isPermaLink="no" for guids in rss feeds. + * blogspam: Fix crash when content contained utf-8. -- Joey Hess Tue, 07 Sep 2010 12:08:05 -0400 diff --git a/doc/bugs/blog_spam_plugin_not_allowing_non-ASCII_chars__63__.mdwn b/doc/bugs/blog_spam_plugin_not_allowing_non-ASCII_chars__63__.mdwn index 22242a97f..265040d67 100644 --- a/doc/bugs/blog_spam_plugin_not_allowing_non-ASCII_chars__63__.mdwn +++ b/doc/bugs/blog_spam_plugin_not_allowing_non-ASCII_chars__63__.mdwn @@ -8,3 +8,8 @@ This seems to happen because I had a non-ASCII character in the comment (an elli The interesting part is that the comment preview works fine, just the save fails. Probably this means that the blogspam plugin is the culprit (hence the error in RPC::XML::Client library). I'm using version 3.20100815~bpo50+. Thanks! + +> I've filed an upstream bug about this on RPC::XML: +> +> +> Worked around it in blogspam by decoding. --[[Joey]] -- cgit v1.2.3 From 0ff945ddf19010b890458face057505f7b48b572 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 14 Sep 2010 15:37:45 -0400 Subject: external: Disable RPC::XML's "smart" encoding, which sent ints for strings that contained only a number, fixing a longstanding crash of the rst plugin. --- IkiWiki/Plugin/external.pm | 2 ++ debian/changelog | 3 +++ doc/bugs/rst_fails_on_file_containing_only_a_number.mdwn | 3 +++ 3 files changed, 8 insertions(+) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/external.pm b/IkiWiki/Plugin/external.pm index ec91c79db..a4cc1dd3c 100644 --- a/IkiWiki/Plugin/external.pm +++ b/IkiWiki/Plugin/external.pm @@ -28,7 +28,9 @@ sub import { $plugins{$plugin}={in => $plugin_read, out => $plugin_write, pid => $pid, accum => ""}; + $RPC::XML::ENCODING="utf-8"; + $RPC::XML::FORCE_STRING_ENCODING="true"; rpc_call($plugins{$plugin}, "import"); } diff --git a/debian/changelog b/debian/changelog index 0eb5810d0..46401b58c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -19,6 +19,9 @@ ikiwiki (3.20100832) UNRELEASED; urgency=low * blueview: Fix display of links to translated pages in the page header. * Set isPermaLink="no" for guids in rss feeds. * blogspam: Fix crash when content contained utf-8. + * external: Disable RPC::XML's "smart" encoding, which sent ints + for strings that contained only a number, fixing a longstanding crash + of the rst plugin. -- Joey Hess Tue, 07 Sep 2010 12:08:05 -0400 diff --git a/doc/bugs/rst_fails_on_file_containing_only_a_number.mdwn b/doc/bugs/rst_fails_on_file_containing_only_a_number.mdwn index dab3b7e5b..99e46aac9 100644 --- a/doc/bugs/rst_fails_on_file_containing_only_a_number.mdwn +++ b/doc/bugs/rst_fails_on_file_containing_only_a_number.mdwn @@ -24,3 +24,6 @@ throwing code..): > No, still the same failure. I think it's failing parsing the input data, > (which perl probably transmitted as an int due to perl internals) > not writing out its response. --[[Joey]] + +> On second thought, this was a bug in ikiwiki, it should be transmitting +> that as a string. Fixed in external.pm --[[Joey]] -- cgit v1.2.3 From cd794613b6f5140365e51f79023c882e8ea71197 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 14 Sep 2010 15:45:38 -0400 Subject: git: When updating from remote, use git pull --prune, to avoid possible errors from conflicting obsolete remote branches. --- IkiWiki/Plugin/git.pm | 2 +- debian/changelog | 2 ++ doc/bugs/git.pm_should_prune_remote_branches_when_fetching.mdwn | 3 +++ 3 files changed, 6 insertions(+), 1 deletion(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/git.pm b/IkiWiki/Plugin/git.pm index d342a7398..fd57ce1e4 100644 --- a/IkiWiki/Plugin/git.pm +++ b/IkiWiki/Plugin/git.pm @@ -462,7 +462,7 @@ sub rcs_update () { # Update working directory. if (length $config{gitorigin_branch}) { - run_or_cry('git', 'pull', $config{gitorigin_branch}); + run_or_cry('git', 'pull', '--prune', $config{gitorigin_branch}); } } diff --git a/debian/changelog b/debian/changelog index 46401b58c..27e0fb103 100644 --- a/debian/changelog +++ b/debian/changelog @@ -22,6 +22,8 @@ ikiwiki (3.20100832) UNRELEASED; urgency=low * external: Disable RPC::XML's "smart" encoding, which sent ints for strings that contained only a number, fixing a longstanding crash of the rst plugin. + * git: When updating from remote, use git pull --prune, to avoid possible + errors from conflicting obsolete remote branches. -- Joey Hess Tue, 07 Sep 2010 12:08:05 -0400 diff --git a/doc/bugs/git.pm_should_prune_remote_branches_when_fetching.mdwn b/doc/bugs/git.pm_should_prune_remote_branches_when_fetching.mdwn index 01f3d1a28..5dc4250e3 100644 --- a/doc/bugs/git.pm_should_prune_remote_branches_when_fetching.mdwn +++ b/doc/bugs/git.pm_should_prune_remote_branches_when_fetching.mdwn @@ -9,3 +9,6 @@ Pruning remote branches can be done automatically with the --prune option to "gi > from obsolete remote branches. --[[Joey]] Suppose a remote repository contains a branch named "foo", and you fetch from it. Then, someone renames that branch to "foo/bar". The next time you fetch from that repository, you will get an error because the obsolete branch "foo" is blocking the branch "foo/bar" from being created (due to the way git stores refs for branches). Pruning gets around the problem. It doesn't really add much overhead to the fetch, and in fact it can *save* overhead since obsolete branches do consume resources (any commits they point to cannot be garbage collected). --[[blipvert]] + +> Ok, so git pull --prune can be used to do everything in one command. +> [[done]] --[[Joey]] -- cgit v1.2.3 From 884835ce1cd3b1ba24d6f6bb19786d04e6b8ae90 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 15 Sep 2010 16:24:50 -0400 Subject: cutpaste: Fix bug that occured in some cases involving inlines when text was pasted on a page before being cut. --- IkiWiki/Plugin/cutpaste.pm | 31 +++++++++++++++------- debian/changelog | 2 ++ ..._in_this_page_--_missing_page_dependencies.mdwn | 20 ++++++++++++++ 3 files changed, 44 insertions(+), 9 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/cutpaste.pm b/IkiWiki/Plugin/cutpaste.pm index 4a8817168..0f6ea0b1f 100644 --- a/IkiWiki/Plugin/cutpaste.pm +++ b/IkiWiki/Plugin/cutpaste.pm @@ -5,10 +5,9 @@ use warnings; use strict; use IkiWiki 3.00; -my %savedtext; - sub import { hook(type => "getsetup", id => "cutpaste", call => \&getsetup); + hook(type => "needsbuild", id => "cutpaste", call => \&needsbuild); hook(type => "preprocess", id => "cut", call => \&preprocess_cut, scan => 1); hook(type => "preprocess", id => "copy", call => \&preprocess_copy, scan => 1); hook(type => "preprocess", id => "paste", call => \&preprocess_paste); @@ -23,6 +22,22 @@ sub getsetup () { }, } +sub needsbuild (@) { + my $needsbuild=shift; + foreach my $page (keys %pagestate) { + if (exists $pagestate{$page}{cutpaste}) { + if (exists $pagesources{$page} && + grep { $_ eq $pagesources{$page} } @$needsbuild) { + # remove state, will be re-added if + # the cut/copy directive is still present + # on rebuild. + delete $pagestate{$page}{cutpaste}; + } + } + } + return $needsbuild; +} + sub preprocess_cut (@) { my %params=@_; @@ -32,8 +47,7 @@ sub preprocess_cut (@) { } } - $savedtext{$params{page}} = {} if not exists $savedtext{$params{"page"}}; - $savedtext{$params{page}}->{$params{id}} = $params{text}; + $pagestate{$params{page}}{cutpaste}{$params{id}} = $params{text}; return "" if defined wantarray; } @@ -47,8 +61,7 @@ sub preprocess_copy (@) { } } - $savedtext{$params{page}} = {} if not exists $savedtext{$params{"page"}}; - $savedtext{$params{page}}->{$params{id}} = $params{text}; + $pagestate{$params{page}}{cutpaste}{$params{id}} = $params{text}; return IkiWiki::preprocess($params{page}, $params{destpage}, $params{text}) if defined wantarray; @@ -63,15 +76,15 @@ sub preprocess_paste (@) { } } - if (! exists $savedtext{$params{page}}) { + if (! exists $pagestate{$params{page}}{cutpaste}) { error gettext('no text was copied in this page'); } - if (! exists $savedtext{$params{page}}->{$params{id}}) { + if (! exists $pagestate{$params{page}}{cutpaste}{$params{id}}) { error sprintf(gettext('no text was copied in this page with id %s'), $params{id}); } return IkiWiki::preprocess($params{page}, $params{destpage}, - $savedtext{$params{page}}->{$params{id}}); + $pagestate{$params{page}}{cutpaste}{$params{id}}); } 1; diff --git a/debian/changelog b/debian/changelog index 27e0fb103..d6eebea78 100644 --- a/debian/changelog +++ b/debian/changelog @@ -24,6 +24,8 @@ ikiwiki (3.20100832) UNRELEASED; urgency=low of the rst plugin. * git: When updating from remote, use git pull --prune, to avoid possible errors from conflicting obsolete remote branches. + * cutpaste: Fix bug that occured in some cases involving inlines when + text was pasted on a page before being cut. -- Joey Hess Tue, 07 Sep 2010 12:08:05 -0400 diff --git a/doc/bugs/Error:_no_text_was_copied_in_this_page_--_missing_page_dependencies.mdwn b/doc/bugs/Error:_no_text_was_copied_in_this_page_--_missing_page_dependencies.mdwn index 356f9155a..4535cf35d 100644 --- a/doc/bugs/Error:_no_text_was_copied_in_this_page_--_missing_page_dependencies.mdwn +++ b/doc/bugs/Error:_no_text_was_copied_in_this_page_--_missing_page_dependencies.mdwn @@ -24,3 +24,23 @@ This error shows up only for *news.html*, but not in *news/2010-07-31* or for the aggregation in *index.html* or its RSS and atom files. --[[tschwinge]] + +> So the cutpaste plugin, in order to support pastes +> that come before the corresponding cut in the page, +> relies on the scan hook being called for the page +> before it is preprocessed. +> +> In the case of an inline, this doesn't happen, if +> the page in question has not changed. +> +> Really though it's not just inline, it's potentially anything +> that preprocesses content. None of those things guarantee that +> scan gets re-run on it first. +> +> I think cutpaste is going beyond the intended use of scan hooks, +> which is to gather link information, not do arbitrary data collection. +> Requiring scan be run repeatedly could be a lot more work. +> +> Using `%pagestate` to store the cut content when scanning would be +> one way to fix this bug. It would mean storing potentially big chunks +> of page content in the indexdb. --[[Joey]] -- cgit v1.2.3 From 2ca4ff8ae6d2d528b8895f7907d74c2f8859dc8d Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 19 Sep 2010 20:04:31 -0400 Subject: add missing space --- IkiWiki/Plugin/meta.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/meta.pm b/IkiWiki/Plugin/meta.pm index 5941e3f3f..ae593555e 100644 --- a/IkiWiki/Plugin/meta.pm +++ b/IkiWiki/Plugin/meta.pm @@ -198,7 +198,7 @@ sub preprocess (@) { '" rel="openid2.local_id" />' if $delegate ne 1; } if (exists $params{"xrds-location"} && safeurl($params{"xrds-location"})) { - push @{$metaheaders{$page}}, ''; } } -- cgit v1.2.3 From 8063b960ade41a089d859b655ff26fb61fb18d3f Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 19 Sep 2010 20:15:34 -0400 Subject: meta: Ensure that the url specified by xrds-location is absolute. With a relative xrds-location, the openid perl client module will fail. I haven't checked the specs to see if it needs to be absolute, but all examples I've seen are absolute, so it seems a very good idea. --- IkiWiki/Plugin/meta.pm | 6 +++++- debian/changelog | 6 ++++++ 2 files changed, 11 insertions(+), 1 deletion(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/meta.pm b/IkiWiki/Plugin/meta.pm index ae593555e..5cfa72833 100644 --- a/IkiWiki/Plugin/meta.pm +++ b/IkiWiki/Plugin/meta.pm @@ -198,8 +198,12 @@ sub preprocess (@) { '" rel="openid2.local_id" />' if $delegate ne 1; } if (exists $params{"xrds-location"} && safeurl($params{"xrds-location"})) { + # force url absolute + eval q{use URI}; + error($@) if $@; + my $url=URI->new_abs($params{"xrds-location"}, $config{url}); push @{$metaheaders{$page}}, ''; + 'content="'.encode_entities($url).'" />'; } } elsif ($key eq 'redir') { diff --git a/debian/changelog b/debian/changelog index 8286b7887..24115c177 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +ikiwiki (3.20100916) UNRELEASED; urgency=low + + * meta: Ensure that the url specified by xrds-location is absolute. + + -- Joey Hess Sun, 19 Sep 2010 20:13:06 -0400 + ikiwiki (3.20100915) unstable; urgency=low * needsbuild hook interface changed; the hooks should now return -- cgit v1.2.3 From 90bc68589e8c9e0243d563a9616701c946b2d3fd Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 21 Sep 2010 15:33:42 -0400 Subject: attachment: Fix attachment file size display. --- IkiWiki/Plugin/attachment.pm | 2 +- debian/changelog | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/attachment.pm b/IkiWiki/Plugin/attachment.pm index f73e355ee..bd93d3718 100644 --- a/IkiWiki/Plugin/attachment.pm +++ b/IkiWiki/Plugin/attachment.pm @@ -242,7 +242,7 @@ sub attachment_list ($) { push @ret, { "field-select" => '', link => htmllink($page, $page, $f, noimageinline => 1), - size => IkiWiki::Plugin::filecheck::humansize((stat(_))[7]), + size => IkiWiki::Plugin::filecheck::humansize((stat($f))[7]), mtime => displaytime($IkiWiki::pagemtime{$f}), mtime_raw => $IkiWiki::pagemtime{$f}, }; diff --git a/debian/changelog b/debian/changelog index 24115c177..cae182f63 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,7 @@ ikiwiki (3.20100916) UNRELEASED; urgency=low * meta: Ensure that the url specified by xrds-location is absolute. + * attachment: Fix attachment file size display. -- Joey Hess Sun, 19 Sep 2010 20:13:06 -0400 -- cgit v1.2.3 From 5876968fa1ff1225542d2afd836d1027276bab44 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Sun, 26 Sep 2010 22:12:10 +0100 Subject: htmlbalance: be compatible with HTML::Tree 4.0 The HTML::Tree changelog says: [THINGS THAT MAY BREAK YOUR CODE OR TESTS] ... * Attribute names are now validated in as_XML and invalid names will cause an error. and indeed the regression tests do get an error. --- IkiWiki/Plugin/htmlbalance.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/htmlbalance.pm b/IkiWiki/Plugin/htmlbalance.pm index 26f8e494b..da450eea7 100644 --- a/IkiWiki/Plugin/htmlbalance.pm +++ b/IkiWiki/Plugin/htmlbalance.pm @@ -43,7 +43,7 @@ sub sanitize (@) { my @nodes = $tree->disembowel(); foreach my $node (@nodes) { if (ref $node) { - $ret .= $node->as_XML(); + $ret .= $node->as_HTML(undef, '', {}); chomp $ret; $node->delete(); } -- cgit v1.2.3 From 1883e31de2044eba87035c7bbb4b34c45fefa432 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 26 Sep 2010 22:27:46 -0400 Subject: Propigate PATH into wrapper. In the last version, the ikiwiki script stopped setting PATH. But that leads to gcc failing when run from websetup. See http://www.branchable.com/bugs/Crashes_when_rebuilding_wiki_after_setup_change/ --- IkiWiki/Wrapper.pm | 3 ++- debian/changelog | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Wrapper.pm b/IkiWiki/Wrapper.pm index 927368fae..5eb96f4ae 100644 --- a/IkiWiki/Wrapper.pm +++ b/IkiWiki/Wrapper.pm @@ -128,7 +128,7 @@ EOF #include extern char **environ; -char *newenviron[$#envsave+6]; +char *newenviron[$#envsave+7]; int i=0; void addenv(char *var, char *val) { @@ -147,6 +147,7 @@ $check_commit_hook @wrapper_hooks $envsave newenviron[i++]="HOME=$ENV{HOME}"; + newenviron[i++]="PATH=$ENV{PATH}"; newenviron[i++]="WRAPPED_OPTIONS=$configstring"; #ifdef __TINYC__ diff --git a/debian/changelog b/debian/changelog index cae182f63..97f9d3c79 100644 --- a/debian/changelog +++ b/debian/changelog @@ -2,6 +2,7 @@ ikiwiki (3.20100916) UNRELEASED; urgency=low * meta: Ensure that the url specified by xrds-location is absolute. * attachment: Fix attachment file size display. + * Propigate PATH into wrapper. -- Joey Hess Sun, 19 Sep 2010 20:13:06 -0400 -- cgit v1.2.3 From 00595b62be624b2b105a7b137d0502d235e55f87 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 27 Sep 2010 15:44:04 -0400 Subject: avoid fatal error if aggregate page template could not be found That template is user-controlled. --- IkiWiki/Plugin/aggregate.pm | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/aggregate.pm b/IkiWiki/Plugin/aggregate.pm index fe53d868d..9b70e5df0 100644 --- a/IkiWiki/Plugin/aggregate.pm +++ b/IkiWiki/Plugin/aggregate.pm @@ -644,7 +644,14 @@ sub add_page (@) { $guid->{md5}=$digest; # Create the page. - my $template=template($feed->{template}, blind_cache => 1); + my $template; + eval { + $template=template($feed->{template}, blind_cache => 1); + }; + if ($@) { + print STDERR gettext("failed to process template:")." $@"; + return; + } $template->param(title => $params{title}) if defined $params{title} && length($params{title}); $template->param(content => wikiescape(htmlabs($params{content}, -- cgit v1.2.3 From e22b18aabcb46e3c0eafeb466b51bb3eb18cf1e1 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 27 Sep 2010 15:47:14 -0400 Subject: template_depends: throw nice error message when template cannot be found plovs reported a crash when templates were not installed properly, with a non-useful error about the template object not being defined. I've audited all uses of template_depends(), and template(), and it makes sense for them to throw an error if the template cannot be found. All code with a user-supplied template catches errors already, to handle template parse failures. It did not make sense for template_file to throw errors, as some code uses it to probe if a template file is available. --- IkiWiki.pm | 8 +++++--- IkiWiki/Plugin/edittemplate.pm | 3 --- IkiWiki/Plugin/inline.pm | 5 +---- IkiWiki/Plugin/template.pm | 7 ++----- doc/plugins/write.mdwn | 2 ++ 5 files changed, 10 insertions(+), 15 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki.pm b/IkiWiki.pm index 6da281999..66ae86809 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -1769,12 +1769,14 @@ sub template_depends ($$;@) { my $page=shift; my ($filename, $tpage, $untrusted)=template_file($name); + if (! defined $filename) { + error(sprintf(gettext("template %s not found"), $name)) + } + if (defined $page && defined $tpage) { add_depends($page, $tpage); } - - return unless defined $filename; - + my @opts=( filter => sub { my $text_ref = shift; diff --git a/IkiWiki/Plugin/edittemplate.pm b/IkiWiki/Plugin/edittemplate.pm index 4f07866e4..576c94be4 100644 --- a/IkiWiki/Plugin/edittemplate.pm +++ b/IkiWiki/Plugin/edittemplate.pm @@ -132,9 +132,6 @@ sub filltemplate ($$) { # up a template that doesn't work. return "[[!pagetemplate ".gettext("failed to process template:")." $@]]"; } - if (! defined $template) { - return; - } $template->param(name => $page); diff --git a/IkiWiki/Plugin/inline.pm b/IkiWiki/Plugin/inline.pm index 715a3d652..c00aed299 100644 --- a/IkiWiki/Plugin/inline.pm +++ b/IkiWiki/Plugin/inline.pm @@ -336,10 +336,7 @@ sub preprocess_inline (@) { blind_cache => 1); }; if ($@) { - error gettext("failed to process template:")." $@"; - } - if (! $template) { - error sprintf(gettext("template %s not found"), $params{template}.".tmpl"); + error sprintf(gettext("failed to process template %s"), $params{template}.".tmpl").": $@"; } } my $needcontent=$raw || (!($archive && $quick) && $template->query(name => 'content')); diff --git a/IkiWiki/Plugin/template.pm b/IkiWiki/Plugin/template.pm index db26bfe31..3df06e652 100644 --- a/IkiWiki/Plugin/template.pm +++ b/IkiWiki/Plugin/template.pm @@ -41,12 +41,9 @@ sub preprocess (@) { blind_cache => 1); }; if ($@) { - error gettext("failed to process template:")." $@"; - } - if (! $template) { - error sprintf(gettext("%s not found"), + error sprintf(gettext("failed to process template %s"), htmllink($params{page}, $params{destpage}, - "/templates/$params{id}")) + "/templates/$params{id}"))." $@"; } $params{basename}=IkiWiki::basename($params{page}); diff --git a/doc/plugins/write.mdwn b/doc/plugins/write.mdwn index e60314485..d5bd1dd76 100644 --- a/doc/plugins/write.mdwn +++ b/doc/plugins/write.mdwn @@ -740,6 +740,8 @@ with no ".tmpl" extension. Template pages are normally looked for in the templates/ directory. If the page name starts with "/", a page elsewhere in the wiki can be used. +If the template is not found, or contains a syntax error, an error is thrown. + ### `template_depends($$;@)` Use this instead of `template()` if the content of a template is being -- cgit v1.2.3 From acecbad0ff4a8c441da520522710dd5357ab31e0 Mon Sep 17 00:00:00 2001 From: Peter Gammie Date: Wed, 29 Sep 2010 15:14:19 +1000 Subject: First cut at the revert plugin. --- IkiWiki.pm | 12 ++++++++ IkiWiki/Plugin/git.pm | 35 +++++++++++++++++++++ IkiWiki/Plugin/recentchanges.pm | 66 ++++++++++++++++++++++++++++++++++++++++ doc/templates.mdwn | 2 +- doc/wikiicons/revert.png | Bin 0 -> 840 bytes templates/revert.tmpl | 13 ++++++++ 6 files changed, 127 insertions(+), 1 deletion(-) create mode 100644 doc/wikiicons/revert.png create mode 100644 templates/revert.tmpl (limited to 'IkiWiki') diff --git a/IkiWiki.pm b/IkiWiki.pm index 66ae86809..e2b2ceda3 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -1941,6 +1941,18 @@ sub rcs_receive () { $hooks{rcs}{rcs_receive}{call}->(); } +sub rcs_preprevert ($) { + $hooks{rcs}{rcs_preprevert}{call}->(@_); +} + +sub rcs_revert (@) { + $hooks{rcs}{rcs_revert}{call}->(@_); +} + +sub rcs_showpatch ($) { + $hooks{rcs}{rcs_showpatch}{call}->(@_); +} + sub add_depends ($$;$) { my $page=shift; my $pagespec=shift; diff --git a/IkiWiki/Plugin/git.pm b/IkiWiki/Plugin/git.pm index fd57ce1e4..a68bd0b0e 100644 --- a/IkiWiki/Plugin/git.pm +++ b/IkiWiki/Plugin/git.pm @@ -27,6 +27,10 @@ sub import { hook(type => "rcs", id => "rcs_getctime", call => \&rcs_getctime); hook(type => "rcs", id => "rcs_getmtime", call => \&rcs_getmtime); hook(type => "rcs", id => "rcs_receive", call => \&rcs_receive); + hook(type => "rcs", id => "rcs_preprevert", call => \&rcs_preprevert); + hook(type => "rcs", id => "rcs_revert", call => \&rcs_revert); + hook(type => "rcs", id => "rcs_showpatch", call => \&rcs_showpatch); + hook(type => "rcs", id => "rcs_revert", call => \&rcs_revert); } sub checkconfig () { @@ -811,4 +815,35 @@ sub rcs_receive () { return reverse @rets; } +sub rcs_preprevert ($) { + # FIXME implement +} + +sub rcs_revert (@) { + # Try to revert the given patch; returns undef on _success_. + # Same parameters as rcs_commit_staged + 'rev', the patch ID to be + # reverted. + my %params = @_; + my $rev = $params{rev}; + + if(run_or_non('git', 'revert', '--no-commit', $rev)) { + debug "Committing revert for patch '$rev'."; + rcs_commit_staged(message => "This reverts commit $rev", @_); + } else { + # No idea what is actually getting reverted, so all we can do is say we failed. + run_or_die('git', 'reset', '--hard'); + return "Failed to revert patch $rev."; + } +} + +sub rcs_showpatch ($) { + # Show the patch with the given revision id. + my ($rev) = @_; + + # FIXME check + my @r = run_or_die('git', 'show', $rev); + + return join "\n", @r; +} + 1 diff --git a/IkiWiki/Plugin/recentchanges.pm b/IkiWiki/Plugin/recentchanges.pm index 758b98348..2a78566e1 100644 --- a/IkiWiki/Plugin/recentchanges.pm +++ b/IkiWiki/Plugin/recentchanges.pm @@ -60,6 +60,72 @@ sub refresh ($) { } } +sub confirmation_form { + my ($q, $session, $rev) = @_; + + eval q{use CGI::FormBuilder}; + error($@) if $@; + my $f = CGI::FormBuilder->new( + name => "revert", + header => 0, + charset => "utf-8", + method => 'POST', + javascript => 0, + params => $q, + action => $config{cgiurl}, + stylesheet => 1, + template => { template('revert.tmpl') }, + ); + + $f->field(name => "sid", type => "hidden", value => $session->id, + force => 1); + $f->field(name => "do", type => "hidden", value => "revert", force => 1); + $f->field(name => "rev", type => "hidden", value => $rev, force => 1); + + return $f, ["Revert", "Cancel"]; +} + +sub sessioncgi ($$) { + my ($q, $session) = @_; + my $do = $q->param('do'); + my $rev = $q->param('rev'); + + return unless $do eq 'revert' && $rev; + + # FIXME rcs_preprevert ?? + IkiWiki::check_canedit('FIXME', $q, $session); + + my ($form, $buttons) = confirmation_form($q, $session); + IkiWiki::decode_form_utf8($form); + + if($form->submitted eq 'Revert' && $form->validate) { + IkiWiki::checksessionexpiry($q, $session, $q->param('sid')); + + IkiWiki::disable_commit_hook(); + my $r = IkiWiki::rcs_revert( + session => $session, + rev => $rev); + IkiWiki::enable_commit_hook(); + + if($r) { + die "FIXME revert '$rev' failed."; + } else { + IkiWiki::refresh(); + IkiWiki::saveindex(); + # FIXME indicate success. + } + } else { + $form->title(sprintf(gettext("confirm reversion of %s"), $rev)); + my $patch_contents = IkiWiki::rcs_showpatch($rev); + $form->tmpl_param(patch_contents => encode_entities($patch_contents)); + IkiWiki::showform($form, $buttons, $session, $q); + exit 0; + } + + IkiWiki::redirect($q, urlto($config{recentchangespage}, '')); + exit 0; +} + # Enable the recentchanges link. sub pagetemplate (@) { my %params=@_; diff --git a/doc/templates.mdwn b/doc/templates.mdwn index bfb6a439a..4fd2bf501 100644 --- a/doc/templates.mdwn +++ b/doc/templates.mdwn @@ -74,7 +74,7 @@ html out of ikiwiki and in the templates. * `editpage.tmpl`, `editconflict.tmpl`, `editcreationconflict.tmpl`, `editfailedsave.tmpl`, `editpagegone.tmpl`, `pocreatepage.tmpl`, `editcomment.tmpl` `commentmoderation.tmpl`, `renamesummary.tmpl`, - `passwordmail.tmpl`, `openid-selector.tmpl` - Parts of ikiwiki's user + `passwordmail.tmpl`, `openid-selector.tmpl`, `revert.tmpl` - Parts of ikiwiki's user interface; do not normally need to be customised. [[!meta robots="noindex, follow"]] diff --git a/doc/wikiicons/revert.png b/doc/wikiicons/revert.png new file mode 100644 index 000000000..9036046e9 Binary files /dev/null and b/doc/wikiicons/revert.png differ diff --git a/templates/revert.tmpl b/templates/revert.tmpl new file mode 100644 index 000000000..3cf069dca --- /dev/null +++ b/templates/revert.tmpl @@ -0,0 +1,13 @@ +
+
+
+ +
+ + +
+
+ + +
+ -- cgit v1.2.3 From 941755e46661b65f29aeebcf38f8410f9c8cfc2e Mon Sep 17 00:00:00 2001 From: Peter Gammie Date: Wed, 29 Sep 2010 15:43:44 +1000 Subject: Get things right after moving to a branch. --- IkiWiki/Plugin/recentchanges.pm | 11 ++++++++++- templates/change.tmpl | 2 ++ templates/revert.tmpl | 1 + 3 files changed, 13 insertions(+), 1 deletion(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/recentchanges.pm b/IkiWiki/Plugin/recentchanges.pm index 2a78566e1..79d175328 100644 --- a/IkiWiki/Plugin/recentchanges.pm +++ b/IkiWiki/Plugin/recentchanges.pm @@ -13,6 +13,7 @@ sub import { hook(type => "refresh", id => "recentchanges", call => \&refresh); hook(type => "pagetemplate", id => "recentchanges", call => \&pagetemplate); hook(type => "htmlize", id => "_change", call => \&htmlize); + hook(type => "sessioncgi", id => "recentchanges", call => \&sessioncgi); # Load goto to fix up links from recentchanges IkiWiki::loadplugin("goto"); } @@ -80,7 +81,6 @@ sub confirmation_form { $f->field(name => "sid", type => "hidden", value => $session->id, force => 1); $f->field(name => "do", type => "hidden", value => "revert", force => 1); - $f->field(name => "rev", type => "hidden", value => $rev, force => 1); return $f, ["Revert", "Cancel"]; } @@ -110,6 +110,7 @@ sub sessioncgi ($$) { if($r) { die "FIXME revert '$rev' failed."; } else { + require IkiWiki::Render; IkiWiki::refresh(); IkiWiki::saveindex(); # FIXME indicate success. @@ -118,6 +119,7 @@ sub sessioncgi ($$) { $form->title(sprintf(gettext("confirm reversion of %s"), $rev)); my $patch_contents = IkiWiki::rcs_showpatch($rev); $form->tmpl_param(patch_contents => encode_entities($patch_contents)); + $form->field(name => "rev", type => "hidden", value => $rev, force => 1); IkiWiki::showform($form, $buttons, $session, $q); exit 0; } @@ -180,6 +182,13 @@ sub store ($$$) { ]; push @{$change->{pages}}, { link => '...' } if $is_excess; + if (length $config{cgiurl}) { + $change->{reverturl} = IkiWiki::cgiurl( + do => "revert", + rev => $change->{rev} + ); + } + $change->{author}=$change->{user}; my $oiduser=eval { IkiWiki::openiduser($change->{user}) }; if (defined $oiduser) { diff --git a/templates/change.tmpl b/templates/change.tmpl index 671b9e483..148b4376e 100644 --- a/templates/change.tmpl +++ b/templates/change.tmpl @@ -28,6 +28,8 @@
Date:
+
+[[diff|wikiicons/revert.png]]
diff --git a/templates/revert.tmpl b/templates/revert.tmpl index 3cf069dca..03cd0838d 100644 --- a/templates/revert.tmpl +++ b/templates/revert.tmpl @@ -5,6 +5,7 @@
+
-- cgit v1.2.3 From 408ee89fd7c1dc70510385a7cf263a05862dda97 Mon Sep 17 00:00:00 2001 From: "W. Trevor King" Date: Thu, 30 Sep 2010 07:53:37 -0400 Subject: Make tidy command line configurable for the htmltidy plugin. --- IkiWiki/Plugin/htmltidy.pm | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/htmltidy.pm b/IkiWiki/Plugin/htmltidy.pm index e6d377f8a..8a0e8f428 100644 --- a/IkiWiki/Plugin/htmltidy.pm +++ b/IkiWiki/Plugin/htmltidy.pm @@ -23,6 +23,13 @@ sub getsetup () { safe => 1, rebuild => undef, }, + htmltidy => { + type => "string", + example => "tidy --show-body-only yes --show-warnings no --tidy-mark no --markup yes -quiet -asxhtml -utf8", + description => "tidy command line", + safe => 0, # path + rebuild => 0, + }, } sub sanitize (@) { @@ -31,7 +38,7 @@ sub sanitize (@) { my $pid; my $sigpipe=0; $SIG{PIPE}=sub { $sigpipe=1 }; - $pid=open2(*IN, *OUT, 'tidy -quiet -asxhtml -utf8 --show-body-only yes --show-warnings no --tidy-mark no --markup yes 2>/dev/null'); + $pid=open2(*IN, *OUT, "$config{htmltidy} 2>/dev/null"); # open2 doesn't respect "use open ':utf8'" binmode (IN, ':utf8'); -- cgit v1.2.3 From 8024a2636feb60026a79715430a66bb572b9eae8 Mon Sep 17 00:00:00 2001 From: Peter Gammie Date: Fri, 1 Oct 2010 14:06:00 +1000 Subject: Complete rcs_preprevert and lightly test. --- IkiWiki.pm | 4 +- IkiWiki/Plugin/git.pm | 188 +++++++++++++++++++++++----------------- IkiWiki/Plugin/recentchanges.pm | 5 +- IkiWiki/Receive.pm | 32 +++++-- 4 files changed, 136 insertions(+), 93 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki.pm b/IkiWiki.pm index e2b2ceda3..aa4dccac3 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -1941,7 +1941,7 @@ sub rcs_receive () { $hooks{rcs}{rcs_receive}{call}->(); } -sub rcs_preprevert ($) { +sub rcs_preprevert (@) { $hooks{rcs}{rcs_preprevert}{call}->(@_); } @@ -1949,7 +1949,7 @@ sub rcs_revert (@) { $hooks{rcs}{rcs_revert}{call}->(@_); } -sub rcs_showpatch ($) { +sub rcs_showpatch (@) { $hooks{rcs}{rcs_showpatch}{call}->(@_); } diff --git a/IkiWiki/Plugin/git.pm b/IkiWiki/Plugin/git.pm index a68bd0b0e..46fa7d2e0 100644 --- a/IkiWiki/Plugin/git.pm +++ b/IkiWiki/Plugin/git.pm @@ -722,101 +722,130 @@ sub rcs_getmtime ($) { return findtimes($file, 0); } -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. - 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 $git_root; +sub git_find_root { + # 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. + + return $git_root if $git_root; + + 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"); + } + } + + return $subdir; +} +} + +sub git_parse_changes { + my @changes = @_; + + my $subdir = git_find_root(); + my @rets; + foreach my $ci (@changes) { + 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//)) { + error sprintf(gettext("you are not allowed to change %s"), $file); + } + + my ($action, $mode, $path); + if ($detail->{'status'} =~ /^[M]+\d*$/) { + $action="change"; + $mode=$detail->{'mode_to'}; + } + elsif ($detail->{'status'} =~ /^[AM]+\d*$/) { + $action="add"; + $mode=$detail->{'mode_to'}; + } + elsif ($detail->{'status'} =~ /^[DAM]+\d*/) { + $action="remove"; + $mode=$detail->{'mode_from'}; + } + else { + 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"); + } + } + + # 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); + # Ensure we run this in the right place, see comments in rcs_receive. + my $cmd = ($no_chdir ? '' : "cd $config{srcdir} && ") + . "git show $detail->{sha1_to} > '$path'"; + if (system($cmd) != 0) { + error("failed writing temp file '$path'."); + } + } + + push @rets, { + file => $file, + action => $action, + path => $path, + }; + } + } + + return @rets; +} +sub rcs_receive () { 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$/) { error sprintf(gettext("you are not allowed to change %s"), $refname); } - + # 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); + push @rets, git_parse_changes(git_commit_info($oldrev."..".$newrev)); $no_chdir=0; - - foreach my $ci (@changes) { - 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//)) { - error sprintf(gettext("you are not allowed to change %s"), $file); - } - - my ($action, $mode, $path); - if ($detail->{'status'} =~ /^[M]+\d*$/) { - $action="change"; - $mode=$detail->{'mode_to'}; - } - elsif ($detail->{'status'} =~ /^[AM]+\d*$/) { - $action="add"; - $mode=$detail->{'mode_to'}; - } - elsif ($detail->{'status'} =~ /^[DAM]+\d*/) { - $action="remove"; - $mode=$detail->{'mode_from'}; - } - else { - 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"); - } - } - - # 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, - action => $action, - path => $path, - }; - } - } } return reverse @rets; } -sub rcs_preprevert ($) { - # FIXME implement +sub rcs_preprevert (@) { + # Determine what the effects are of reverting the patch with the + # ID given by 'rev'. Returns the same structure as rcs_receive. + # FIXME note test_changes expects 'cgi' and 'session' parameters. + my %params = @_; + my $rev = $params{rev}; + + require IkiWiki::Receive; + IkiWiki::Receive::test_changes(%params, changes => [git_parse_changes(git_commit_info($rev, 1))]); } sub rcs_revert (@) { @@ -836,9 +865,10 @@ sub rcs_revert (@) { } } -sub rcs_showpatch ($) { +sub rcs_showpatch (@) { # Show the patch with the given revision id. - my ($rev) = @_; + my %params = @_; + my $rev = $params{rev}; # FIXME check my @r = run_or_die('git', 'show', $rev); diff --git a/IkiWiki/Plugin/recentchanges.pm b/IkiWiki/Plugin/recentchanges.pm index 79d175328..4a8d1bf80 100644 --- a/IkiWiki/Plugin/recentchanges.pm +++ b/IkiWiki/Plugin/recentchanges.pm @@ -92,8 +92,7 @@ sub sessioncgi ($$) { return unless $do eq 'revert' && $rev; - # FIXME rcs_preprevert ?? - IkiWiki::check_canedit('FIXME', $q, $session); + IkiWiki::rcs_preprevert(cgi => $q, session => $session, rev => $rev); my ($form, $buttons) = confirmation_form($q, $session); IkiWiki::decode_form_utf8($form); @@ -117,7 +116,7 @@ sub sessioncgi ($$) { } } else { $form->title(sprintf(gettext("confirm reversion of %s"), $rev)); - my $patch_contents = IkiWiki::rcs_showpatch($rev); + my $patch_contents = IkiWiki::rcs_showpatch(rev => $rev); $form->tmpl_param(patch_contents => encode_entities($patch_contents)); $form->field(name => "rev", type => "hidden", value => $rev, force => 1); IkiWiki::showform($form, $buttons, $session, $q); diff --git a/IkiWiki/Receive.pm b/IkiWiki/Receive.pm index e77c477a9..48228e5f0 100644 --- a/IkiWiki/Receive.pm +++ b/IkiWiki/Receive.pm @@ -48,10 +48,10 @@ EOF 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}; @@ -72,10 +72,22 @@ sub test () { regdate => time, }) || error("failed adding user"); } - - my %newfiles; - foreach my $change (IkiWiki::rcs_receive()) { + test_changes(cgi => $cgi, + session => $session, + changes => [IkiWiki::rcs_receive()] + ); + exit 0; +} + +sub test_changes { + my %params = @_; + my $cgi = $params{cgi}; + my $session = $params{session}; + my @changes = @{$params{changes}}; + + my %newfiles; + foreach my $change (@changes) { # This untaint is safe because we check file_pruned and # wiki_file_regexp. my ($file)=$change->{file}=~/$config{wiki_file_regexp}/; @@ -87,7 +99,7 @@ sub test () { my $type=pagetype($file); my $page=pagename($file) if defined $type; - + if ($change->{action} eq 'add') { $newfiles{$file}=1; } @@ -104,6 +116,10 @@ sub test () { IkiWiki::check_canedit($file, $cgi, $session); next; } + else { + use Data::Dumper; + die "fall through test_changes add: " . Data::Dumper::Dumper($change); + } } } elsif ($change->{action} eq 'remove') { @@ -125,11 +141,9 @@ sub test () { else { error "unknown action ".$change->{action}; } - + error sprintf(gettext("you are not allowed to change %s"), $file); } - - exit 0; } 1 -- cgit v1.2.3 From 7d1c3aa1cb42f4306535481c009367ffa42c7223 Mon Sep 17 00:00:00 2001 From: Peter Gammie Date: Fri, 1 Oct 2010 14:08:07 +1000 Subject: Minor tidy-ups. --- IkiWiki/Plugin/git.pm | 7 ++----- IkiWiki/Plugin/recentchanges.pm | 3 +-- 2 files changed, 3 insertions(+), 7 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/git.pm b/IkiWiki/Plugin/git.pm index 46fa7d2e0..457975d95 100644 --- a/IkiWiki/Plugin/git.pm +++ b/IkiWiki/Plugin/git.pm @@ -840,7 +840,7 @@ sub rcs_receive () { sub rcs_preprevert (@) { # Determine what the effects are of reverting the patch with the # ID given by 'rev'. Returns the same structure as rcs_receive. - # FIXME note test_changes expects 'cgi' and 'session' parameters. + # Note test_changes expects 'cgi' and 'session' parameters. my %params = @_; my $rev = $params{rev}; @@ -870,10 +870,7 @@ sub rcs_showpatch (@) { my %params = @_; my $rev = $params{rev}; - # FIXME check - my @r = run_or_die('git', 'show', $rev); - - return join "\n", @r; + return join "\n", run_or_die('git', 'show', $rev); } 1 diff --git a/IkiWiki/Plugin/recentchanges.pm b/IkiWiki/Plugin/recentchanges.pm index 4a8d1bf80..9a62cb243 100644 --- a/IkiWiki/Plugin/recentchanges.pm +++ b/IkiWiki/Plugin/recentchanges.pm @@ -107,12 +107,11 @@ sub sessioncgi ($$) { IkiWiki::enable_commit_hook(); if($r) { - die "FIXME revert '$rev' failed."; + die "Revert '$rev' failed."; } else { require IkiWiki::Render; IkiWiki::refresh(); IkiWiki::saveindex(); - # FIXME indicate success. } } else { $form->title(sprintf(gettext("confirm reversion of %s"), $rev)); -- cgit v1.2.3 From bd48ff734a0e01a6f2c097932f728ccb680702a2 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 2 Oct 2010 12:02:34 -0400 Subject: fixups tidy change Need checkconfig hook; examples don't become default values. --- IkiWiki/Plugin/htmltidy.pm | 9 +++++++-- debian/changelog | 2 ++ 2 files changed, 9 insertions(+), 2 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/htmltidy.pm b/IkiWiki/Plugin/htmltidy.pm index 8a0e8f428..185d01dd6 100644 --- a/IkiWiki/Plugin/htmltidy.pm +++ b/IkiWiki/Plugin/htmltidy.pm @@ -25,13 +25,18 @@ sub getsetup () { }, htmltidy => { type => "string", - example => "tidy --show-body-only yes --show-warnings no --tidy-mark no --markup yes -quiet -asxhtml -utf8", description => "tidy command line", safe => 0, # path - rebuild => 0, + rebuild => undef, }, } +sub checkconfig () { + if (! defined $config{htmltidy}) { + $config{htmltidy}="tidy -quiet -asxhtml -utf8 --show-body-only yes --show-warnings no --tidy-mark no --markup yes"; + } +} + sub sanitize (@) { my %params=@_; diff --git a/debian/changelog b/debian/changelog index 527dd7884..c59c19af7 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,8 @@ ikiwiki (3.20100927) UNRELEASED; urgency=low * Fix test suite failure on other side of date line. + * htmltidy: Allow configuring tidy parameters in setup file. + (W. Trevor King) -- Joey Hess Wed, 29 Sep 2010 11:58:23 -0400 -- cgit v1.2.3 From 49ef98505aa7ada6b1de81860c7e69b600b6c953 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 4 Oct 2010 16:01:21 -0400 Subject: fix bug if git_root is "0" --- IkiWiki/Plugin/git.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/git.pm b/IkiWiki/Plugin/git.pm index 457975d95..b6ed61428 100644 --- a/IkiWiki/Plugin/git.pm +++ b/IkiWiki/Plugin/git.pm @@ -729,7 +729,7 @@ sub git_find_root { # Determine if it is in a subdirectory by examining the srcdir, # and its parents, looking for the .git directory. - return $git_root if $git_root; + return $git_root if defined $git_root; my $subdir=""; my $dir=$config{srcdir}; -- cgit v1.2.3 From 68670cad823def2bbd4f8ed294a5e2ba21bac41c Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 4 Oct 2010 16:03:00 -0400 Subject: indentation --- IkiWiki/Plugin/git.pm | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/git.pm b/IkiWiki/Plugin/git.pm index b6ed61428..a0f9b15a7 100644 --- a/IkiWiki/Plugin/git.pm +++ b/IkiWiki/Plugin/git.pm @@ -724,25 +724,27 @@ sub rcs_getmtime ($) { { my $git_root; + sub git_find_root { - # 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. - - return $git_root if defined $git_root; - - 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"); - } - } + # 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. + + return $git_root if defined $git_root; + + 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"); + } + } - return $subdir; + return $subdir; } + } sub git_parse_changes { -- cgit v1.2.3 From 3f3aab3793fb471f8a99ed12df1bbad7abdc3455 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 4 Oct 2010 16:22:50 -0400 Subject: document new rcs reversion support functions --- IkiWiki/Plugin/git.pm | 175 ++++++++++++++++++++++---------------------- doc/plugins/write.mdwn | 33 ++++++++- doc/todo/web_reversion.mdwn | 6 ++ 3 files changed, 123 insertions(+), 91 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/git.pm b/IkiWiki/Plugin/git.pm index a0f9b15a7..33ec00d8a 100644 --- a/IkiWiki/Plugin/git.pm +++ b/IkiWiki/Plugin/git.pm @@ -748,73 +748,72 @@ sub git_find_root { } sub git_parse_changes { - my @changes = @_; - - my $subdir = git_find_root(); - my @rets; - foreach my $ci (@changes) { - 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//)) { - error sprintf(gettext("you are not allowed to change %s"), $file); - } - - my ($action, $mode, $path); - if ($detail->{'status'} =~ /^[M]+\d*$/) { - $action="change"; - $mode=$detail->{'mode_to'}; - } - elsif ($detail->{'status'} =~ /^[AM]+\d*$/) { - $action="add"; - $mode=$detail->{'mode_to'}; - } - elsif ($detail->{'status'} =~ /^[DAM]+\d*/) { - $action="remove"; - $mode=$detail->{'mode_from'}; - } - else { - 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"); - } - } - - # 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); - # Ensure we run this in the right place, see comments in rcs_receive. - my $cmd = ($no_chdir ? '' : "cd $config{srcdir} && ") - . "git show $detail->{sha1_to} > '$path'"; - if (system($cmd) != 0) { - error("failed writing temp file '$path'."); - } - } - - push @rets, { - file => $file, - action => $action, - path => $path, - }; - } - } - - return @rets; + my @changes = @_; + + my $subdir = git_find_root(); + my @rets; + foreach my $ci (@changes) { + 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//)) { + error sprintf(gettext("you are not allowed to change %s"), $file); + } + + my ($action, $mode, $path); + if ($detail->{'status'} =~ /^[M]+\d*$/) { + $action="change"; + $mode=$detail->{'mode_to'}; + } + elsif ($detail->{'status'} =~ /^[AM]+\d*$/) { + $action="add"; + $mode=$detail->{'mode_to'}; + } + elsif ($detail->{'status'} =~ /^[DAM]+\d*/) { + $action="remove"; + $mode=$detail->{'mode_from'}; + } + else { + 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"); + } + } + + # 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); + # Ensure we run this in the right place, + # see comments in rcs_receive. + my $cmd = ($no_chdir ? '' : "cd $config{srcdir} && ") + . "git show $detail->{sha1_to} > '$path'"; + if (system($cmd) != 0) { + error("failed writing temp file '$path'."); + } + } + + push @rets, { + file => $file, + action => $action, + path => $path, + }; + } + } + + return @rets; } sub rcs_receive () { @@ -832,7 +831,7 @@ sub rcs_receive () { # are in the master git repo, not the srcdir repo. # The pre-receive hook already puts us in the right place. $no_chdir=1; - push @rets, git_parse_changes(git_commit_info($oldrev."..".$newrev)); + push @rets, git_parse_changes(git_commit_info($oldrev."..".$newrev)); $no_chdir=0; } @@ -840,31 +839,31 @@ sub rcs_receive () { } sub rcs_preprevert (@) { - # Determine what the effects are of reverting the patch with the - # ID given by 'rev'. Returns the same structure as rcs_receive. - # Note test_changes expects 'cgi' and 'session' parameters. - my %params = @_; - my $rev = $params{rev}; + my %params = @_; + my $rev = $params{rev}; - require IkiWiki::Receive; - IkiWiki::Receive::test_changes(%params, changes => [git_parse_changes(git_commit_info($rev, 1))]); + # Note test_changes expects 'cgi' and 'session' parameters. + require IkiWiki::Receive; + IkiWiki::Receive::test_changes(%params, changes => + [git_parse_changes(git_commit_info($rev, 1))]); } sub rcs_revert (@) { - # Try to revert the given patch; returns undef on _success_. - # Same parameters as rcs_commit_staged + 'rev', the patch ID to be - # reverted. - my %params = @_; - my $rev = $params{rev}; + # Try to revert the given patch; returns undef on _success_. + my %params = @_; + my $rev = $params{rev}; - if(run_or_non('git', 'revert', '--no-commit', $rev)) { - debug "Committing revert for patch '$rev'."; - rcs_commit_staged(message => "This reverts commit $rev", @_); - } else { - # No idea what is actually getting reverted, so all we can do is say we failed. - run_or_die('git', 'reset', '--hard'); - return "Failed to revert patch $rev."; - } + if (run_or_non('git', 'revert', '--no-commit', $rev)) { + debug "Committing revert for patch '$rev'."; + rcs_commit_staged(message => + sprintf(gettext("This reverts commit %s"), $rev), @_); + } + else { + # No idea what is actually getting reverted, so all we can + # do is say we failed. + run_or_die('git', 'reset', '--hard'); + return sprintf(gettext("Failed to revert commit %s"), $rev); + } } sub rcs_showpatch (@) { diff --git a/doc/plugins/write.mdwn b/doc/plugins/write.mdwn index d5bd1dd76..1bd3b0f87 100644 --- a/doc/plugins/write.mdwn +++ b/doc/plugins/write.mdwn @@ -1176,9 +1176,9 @@ 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 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: +removes, and changes. If something bad is found, it should die, 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 @@ -1191,6 +1191,33 @@ files that were changed, in the form: The list will then be checked to make sure that each change is one that is allowed to be made via the web interface. +#### `rcs_preprevert($)` + +This is called by the revert web interface. It is passed a RCS-specific +change ID, and should determine what the effects would be of reverting +that change, and return the same data structure as `rcs_receive`. + +Like `rcs_receive`, it should do whatever sanity checks are appropriate +for the RCS to limit changes to safe changes, and die if a change would +be unsafe to revert. + +#### `rcs_revert(@)` + +This is called by the revert web interface. It is passed a named +parameter rev that is the RCS-specific change ID to revert. + +Addition named parameters: `message`, and `session` (optional). + +It should try to revert the specified rev, which includes committing +the reversion, and returns undef on _success_ and an error message +on failure. + +#### `rcs_showpatch(@)` + +This is passed a named parameter rev that is a RCS-specific +change ID. It should generate a diff-style patch showing the changes +made and return it. + ### PageSpec plugins It's also possible to write plugins that add new functions to diff --git a/doc/todo/web_reversion.mdwn b/doc/todo/web_reversion.mdwn index 34947b710..9e5880558 100644 --- a/doc/todo/web_reversion.mdwn +++ b/doc/todo/web_reversion.mdwn @@ -65,3 +65,9 @@ Peter Gammie has done an initial implementation of the above. >> gets used to check whether attachments are allowed -- there really should be a hook for that. >> >> Please look it over and tell me what else needs fixing... -- [[peteg]] + +>>> I have made my own revert branch and put a few fixes in there. Issues +>>> I noticed but have not gotten to: +>>> +>>> * `rcs_diff` already exists; why add `rcs_showpatch`? +>>> * -- cgit v1.2.3 From f025923d146adc83dd67265b4ae58a7f3e5cb8ab Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 4 Oct 2010 16:33:36 -0400 Subject: fix indentation --- IkiWiki/Plugin/git.pm | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/git.pm b/IkiWiki/Plugin/git.pm index 33ec00d8a..794afb740 100644 --- a/IkiWiki/Plugin/git.pm +++ b/IkiWiki/Plugin/git.pm @@ -27,10 +27,9 @@ sub import { hook(type => "rcs", id => "rcs_getctime", call => \&rcs_getctime); hook(type => "rcs", id => "rcs_getmtime", call => \&rcs_getmtime); hook(type => "rcs", id => "rcs_receive", call => \&rcs_receive); - hook(type => "rcs", id => "rcs_preprevert", call => \&rcs_preprevert); - hook(type => "rcs", id => "rcs_revert", call => \&rcs_revert); - hook(type => "rcs", id => "rcs_showpatch", call => \&rcs_showpatch); + hook(type => "rcs", id => "rcs_preprevert", call => \&rcs_preprevert); hook(type => "rcs", id => "rcs_revert", call => \&rcs_revert); + hook(type => "rcs", id => "rcs_showpatch", call => \&rcs_showpatch); } sub checkconfig () { @@ -867,11 +866,11 @@ sub rcs_revert (@) { } sub rcs_showpatch (@) { - # Show the patch with the given revision id. - my %params = @_; - my $rev = $params{rev}; + # Show the patch with the given revision id. + my %params = @_; + my $rev = $params{rev}; - return join "\n", run_or_die('git', 'show', $rev); + return join "\n", run_or_die('git', 'show', $rev); } 1 -- cgit v1.2.3 From 80da2b28403a7b2c9dd797e8acecdbe8088ec279 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 4 Oct 2010 16:35:17 -0400 Subject: fix $git_root caching --- IkiWiki/Plugin/git.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/git.pm b/IkiWiki/Plugin/git.pm index 794afb740..5922494bc 100644 --- a/IkiWiki/Plugin/git.pm +++ b/IkiWiki/Plugin/git.pm @@ -741,7 +741,7 @@ sub git_find_root { } } - return $subdir; + return $git_root=$subdir; } } -- cgit v1.2.3 From 3dce3cc1be0141bd0d9df65a7049df454fee5137 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 4 Oct 2010 16:52:52 -0400 Subject: indentation and layout --- IkiWiki/Plugin/recentchanges.pm | 110 ++++++++++++++++++++-------------------- IkiWiki/Receive.pm | 24 ++++----- 2 files changed, 68 insertions(+), 66 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/recentchanges.pm b/IkiWiki/Plugin/recentchanges.pm index 9a62cb243..7e71d4fc3 100644 --- a/IkiWiki/Plugin/recentchanges.pm +++ b/IkiWiki/Plugin/recentchanges.pm @@ -62,11 +62,11 @@ sub refresh ($) { } sub confirmation_form { - my ($q, $session, $rev) = @_; + my ($q, $session, $rev) = @_; - eval q{use CGI::FormBuilder}; - error($@) if $@; - my $f = CGI::FormBuilder->new( + eval q{use CGI::FormBuilder}; + error($@) if $@; + my $f = CGI::FormBuilder->new( name => "revert", header => 0, charset => "utf-8", @@ -75,55 +75,57 @@ sub confirmation_form { params => $q, action => $config{cgiurl}, stylesheet => 1, - template => { template('revert.tmpl') }, + template => { template('revert.tmpl') }, ); - $f->field(name => "sid", type => "hidden", value => $session->id, - force => 1); - $f->field(name => "do", type => "hidden", value => "revert", force => 1); + $f->field(name => "sid", type => "hidden", value => $session->id, + force => 1); + $f->field(name => "do", type => "hidden", value => "revert", + force => 1); - return $f, ["Revert", "Cancel"]; + return $f, ["Revert", "Cancel"]; } sub sessioncgi ($$) { - my ($q, $session) = @_; - my $do = $q->param('do'); - my $rev = $q->param('rev'); - - return unless $do eq 'revert' && $rev; - - IkiWiki::rcs_preprevert(cgi => $q, session => $session, rev => $rev); - - my ($form, $buttons) = confirmation_form($q, $session); - IkiWiki::decode_form_utf8($form); - - if($form->submitted eq 'Revert' && $form->validate) { - IkiWiki::checksessionexpiry($q, $session, $q->param('sid')); - - IkiWiki::disable_commit_hook(); - my $r = IkiWiki::rcs_revert( - session => $session, - rev => $rev); - IkiWiki::enable_commit_hook(); - - if($r) { - die "Revert '$rev' failed."; - } else { - require IkiWiki::Render; - IkiWiki::refresh(); - IkiWiki::saveindex(); - } - } else { - $form->title(sprintf(gettext("confirm reversion of %s"), $rev)); - my $patch_contents = IkiWiki::rcs_showpatch(rev => $rev); - $form->tmpl_param(patch_contents => encode_entities($patch_contents)); - $form->field(name => "rev", type => "hidden", value => $rev, force => 1); - IkiWiki::showform($form, $buttons, $session, $q); - exit 0; - } - - IkiWiki::redirect($q, urlto($config{recentchangespage}, '')); - exit 0; + my ($q, $session) = @_; + my $do = $q->param('do'); + my $rev = $q->param('rev'); + + return unless $do eq 'revert' && $rev; + + IkiWiki::rcs_preprevert(cgi => $q, session => $session, rev => $rev); + + my ($form, $buttons) = confirmation_form($q, $session); + IkiWiki::decode_form_utf8($form); + + if ($form->submitted eq 'Revert' && $form->validate) { + IkiWiki::checksessionexpiry($q, $session, $q->param('sid')); + IkiWiki::disable_commit_hook(); + my $r = IkiWiki::rcs_revert( + session => $session, + rev => $rev); + IkiWiki::enable_commit_hook(); + + if ($r) { + die "Revert '$rev' failed."; + } + else { + require IkiWiki::Render; + IkiWiki::refresh(); + IkiWiki::saveindex(); + } + } + else { + $form->title(sprintf(gettext("confirm reversion of %s"), $rev)); + my $patch_contents = IkiWiki::rcs_showpatch(rev => $rev); + $form->tmpl_param(patch_contents => encode_entities($patch_contents)); + $form->field(name => "rev", type => "hidden", value => $rev, force => 1); + IkiWiki::showform($form, $buttons, $session, $q); + exit 0; + } + + IkiWiki::redirect($q, urlto($config{recentchangespage}, '')); + exit 0; } # Enable the recentchanges link. @@ -179,13 +181,13 @@ sub store ($$$) { } @{$change->{pages}} ]; push @{$change->{pages}}, { link => '...' } if $is_excess; - - if (length $config{cgiurl}) { - $change->{reverturl} = IkiWiki::cgiurl( - do => "revert", - rev => $change->{rev} - ); - } + + if (length $config{cgiurl}) { + $change->{reverturl} = IkiWiki::cgiurl( + do => "revert", + rev => $change->{rev} + ); + } $change->{author}=$change->{user}; my $oiduser=eval { IkiWiki::openiduser($change->{user}) }; diff --git a/IkiWiki/Receive.pm b/IkiWiki/Receive.pm index 48228e5f0..2b02da8a3 100644 --- a/IkiWiki/Receive.pm +++ b/IkiWiki/Receive.pm @@ -73,18 +73,18 @@ sub test () { }) || error("failed adding user"); } - test_changes(cgi => $cgi, - session => $session, - changes => [IkiWiki::rcs_receive()] - ); + test_changes(cgi => $cgi, + session => $session, + changes => [IkiWiki::rcs_receive()] + ); exit 0; } sub test_changes { - my %params = @_; - my $cgi = $params{cgi}; - my $session = $params{session}; - my @changes = @{$params{changes}}; + my %params = @_; + my $cgi = $params{cgi}; + my $session = $params{session}; + my @changes = @{$params{changes}}; my %newfiles; foreach my $change (@changes) { @@ -116,10 +116,10 @@ sub test_changes { IkiWiki::check_canedit($file, $cgi, $session); next; } - else { - use Data::Dumper; - die "fall through test_changes add: " . Data::Dumper::Dumper($change); - } + else { + use Data::Dumper; + die "fall through test_changes add: " . Data::Dumper::Dumper($change); + } } } elsif ($change->{action} eq 'remove') { -- cgit v1.2.3 From fe582418d21f8b619db872b84bc718459325bd15 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 4 Oct 2010 16:56:21 -0400 Subject: remove debugging dumper code --- IkiWiki/Receive.pm | 4 ---- 1 file changed, 4 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Receive.pm b/IkiWiki/Receive.pm index 2b02da8a3..88fb49725 100644 --- a/IkiWiki/Receive.pm +++ b/IkiWiki/Receive.pm @@ -116,10 +116,6 @@ sub test_changes { IkiWiki::check_canedit($file, $cgi, $session); next; } - else { - use Data::Dumper; - die "fall through test_changes add: " . Data::Dumper::Dumper($change); - } } } elsif ($change->{action} eq 'remove') { -- cgit v1.2.3 From 237ea79d715fbba5c1be0b73fbe008b3221975fb Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 6 Oct 2010 14:39:10 -0400 Subject: remove rcs_showpatch --- IkiWiki.pm | 4 ---- IkiWiki/Plugin/git.pm | 9 --------- IkiWiki/Plugin/recentchanges.pm | 2 +- doc/plugins/write.mdwn | 6 ------ doc/todo/web_reversion.mdwn | 4 ---- 5 files changed, 1 insertion(+), 24 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki.pm b/IkiWiki.pm index 466907c9d..269647eb4 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -1949,10 +1949,6 @@ sub rcs_revert (@) { $hooks{rcs}{rcs_revert}{call}->(@_); } -sub rcs_showpatch (@) { - $hooks{rcs}{rcs_showpatch}{call}->(@_); -} - sub add_depends ($$;$) { my $page=shift; my $pagespec=shift; diff --git a/IkiWiki/Plugin/git.pm b/IkiWiki/Plugin/git.pm index 5922494bc..3ccaa446a 100644 --- a/IkiWiki/Plugin/git.pm +++ b/IkiWiki/Plugin/git.pm @@ -29,7 +29,6 @@ sub import { hook(type => "rcs", id => "rcs_receive", call => \&rcs_receive); hook(type => "rcs", id => "rcs_preprevert", call => \&rcs_preprevert); hook(type => "rcs", id => "rcs_revert", call => \&rcs_revert); - hook(type => "rcs", id => "rcs_showpatch", call => \&rcs_showpatch); } sub checkconfig () { @@ -865,12 +864,4 @@ sub rcs_revert (@) { } } -sub rcs_showpatch (@) { - # Show the patch with the given revision id. - my %params = @_; - my $rev = $params{rev}; - - return join "\n", run_or_die('git', 'show', $rev); -} - 1 diff --git a/IkiWiki/Plugin/recentchanges.pm b/IkiWiki/Plugin/recentchanges.pm index 7e71d4fc3..948bb1366 100644 --- a/IkiWiki/Plugin/recentchanges.pm +++ b/IkiWiki/Plugin/recentchanges.pm @@ -117,7 +117,7 @@ sub sessioncgi ($$) { } else { $form->title(sprintf(gettext("confirm reversion of %s"), $rev)); - my $patch_contents = IkiWiki::rcs_showpatch(rev => $rev); + my $patch_contents = IkiWiki::rcs_diff($rev); $form->tmpl_param(patch_contents => encode_entities($patch_contents)); $form->field(name => "rev", type => "hidden", value => $rev, force => 1); IkiWiki::showform($form, $buttons, $session, $q); diff --git a/doc/plugins/write.mdwn b/doc/plugins/write.mdwn index 1bd3b0f87..3eade34ee 100644 --- a/doc/plugins/write.mdwn +++ b/doc/plugins/write.mdwn @@ -1212,12 +1212,6 @@ It should try to revert the specified rev, which includes committing the reversion, and returns undef on _success_ and an error message on failure. -#### `rcs_showpatch(@)` - -This is passed a named parameter rev that is a RCS-specific -change ID. It should generate a diff-style patch showing the changes -made and return it. - ### PageSpec plugins It's also possible to write plugins that add new functions to diff --git a/doc/todo/web_reversion.mdwn b/doc/todo/web_reversion.mdwn index 33fa79aad..7cb412f79 100644 --- a/doc/todo/web_reversion.mdwn +++ b/doc/todo/web_reversion.mdwn @@ -55,7 +55,6 @@ Peter Gammie has done an initial implementation of the above. > (The data from `rcs_preprevert` could also be used for a confirmation > prompt -- it doesn't currently include enough info for diffs, but at > least could have a list of changed files.) ->> I added `rcs_showpatch` which simply yields the output of `git show `. -- [[peteg]] > > Note that it's possible for a git repo to have commits that modify wiki > files in a subdir, and code files elsewhere. `rcs_preprevert` should @@ -71,9 +70,6 @@ Peter Gammie has done an initial implementation of the above. >>> (and fixed all the indention..). Issues I noticed but have not gotten >>> to: --[[Joey]] >>>> Please change the git pointer above, then. I will work on your branch. -- [[peteg]] ->>> ->>> * `rcs_diff` already exists; why add `rcs_showpatch`? ->>>> If `rcs_diff` is intended for human consumption, by all means we can use that. -- [[peteg]] >>> * Would it be better for `rcs_revert` to not commit, and >>> `rcs_commit_staged` to then be used? This would work for git, but -- cgit v1.2.3 From d4fd8cd67dd868ed8b0d51c2d710b834d6a33b05 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 6 Oct 2010 14:59:20 -0400 Subject: put diff at end of revert form --- IkiWiki/Plugin/recentchanges.pm | 3 +-- templates/revert.tmpl | 15 ++++++++++----- 2 files changed, 11 insertions(+), 7 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/recentchanges.pm b/IkiWiki/Plugin/recentchanges.pm index 948bb1366..4cd910667 100644 --- a/IkiWiki/Plugin/recentchanges.pm +++ b/IkiWiki/Plugin/recentchanges.pm @@ -117,8 +117,7 @@ sub sessioncgi ($$) { } else { $form->title(sprintf(gettext("confirm reversion of %s"), $rev)); - my $patch_contents = IkiWiki::rcs_diff($rev); - $form->tmpl_param(patch_contents => encode_entities($patch_contents)); + $form->tmpl_param(diff => encode_entities(scalar IkiWiki::rcs_diff($rev))); $form->field(name => "rev", type => "hidden", value => $rev, force => 1); IkiWiki::showform($form, $buttons, $session, $q); exit 0; diff --git a/templates/revert.tmpl b/templates/revert.tmpl index 03cd0838d..6289bea6b 100644 --- a/templates/revert.tmpl +++ b/templates/revert.tmpl @@ -1,6 +1,3 @@ -
-
-
@@ -8,7 +5,15 @@
- - + +
+
+
+Diff being reverted: +
+
+
+
+
-- cgit v1.2.3 From 58a0698d921efe0daa932599515f6b41b2da4044 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 6 Oct 2010 15:02:06 -0400 Subject: return to recentchanges page on form cancel --- IkiWiki/Plugin/recentchanges.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/recentchanges.pm b/IkiWiki/Plugin/recentchanges.pm index 4cd910667..439241b93 100644 --- a/IkiWiki/Plugin/recentchanges.pm +++ b/IkiWiki/Plugin/recentchanges.pm @@ -115,7 +115,7 @@ sub sessioncgi ($$) { IkiWiki::saveindex(); } } - else { + elsif ($form->submitted ne 'Cancel') { $form->title(sprintf(gettext("confirm reversion of %s"), $rev)); $form->tmpl_param(diff => encode_entities(scalar IkiWiki::rcs_diff($rev))); $form->field(name => "rev", type => "hidden", value => $rev, force => 1); -- cgit v1.2.3 From 238e8b95a5b084e7131d3314b78419b9404cba4c Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 6 Oct 2010 15:08:12 -0400 Subject: convert rcs_revert to only stage the reversion --- IkiWiki.pm | 4 ++-- IkiWiki/Plugin/git.pm | 13 ++++--------- IkiWiki/Plugin/recentchanges.pm | 13 +++++++++---- doc/plugins/write.mdwn | 10 ++++------ doc/todo/web_reversion.mdwn | 4 ---- 5 files changed, 19 insertions(+), 25 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki.pm b/IkiWiki.pm index 269647eb4..faf4af5c7 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -1941,11 +1941,11 @@ sub rcs_receive () { $hooks{rcs}{rcs_receive}{call}->(); } -sub rcs_preprevert (@) { +sub rcs_preprevert ($) { $hooks{rcs}{rcs_preprevert}{call}->(@_); } -sub rcs_revert (@) { +sub rcs_revert ($) { $hooks{rcs}{rcs_revert}{call}->(@_); } diff --git a/IkiWiki/Plugin/git.pm b/IkiWiki/Plugin/git.pm index 3ccaa446a..996ab6fba 100644 --- a/IkiWiki/Plugin/git.pm +++ b/IkiWiki/Plugin/git.pm @@ -846,19 +846,14 @@ sub rcs_preprevert (@) { [git_parse_changes(git_commit_info($rev, 1))]); } -sub rcs_revert (@) { - # Try to revert the given patch; returns undef on _success_. - my %params = @_; - my $rev = $params{rev}; +sub rcs_revert ($) { + # Try to revert the given rev; returns undef on _success_. + my $rev = $shift; if (run_or_non('git', 'revert', '--no-commit', $rev)) { - debug "Committing revert for patch '$rev'."; - rcs_commit_staged(message => - sprintf(gettext("This reverts commit %s"), $rev), @_); + return undef; } else { - # No idea what is actually getting reverted, so all we can - # do is say we failed. run_or_die('git', 'reset', '--hard'); return sprintf(gettext("Failed to revert commit %s"), $rev); } diff --git a/IkiWiki/Plugin/recentchanges.pm b/IkiWiki/Plugin/recentchanges.pm index 439241b93..44c981548 100644 --- a/IkiWiki/Plugin/recentchanges.pm +++ b/IkiWiki/Plugin/recentchanges.pm @@ -101,12 +101,17 @@ sub sessioncgi ($$) { if ($form->submitted eq 'Revert' && $form->validate) { IkiWiki::checksessionexpiry($q, $session, $q->param('sid')); IkiWiki::disable_commit_hook(); - my $r = IkiWiki::rcs_revert( - session => $session, - rev => $rev); + my $r = IkiWiki::rcs_revert($rev); + if (! defined $r) { # success + rcs_commit_staged( + message => sprintf(gettext("This reverts commit %s"), $rev), + session => $session, + rev => $rev, + ); + } IkiWiki::enable_commit_hook(); - if ($r) { + if (defined $r) { die "Revert '$rev' failed."; } else { diff --git a/doc/plugins/write.mdwn b/doc/plugins/write.mdwn index 3eade34ee..dbbe83851 100644 --- a/doc/plugins/write.mdwn +++ b/doc/plugins/write.mdwn @@ -1201,16 +1201,14 @@ Like `rcs_receive`, it should do whatever sanity checks are appropriate for the RCS to limit changes to safe changes, and die if a change would be unsafe to revert. -#### `rcs_revert(@)` +#### `rcs_revert($)` This is called by the revert web interface. It is passed a named parameter rev that is the RCS-specific change ID to revert. -Addition named parameters: `message`, and `session` (optional). - -It should try to revert the specified rev, which includes committing -the reversion, and returns undef on _success_ and an error message -on failure. +It should try to revert the specified rev, and leave the reversion staged +so `rcs_commit_staged` will complete it. It should return undef on _success_ +and an error message on failure. ### PageSpec plugins diff --git a/doc/todo/web_reversion.mdwn b/doc/todo/web_reversion.mdwn index 7cb412f79..784b72e05 100644 --- a/doc/todo/web_reversion.mdwn +++ b/doc/todo/web_reversion.mdwn @@ -71,10 +71,6 @@ Peter Gammie has done an initial implementation of the above. >>> to: --[[Joey]] >>>> Please change the git pointer above, then. I will work on your branch. -- [[peteg]] ->>> * Would it be better for `rcs_revert` to not commit, and ->>> `rcs_commit_staged` to then be used? This would work for git, but ->>> maybe other RCSs would be problimatic. It would simplifiy the ->>> interface and allow for future mulitple-revert interfaces. >>> * I quite don't understand why one caller of `git_parse_changes` >>> needs it to chdir, and not the other one. It's running >>> in the same git repo either way, and git doesn't need -- cgit v1.2.3 From 84111d96c461a5d31a615ebf64cae751e6fd9aef Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 8 Oct 2010 17:54:12 -0400 Subject: make revert hooks optional I removed the IkiWiki::rcs_ stubs for the revert hooks. Instead recentchanges tests to see if the hooks are available and calls them directly. --- IkiWiki.pm | 8 -------- IkiWiki/Plugin/recentchanges.pm | 9 ++++++--- doc/plugins/write.mdwn | 5 +++-- templates/change.tmpl | 2 ++ 4 files changed, 11 insertions(+), 13 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki.pm b/IkiWiki.pm index faf4af5c7..1f6d70ba3 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -1941,14 +1941,6 @@ sub rcs_receive () { $hooks{rcs}{rcs_receive}{call}->(); } -sub rcs_preprevert ($) { - $hooks{rcs}{rcs_preprevert}{call}->(@_); -} - -sub rcs_revert ($) { - $hooks{rcs}{rcs_revert}{call}->(@_); -} - sub add_depends ($$;$) { my $page=shift; my $pagespec=shift; diff --git a/IkiWiki/Plugin/recentchanges.pm b/IkiWiki/Plugin/recentchanges.pm index 44c981548..a6d7f9fce 100644 --- a/IkiWiki/Plugin/recentchanges.pm +++ b/IkiWiki/Plugin/recentchanges.pm @@ -93,7 +93,8 @@ sub sessioncgi ($$) { return unless $do eq 'revert' && $rev; - IkiWiki::rcs_preprevert(cgi => $q, session => $session, rev => $rev); + $IkiWiki::hooks{rcs}{rcs_preprevert}{call}->( + cgi => $q, session => $session, rev => $rev); my ($form, $buttons) = confirmation_form($q, $session); IkiWiki::decode_form_utf8($form); @@ -101,7 +102,7 @@ sub sessioncgi ($$) { if ($form->submitted eq 'Revert' && $form->validate) { IkiWiki::checksessionexpiry($q, $session, $q->param('sid')); IkiWiki::disable_commit_hook(); - my $r = IkiWiki::rcs_revert($rev); + my $r = $IkiWiki::hooks{rcs}{rcs_revert}{call}->($rev); if (! defined $r) { # success rcs_commit_staged( message => sprintf(gettext("This reverts commit %s"), $rev), @@ -186,7 +187,9 @@ sub store ($$$) { ]; push @{$change->{pages}}, { link => '...' } if $is_excess; - if (length $config{cgiurl}) { + if (length $config{cgiurl} && + exists $IkiWiki::hooks{rcs}{rcs_preprevert} && + exists $IkiWiki::hooks{rcs}{rcs_revert}) { $change->{reverturl} = IkiWiki::cgiurl( do => "revert", rev => $change->{rev} diff --git a/doc/plugins/write.mdwn b/doc/plugins/write.mdwn index dbbe83851..6b751f0cd 100644 --- a/doc/plugins/write.mdwn +++ b/doc/plugins/write.mdwn @@ -1154,8 +1154,6 @@ context, and the whole diff in scalar context. This is used to get the page creation time for a file from the RCS, by looking it up in the history. -It's ok if this is not implemented, and throws an error. - If the RCS cannot determine a ctime for the file, return 0. #### `rcs_getmtime($)` @@ -1210,6 +1208,9 @@ It should try to revert the specified rev, and leave the reversion staged so `rcs_commit_staged` will complete it. It should return undef on _success_ and an error message on failure. +This hook and `rcs_preprevert` are optional, if not implemented, no revert +web interface will be available. + ### PageSpec plugins It's also possible to write plugins that add new functions to diff --git a/templates/change.tmpl b/templates/change.tmpl index 4525402a7..60a9d94b5 100644 --- a/templates/change.tmpl +++ b/templates/change.tmpl @@ -28,9 +28,11 @@
+ [[revert|wikiicons/revert.png]] +
-- cgit v1.2.3 From 5c6f7a8d1b805001a3d1ee912683755cec773682 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 8 Oct 2010 18:02:47 -0400 Subject: fix rcs_prepedit implementation to match spec --- IkiWiki/Plugin/git.pm | 14 +++++--------- IkiWiki/Plugin/recentchanges.pm | 9 +++++++-- 2 files changed, 12 insertions(+), 11 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/git.pm b/IkiWiki/Plugin/git.pm index 996ab6fba..48e71aa9a 100644 --- a/IkiWiki/Plugin/git.pm +++ b/IkiWiki/Plugin/git.pm @@ -836,19 +836,15 @@ sub rcs_receive () { return reverse @rets; } -sub rcs_preprevert (@) { - my %params = @_; - my $rev = $params{rev}; - - # Note test_changes expects 'cgi' and 'session' parameters. - require IkiWiki::Receive; - IkiWiki::Receive::test_changes(%params, changes => - [git_parse_changes(git_commit_info($rev, 1))]); +sub rcs_preprevert ($) { + my $rev=shift; + + return git_parse_changes(git_commit_info($rev, 1)); } sub rcs_revert ($) { # Try to revert the given rev; returns undef on _success_. - my $rev = $shift; + my $rev = shift; if (run_or_non('git', 'revert', '--no-commit', $rev)) { return undef; diff --git a/IkiWiki/Plugin/recentchanges.pm b/IkiWiki/Plugin/recentchanges.pm index a6d7f9fce..56e17dcca 100644 --- a/IkiWiki/Plugin/recentchanges.pm +++ b/IkiWiki/Plugin/recentchanges.pm @@ -93,8 +93,13 @@ sub sessioncgi ($$) { return unless $do eq 'revert' && $rev; - $IkiWiki::hooks{rcs}{rcs_preprevert}{call}->( - cgi => $q, session => $session, rev => $rev); + my @changes=$IkiWiki::hooks{rcs}{rcs_preprevert}{call}->($rev); + require IkiWiki::Receive; + IkiWiki::Receive::test_changes( + cgi => $q, + session => $session, + changes => \@changes, + ); my ($form, $buttons) = confirmation_form($q, $session); IkiWiki::decode_form_utf8($form); -- cgit v1.2.3 From faf94b578729387f85af2b2b248959debe2fa4b8 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 8 Oct 2010 18:06:38 -0400 Subject: refactor check_canchange into IkiWiki library --- IkiWiki.pm | 63 +++++++++++++++++++++++++++++++++++++++ IkiWiki/Plugin/recentchanges.pm | 3 +- IkiWiki/Receive.pm | 65 ++--------------------------------------- 3 files changed, 66 insertions(+), 65 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki.pm b/IkiWiki.pm index 1f6d70ba3..2190f008c 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -1519,6 +1519,69 @@ sub check_content (@) { return defined $ok ? $ok : 1; } +sub check_canchange (@) { + my %params = @_; + my $cgi = $params{cgi}; + my $session = $params{session}; + my @changes = @{$params{changes}}; + + my %newfiles; + foreach my $change (@changes) { + # 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 || + file_pruned($file)) { + error(gettext("bad file name %s"), $file); + } + + 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) { + check_canedit($page, $cgi, $session); + next; + } + else { + if (IkiWiki::Plugin::attachment->can("check_canattach")) { + IkiWiki::Plugin::attachment::check_canattach($session, $file, $change->{path}); + check_canedit($file, $cgi, $session); + next; + } + } + } + elsif ($change->{action} eq 'remove') { + # check_canremove tests to see if the file is present + # on disk. This will fail when 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 not add.) + next if $newfiles{$file}; + + if (IkiWiki::Plugin::remove->can("check_canremove")) { + IkiWiki::Plugin::remove::check_canremove(defined $page ? $page : $file, $cgi, $session); + check_canedit(defined $page ? $page : $file, $cgi, $session); + next; + } + } + else { + error "unknown action ".$change->{action}; + } + + error sprintf(gettext("you are not allowed to change %s"), $file); + } +} + + my $wikilock; sub lockwiki () { diff --git a/IkiWiki/Plugin/recentchanges.pm b/IkiWiki/Plugin/recentchanges.pm index 56e17dcca..fe414d865 100644 --- a/IkiWiki/Plugin/recentchanges.pm +++ b/IkiWiki/Plugin/recentchanges.pm @@ -94,8 +94,7 @@ sub sessioncgi ($$) { return unless $do eq 'revert' && $rev; my @changes=$IkiWiki::hooks{rcs}{rcs_preprevert}{call}->($rev); - require IkiWiki::Receive; - IkiWiki::Receive::test_changes( + IkiWiki::check_canchange( cgi => $q, session => $session, changes => \@changes, diff --git a/IkiWiki/Receive.pm b/IkiWiki/Receive.pm index 88fb49725..225f2b9ab 100644 --- a/IkiWiki/Receive.pm +++ b/IkiWiki/Receive.pm @@ -73,73 +73,12 @@ sub test () { }) || error("failed adding user"); } - test_changes(cgi => $cgi, + check_canchange( + cgi => $cgi, session => $session, changes => [IkiWiki::rcs_receive()] ); exit 0; } -sub test_changes { - my %params = @_; - my $cgi = $params{cgi}; - my $session = $params{session}; - my @changes = @{$params{changes}}; - - my %newfiles; - foreach my $change (@changes) { - # This untaint is safe because we check file_pruned and - # wiki_file_regexp. - my ($file)=$change->{file}=~/$config{wiki_file_regexp}/; - $file=IkiWiki::possibly_foolish_untaint($file); - if (! defined $file || ! length $file || - IkiWiki::file_pruned($file)) { - error(gettext("bad file name %s"), $file); - } - - 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) { - IkiWiki::check_canedit($page, $cgi, $session); - next; - } - else { - if (IkiWiki::Plugin::attachment->can("check_canattach")) { - IkiWiki::Plugin::attachment::check_canattach($session, $file, $change->{path}); - IkiWiki::check_canedit($file, $cgi, $session); - next; - } - } - } - elsif ($change->{action} eq 'remove') { - # check_canremove tests to see if the file is present - # on disk. This will fail when 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 not add.) - next if $newfiles{$file}; - - if (IkiWiki::Plugin::remove->can("check_canremove")) { - IkiWiki::Plugin::remove::check_canremove(defined $page ? $page : $file, $cgi, $session); - IkiWiki::check_canedit(defined $page ? $page : $file, $cgi, $session); - next; - } - } - else { - error "unknown action ".$change->{action}; - } - - error sprintf(gettext("you are not allowed to change %s"), $file); - } -} - 1 -- cgit v1.2.3 From e7d6dcfed618c57c775478c95b77a15097142e6e Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 8 Oct 2010 18:46:30 -0400 Subject: remove todo item I understand the need to avoid chdir when running git_parse_changes for receive now. At that point, the changes have not been pushed to the srcdir's repo yet. When running the same code for preprevert, chdir to the srcdir is ok, and necessary. --- IkiWiki/Plugin/git.pm | 2 -- doc/todo/web_reversion.mdwn | 9 +-------- 2 files changed, 1 insertion(+), 10 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/git.pm b/IkiWiki/Plugin/git.pm index 48e71aa9a..47e806209 100644 --- a/IkiWiki/Plugin/git.pm +++ b/IkiWiki/Plugin/git.pm @@ -794,8 +794,6 @@ sub git_parse_changes { die $@ if $@; my $fh; ($fh, $path)=File::Temp::tempfile("XXXXXXXXXX", UNLINK => 1); - # Ensure we run this in the right place, - # see comments in rcs_receive. my $cmd = ($no_chdir ? '' : "cd $config{srcdir} && ") . "git show $detail->{sha1_to} > '$path'"; if (system($cmd) != 0) { diff --git a/doc/todo/web_reversion.mdwn b/doc/todo/web_reversion.mdwn index 4335b3fbf..212fd3a53 100644 --- a/doc/todo/web_reversion.mdwn +++ b/doc/todo/web_reversion.mdwn @@ -69,12 +69,5 @@ Peter Gammie has done an initial implementation of the above. >>> I have made my own revert branch and put a few fixes in there >>> [[!template id=gitbranch branch=origin/revert author="[[joey]]"]] ->>> (and fixed all the indention..). Issues I noticed but have not gotten ->>> to: --[[Joey]] +>>> (and fixed all the indention..). --[[Joey]] >>>> Please change the git pointer above, then. I will work on your branch. -- [[peteg]] - ->>> * I quite don't understand why one caller of `git_parse_changes` ->>> needs it to chdir, and not the other one. It's running ->>> in the same git repo either way, and git doesn't need ->>> `git show` to run in a subdir at all.. ->>>> I was aping (preserving) what was already there. I don't understand what you say about `git show` - it must run under $srcdir, surely? And empirically the CGI process wasn't in the right place. By all means simplify that. -- [[peteg]] -- cgit v1.2.3 From c430792148b2193585dfed6cc2a5f778f7167de1 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 8 Oct 2010 18:50:24 -0400 Subject: refactor --- IkiWiki/Plugin/recentchanges.pm | 40 +++++++++++++++++----------------------- 1 file changed, 17 insertions(+), 23 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/recentchanges.pm b/IkiWiki/Plugin/recentchanges.pm index fe414d865..88100af0f 100644 --- a/IkiWiki/Plugin/recentchanges.pm +++ b/IkiWiki/Plugin/recentchanges.pm @@ -61,12 +61,23 @@ sub refresh ($) { } } -sub confirmation_form { - my ($q, $session, $rev) = @_; +sub sessioncgi ($$) { + my ($q, $session) = @_; + my $do = $q->param('do'); + my $rev = $q->param('rev'); + + return unless $do eq 'revert' && $rev; + + my @changes=$IkiWiki::hooks{rcs}{rcs_preprevert}{call}->($rev); + IkiWiki::check_canchange( + cgi => $q, + session => $session, + changes => \@changes, + ); eval q{use CGI::FormBuilder}; error($@) if $@; - my $f = CGI::FormBuilder->new( + my $form = CGI::FormBuilder->new( name => "revert", header => 0, charset => "utf-8", @@ -77,30 +88,13 @@ sub confirmation_form { stylesheet => 1, template => { template('revert.tmpl') }, ); + my $buttons=["Revert", "Cancel"]; - $f->field(name => "sid", type => "hidden", value => $session->id, + $form->field(name => "sid", type => "hidden", value => $session->id, force => 1); - $f->field(name => "do", type => "hidden", value => "revert", + $form->field(name => "do", type => "hidden", value => "revert", force => 1); - return $f, ["Revert", "Cancel"]; -} - -sub sessioncgi ($$) { - my ($q, $session) = @_; - my $do = $q->param('do'); - my $rev = $q->param('rev'); - - return unless $do eq 'revert' && $rev; - - my @changes=$IkiWiki::hooks{rcs}{rcs_preprevert}{call}->($rev); - IkiWiki::check_canchange( - cgi => $q, - session => $session, - changes => \@changes, - ); - - my ($form, $buttons) = confirmation_form($q, $session); IkiWiki::decode_form_utf8($form); if ($form->submitted eq 'Revert' && $form->validate) { -- cgit v1.2.3 From 4efc1f22d428ebfdc1c0ef5b4c6375cf3287526b Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 8 Oct 2010 18:58:47 -0400 Subject: taint handling for rev --- IkiWiki/Plugin/git.pm | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/git.pm b/IkiWiki/Plugin/git.pm index 47e806209..e89813253 100644 --- a/IkiWiki/Plugin/git.pm +++ b/IkiWiki/Plugin/git.pm @@ -836,20 +836,22 @@ sub rcs_receive () { sub rcs_preprevert ($) { my $rev=shift; + my ($sha1) = $rev =~ /^($sha1_pattern)$/; # untaint - return git_parse_changes(git_commit_info($rev, 1)); + return git_parse_changes(git_commit_info($sha1, 1)); } sub rcs_revert ($) { # Try to revert the given rev; returns undef on _success_. my $rev = shift; + my ($sha1) = $rev =~ /^($sha1_pattern)$/; # untaint - if (run_or_non('git', 'revert', '--no-commit', $rev)) { + if (run_or_non('git', 'revert', '--no-commit', $sha1)) { return undef; } else { run_or_die('git', 'reset', '--hard'); - return sprintf(gettext("Failed to revert commit %s"), $rev); + return sprintf(gettext("Failed to revert commit %s"), $sha1); } } -- cgit v1.2.3 From fb4ee927a0ee3d959b2e910928d24facb1fd8068 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 8 Oct 2010 18:59:04 -0400 Subject: propigate rcs_revert error message and misc reorg --- IkiWiki/Plugin/recentchanges.pm | 25 +++++++++---------------- 1 file changed, 9 insertions(+), 16 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/recentchanges.pm b/IkiWiki/Plugin/recentchanges.pm index 88100af0f..b7c014e90 100644 --- a/IkiWiki/Plugin/recentchanges.pm +++ b/IkiWiki/Plugin/recentchanges.pm @@ -99,25 +99,18 @@ sub sessioncgi ($$) { if ($form->submitted eq 'Revert' && $form->validate) { IkiWiki::checksessionexpiry($q, $session, $q->param('sid')); - IkiWiki::disable_commit_hook(); my $r = $IkiWiki::hooks{rcs}{rcs_revert}{call}->($rev); - if (! defined $r) { # success - rcs_commit_staged( - message => sprintf(gettext("This reverts commit %s"), $rev), - session => $session, - rev => $rev, - ); - } + error $r if defined $r; + IkiWiki::disable_commit_hook(); + rcs_commit_staged( + message => sprintf(gettext("This reverts commit %s"), $rev), + session => $session, + ); IkiWiki::enable_commit_hook(); - if (defined $r) { - die "Revert '$rev' failed."; - } - else { - require IkiWiki::Render; - IkiWiki::refresh(); - IkiWiki::saveindex(); - } + require IkiWiki::Render; + IkiWiki::refresh(); + IkiWiki::saveindex(); } elsif ($form->submitted ne 'Cancel') { $form->title(sprintf(gettext("confirm reversion of %s"), $rev)); -- cgit v1.2.3 From 7e9ca590c745ad01f7d0beb44bbe24eea35f531d Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 8 Oct 2010 19:19:43 -0400 Subject: add message field to revert form --- IkiWiki/Plugin/recentchanges.pm | 9 ++++++++- templates/revert.tmpl | 2 ++ 2 files changed, 10 insertions(+), 1 deletion(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/recentchanges.pm b/IkiWiki/Plugin/recentchanges.pm index b7c014e90..c57b6749a 100644 --- a/IkiWiki/Plugin/recentchanges.pm +++ b/IkiWiki/Plugin/recentchanges.pm @@ -87,9 +87,11 @@ sub sessioncgi ($$) { action => $config{cgiurl}, stylesheet => 1, template => { template('revert.tmpl') }, + fields => [qw{revertmessage do sid rev}], ); my $buttons=["Revert", "Cancel"]; + $form->field(name => "revertmessage", type => "text", size => 80); $form->field(name => "sid", type => "hidden", value => $session->id, force => 1); $form->field(name => "do", type => "hidden", value => "revert", @@ -99,11 +101,16 @@ sub sessioncgi ($$) { if ($form->submitted eq 'Revert' && $form->validate) { IkiWiki::checksessionexpiry($q, $session, $q->param('sid')); + my $message=sprintf(gettext("This reverts commit %s"), $rev); + if (defined $form->field('revertmessage') && + length $form->field('revertmessage')) { + $message=$form->field('revertmessage')."\n".$message; + } my $r = $IkiWiki::hooks{rcs}{rcs_revert}{call}->($rev); error $r if defined $r; IkiWiki::disable_commit_hook(); rcs_commit_staged( - message => sprintf(gettext("This reverts commit %s"), $rev), + message => $message, session => $session, ); IkiWiki::enable_commit_hook(); diff --git a/templates/revert.tmpl b/templates/revert.tmpl index 6289bea6b..0de32811b 100644 --- a/templates/revert.tmpl +++ b/templates/revert.tmpl @@ -3,6 +3,8 @@ + +
-- cgit v1.2.3 From 7d5ac1cdd9357bab089cfd03189f2c2351f6dad1 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 8 Oct 2010 19:25:35 -0400 Subject: typo --- IkiWiki/Plugin/recentchanges.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/recentchanges.pm b/IkiWiki/Plugin/recentchanges.pm index c57b6749a..a846cc899 100644 --- a/IkiWiki/Plugin/recentchanges.pm +++ b/IkiWiki/Plugin/recentchanges.pm @@ -109,7 +109,7 @@ sub sessioncgi ($$) { my $r = $IkiWiki::hooks{rcs}{rcs_revert}{call}->($rev); error $r if defined $r; IkiWiki::disable_commit_hook(); - rcs_commit_staged( + IkiWiki::rcs_commit_staged( message => $message, session => $session, ); -- cgit v1.2.3 From 9aa9604c36a2111fb778cd74260c8b7591188fc5 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 8 Oct 2010 19:26:31 -0400 Subject: add blank line --- IkiWiki/Plugin/recentchanges.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/recentchanges.pm b/IkiWiki/Plugin/recentchanges.pm index a846cc899..562f61d40 100644 --- a/IkiWiki/Plugin/recentchanges.pm +++ b/IkiWiki/Plugin/recentchanges.pm @@ -104,7 +104,7 @@ sub sessioncgi ($$) { my $message=sprintf(gettext("This reverts commit %s"), $rev); if (defined $form->field('revertmessage') && length $form->field('revertmessage')) { - $message=$form->field('revertmessage')."\n".$message; + $message=$form->field('revertmessage')."\n\n".$message; } my $r = $IkiWiki::hooks{rcs}{rcs_revert}{call}->($rev); error $r if defined $r; -- cgit v1.2.3 From 274219ecc865f9bdcb65ad26e4750fa90dfaa670 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 11 Oct 2010 11:12:41 -0400 Subject: websetup: Fix saving of advanced mode changes. The showadvanced field was not known to formbuilder when hitting the save changes button. --- IkiWiki/Plugin/websetup.pm | 1 + debian/changelog | 1 + 2 files changed, 2 insertions(+) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/websetup.pm b/IkiWiki/Plugin/websetup.pm index 11b4428e3..2674b91e8 100644 --- a/IkiWiki/Plugin/websetup.pm +++ b/IkiWiki/Plugin/websetup.pm @@ -295,6 +295,7 @@ sub showform ($$) { $form->field(name => "do", type => "hidden", value => "setup", force => 1); $form->field(name => "rebuild_asked", type => "hidden"); + $form->field(name => "showadvanced", type => "hidden"); if ($form->submitted eq 'Basic Mode') { $form->field(name => "showadvanced", type => "hidden", diff --git a/debian/changelog b/debian/changelog index 53bee5df6..fb012abd2 100644 --- a/debian/changelog +++ b/debian/changelog @@ -10,6 +10,7 @@ ikiwiki (3.20100927) UNRELEASED; urgency=low * Thanks to Peter Gammie for his assistance with the web-based reversion feature. * actiontabs: More consistent styling of Hn tags. + * websetup: Fix saving of advanced mode changes. -- Joey Hess Wed, 29 Sep 2010 11:58:23 -0400 -- cgit v1.2.3 From cfbd272c8bdbb96b6e92449f4d940fb2b72aa651 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 11 Oct 2010 11:27:06 -0400 Subject: websetup: Fix defaults of checkboxes in advanced mode. So formbuilder has an annoying glitch, that setting the value of a checkbox, even without force, will override the value currently on the form. Thus the guards against changing checkbox values when a form has been submitted. But those guards also prevented the checkboxes for advanced items getting the right value when going into advanced mode. Note that if the user makes changes to advanced mode stuff and leaves advanced mode, those changes are lost. That seems reasonable so I didn't change it -- and it made this fix simple. --- IkiWiki/Plugin/websetup.pm | 3 ++- debian/changelog | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/websetup.pm b/IkiWiki/Plugin/websetup.pm index 2674b91e8..0ab18997c 100644 --- a/IkiWiki/Plugin/websetup.pm +++ b/IkiWiki/Plugin/websetup.pm @@ -219,7 +219,8 @@ sub showfields ($$$@) { options => [ [ 1 => $description ] ], fieldset => $section, ); - if (! $form->submitted) { + if (! $form->submitted || + ($info{advanced} && $form->submitted eq 'Advanced Mode')) { $form->field(name => $name, value => $value); } } diff --git a/debian/changelog b/debian/changelog index fb012abd2..6d333a843 100644 --- a/debian/changelog +++ b/debian/changelog @@ -11,6 +11,7 @@ ikiwiki (3.20100927) UNRELEASED; urgency=low feature. * actiontabs: More consistent styling of Hn tags. * websetup: Fix saving of advanced mode changes. + * websetup: Fix defaults of checkboxes in advanced mode. -- Joey Hess Wed, 29 Sep 2010 11:58:23 -0400 -- cgit v1.2.3 From 7ba0f7d297e7d3e833756016b635ffa0cc78200e Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 11 Oct 2010 20:30:14 -0400 Subject: monotone: Fix recentchanges page when the srcdir is not at the top of the monotone workspace. Thanks, tommyd. --- IkiWiki/Plugin/monotone.pm | 13 ++++++++++++- debian/changelog | 2 ++ .../monotone_backend_does_not_support_srcdir_in_subdir.mdwn | 2 ++ 3 files changed, 16 insertions(+), 1 deletion(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/monotone.pm b/IkiWiki/Plugin/monotone.pm index 95fbcee76..75bf2f458 100644 --- a/IkiWiki/Plugin/monotone.pm +++ b/IkiWiki/Plugin/monotone.pm @@ -252,9 +252,20 @@ sub get_changed_files ($$) { my @ret; my %seen = (); - + + # we need to strip off the relative path to the source dir + # because monotone outputs all file paths absolute according + # to the workspace root + my $rel_src_dir = $config{'srcdir'}; + $rel_src_dir =~ s/^\Q$config{'mtnrootdir'}\E\/?//; + $rel_src_dir .= "/" if length $rel_src_dir; + while ($changes =~ m/\s*(add_file|patch|delete|rename)\s"(.*?)(? Wed, 29 Sep 2010 11:58:23 -0400 diff --git a/doc/bugs/monotone_backend_does_not_support_srcdir_in_subdir.mdwn b/doc/bugs/monotone_backend_does_not_support_srcdir_in_subdir.mdwn index 9e1924472..35f624f78 100644 --- a/doc/bugs/monotone_backend_does_not_support_srcdir_in_subdir.mdwn +++ b/doc/bugs/monotone_backend_does_not_support_srcdir_in_subdir.mdwn @@ -1,3 +1,5 @@ The [[rcs/monotone]] backend does not currently support putting the ikiwiki srcdir in a subdirectory of the repository. It must be at the top. Git has special code to handle this case. --[[Joey]] + +[[done]] -- cgit v1.2.3 From 8555d10f6369d78c44cf4677010b7e1260d9f5c0 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 13 Oct 2010 12:57:16 -0400 Subject: img: If a class is specified, don't also put the img in the img class. --- IkiWiki/Plugin/img.pm | 5 +---- debian/changelog | 2 ++ .../class_parameter_of_img_directive_behave_not_as_documented.mdwn | 2 ++ 3 files changed, 5 insertions(+), 4 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/img.pm b/IkiWiki/Plugin/img.pm index 2375ead89..bd527c8c8 100644 --- a/IkiWiki/Plugin/img.pm +++ b/IkiWiki/Plugin/img.pm @@ -156,10 +156,7 @@ sub preprocess (@) { $imgurl="$config{url}/$imglink"; } - if (exists $params{class}) { - $params{class}.=" img"; - } - else { + if (! exists $params{class}) { $params{class}="img"; } diff --git a/debian/changelog b/debian/changelog index 12cc90b11..5433ba05f 100644 --- a/debian/changelog +++ b/debian/changelog @@ -14,6 +14,8 @@ ikiwiki (3.20100927) UNRELEASED; urgency=low * websetup: Fix defaults of checkboxes in advanced mode. * monotone: Fix recentchanges page when the srcdir is not at the top of the monotone workspace. Thanks, tommyd. + * img: If a class is specified, don't also put the img in the img + class. -- Joey Hess Wed, 29 Sep 2010 11:58:23 -0400 diff --git a/doc/bugs/class_parameter_of_img_directive_behave_not_as_documented.mdwn b/doc/bugs/class_parameter_of_img_directive_behave_not_as_documented.mdwn index 10ba15066..e7797765f 100644 --- a/doc/bugs/class_parameter_of_img_directive_behave_not_as_documented.mdwn +++ b/doc/bugs/class_parameter_of_img_directive_behave_not_as_documented.mdwn @@ -27,3 +27,5 @@ I would prefer if the `img` class were only added if no class attribute is passed. If you keep the current behaviour, please document it. + +> [[done]] --[[Joey]] -- cgit v1.2.3 From 9b832df0d257e3d358ead63fd865d2a6b1914e19 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 19 Oct 2010 21:37:31 -0400 Subject: add a missing chomp --- IkiWiki/Plugin/filecheck.pm | 1 + 1 file changed, 1 insertion(+) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/filecheck.pm b/IkiWiki/Plugin/filecheck.pm index a78058ffe..3b0a7b314 100644 --- a/IkiWiki/Plugin/filecheck.pm +++ b/IkiWiki/Plugin/filecheck.pm @@ -148,6 +148,7 @@ sub match_mimetype ($$;@) { if (! defined $mimetype) { open(my $file_h, "-|", "file", "-bi", $file); $mimetype=<$file_h>; + chomp $mimetype; close $file_h; } if (! defined $mimetype || $mimetype !~s /;.*//) { -- cgit v1.2.3 From 1c5a3f2c67c153a57439bce02f320e6e950a58ea Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 23 Oct 2010 15:25:29 -0400 Subject: Fix typo that broke anonymous git push. --- IkiWiki/Receive.pm | 2 +- debian/changelog | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Receive.pm b/IkiWiki/Receive.pm index 225f2b9ab..c73adfbbb 100644 --- a/IkiWiki/Receive.pm +++ b/IkiWiki/Receive.pm @@ -73,7 +73,7 @@ sub test () { }) || error("failed adding user"); } - check_canchange( + IkiWiki::check_canchange( cgi => $cgi, session => $session, changes => [IkiWiki::rcs_receive()] diff --git a/debian/changelog b/debian/changelog index 951e59c9a..3f649a2ce 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +ikiwiki (3.20101020) UNRELEASED; urgency=low + + * Fix typo that broke anonymous git push. + + -- Joey Hess Sat, 23 Oct 2010 15:25:19 -0400 + ikiwiki (3.20101019) unstable; urgency=low * Fix test suite failure on other side of date line. -- cgit v1.2.3 From 9ca9959eda17ca85ca1550353d09ee33f6bb0469 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 23 Oct 2010 16:19:16 -0400 Subject: fix web reversion when the srcdir is in a subdir of the git repo. --- IkiWiki/Plugin/git.pm | 35 +++++++++++++++++++++++------------ debian/changelog | 1 + 2 files changed, 24 insertions(+), 12 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/git.pm b/IkiWiki/Plugin/git.pm index e89813253..892b711d8 100644 --- a/IkiWiki/Plugin/git.pm +++ b/IkiWiki/Plugin/git.pm @@ -9,7 +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; +my $git_dir=undef; sub import { hook(type => "checkconfig", id => "git", call => \&checkconfig); @@ -164,9 +164,13 @@ sub safe_git (&@) { if (!$pid) { # In child. # Git commands want to be in wc. - if (! $no_chdir) { + if (! defined $git_dir) { chdir $config{srcdir} - or error("Cannot chdir to $config{srcdir}: $!"); + or error("cannot chdir to $config{srcdir}: $!"); + } + else { + chdir $git_dir + or error("cannot chdir to $git_dir: $!"); } exec @cmdline or error("Cannot exec '@cmdline': $!"); } @@ -721,14 +725,13 @@ sub rcs_getmtime ($) { } { -my $git_root; - +my $ret; sub git_find_root { # 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. - return $git_root if defined $git_root; + return @$ret if defined $ret; my $subdir=""; my $dir=$config{srcdir}; @@ -740,7 +743,8 @@ sub git_find_root { } } - return $git_root=$subdir; + $ret=[$subdir, $dir]; + return @$ret; } } @@ -748,7 +752,7 @@ sub git_find_root { sub git_parse_changes { my @changes = @_; - my $subdir = git_find_root(); + my ($subdir, $rootdir) = git_find_root(); my @rets; foreach my $ci (@changes) { foreach my $detail (@{ $ci->{'details'} }) { @@ -794,8 +798,8 @@ sub git_parse_changes { die $@ if $@; my $fh; ($fh, $path)=File::Temp::tempfile("XXXXXXXXXX", UNLINK => 1); - my $cmd = ($no_chdir ? '' : "cd $config{srcdir} && ") - . "git show $detail->{sha1_to} > '$path'"; + my $cmd = "cd $git_dir && ". + "git show $detail->{sha1_to} > '$path'"; if (system($cmd) != 0) { error("failed writing temp file '$path'."); } @@ -825,10 +829,12 @@ sub rcs_receive () { # Avoid chdir when running git here, because the changes # are in the master git repo, not the srcdir repo. + # (Also, if a subdir is involved, we don't want to chdir to + # it and only see changes in it.) # The pre-receive hook already puts us in the right place. - $no_chdir=1; + $git_dir="."; push @rets, git_parse_changes(git_commit_info($oldrev."..".$newrev)); - $no_chdir=0; + $git_dir=undef; } return reverse @rets; @@ -838,7 +844,12 @@ sub rcs_preprevert ($) { my $rev=shift; my ($sha1) = $rev =~ /^($sha1_pattern)$/; # untaint + # Examine changes from root of git repo, not from any subdir, + # in order to see all changes. + my ($subdir, $rootdir) = git_find_root(); + $git_dir=$rootdir; return git_parse_changes(git_commit_info($sha1, 1)); + $git_dir=undef; } sub rcs_revert ($) { diff --git a/debian/changelog b/debian/changelog index 3f649a2ce..cee42dc85 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,7 @@ ikiwiki (3.20101020) UNRELEASED; urgency=low * Fix typo that broke anonymous git push. + * fix web reversion when the srcdir is in a subdir of the git repo. -- Joey Hess Sat, 23 Oct 2010 15:25:19 -0400 -- cgit v1.2.3 From 62a0f2f3d65aa86996f11a01cadb88380ba3d4e4 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 23 Oct 2010 16:31:58 -0400 Subject: bugfix --- IkiWiki/Plugin/git.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/git.pm b/IkiWiki/Plugin/git.pm index 892b711d8..f8e16859b 100644 --- a/IkiWiki/Plugin/git.pm +++ b/IkiWiki/Plugin/git.pm @@ -848,8 +848,9 @@ sub rcs_preprevert ($) { # in order to see all changes. my ($subdir, $rootdir) = git_find_root(); $git_dir=$rootdir; - return git_parse_changes(git_commit_info($sha1, 1)); + my @ret=git_parse_changes(git_commit_info($sha1, 1)); $git_dir=undef; + return @ret; } sub rcs_revert ($) { -- cgit v1.2.3 From 5db2d6f6b224872b119535d57e675d12a2c7dfe1 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 23 Oct 2010 17:13:04 -0400 Subject: nice message if someone tries to revert a merge commit --- IkiWiki/Plugin/git.pm | 15 +++++++++++++-- debian/changelog | 6 +++--- 2 files changed, 16 insertions(+), 5 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/git.pm b/IkiWiki/Plugin/git.pm index f8e16859b..f5101d904 100644 --- a/IkiWiki/Plugin/git.pm +++ b/IkiWiki/Plugin/git.pm @@ -848,9 +848,20 @@ sub rcs_preprevert ($) { # in order to see all changes. my ($subdir, $rootdir) = git_find_root(); $git_dir=$rootdir; - my @ret=git_parse_changes(git_commit_info($sha1, 1)); + my @commits=git_commit_info($sha1, 1); $git_dir=undef; - return @ret; + + if (! @commits) { + error "unknown commit"; # just in case + } + + # git revert will fail on merge commits. Add a nice message. + if (exists $commits[0]->{parents} && + @{$commits[0]->{parents}} > 1) { + error gettext("you are not allowed to revert a merge"); + } + + return git_parse_changes(@commits); } sub rcs_revert ($) { diff --git a/debian/changelog b/debian/changelog index cee42dc85..b304e4b86 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,9 +1,9 @@ -ikiwiki (3.20101020) UNRELEASED; urgency=low +ikiwiki (3.20101023) unstable; urgency=low * Fix typo that broke anonymous git push. - * fix web reversion when the srcdir is in a subdir of the git repo. + * Fix web reversion when the srcdir is in a subdir of the git repo. - -- Joey Hess Sat, 23 Oct 2010 15:25:19 -0400 + -- Joey Hess Sat, 23 Oct 2010 16:36:50 -0400 ikiwiki (3.20101019) unstable; urgency=low -- cgit v1.2.3 From 2076ed597c02bfede9063c3d40f4b855d4e8f8b8 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 25 Oct 2010 22:37:34 -0400 Subject: txt: Fix display when used inside a format directive. txt's use of a format hook can't work in that case, so it needs to use a htmlizeformat hook in this case to handle wrapping the text in pre tags. --- IkiWiki/Plugin/format.pm | 24 +++++++++++++----------- IkiWiki/Plugin/highlight.pm | 6 +++--- IkiWiki/Plugin/txt.pm | 38 ++++++++++++++++++++++++++++---------- debian/changelog | 6 ++++++ 4 files changed, 50 insertions(+), 24 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/format.pm b/IkiWiki/Plugin/format.pm index d54e71131..b596bc0a1 100644 --- a/IkiWiki/Plugin/format.pm +++ b/IkiWiki/Plugin/format.pm @@ -29,22 +29,24 @@ sub preprocess (@) { if (! defined $format || ! defined $text) { error(gettext("must specify format and text")); } + + # Other plugins can register htmlizeformat hooks to add support + # for page types not suitable for htmlize, or that need special + # processing when included via format. Try them until one succeeds. + my $ret; + IkiWiki::run_hooks(htmlizeformat => sub { + $ret=shift->($format, $text) + unless defined $ret; + }); + + if (defined $ret) { + return $ret; + } elsif (exists $IkiWiki::hooks{htmlize}{$format}) { return IkiWiki::htmlize($params{page}, $params{destpage}, $format, $text); } else { - # Other plugins can register htmlizefallback - # hooks to add support for page types - # not suitable for htmlize. Try them until - # one succeeds. - my $ret; - IkiWiki::run_hooks(htmlizefallback => sub { - $ret=shift->($format, $text) - unless defined $ret; - }); - return $ret if defined $ret; - error(sprintf(gettext("unsupported page format %s"), $format)); } } diff --git a/IkiWiki/Plugin/highlight.pm b/IkiWiki/Plugin/highlight.pm index d4ade0a7b..5674f0b4a 100644 --- a/IkiWiki/Plugin/highlight.pm +++ b/IkiWiki/Plugin/highlight.pm @@ -10,8 +10,8 @@ sub import { hook(type => "getsetup", id => "highlight", call => \&getsetup); hook(type => "checkconfig", id => "highlight", call => \&checkconfig); # this hook is used by the format plugin - hook(type => "htmlizefallback", id => "highlight", call => - \&htmlizefallback); + hook(type => "htmlizeformat", id => "highlight", call => + \&htmlizeformat); } sub getsetup () { @@ -79,7 +79,7 @@ sub checkconfig () { } } -sub htmlizefallback { +sub htmlizeformat { my $format=lc shift; my $langfile=ext2langfile($format); diff --git a/IkiWiki/Plugin/txt.pm b/IkiWiki/Plugin/txt.pm index 0d9a0b35b..fcfb68be9 100644 --- a/IkiWiki/Plugin/txt.pm +++ b/IkiWiki/Plugin/txt.pm @@ -17,6 +17,7 @@ sub import { hook(type => "getsetup", id => "txt", call => \&getsetup); hook(type => "filter", id => "txt", call => \&filter); hook(type => "htmlize", id => "txt", call => \&htmlize); + hook(type => "htmlizeformat", id => "txt", call => \&htmlizeformat); eval q{use URI::Find}; if (! $@) { @@ -46,25 +47,42 @@ sub filter (@) { will_render($params{page}, 'robots.txt'); writefile('robots.txt', $config{destdir}, $content); } - - encode_entities($content, "<>&"); - if ($findurl) { - my $finder = URI::Find->new(sub { - my ($uri, $orig_uri) = @_; - return qq|$orig_uri|; - }); - $finder->find(\$content); - } - $content = "
" . $content . "
"; + return txt2html($content); } return $content; } +sub txt2html ($) { + my $content=shift; + + encode_entities($content, "<>&"); + if ($findurl) { + my $finder = URI::Find->new(sub { + my ($uri, $orig_uri) = @_; + return qq|$orig_uri|; + }); + $finder->find(\$content); + } + return "
" . $content . "
"; +} + # We need this to register the .txt file extension sub htmlize (@) { my %params=@_; return $params{content}; } +sub htmlizeformat ($$) { + my $format=shift; + my $content=shift; + + if ($format eq 'txt') { + return txt2html($content); + } + else { + return; + } +} + 1 diff --git a/debian/changelog b/debian/changelog index b304e4b86..2857ec482 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +ikiwiki (3.20101024) UNRELEASED; urgency=low + + * txt: Fix display when used inside a format directive. + + -- Joey Hess Mon, 25 Oct 2010 22:30:29 -0400 + ikiwiki (3.20101023) unstable; urgency=low * Fix typo that broke anonymous git push. -- cgit v1.2.3 From 5c6eb167b8e69e0607330f06c893a73dfe1c675a Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 25 Oct 2010 23:00:32 -0400 Subject: highlight: Ensure that other, more-specific format plugins, like txt are used in preference to this one in case of ties. --- IkiWiki/Plugin/highlight.pm | 5 +++-- debian/changelog | 2 ++ 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/highlight.pm b/IkiWiki/Plugin/highlight.pm index 5674f0b4a..872537c72 100644 --- a/IkiWiki/Plugin/highlight.pm +++ b/IkiWiki/Plugin/highlight.pm @@ -10,8 +10,8 @@ sub import { hook(type => "getsetup", id => "highlight", call => \&getsetup); hook(type => "checkconfig", id => "highlight", call => \&checkconfig); # this hook is used by the format plugin - hook(type => "htmlizeformat", id => "highlight", call => - \&htmlizeformat); + hook(type => "htmlizeformat", id => "highlight", + call => \&htmlizeformat, last => 1); } sub getsetup () { @@ -74,6 +74,7 @@ sub checkconfig () { }, longname => sprintf(gettext("Source code: %s"), $file), @opts, + last => 1, ); } } diff --git a/debian/changelog b/debian/changelog index 2857ec482..f6ca122a0 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,8 @@ ikiwiki (3.20101024) UNRELEASED; urgency=low * txt: Fix display when used inside a format directive. + * highlight: Ensure that other, more-specific format plugins, + like txt are used in preference to this one in case of ties. -- Joey Hess Mon, 25 Oct 2010 22:30:29 -0400 -- cgit v1.2.3 From ac8aad2ecaad1204e00d0b6eac834ff619e0dc09 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 25 Oct 2010 23:03:28 -0400 Subject: remove a last that won't work --- IkiWiki/Plugin/highlight.pm | 1 - 1 file changed, 1 deletion(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/highlight.pm b/IkiWiki/Plugin/highlight.pm index 872537c72..934e64bed 100644 --- a/IkiWiki/Plugin/highlight.pm +++ b/IkiWiki/Plugin/highlight.pm @@ -74,7 +74,6 @@ sub checkconfig () { }, longname => sprintf(gettext("Source code: %s"), $file), @opts, - last => 1, ); } } -- cgit v1.2.3 From ac6b5c12fa9c834555fde4a4cf06db7b792556d4 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Mon, 25 Oct 2010 23:31:41 -0400 Subject: squash undef --- IkiWiki/Plugin/goto.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/goto.pm b/IkiWiki/Plugin/goto.pm index 42d2425ca..348a663ef 100644 --- a/IkiWiki/Plugin/goto.pm +++ b/IkiWiki/Plugin/goto.pm @@ -52,7 +52,7 @@ sub cgi_goto ($;$) { IkiWiki::redirect($q, $pagestate{$page}{meta}{permalink}); } - if (! length $link) { + if (! defined $link || ! length $link) { IkiWiki::cgi_custom_failure( $q, "404 Not Found", -- cgit v1.2.3 From 4573524196abfa2ba130d725ce67b8963da09c62 Mon Sep 17 00:00:00 2001 From: Tuomas Jormola Date: Sun, 31 Oct 2010 03:02:38 +0200 Subject: Added missing hook registration for checkconfig Signed-off-by: Tuomas Jormola --- IkiWiki/Plugin/htmltidy.pm | 1 + 1 file changed, 1 insertion(+) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/htmltidy.pm b/IkiWiki/Plugin/htmltidy.pm index 185d01dd6..1108aeb89 100644 --- a/IkiWiki/Plugin/htmltidy.pm +++ b/IkiWiki/Plugin/htmltidy.pm @@ -15,6 +15,7 @@ use IPC::Open2; sub import { hook(type => "getsetup", id => "tidy", call => \&getsetup); hook(type => "sanitize", id => "tidy", call => \&sanitize); + hook(type => "checkconfig", id => "tidy", call => \&checkconfig); } sub getsetup () { -- cgit v1.2.3 From cf2e3cb7d9d825ec2e517acdbc61e2502b5a87df Mon Sep 17 00:00:00 2001 From: Craig Lennox Date: Sat, 30 Oct 2010 12:34:00 -0400 Subject: Added missing registration of checkconfig hook. --- IkiWiki/Plugin/sortnaturally.pm | 1 + 1 file changed, 1 insertion(+) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/sortnaturally.pm b/IkiWiki/Plugin/sortnaturally.pm index 62e42767c..b038b2f9a 100644 --- a/IkiWiki/Plugin/sortnaturally.pm +++ b/IkiWiki/Plugin/sortnaturally.pm @@ -7,6 +7,7 @@ no warnings; sub import { hook(type => "getsetup", id => "sortnaturally", call => \&getsetup); + hook(type => "checkconfig", id => "sortnaturally", call => \&checkconfig); } sub getsetup { -- cgit v1.2.3 From d32a1028ab59e20b2c1d8caaefa65e154181ea05 Mon Sep 17 00:00:00 2001 From: Tuomas Jormola Date: Sun, 31 Oct 2010 19:53:06 +0200 Subject: Use author date instead of commit date Signed-off-by: Tuomas Jormola --- IkiWiki/Plugin/git.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/git.pm b/IkiWiki/Plugin/git.pm index f5101d904..3fa29b22f 100644 --- a/IkiWiki/Plugin/git.pm +++ b/IkiWiki/Plugin/git.pm @@ -688,7 +688,7 @@ sub findtimes ($$) { if (! keys %time_cache) { my $date; foreach my $line (run_or_die('git', 'log', - '--pretty=format:%ct', + '--pretty=format:%at', '--name-only', '--relative')) { if (! defined $date && $line =~ /^(\d+)$/) { $date=$line; -- cgit v1.2.3 From 289b30a47d548326aad9c1dc5252fc0269494c87 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Thu, 11 Nov 2010 23:59:24 -0400 Subject: Fix htmlscrubber_skip to be matched on the source page, not the page it is inlined into. Should allow setting to "* and !comment(*)" to scrub comments, but leave your blog posts unscrubbed, etc. --- IkiWiki/Plugin/htmlscrubber.pm | 4 ++-- debian/changelog | 3 +++ 2 files changed, 5 insertions(+), 2 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/htmlscrubber.pm b/IkiWiki/Plugin/htmlscrubber.pm index 927792f79..a58a27d52 100644 --- a/IkiWiki/Plugin/htmlscrubber.pm +++ b/IkiWiki/Plugin/htmlscrubber.pm @@ -57,8 +57,8 @@ sub sanitize (@) { if (exists $config{htmlscrubber_skip} && length $config{htmlscrubber_skip} && - exists $params{destpage} && - pagespec_match($params{destpage}, $config{htmlscrubber_skip})) { + exists $params{page} && + pagespec_match($params{page}, $config{htmlscrubber_skip})) { return $params{content}; } diff --git a/debian/changelog b/debian/changelog index 59d7eb761..63e13896e 100644 --- a/debian/changelog +++ b/debian/changelog @@ -8,6 +8,9 @@ ikiwiki (3.20101024) UNRELEASED; urgency=low (Thanks, Craig Lennox and Tuomas Jormola) * git: Use author date, not committer date. Closes: #602012 (Thanks, Tuomas Jormola) + * Fix htmlscrubber_skip to be matched on the source page, not the page it is + inlined into. Should allow setting to "* and !comment(*)" to scrub + comments, but leave your blog posts unscrubbed, etc. -- Joey Hess Mon, 25 Oct 2010 22:30:29 -0400 -- cgit v1.2.3 From 78de33d2eaf8a187b610685f70e60b7d5946374f Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 12 Nov 2010 00:25:31 -0400 Subject: comments: Make postcomment() pagespec work when previewing a comment. --- IkiWiki/Plugin/comments.pm | 6 ++++++ debian/changelog | 2 ++ 2 files changed, 8 insertions(+) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/comments.pm b/IkiWiki/Plugin/comments.pm index 851f4862e..57f5b1304 100644 --- a/IkiWiki/Plugin/comments.pm +++ b/IkiWiki/Plugin/comments.pm @@ -727,6 +727,10 @@ sub previewcomment ($$$) { my $page=shift; my $time=shift; + # Previewing a comment should implicitly enable comment posting mode. + my $oldpostcomment=$postcomment; + $postcomment=1; + my $preview = IkiWiki::htmlize($location, $page, '_comment', IkiWiki::linkify($location, $page, IkiWiki::preprocess($location, $page, @@ -745,6 +749,8 @@ sub previewcomment ($$$) { $template->param(have_actions => 0); + $postcomment=$oldpostcomment; + return $template->output; } diff --git a/debian/changelog b/debian/changelog index 63e13896e..91a678805 100644 --- a/debian/changelog +++ b/debian/changelog @@ -11,6 +11,8 @@ ikiwiki (3.20101024) UNRELEASED; urgency=low * Fix htmlscrubber_skip to be matched on the source page, not the page it is inlined into. Should allow setting to "* and !comment(*)" to scrub comments, but leave your blog posts unscrubbed, etc. + * comments: Make postcomment() pagespec work when previewing a comment, + including during moderation. -- Joey Hess Mon, 25 Oct 2010 22:30:29 -0400 -- cgit v1.2.3 From d8de98911ec98f9e4560ab2939b4edf8fb04066b Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Fri, 12 Nov 2010 00:36:03 -0400 Subject: comments: Make comment() pagespec also match comments that are being posted. --- IkiWiki/Plugin/comments.pm | 18 ++++++++++-------- debian/changelog | 2 ++ 2 files changed, 12 insertions(+), 8 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/comments.pm b/IkiWiki/Plugin/comments.pm index 57f5b1304..a39dab36c 100644 --- a/IkiWiki/Plugin/comments.pm +++ b/IkiWiki/Plugin/comments.pm @@ -947,14 +947,16 @@ sub match_comment ($$;@) { my $page = shift; my $glob = shift; - # To see if it's a comment, check the source file type. - # Deal with comments that were just deleted. - my $source=exists $IkiWiki::pagesources{$page} ? - $IkiWiki::pagesources{$page} : - $IkiWiki::delpagesources{$page}; - my $type=defined $source ? IkiWiki::pagetype($source) : undef; - if (! defined $type || $type ne "_comment") { - return IkiWiki::FailReason->new("$page is not a comment"); + if (! $postcomment) { + # To see if it's a comment, check the source file type. + # Deal with comments that were just deleted. + my $source=exists $IkiWiki::pagesources{$page} ? + $IkiWiki::pagesources{$page} : + $IkiWiki::delpagesources{$page}; + my $type=defined $source ? IkiWiki::pagetype($source) : undef; + if (! defined $type || $type ne "_comment") { + return IkiWiki::FailReason->new("$page is not a comment"); + } } return match_glob($page, "$glob/*", internal => 1, @_); diff --git a/debian/changelog b/debian/changelog index 91a678805..2c4c9274a 100644 --- a/debian/changelog +++ b/debian/changelog @@ -13,6 +13,8 @@ ikiwiki (3.20101024) UNRELEASED; urgency=low comments, but leave your blog posts unscrubbed, etc. * comments: Make postcomment() pagespec work when previewing a comment, including during moderation. + * comments: Make comment() pagespec also match comments that are being + posted. -- Joey Hess Mon, 25 Oct 2010 22:30:29 -0400 -- cgit v1.2.3 From b85ca8603aecbd3523201d99edf019db1094b558 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 16 Nov 2010 14:24:15 -0400 Subject: websetup: Fix encoding problem when restoring old setup file. --- IkiWiki/Plugin/websetup.pm | 2 +- debian/changelog | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/websetup.pm b/IkiWiki/Plugin/websetup.pm index 0ab18997c..9c032fdc6 100644 --- a/IkiWiki/Plugin/websetup.pm +++ b/IkiWiki/Plugin/websetup.pm @@ -475,7 +475,7 @@ sub showform ($$) { join(" ", @command), $ret). '

'; open(OUT, ">", $config{setupfile}) || error("$config{setupfile}: $!"); - print OUT $oldsetup; + print OUT Encode::encode_utf8($oldsetup); close OUT; } diff --git a/debian/changelog b/debian/changelog index 582a8e36a..91ff0964b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +ikiwiki (3.20101113) UNRELEASED; urgency=low + + * websetup: Fix encoding problem when restoring old setup file. + + -- Joey Hess Tue, 16 Nov 2010 14:23:47 -0400 + ikiwiki (3.20101112) unstable; urgency=HIGH * txt: Fix display when used inside a format directive. -- cgit v1.2.3 From ec6c1269d251c78d2eef68cb789de6cfc6272464 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 16 Nov 2010 15:00:04 -0400 Subject: more: Add pages parameter to limit where the more is displayed. (thanks, dark) --- IkiWiki/Plugin/more.pm | 5 ++++- debian/changelog | 2 ++ doc/ikiwiki/directive/more.mdwn | 5 +++++ doc/todo/selective_more_directive.mdwn | 2 ++ 4 files changed, 13 insertions(+), 1 deletion(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/more.pm b/IkiWiki/Plugin/more.pm index 80e339a1b..6880e366d 100644 --- a/IkiWiki/Plugin/more.pm +++ b/IkiWiki/Plugin/more.pm @@ -26,7 +26,10 @@ sub preprocess (@) { $params{linktext} = $linktext unless defined $params{linktext}; - if ($params{page} ne $params{destpage}) { + if ($params{page} ne $params{destpage} && + (! exists $params{pages} || + pagespec_match($params{destpage}, $params{pages}, + location => $params{page}))) { return "\n". htmllink($params{page}, $params{destpage}, $params{page}, linktext => $params{linktext}, diff --git a/debian/changelog b/debian/changelog index 91ff0964b..faabf1993 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,6 +1,8 @@ ikiwiki (3.20101113) UNRELEASED; urgency=low * websetup: Fix encoding problem when restoring old setup file. + * more: Add pages parameter to limit where the more is displayed. + (thanks, dark) -- Joey Hess Tue, 16 Nov 2010 14:23:47 -0400 diff --git a/doc/ikiwiki/directive/more.mdwn b/doc/ikiwiki/directive/more.mdwn index 506551910..bda1427f3 100644 --- a/doc/ikiwiki/directive/more.mdwn +++ b/doc/ikiwiki/directive/more.mdwn @@ -11,6 +11,11 @@ leads to the full version of the page. Use it like this: If the `linktext` parameter is omitted it defaults to just "more". +An optional `pages` parameter can be used to specify a +[[ikiwiki/PageSpec]], and then the "more" link will only be displayed +when the page is inlined into a page matching that PageSpec, and otherwise +the full content shown. + Note that you can accomplish something similar using a [[toggle]] instead. [[!meta robots="noindex, follow"]] diff --git a/doc/todo/selective_more_directive.mdwn b/doc/todo/selective_more_directive.mdwn index 24e6ab568..2a9998205 100644 --- a/doc/todo/selective_more_directive.mdwn +++ b/doc/todo/selective_more_directive.mdwn @@ -24,3 +24,5 @@ I can now call it as I'm not entirely happy with the design, since I would rather put this information in the inline directive instead of in every story post. Unfortunately I found no way to pass parameters from the inline directive to the inlined page. -- [[dark]] + +> Me neither, but nor do I see a better way, so [[applied|done]]. --[[Joey]] -- cgit v1.2.3 From cedf2c0af568d801fe2cf1917ac0202ce64f838b Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 16 Nov 2010 15:12:52 -0400 Subject: Fix escaping of filenames in historyurl. (Thanks, aj) --- IkiWiki/Render.pm | 4 ++-- debian/changelog | 1 + 2 files changed, 3 insertions(+), 2 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Render.pm b/IkiWiki/Render.pm index 7ea919abc..8e8336b99 100644 --- a/IkiWiki/Render.pm +++ b/IkiWiki/Render.pm @@ -5,7 +5,6 @@ package IkiWiki; use warnings; use strict; use IkiWiki; -use Encode; my (%backlinks, %rendered); our %brokenlinks; @@ -94,7 +93,8 @@ sub genpage ($$) { } if (defined $config{historyurl} && length $config{historyurl}) { my $u=$config{historyurl}; - $u=~s/\[\[file\]\]/$pagesources{$page}/g; + my $p=uri_escape_utf8($pagesources{$page}); + $u=~s/\[\[file\]\]/$p/g; $template->param(historyurl => $u); $actions++; } diff --git a/debian/changelog b/debian/changelog index faabf1993..00c32e95d 100644 --- a/debian/changelog +++ b/debian/changelog @@ -3,6 +3,7 @@ ikiwiki (3.20101113) UNRELEASED; urgency=low * websetup: Fix encoding problem when restoring old setup file. * more: Add pages parameter to limit where the more is displayed. (thanks, dark) + * Fix escaping of filenames in historyurl. (Thanks, aj) -- Joey Hess Tue, 16 Nov 2010 14:23:47 -0400 -- cgit v1.2.3 From c502b8fe548329d2904e928af3b581456a374a8a Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Tue, 16 Nov 2010 15:40:16 -0400 Subject: indentation --- IkiWiki/Plugin/inline.pm | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/inline.pm b/IkiWiki/Plugin/inline.pm index c00aed299..3b98bf8dd 100644 --- a/IkiWiki/Plugin/inline.pm +++ b/IkiWiki/Plugin/inline.pm @@ -104,7 +104,7 @@ sub checkconfig () { } sub format (@) { - my %params=@_; + my %params=@_; # Fill in the inline content generated earlier. This is actually an # optimisation. @@ -513,16 +513,16 @@ sub absolute_urls ($$) { my $url=$baseurl; $url=~s/[^\/]+$//; - # what is the non path part of the url? - my $top_uri = URI->new($url); - $top_uri->path_query(""); # reset the path - my $urltop = $top_uri->as_string; + # what is the non path part of the url? + my $top_uri = URI->new($url); + $top_uri->path_query(""); # reset the path + my $urltop = $top_uri->as_string; $content=~s/( Date: Tue, 16 Nov 2010 16:57:50 -0400 Subject: inline: Improve RSS url munging to use a proper html parser and support all elements that HTML::Tagset knows about. (Which doesn't include html5 just yet, but then the old version didn't either.) Bonus: 4 times faster than old regexp method. --- IkiWiki/Plugin/inline.pm | 63 ++++++++++++++++++++++++++++++++++++------------ debian/changelog | 4 +++ 2 files changed, 52 insertions(+), 15 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/inline.pm b/IkiWiki/Plugin/inline.pm index 3b98bf8dd..1fe40a5ea 100644 --- a/IkiWiki/Plugin/inline.pm +++ b/IkiWiki/Plugin/inline.pm @@ -506,26 +506,59 @@ sub date_822 ($) { } sub absolute_urls ($$) { - # sucky sub because rss sucks - my $content=shift; + # needed because rss sucks + my $html=shift; my $baseurl=shift; my $url=$baseurl; $url=~s/[^\/]+$//; + my $urltop; # calculated if needed - # what is the non path part of the url? - my $top_uri = URI->new($url); - $top_uri->path_query(""); # reset the path - my $urltop = $top_uri->as_string; - - $content=~s/(new(api_version => 3); + $p->handler(default => sub { $ret.=join("", @_) }, "text"); + $p->handler(start => sub { + my ($tagname, $pos, $text) = @_; + if (ref $HTML::Tagset::linkElements{$tagname}) { + while (4 <= @$pos) { + # use attribute sets from right to left + # to avoid invalidating the offsets + # when replacing the values + my ($k_offset, $k_len, $v_offset, $v_len) = + splice(@$pos, -4); + my $attrname = lc(substr($text, $k_offset, $k_len)); + next unless grep { $_ eq $attrname } @{$HTML::Tagset::linkElements{$tagname}}; + next unless $v_offset; # 0 v_offset means no value + my $v = substr($text, $v_offset, $v_len); + $v =~ s/^([\'\"])(.*)\1$/$2/; + if ($v=~/^#/) { + $v=$baseurl.$v; # anchor + } + elsif ($v=~/^(?!\w+:)[^\/]/) { + $v=$url.$v; # relative url + } + elsif ($v=~/^\//) { + if (! defined $urltop) { + # what is the non path part of the url? + my $top_uri = URI->new($url); + $top_uri->path_query(""); # reset the path + $urltop = $top_uri->as_string; + } + $v=$urltop.$v; # url relative to top of site + } + $v =~ s/\"/"/g; # since we quote with "" + substr($text, $v_offset, $v_len) = qq("$v"); + } + } + $ret.=$text; + }, "tagname, tokenpos, text"); + $p->parse($html); + $p->eof; + + return $ret; } sub genfeed ($$$$$@) { diff --git a/debian/changelog b/debian/changelog index 00c32e95d..0edb78004 100644 --- a/debian/changelog +++ b/debian/changelog @@ -4,6 +4,10 @@ ikiwiki (3.20101113) UNRELEASED; urgency=low * more: Add pages parameter to limit where the more is displayed. (thanks, dark) * Fix escaping of filenames in historyurl. (Thanks, aj) + * inline: Improve RSS url munging to use a proper html parser, + and support all elements that HTML::Tagset knows about. + (Which doesn't include html5 just yet, but then the old version + didn't either.) Bonus: 4 times faster than old regexp method. -- Joey Hess Tue, 16 Nov 2010 14:23:47 -0400 -- cgit v1.2.3 From 55515050e1f3aad13dc96796a347cefa98e8e472 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Sat, 20 Nov 2010 00:02:49 +0000 Subject: make use of precompiled regex objects --- IkiWiki.pm | 4 ++-- IkiWiki/Plugin/filecheck.pm | 2 +- IkiWiki/Plugin/meta.pm | 2 +- IkiWiki/Plugin/po.pm | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki.pm b/IkiWiki.pm index bb7d46ccf..e5370f4a6 100644 --- a/IkiWiki.pm +++ b/IkiWiki.pm @@ -2495,7 +2495,7 @@ sub match_glob ($$;@) { # cache the compiled regex to save time. if (!defined $glob_cache{$glob}) { my $re = IkiWiki::glob2re($glob); - $glob_cache{$glob} = qr/^$re$/i; + $glob_cache{$glob} = $re; } if ($page=~ $glob_cache{$glob}) { if (! IkiWiki::isinternal($page) || $params{internal}) { @@ -2667,7 +2667,7 @@ sub match_user ($$;@) { return IkiWiki::ErrorReason->new("no user specified"); } - if (defined $params{user} && $params{user}=~/^$regexp$/i) { + if (defined $params{user} && $params{user}=~$regexp) { return IkiWiki::SuccessReason->new("user is $user"); } elsif (! defined $params{user}) { diff --git a/IkiWiki/Plugin/filecheck.pm b/IkiWiki/Plugin/filecheck.pm index 3b0a7b314..4f4e67489 100644 --- a/IkiWiki/Plugin/filecheck.pm +++ b/IkiWiki/Plugin/filecheck.pm @@ -161,7 +161,7 @@ sub match_mimetype ($$;@) { } my $regexp=IkiWiki::glob2re($wanted); - if ($mimetype!~/^$regexp$/i) { + if ($mimetype!~$regexp) { return IkiWiki::FailReason->new("file MIME type is $mimetype, not $wanted"); } else { diff --git a/IkiWiki/Plugin/meta.pm b/IkiWiki/Plugin/meta.pm index 5cfa72833..47007afe2 100644 --- a/IkiWiki/Plugin/meta.pm +++ b/IkiWiki/Plugin/meta.pm @@ -355,7 +355,7 @@ sub match { } if (defined $val) { - if ($val=~/^$re$/i) { + if ($val=~$re) { return IkiWiki::SuccessReason->new("$re matches $field of $page", $page => $IkiWiki::DEPEND_CONTENT, "" => 1); } else { diff --git a/IkiWiki/Plugin/po.pm b/IkiWiki/Plugin/po.pm index a79e7d7f0..79142ed1f 100644 --- a/IkiWiki/Plugin/po.pm +++ b/IkiWiki/Plugin/po.pm @@ -1297,7 +1297,7 @@ sub match_lang ($$;@) { my $regexp=IkiWiki::glob2re($wanted); my $lang=IkiWiki::Plugin::po::lang($page); - if ($lang !~ /^$regexp$/i) { + if ($lang !~ $regexp) { return IkiWiki::FailReason->new("file language is $lang, not $wanted"); } else { -- cgit v1.2.3 From af5f162ca7c8cd14d64f6282e05a3032dbd7c2fb Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 20 Nov 2010 12:55:26 -0400 Subject: highlight: Support new format of filetypes.conf used by version 3.2 of the highlight package. --- IkiWiki/Plugin/highlight.pm | 27 +++++++++++++++++++++------ debian/changelog | 2 ++ 2 files changed, 23 insertions(+), 6 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/highlight.pm b/IkiWiki/Plugin/highlight.pm index 934e64bed..9d05e9fcf 100644 --- a/IkiWiki/Plugin/highlight.pm +++ b/IkiWiki/Plugin/highlight.pm @@ -96,14 +96,29 @@ my %highlighters; # Parse highlight's config file to get extension => language mappings. sub read_filetypes () { - open (IN, $config{filetypes_conf}) || error("$config{filetypes_conf}: $!"); - while () { - chomp; - if (/^\$ext\((.*)\)=(.*)$/) { - $ext2lang{$_}=$1 foreach $1, split ' ', $2; + open (my $f, $config{filetypes_conf}) || error("$config{filetypes_conf}: $!"); + local $/=undef; + my $config=<$f>; + close $f; + + # highlight >= 3.2 format (bind-style) + while ($config=~m/Lang\s*=\s*\"([^"]+)\"[,\s]+Extensions\s*=\s*{([^}]+)}/sg) { + my $lang=$1; + foreach my $bit (split ',', $2) { + $bit=~s/.*"(.*)".*/$1/s; + $ext2lang{$bit}=$lang; } } - close IN; + + # highlight < 3.2 format + if (! keys %ext2lang) { + foreach (split("\n", $config)) { + if (/^\$ext\((.*)\)=(.*)$/) { + $ext2lang{$_}=$1 foreach $1, split ' ', $2; + } + } + } + $filetypes_read=1; } diff --git a/debian/changelog b/debian/changelog index 65c235317..ecd028a0c 100644 --- a/debian/changelog +++ b/debian/changelog @@ -9,6 +9,8 @@ ikiwiki (3.20101113) UNRELEASED; urgency=low (Which doesn't include html5 just yet, but then the old version didn't either.) Bonus: 4 times faster than old regexp method. * Optimise glob() pagespec. (Thanks, Kathryn and smcv) + * highlight: Support new format of filetypes.conf used by version 3.2 + of the highlight package. -- Joey Hess Tue, 16 Nov 2010 14:23:47 -0400 -- cgit v1.2.3 From 31f0e459b8143cd986f04d122d255f4d0f44a505 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sat, 20 Nov 2010 14:54:43 -0400 Subject: edittemplate: Fix crash if using a .tmpl file or other non-page file as a template for a new page. --- IkiWiki/Plugin/edittemplate.pm | 6 ++++-- debian/changelog | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/edittemplate.pm b/IkiWiki/Plugin/edittemplate.pm index 576c94be4..061242fd8 100644 --- a/IkiWiki/Plugin/edittemplate.pm +++ b/IkiWiki/Plugin/edittemplate.pm @@ -107,9 +107,11 @@ sub formbuilder (@) { my $template=$pagestate{$registering_page}{edittemplate}{$pagespec}; $form->field(name => "editcontent", value => filltemplate($template, $page)); - $form->field(name => "type", - value => pagetype($pagesources{$template})) + my $type=pagetype($pagesources{$template}) if $pagesources{$template}; + $form->field(name => "type", + value => $type) + if defined $type; return; } } diff --git a/debian/changelog b/debian/changelog index ecd028a0c..d236361d2 100644 --- a/debian/changelog +++ b/debian/changelog @@ -11,6 +11,8 @@ ikiwiki (3.20101113) UNRELEASED; urgency=low * Optimise glob() pagespec. (Thanks, Kathryn and smcv) * highlight: Support new format of filetypes.conf used by version 3.2 of the highlight package. + * edittemplate: Fix crash if using a .tmpl file or other non-page file + as a template for a new page. -- Joey Hess Tue, 16 Nov 2010 14:23:47 -0400 -- cgit v1.2.3 From d2e3741a6f289bd25b75683990a0548f41661a85 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 23 Nov 2010 00:00:11 +0000 Subject: Use local paths for redirection where possible --- IkiWiki/CGI.pm | 4 ++-- IkiWiki/Plugin/comments.pm | 4 ++-- IkiWiki/Plugin/editpage.pm | 10 +++++----- IkiWiki/Plugin/goto.pm | 2 +- IkiWiki/Plugin/openid.pm | 2 +- IkiWiki/Plugin/poll.pm | 4 ++-- IkiWiki/Plugin/remove.pm | 2 +- IkiWiki/Plugin/websetup.pm | 2 +- 8 files changed, 15 insertions(+), 15 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/CGI.pm b/IkiWiki/CGI.pm index f2a32a958..ed6959f89 100644 --- a/IkiWiki/CGI.pm +++ b/IkiWiki/CGI.pm @@ -231,11 +231,11 @@ sub cgi_prefs ($$) { if ($form->submitted eq 'Logout') { $session->delete(); - redirect($q, $config{url}); + redirect($q, baseurl(undef)); return; } elsif ($form->submitted eq 'Cancel') { - redirect($q, $config{url}); + redirect($q, baseurl(undef)); return; } elsif ($form->submitted eq 'Save Preferences' && $form->validate) { diff --git a/IkiWiki/Plugin/comments.pm b/IkiWiki/Plugin/comments.pm index a39dab36c..eefd65741 100644 --- a/IkiWiki/Plugin/comments.pm +++ b/IkiWiki/Plugin/comments.pm @@ -386,7 +386,7 @@ sub editcomment ($$) { if ($form->submitted eq CANCEL) { # bounce back to the page they wanted to comment on, and exit. # CANCEL need not be considered in future - IkiWiki::redirect($cgi, urlto($page, undef, 1)); + IkiWiki::redirect($cgi, urlto($page, undef)); exit; } @@ -552,7 +552,7 @@ sub editcomment ($$) { # Jump to the new comment on the page. # The trailing question mark tries to avoid broken # caches and get the most recent version of the page. - IkiWiki::redirect($cgi, urlto($page, undef, 1). + IkiWiki::redirect($cgi, urlto($page, undef). "?updated#".page_to_id($location)); } diff --git a/IkiWiki/Plugin/editpage.pm b/IkiWiki/Plugin/editpage.pm index 1a04a72b5..8915211d4 100644 --- a/IkiWiki/Plugin/editpage.pm +++ b/IkiWiki/Plugin/editpage.pm @@ -156,13 +156,13 @@ sub cgi_editpage ($$) { my $previewing=0; if ($form->submitted eq "Cancel") { if ($form->field("do") eq "create" && defined $from) { - redirect($q, urlto($from, undef, 1)); + redirect($q, urlto($from, undef)); } elsif ($form->field("do") eq "create") { - redirect($q, $config{url}); + redirect($q, baseurl(undef)); } else { - redirect($q, urlto($page, undef, 1)); + redirect($q, urlto($page, undef)); } exit; } @@ -262,7 +262,7 @@ sub cgi_editpage ($$) { @page_locs=$page; } else { - redirect($q, urlto($page, undef, 1)); + redirect($q, urlto($page, undef)); exit; } } @@ -434,7 +434,7 @@ sub cgi_editpage ($$) { else { # The trailing question mark tries to avoid broken # caches and get the most recent version of the page. - redirect($q, urlto($page, undef, 1)."?updated"); + redirect($q, urlto($page, undef)."?updated"); } } diff --git a/IkiWiki/Plugin/goto.pm b/IkiWiki/Plugin/goto.pm index 348a663ef..7f31fa5ca 100644 --- a/IkiWiki/Plugin/goto.pm +++ b/IkiWiki/Plugin/goto.pm @@ -64,7 +64,7 @@ sub cgi_goto ($;$) { ) } else { - IkiWiki::redirect($q, urlto($link, undef, 1)); + IkiWiki::redirect($q, urlto($link, undef)); } exit; diff --git a/IkiWiki/Plugin/openid.pm b/IkiWiki/Plugin/openid.pm index fae9fb77f..3b75c31a2 100644 --- a/IkiWiki/Plugin/openid.pm +++ b/IkiWiki/Plugin/openid.pm @@ -175,7 +175,7 @@ sub auth ($$) { IkiWiki::redirect($q, $setup_url); } elsif ($csr->user_cancel) { - IkiWiki::redirect($q, $config{url}); + IkiWiki::redirect($q, IkiWiki::baseurl(undef)); } elsif (my $vident = $csr->verified_identity) { $session->param(name => $vident->url); diff --git a/IkiWiki/Plugin/poll.pm b/IkiWiki/Plugin/poll.pm index b333e2cdc..988f4c113 100644 --- a/IkiWiki/Plugin/poll.pm +++ b/IkiWiki/Plugin/poll.pm @@ -103,7 +103,7 @@ sub sessioncgi ($$) { my $oldchoice=$session->param($choice_param); if (defined $oldchoice && $oldchoice eq $choice) { # Same vote; no-op. - IkiWiki::redirect($cgi, urlto($page, undef, 1)); + IkiWiki::redirect($cgi, urlto($page, undef)); exit; } @@ -153,7 +153,7 @@ sub sessioncgi ($$) { error($@) if $@; my $cookie = CGI::Cookie->new(-name=> $session->name, -value=> $session->id); print $cgi->redirect(-cookie => $cookie, - -url => urlto($page, undef, 1)); + -url => urlto($page, undef)); exit; } } diff --git a/IkiWiki/Plugin/remove.pm b/IkiWiki/Plugin/remove.pm index 1717c8cf3..ab1897663 100644 --- a/IkiWiki/Plugin/remove.pm +++ b/IkiWiki/Plugin/remove.pm @@ -240,7 +240,7 @@ sub sessioncgi ($$) { if (! exists $pagesources{$parent}) { $parent="index"; } - IkiWiki::redirect($q, urlto($parent, '/', 1)); + IkiWiki::redirect($q, urlto($parent, undef)); } } else { diff --git a/IkiWiki/Plugin/websetup.pm b/IkiWiki/Plugin/websetup.pm index 9c032fdc6..ef9a93886 100644 --- a/IkiWiki/Plugin/websetup.pm +++ b/IkiWiki/Plugin/websetup.pm @@ -344,7 +344,7 @@ sub showform ($$) { IkiWiki::decode_form_utf8($form); if ($form->submitted eq "Cancel") { - IkiWiki::redirect($cgi, $config{url}); + IkiWiki::redirect($cgi, IkiWiki::baseurl(undef)); return; } elsif (($form->submitted eq 'Save Setup' || $form->submitted eq 'Rebuild Wiki') && $form->validate) { -- cgit v1.2.3 From 78c595736ef6903ad8e7bab232875474aedfd328 Mon Sep 17 00:00:00 2001 From: Simon McVittie Date: Tue, 23 Nov 2010 00:06:07 +0000 Subject: Use local paths when including Javascript --- IkiWiki/Plugin/relativedate.pm | 11 +++++------ IkiWiki/Plugin/toggle.pm | 11 +++++------ IkiWiki/Plugin/wmd.pm | 9 ++++----- 3 files changed, 14 insertions(+), 17 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/relativedate.pm b/IkiWiki/Plugin/relativedate.pm index 7296889ab..4ae0be861 100644 --- a/IkiWiki/Plugin/relativedate.pm +++ b/IkiWiki/Plugin/relativedate.pm @@ -28,18 +28,17 @@ sub format (@) { if (! ($params{content}=~s!^(]*>)!$1.include_javascript($params{page})!em)) { # no tag, probably in preview mode - $params{content}=include_javascript($params{page}, 1).$params{content}; + $params{content}=include_javascript(undef).$params{content}; } return $params{content}; } -sub include_javascript ($;$) { - my $page=shift; - my $absolute=shift; +sub include_javascript ($) { + my $from=shift; - return ''."\n". - ''; } diff --git a/IkiWiki/Plugin/toggle.pm b/IkiWiki/Plugin/toggle.pm index 1f93f87fe..af4d2ba3a 100644 --- a/IkiWiki/Plugin/toggle.pm +++ b/IkiWiki/Plugin/toggle.pm @@ -70,19 +70,18 @@ sub format (@) { $params{content}=~s/
//g; if (! ($params{content}=~s!^(]*>)!$1.include_javascript($params{page})!em)) { # no tag, probably in preview mode - $params{content}=include_javascript($params{page}, 1).$params{content}; + $params{content}=include_javascript(undef).$params{content}; } } return $params{content}; } -sub include_javascript ($;$) { - my $page=shift; - my $absolute=shift; +sub include_javascript ($) { + my $from=shift; - return ''."\n". - ''; } diff --git a/IkiWiki/Plugin/wmd.pm b/IkiWiki/Plugin/wmd.pm index 71d7c9d17..134cfb910 100644 --- a/IkiWiki/Plugin/wmd.pm +++ b/IkiWiki/Plugin/wmd.pm @@ -31,14 +31,13 @@ sub formbuilder_setup (@) { $form->field("do") eq "comment"; $form->tmpl_param("wmd_preview", "
\n". - include_javascript(undef, 1)); + include_javascript(undef)); } -sub include_javascript ($;$) { - my $page=shift; - my $absolute=shift; +sub include_javascript ($) { + my $from=shift; - my $wmdjs=urlto("wmd/wmd.js", $page, $absolute); + my $wmdjs=urlto("wmd/wmd.js", $from); return <<"EOF"