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};
error(gettext("bad page name"));
}
- my $baseurl = urlto($page);
-
$form->title(sprintf(gettext("commenting on %s"),
IkiWiki::pagetitle(IkiWiki::basename($page))));
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;
}
}
else {
- IkiWiki::showform ($form, \@buttons, $session, $cgi,
- forcebaseurl => $baseurl, page => $page);
+ IkiWiki::showform_preview($form, \@buttons, $session, $cgi,
+ page => $page);
}
exit;
$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
$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) {
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;
}
$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;
}
$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