diff options
-rw-r--r-- | IkiWiki/CGI.pm | 18 | ||||
-rw-r--r-- | IkiWiki/Plugin/comments.pm | 8 | ||||
-rw-r--r-- | IkiWiki/Plugin/editpage.pm | 19 | ||||
-rw-r--r-- | debian/changelog | 1 |
4 files changed, 31 insertions, 15 deletions
diff --git a/IkiWiki/CGI.pm b/IkiWiki/CGI.pm index ede194ff9..df5179834 100644 --- a/IkiWiki/CGI.pm +++ b/IkiWiki/CGI.pm @@ -49,6 +49,24 @@ sub showform ($$$$;@) { print misctemplate($form->title, $form->render(submit => $buttons), @_); } +# Like showform, but the base url will be set to allow edit previews +# that use links relative to the specified page. +sub showform_preview ($$$$;@) { + my $form=shift; + my $buttons=shift; + my $session=shift; + my $cgi=shift; + my %params=@_; + + eval q{use URI}; + # The base url needs to be a full URL. If urlto returns relative, + # force it absolute, using the same URL scheme used for the cgi. + my $baseurl = URI->new_abs(urlto($params{page}), $cgi->url); + + showform($form, $buttons, $session, $cgi, @_, + forcebaseurl => $baseurl); +} + sub redirect ($$) { my $q=shift; eval q{use URI}; diff --git a/IkiWiki/Plugin/comments.pm b/IkiWiki/Plugin/comments.pm index 63e9ab499..f3d6f20d6 100644 --- a/IkiWiki/Plugin/comments.pm +++ b/IkiWiki/Plugin/comments.pm @@ -372,8 +372,6 @@ sub editcomment ($$) { error(gettext("bad page name")); } - my $baseurl = urlto($page); - $form->title(sprintf(gettext("commenting on %s"), IkiWiki::pagetitle(IkiWiki::basename($page)))); @@ -385,7 +383,7 @@ sub editcomment ($$) { if ($form->submitted eq CANCEL) { # bounce back to the page they wanted to comment on, and exit. - IkiWiki::redirect($cgi, $baseurl); + IkiWiki::redirect($cgi, urlto($page)); exit; } @@ -556,8 +554,8 @@ sub editcomment ($$) { } else { - IkiWiki::showform ($form, \@buttons, $session, $cgi, - forcebaseurl => $baseurl, page => $page); + IkiWiki::showform_preview($form, \@buttons, $session, $cgi, + page => $page); } exit; diff --git a/IkiWiki/Plugin/editpage.pm b/IkiWiki/Plugin/editpage.pm index 537b86ad1..f6cebd4cd 100644 --- a/IkiWiki/Plugin/editpage.pm +++ b/IkiWiki/Plugin/editpage.pm @@ -312,8 +312,7 @@ sub cgi_editpage ($$) { $form->title(sprintf(gettext("editing %s"), pagetitle(basename($page)))); } - showform($form, \@buttons, $session, $q, - forcebaseurl => $baseurl, page => $page); + showform_preview($form, \@buttons, $session, $q, page => $page); } else { # save page @@ -330,8 +329,8 @@ sub cgi_editpage ($$) { $form->field(name => "page", type => 'hidden'); $form->field(name => "type", type => 'hidden'); $form->title(sprintf(gettext("editing %s"), $page)); - showform($form, \@buttons, $session, $q, - forcebaseurl => $baseurl, page => $page); + showform_preview($form, \@buttons, $session, $q, + page => $page); exit; } elsif ($form->field("do") eq "create" && $exists) { @@ -345,8 +344,8 @@ sub cgi_editpage ($$) { value => readfile("$config{srcdir}/$file"). "\n\n\n".$form->field("editcontent"), force => 1); - showform($form, \@buttons, $session, $q, - forcebaseurl => $baseurl, page => $page); + showform_preview($form, \@buttons, $session, $q, + page => $page); exit; } @@ -386,8 +385,8 @@ sub cgi_editpage ($$) { $form->field(name => "page", type => 'hidden'); $form->field(name => "type", type => 'hidden'); $form->title(sprintf(gettext("editing %s"), $page)); - showform($form, \@buttons, $session, $q, - forcebaseurl => $baseurl, page => $page); + showform_preview($form, \@buttons, $session, $q, + page => $page); exit; } @@ -428,8 +427,8 @@ sub cgi_editpage ($$) { $form->field(name => "page", type => 'hidden'); $form->field(name => "type", type => 'hidden'); $form->title(sprintf(gettext("editing %s"), $page)); - showform($form, \@buttons, $session, $q, - forcebaseurl => $baseurl, page => $page); + showform_preview($form, \@buttons, $session, $q, + page => $page); } else { # The trailing question mark tries to avoid broken diff --git a/debian/changelog b/debian/changelog index a61d910ce..baf3e1906 100644 --- a/debian/changelog +++ b/debian/changelog @@ -3,6 +3,7 @@ ikiwiki (3.20101232) UNRELEASED; urgency=low * tag: Do not include tagbase in rss/atom category tags. (Giuseppe Bilotta) * tag: Improve display of tags with a slash in their names. (Giuseppe Bilotta) + * Fix base url when previewing. Was broken by urlto changes in last release. -- Joey Hess <joeyh@debian.org> Tue, 04 Jan 2011 16:00:55 -0400 |