From 8c9c3915ecaf9cce4d0335f2b3c588d7f96d2b36 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 5 Jan 2011 13:49:04 -0400 Subject: Fix base url when previewing. Was broken by urlto changes in last release. Added a showform_preview that is like showform, but sets forcebaseurl to point to the page being previewed. --- IkiWiki/CGI.pm | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'IkiWiki/CGI.pm') 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}; -- cgit v1.2.3