From 30248df40a19dc03c0d8c07e136105f3c2299191 Mon Sep 17 00:00:00 2001 From: Jon Dowland Date: Sat, 16 May 2009 13:56:25 +0100 Subject: check for longname for each syntax plugin We build an array of [ plugin name, long name ] pairs, where long name is an optional argument to hook(). So, a syntax plugin could define long "friendly" name, such as "Markdown" instead of mdwn, and we would then pass this array to formbuilder to populate the drop-down on the edit page. --- IkiWiki/Plugin/editpage.pm | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/editpage.pm b/IkiWiki/Plugin/editpage.pm index 0068a6b11..eb6a7bbcb 100644 --- a/IkiWiki/Plugin/editpage.pm +++ b/IkiWiki/Plugin/editpage.pm @@ -276,8 +276,14 @@ sub cgi_editpage ($$) { my @page_types; if (exists $hooks{htmlize}) { - @page_types=grep { !/^_/ } - keys %{$hooks{htmlize}}; + foreach my $key (grep { !/^_/ } keys %{$hooks{htmlize}}) { + my $pluginref = ${$hooks{htmlize}}{$key}; + if(${$pluginref}{'longname'}) { + push @page_types, [$key, ${$pluginref}{'longname'}]; + } else { + push @page_types, [$key, $key]; + } + } } $form->tmpl_param("page_select", 1); -- cgit v1.2.3 From 79510950f09ace7906e149799ffda5aa26decbf6 Mon Sep 17 00:00:00 2001 From: Jon Dowland Date: Sat, 16 May 2009 13:59:27 +0100 Subject: add a long name for mdwn ("Markdown") --- IkiWiki/Plugin/mdwn.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/mdwn.pm b/IkiWiki/Plugin/mdwn.pm index 0e134c822..c62780cb8 100644 --- a/IkiWiki/Plugin/mdwn.pm +++ b/IkiWiki/Plugin/mdwn.pm @@ -8,7 +8,7 @@ use IkiWiki 3.00; sub import { hook(type => "getsetup", id => "mdwn", call => \&getsetup); - hook(type => "htmlize", id => "mdwn", call => \&htmlize); + hook(type => "htmlize", id => "mdwn", call => \&htmlize, longname => "Markdown"); } sub getsetup () { -- cgit v1.2.3 From 83e3fc3af031abfd0321fadf0a64bbf6ecee5886 Mon Sep 17 00:00:00 2001 From: Jon Dowland Date: Sat, 16 May 2009 13:59:36 +0100 Subject: add a long name for textile/txtl ("Textile") --- IkiWiki/Plugin/textile.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/textile.pm b/IkiWiki/Plugin/textile.pm index b604aa3c5..8cc5a7951 100644 --- a/IkiWiki/Plugin/textile.pm +++ b/IkiWiki/Plugin/textile.pm @@ -11,7 +11,7 @@ use Encode; sub import { hook(type => "getsetup", id => "textile", call => \&getsetup); - hook(type => "htmlize", id => "txtl", call => \&htmlize); + hook(type => "htmlize", id => "txtl", call => \&htmlize, longname => "Textile"); } sub getsetup () { -- cgit v1.2.3 From eba9b862b2f7d346dfffcd5576cd96fce9dd239d Mon Sep 17 00:00:00 2001 From: Jon Dowland Date: Sat, 16 May 2009 14:44:23 +0100 Subject: tidy up new page_types code --- IkiWiki/Plugin/editpage.pm | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) (limited to 'IkiWiki') diff --git a/IkiWiki/Plugin/editpage.pm b/IkiWiki/Plugin/editpage.pm index eb6a7bbcb..af42097ba 100644 --- a/IkiWiki/Plugin/editpage.pm +++ b/IkiWiki/Plugin/editpage.pm @@ -277,12 +277,7 @@ sub cgi_editpage ($$) { my @page_types; if (exists $hooks{htmlize}) { foreach my $key (grep { !/^_/ } keys %{$hooks{htmlize}}) { - my $pluginref = ${$hooks{htmlize}}{$key}; - if(${$pluginref}{'longname'}) { - push @page_types, [$key, ${$pluginref}{'longname'}]; - } else { - push @page_types, [$key, $key]; - } + push @page_types, [$key, $hooks{htmlize}{$key}{longname} || $key]; } } -- cgit v1.2.3