]> sipb.mit.edu Git - ikiwiki.git/blobdiff - IkiWiki/Plugin/rename.pm
Avoid relying on translators preserving the case when translating "discussion", which...
[ikiwiki.git] / IkiWiki / Plugin / rename.pm
index 54c7faf137c1c87d5e90156b74be3e1139ef04d3..0b6e74705b29e86330395344140d7b6390db7cf2 100644 (file)
@@ -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)=@_;