]> git.vanrenterghem.biz Git - git.ikiwiki.info.git/blobdiff - IkiWiki/Plugin/rename.pm
Merge branch 'master' of ssh://git.ikiwiki.info/srv/git/ikiwiki.info
[git.ikiwiki.info.git] / IkiWiki / Plugin / rename.pm
index b1bb1576728945a00238949ce48821fe6cc1d5f5..0b6e74705b29e86330395344140d7b6390db7cf2 100644 (file)
@@ -3,7 +3,7 @@ package IkiWiki::Plugin::rename;
 
 use warnings;
 use strict;
-use IkiWiki 2.00;
+use IkiWiki 3.00;
 
 sub import {
        hook(type => "getsetup", id => "rename", call => \&getsetup);
@@ -116,14 +116,16 @@ sub rename_form ($$$) {
                # insert the standard extensions
                my @page_types;
                if (exists $IkiWiki::hooks{htmlize}) {
-                       @page_types=grep { !/^_/ }
-                               keys %{$IkiWiki::hooks{htmlize}};
+                       foreach my $key (grep { !/^_/ } keys %{$IkiWiki::hooks{htmlize}}) {
+                               push @page_types, [$key, $IkiWiki::hooks{htmlize}{$key}{longname} || $key];
+                       }
                }
+               @page_types=sort @page_types;
        
                # make sure the current extension is in the list
                my ($ext) = $pagesources{$page}=~/\.([^.]+)$/;
                if (! $IkiWiki::hooks{htmlize}{$ext}) {
-                       unshift(@page_types, $ext);
+                       unshift(@page_types, [$ext, $ext]);
                }
        
                $f->field(name => "type", type => 'select',
@@ -390,22 +392,8 @@ sub sessioncgi ($$) {
                                $template->param(error => $rename->{error});
                                if ($rename->{src} ne $rename->{dest}) {
                                        $template->param(brokenlinks_checked => 1);
-                                       $template->param(brokenlinks => [
-                                               map {
-                                                       {
-                                                               page => htmllink($rename->{dest}, $rename->{dest}, $_,
-                                                                               noimageinline => 1)
-                                                       }
-                                               } @{$rename->{brokenlinks}}
-                                       ]);
-                                       $template->param(fixedlinks => [
-                                               map {
-                                                       {
-                                                               page => htmllink($rename->{dest}, $rename->{dest}, $_,
-                                                                               noimageinline => 1)
-                                                       }
-                                               } @{$rename->{fixedlinks}}
-                                       ]);
+                                       $template->param(brokenlinks => linklist($rename->{dest}, $rename->{brokenlinks}));
+                                       $template->param(fixedlinks => linklist($rename->{dest}, $rename->{fixedlinks}));
                                }
                                $renamesummary.=$template->output;
                        }
@@ -419,6 +407,23 @@ sub sessioncgi ($$) {
                exit 0;
        }
 }
+                                               
+sub linklist {
+       # generates a list of links in a form suitable for FormBuilder
+       my $dest=shift;
+       my $list=shift;
+       # converts a list of pages into a list of links
+       # in a form suitable for FormBuilder.
+
+       [map {
+               {
+                       page => htmllink($dest, $dest, $_,
+                                       noimageinline => 1,
+                                       linktext => pagetitle($_),
+                               )
+               }
+       } @{$list}]
+}
 
 sub renamepage_hook ($$$$) {
        my ($page, $src, $dest, $content)=@_;