sub cgi_postsignin ($$) { #{{{
my $q=shift;
my $session=shift;
-
+
# Continue with whatever was being done before the signin process.
- my $postsignin=CGI->new($session->param("postsignin"));
- $session->clear("postsignin");
- cgi($postsignin, $session);
- cgi_savesession($session);
- exit;
+ if (defined $session->param("postsignin")) {
+ my $postsignin=CGI->new($session->param("postsignin"));
+ $session->clear("postsignin");
+ cgi($postsignin, $session);
+ cgi_savesession($session);
+ exit;
+ }
+ else {
+ # This can occur, for example, if a user went to the signin
+ # url via a bookmark.
+ redirect($q, $config{url});
+ }
} #}}}
sub cgi_prefs ($$) { #{{{
}
} #}}}
-sub cgi_editpage ($$) { #{{{
+sub cgi_editpage ($$;$) { #{{{
my $q=shift;
my $session=shift;
+ my $blogpost=shift;
- my @fields=qw(do rcsinfo subpage from page type editcontent comments);
+ my @fields=qw(do rcsinfo subpage from page type editcontent comments
+ newfile);
my @buttons=("Save Page", "Preview", "Cancel");
eval q{use CGI::FormBuilder};
# characters.
my ($page)=$form->field('page');
$page=titlepage(possibly_foolish_untaint($page));
+ if ($blogpost) {
+ $page=~s/(\/)/"__".ord($1)."__"/eg;
+ }
if (! defined $page || ! length $page || file_pruned($page, $config{srcdir}) || $page=~/^\//) {
error("bad page name");
}
$file=$page.".".$type;
}
- my $newfile=0;
- if (! -e "$config{srcdir}/$file") {
- $newfile=1;
- }
$form->field(name => "do", type => 'hidden');
$form->field(name => "from", type => 'hidden');
$form->field(name => "comments", type => "text", size => 80);
$form->field(name => "editcontent", type => "textarea", rows => 20,
cols => 80);
+ $form->field(name => "newfile", type => 'hidden');
$form->tmpl_param("can_commit", $config{rcs});
$form->tmpl_param("indexlink", indexlink());
$form->tmpl_param("helponformattinglink",
if (! $form->submitted) {
$form->field(name => "rcsinfo", value => rcs_prepedit($file),
force => 1);
+ $form->field(name => "newfile",
+ value => ! -e "$config{srcdir}/$file",
+ force => 1);
}
if ($form->submitted eq "Cancel") {
- if ($newfile && defined $from) {
+ if ($form->field(name => "newfile") && defined $from) {
redirect($q, "$config{url}/".htmlpage($from));
}
- elsif ($newfile) {
+ elsif ($form->field(name => "newfile")) {
redirect($q, $config{url});
}
else {
value => $content, force => 1);
$form->field(name => "comments",
value => $comments, force => 1);
- $config{rss}=$config{atom}=0; # avoid preview writing a feed!
$form->tmpl_param("page_preview",
htmlize($page, $type,
linkify($page, "",
preprocess($page, $page,
- filter($page, $content)))));
+ filter($page, $content), 0, 1))));
}
else {
$form->tmpl_param("page_preview", "");
$form->tmpl_param("page_select", 1);
$form->field(name => "page", type => 'select',
- options => { map { $_ => pagetitle($_, 1) } @editable_locs },
- value => $best_loc);
+ options => [ map { pagetitle($_, 1) } @editable_locs ],
+ value => pagetitle($best_loc, 1));
$form->field(name => "type", type => 'select',
options => \@page_types);
$form->title(sprintf(gettext("creating %s"), pagetitle($page)));
else {
# save page
check_canedit($page, $q, $session);
+ if (! -e "$config{srcdir}/$file" && ! $form->field(name => 'newfile')){
+ $form->tmpl_param("page_gone", 1);
+ $form->field(name => "newfile",
+ value => 1, force => 1);
+ $form->tmpl_param("page_select", 0);
+ $form->field(name => "page", type => 'hidden');
+ $form->field(name => "type", type => 'hidden');
+ print $form->render(submit => \@buttons);
+ return;
+ }
my $content=$form->field('editcontent');
$form->tmpl_param("failed_save", 1);
$form->tmpl_param("error_message", $@);
$form->field("editcontent", value => $content, force => 1);
- $form->field(name => "comments", value => $form->field('comments'), force => 1);
- $form->field("do", "edit)");
$form->tmpl_param("page_select", 0);
$form->field(name => "page", type => 'hidden');
$form->field(name => "type", type => 'hidden');
$message=$form->field('comments');
}
- if ($newfile) {
+ if ($form->field(name => "newfile")) {
rcs_add($file);
}
force => 1);
$form->tmpl_param("page_conflict", 1);
$form->field("editcontent", value => $conflict, force => 1);
- $form->field(name => "comments", value => $form->field('comments'), force => 1);
- $form->field("do", "edit)");
+ $form->field("do", "edit", force => 1);
$form->tmpl_param("page_select", 0);
$form->field(name => "page", type => 'hidden');
$form->field(name => "type", type => 'hidden');
cgi_editpage($q, $session);
}
elsif ($do eq 'blog') {
- my $page=titlepage(decode_utf8($q->param('title')));
- $page=~s/(\/)/"__".ord($1)."__"/eg; # escape slashes too
+ my $page=decode_utf8($q->param('title'));
# if the page already exists, munge it to be unique
my $from=$q->param('from');
my $add="";
$add++;
}
$q->param('page', $page.$add);
- # now run same as create
+ # now run same as create, except escape slashes too
$q->param('do', 'create');
- cgi_editpage($q, $session);
+ cgi_editpage($q, $session, 1);
}
elsif ($do eq 'postsignin') {
error(gettext("login failed, perhaps you need to turn on cookies?"));