changelog => $changelog,
baseurl => baseurl(),
);
+ run_hooks(pagetemplate => sub {
+ shift->(page => "", destpage => "", template => $template);
+ });
print $q->header(-charset => 'utf-8'), $template->output;
} #}}}
if (! is_admin($user_name)) {
$form->field(name => "locked_pages", type => "hidden");
}
+
+ if ($config{httpauth}) {
+ $form->field(name => "password", type => "hidden");
+ $form->field(name => "confirm_password", type => "hidden");
+ }
if (! $form->submitted) {
$form->field(name => "email", force => 1,
my $q=shift;
my $session=shift;
- eval q{use CGI::FormBuilder};
+ my @fields=qw(do rcsinfo subpage from page type editcontent comments);
+ my @buttons=("Save Page", "Preview", "Cancel");
+
+ eval q{use CGI::FormBuilder; use CGI::FormBuilder::Template::HTML};
+ my $renderer=CGI::FormBuilder::Template::HTML->new(
+ fields => \@fields,
+ template_params("editpage.tmpl"),
+ );
+ run_hooks(pagetemplate => sub {
+ shift->(page => "", destpage => "", template => $renderer->engine);
+ });
my $form = CGI::FormBuilder->new(
- fields => [qw(do rcsinfo subpage from page type editcontent comments)],
+ fields => \@fields,
header => 1,
charset => "utf-8",
method => 'POST',
params => $q,
action => $config{cgiurl},
table => 0,
- template => {template_params("editpage.tmpl")},
+ template => $renderer,
);
- my @buttons=("Save Page", "Preview", "Cancel");
decode_form_utf8($form);
}
if ($form->submitted eq "Cancel") {
- redirect($q, "$config{url}/".htmlpage($page));
+ if ($newfile && defined $from) {
+ redirect($q, "$config{url}/".htmlpage($from));
+ }
+ elsif ($newfile) {
+ redirect($q, $config{url});
+ }
+ else {
+ redirect($q, "$config{url}/".htmlpage($page));
+ }
return;
}
elsif ($form->submitted eq "Preview") {
- require IkiWiki::Render;
my $content=$form->field('editcontent');
my $comments=$form->field('comments');
$form->field(name => "editcontent",
value => $content, force => 1);
$form->field(name => "comments",
value => $comments, force => 1);
- $config{rss}=0; # avoid preview writing an rss feed!
+ $config{rss}=$config{atom}=0; # avoid preview writing a feed!
$form->tmpl_param("page_preview",
htmlize($page, $type,
linkify($page, "",
cgi_hyperestraier();
}
- CGI::Session->name("ikiwiki_session_$config{wikiname}");
+ CGI::Session->name("ikiwiki_session_".encode_utf8($config{wikiname}));
my $oldmask=umask(077);
my $session = CGI::Session->new("driver:DB_File", $q,
# Everything below this point needs the user to be signed in.
if (((! $config{anonok} || $do eq 'prefs') &&
+ (! $config{httpauth}) &&
(! defined $session->param("name") ||
! userinfo_get($session->param("name"), "regdate"))) || $do eq 'signin') {
cgi_signin($q, $session);
return;
}
+
+ if ($config{httpauth} && (! defined $session->param("name"))) {
+ if (! defined $q->remote_user()) {
+ error("Could not determine authenticated username.");
+ }
+ else {
+ $session->param("name", $q->remote_user());
+ if (!userinfo_get($session->param("name"),"regdate")) {
+ userinfo_setall($session->param("name"), {
+ email => "",
+ password => "",
+ regdate=>time,
+ });
+ }
+ }
+ }
if ($do eq 'create' || $do eq 'edit') {
cgi_editpage($q, $session);