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=@_;
+
+ # The base url needs to be a full URL, and urlto may return a path.
+ my $baseurl = absurl(urlto($params{page}), $cgi->url);
+
+ showform($form, $buttons, $session, $cgi, @_,
+ forcebaseurl => $baseurl);
+}
+
+# Forces a partial url (path only) to absolute, using the same
+# URL scheme as the CGI. Full URLs are left unchanged.
+sub absurl ($$) {
+ my $partialurl=shift;
+ my $q=shift;
+
+ eval q{use URI};
+ return URI->new_abs($partialurl, $q->url);
+}
+
sub redirect ($$) {
my $q=shift;
eval q{use URI};
- my $url=URI->new(shift);
+ my $url=URI->new(absurl(shift, $q));
if (! $config{w3mmode}) {
print $q->redirect($url);
}
required => 'NONE',
javascript => 0,
params => $q,
- action => $config{cgiurl},
+ action => cgiurl(),
header => 0,
template => {type => 'div'},
stylesheet => 1,
required => 'NONE',
javascript => 0,
params => $q,
- action => $config{cgiurl},
+ action => cgiurl(),
template => {type => 'div'},
stylesheet => 1,
fieldsets => [
if ($form->submitted eq 'Logout') {
$session->delete();
- redirect($q, $config{url});
+ redirect($q, baseurl(undef));
return;
}
elsif ($form->submitted eq 'Cancel') {
- redirect($q, $config{url});
+ redirect($q, baseurl(undef));
return;
}
elsif ($form->submitted eq 'Save Preferences' && $form->validate) {