X-Git-Url: http://git.vanrenterghem.biz/git.ikiwiki.info.git/blobdiff_plain/dae0f48e91304afcb6ebe0936360e51b22a56548..4093a584a74e250a4f6a4ecc7647f68b997ccb7f:/IkiWiki/CGI.pm diff --git a/IkiWiki/CGI.pm b/IkiWiki/CGI.pm index 074971be1..fe89e2758 100644 --- a/IkiWiki/CGI.pm +++ b/IkiWiki/CGI.pm @@ -83,12 +83,16 @@ sub cgi_recentchanges ($) { #{{{ foreach my $change (@$changelog) { $change->{when} = concise(ago($change->{when})); $change->{user} = htmllink("", "", escapeHTML($change->{user}), 1); + + my $is_excess = exists $change->{pages}[10]; # limit pages to first 10 + delete @{$change->{pages}}[10 .. @{$change->{pages}}] if $is_excess; $change->{pages} = [ map { $_->{link} = htmllink("", "", $_->{page}, 1); $_; } @{$change->{pages}} ]; + push @{$change->{pages}}, { link => '...' } if $is_excess; } my $template=template("recentchanges.tmpl"); @@ -99,6 +103,9 @@ sub cgi_recentchanges ($) { #{{{ changelog => $changelog, baseurl => baseurl(), ); + run_hooks(pagetemplate => sub { + shift->(page => "", destpage => "", template => $template); + }); print $q->header(-charset => 'utf-8'), $template->output; } #}}} @@ -311,6 +318,11 @@ sub cgi_prefs ($$) { #{{{ 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, @@ -349,9 +361,19 @@ sub cgi_editpage ($$) { #{{{ 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', @@ -363,9 +385,8 @@ sub cgi_editpage ($$) { #{{{ params => $q, action => $config{cgiurl}, table => 0, - template => {template_params("editpage.tmpl")}, + template => $renderer, ); - my @buttons=("Save Page", "Preview", "Cancel"); decode_form_utf8($form); @@ -427,7 +448,15 @@ sub cgi_editpage ($$) { #{{{ } 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") { @@ -437,7 +466,7 @@ sub cgi_editpage ($$) { #{{{ 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, "", @@ -614,7 +643,7 @@ sub cgi () { #{{{ 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, @@ -623,6 +652,7 @@ sub cgi () { #{{{ # 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); @@ -634,6 +664,22 @@ sub cgi () { #{{{ 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);