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.master
parent
a554a3d538
commit
8c9c3915ec
|
@ -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};
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in New Issue