]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - IkiWiki/Plugin/rename.pm
get rid of diag explain again
[git.ikiwiki.info.git] / IkiWiki / Plugin / rename.pm
index 1a9da6363165c3ef06cffd1855e9520926c310a2..e871b815d6441a0cc52131932c283421c78c98c6 100644 (file)
@@ -63,9 +63,8 @@ sub check_canrename ($$$$$$) {
                        error(gettext("no change to the file name was specified"));
                }
 
-               # Must be a legal filename, and not absolute.
-               if (IkiWiki::file_pruned($destfile, $config{srcdir}) || 
-                   $destfile=~/^\//) {
+               # Must be a legal filename.
+               if (IkiWiki::file_pruned($destfile)) {
                        error(sprintf(gettext("illegal name")));
                }
 
@@ -109,6 +108,7 @@ sub check_canrename ($$$$$$) {
                        }
                }
        });
+       return defined $canrename ? $canrename : 1;
 }
 
 sub rename_form ($$$) {
@@ -126,12 +126,14 @@ sub rename_form ($$$) {
                method => 'POST',
                javascript => 0,
                params => $q,
-               action => $config{cgiurl},
-               stylesheet => IkiWiki::baseurl()."style.css",
+               action => IkiWiki::cgiurl(),
+               stylesheet => 1,
                fields => [qw{do page new_name attachment}],
        );
        
        $f->field(name => "do", type => "hidden", value => "rename", force => 1);
+       $f->field(name => "sid", type => "hidden", value => $session->id,
+               force => 1);
        $f->field(name => "page", type => "hidden", value => $page, force => 1);
        $f->field(name => "new_name", value => pagetitle($page, 1), size => 60);
        if (!$q->param("attachment")) {
@@ -287,6 +289,8 @@ sub sessioncgi ($$) {
                        postrename($session);
                }
                elsif ($form->submitted eq 'Rename' && $form->validate) {
+                       IkiWiki::checksessionexpiry($q, $session, $q->param('sid'));
+
                        # Queue of rename actions to perfom.
                        my @torename;
 
@@ -346,8 +350,9 @@ sub sessioncgi ($$) {
                                $pagesources{$rename->{src}}=$rename->{destfile};
                        }
                        IkiWiki::rcs_commit_staged(
-                               sprintf(gettext("rename %s to %s"), $srcfile, $destfile),
-                               $session->param("name"), $ENV{REMOTE_ADDR}) if $config{rcs};
+                               message => sprintf(gettext("rename %s to %s"), $srcfile, $destfile),
+                               session => $session,
+                       ) if $config{rcs};
 
                        # Then link fixups.
                        foreach my $rename (@torename) {
@@ -562,6 +567,7 @@ sub fixlinks ($$$) {
                }
                if ($needfix) {
                        my $file=$pagesources{$page};
+                       next unless -e $config{srcdir}."/".$file;
                        my $oldcontent=readfile($config{srcdir}."/".$file);
                        my $content=renamepage_hook($page, $rename->{src}, $rename->{dest}, $oldcontent);
                        if ($oldcontent ne $content) {
@@ -569,11 +575,10 @@ sub fixlinks ($$$) {
                                eval { writefile($file, $config{srcdir}, $content) };
                                next if $@;
                                my $conflict=IkiWiki::rcs_commit(
-                                       $file,
-                                       sprintf(gettext("update for rename of %s to %s"), $rename->{srcfile}, $rename->{destfile}),
-                                       $token,
-                                       $session->param("name"), 
-                                       $ENV{REMOTE_ADDR}
+                                       file => $file,
+                                       message => sprintf(gettext("update for rename of %s to %s"), $rename->{srcfile}, $rename->{destfile}),
+                                       token => $token,
+                                       session => $session,
                                );
                                push @fixedlinks, $page if ! defined $conflict;
                        }