aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoey Hess <joey@kodama.kitenet.net>2008-08-07 16:09:41 -0400
committerJoey Hess <joey@kodama.kitenet.net>2008-08-07 16:09:41 -0400
commit46b9a83b61be0a4c82ad26475df0c7a8115dfcb4 (patch)
treea4f7437708edb411034874fbd2cbdb23b5b2076c
parentd18c75c8532fff42f91a715abe92732865065322 (diff)
downloadikiwiki-46b9a83b61be0a4c82ad26475df0c7a8115dfcb4.tar
ikiwiki-46b9a83b61be0a4c82ad26475df0c7a8115dfcb4.tar.gz
page file type rename patch from willu
-rw-r--r--IkiWiki/Plugin/rename.pm35
1 files changed, 30 insertions, 5 deletions
diff --git a/IkiWiki/Plugin/rename.pm b/IkiWiki/Plugin/rename.pm
index 5dcd4e936..2db8be0f3 100644
--- a/IkiWiki/Plugin/rename.pm
+++ b/IkiWiki/Plugin/rename.pm
@@ -52,7 +52,7 @@ sub check_canrename ($$$$$$$) { #{{{
# Dest checks can be omitted by passing undef.
if (defined $dest) {
- if ($src eq $dest || $srcfile eq $destfile) {
+ if ($srcfile eq $destfile) {
error(gettext("no change to the file name was specified"));
}
@@ -63,7 +63,7 @@ sub check_canrename ($$$$$$$) { #{{{
}
# Must not be a known source file.
- if (exists $pagesources{$dest}) {
+ if ($src ne $dest && exists $pagesources{$dest}) {
error(sprintf(gettext("%s already exists"),
htmllink("", "", $dest, noimageinline => 1)));
}
@@ -106,6 +106,24 @@ sub rename_form ($$$) { #{{{
$f->field(name => "do", type => "hidden", value => "rename", force => 1);
$f->field(name => "page", type => "hidden", value => $page, force => 1);
$f->field(name => "new_name", value => IkiWiki::pagetitle($page), size => 60);
+ if (!$q->param("attachment")) {
+ # insert the standard extensions
+ my @page_types;
+ if (exists $IkiWiki::hooks{htmlize}) {
+ @page_types=grep { !/^_/ }
+ keys %{$IkiWiki::hooks{htmlize}};
+ }
+
+ # make sure the current extension is in the list
+ my ($ext) = $pagesources{$page}=~/\.([^.]+)$/;
+ if (! $IkiWiki::hooks{htmlize}{$ext}) {
+ unshift(@page_types, $ext);
+ }
+
+ $f->field(name => "type", type => 'select',
+ options => \@page_types,
+ value => $ext, force => 1);
+ }
$f->field(name => "attachment", type => "hidden");
return $f, ["Rename", "Cancel"];
@@ -232,12 +250,19 @@ sub sessioncgi ($$) { #{{{
my $dest=IkiWiki::possibly_foolish_untaint(IkiWiki::titlepage($q->param("new_name")));
# The extension of dest is the same as src if it's
- # a page. If it's an extension, the extension is
+ # a page. If it's an attachment, the extension is
# already included.
my $destfile=$dest;
if (! $q->param("attachment")) {
- my ($ext)=$srcfile=~/(\.[^.]+)$/;
- $destfile.=$ext;
+ my $type=$q->param('type');
+ if (defined $type && length $type && $IkiWiki::hooks{htmlize}{$type}) {
+ $type=IkiWiki::possibly_foolish_untaint($type);
+ } else {
+ my ($ext)=$srcfile=~/\.([^.]+)$/;
+ $type=$ext;
+ }
+
+ $destfile.=".".$type;
}
check_canrename($src, $srcfile, $dest, $destfile,