]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/CGI.pm
Fix base url when previewing. Was broken by urlto changes in last release.
[ikiwiki.git] / IkiWiki / CGI.pm
index ede194ff9aee945dc0fb471bedaa47bf93eda829..df51798344cf00b23bea94ddad30bb6682f9a670 100644 (file)
@@ -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};