]> sipb.mit.edu Git - ikiwiki.git/blob - doc/todo/Allow_edittemplate_to_set_file_type.mdwn
edittemplate patch from Willu
[ikiwiki.git] / doc / todo / Allow_edittemplate_to_set_file_type.mdwn
1 Below is a [[patch]] to [[plugins/edittemplate]] that does a few things:
2
3  * It defaults the type of the file to be created to the same type as the template.
4  * It adds a 'silent' parameter to the directive that stops it from printing out what what registered.
5  * It makes the description of what was registered link to the template page (which gives feedback for typos or allows template creation)
6  * It adds a colon to the standard string correcting the syntax.
7
8 ----
9
10     diff --git a/IkiWiki/Plugin/edittemplate.pm b/IkiWiki/Plugin/edittemplate.pm
11     index 98308de..c381940 100644
12     --- a/IkiWiki/Plugin/edittemplate.pm
13     +++ b/IkiWiki/Plugin/edittemplate.pm
14     @@ -56,8 +56,14 @@ sub preprocess (@) { #{{{
15      
16         $pagestate{$params{page}}{edittemplate}{$params{match}}=$params{template};
17      
18     -   return sprintf(gettext("edittemplate %s registered for %s"),
19     -           $params{template}, $params{match});
20     +   return "" if ($params{silent} && IkiWiki::yesno($params{silent}));
21     +
22     +   my $link=IkiWiki::linkpage($params{template});
23     +   add_depends($params{page}, $link);
24     +   my $linkHTML = htmllink($params{page}, $params{destpage}, $link);
25     +
26     +   return sprintf(gettext("edittemplate: %s registered for %s"),
27     +           $linkHTML, $params{match});
28      } # }}}
29      
30      sub formbuilder (@) { #{{{
31     @@ -89,6 +95,9 @@ sub formbuilder (@) { #{{{
32                                         if (pagespec_match($p, $pagespec, location => $registering_page)) {
33                                                 $form->field(name => "editcontent",
34                                                          value => filltemplate($pagestate{$registering_page}{edittemplate}{$pagespec}, $page));
35     +                                           $form->field(name => "type",
36     +                                                    value => pagetype($pagesources{$pagestate{$registering_page}{edittemplate}{$pagespec}}))
37     +                                                           if $pagesources{$pagestate{$registering_page}{edittemplate}{$pagespec}};
38                                                 return;
39                                         }
40                                 }
41
42
43 [[done]]