]> sipb.mit.edu Git - ikiwiki.git/blob - doc/todo/Allow_edittemplate_to_set_file_type.mdwn
Merge branch 'master' of ssh://git.ikiwiki.info/srv/git/ikiwiki.info
[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 [[done]] except for the colon change; it's referring to the template as an
9 edittemplate there. --[[Joey]]
10
11 ----
12
13     diff --git a/IkiWiki/Plugin/edittemplate.pm b/IkiWiki/Plugin/edittemplate.pm
14     index 98308de..c381940 100644
15     --- a/IkiWiki/Plugin/edittemplate.pm
16     +++ b/IkiWiki/Plugin/edittemplate.pm
17     @@ -56,8 +56,14 @@ sub preprocess (@) {
18      
19         $pagestate{$params{page}}{edittemplate}{$params{match}}=$params{template};
20      
21     -   return sprintf(gettext("edittemplate %s registered for %s"),
22     -           $params{template}, $params{match});
23     +   return "" if ($params{silent} && IkiWiki::yesno($params{silent}));
24     +
25     +   my $link=IkiWiki::linkpage($params{template});
26     +   add_depends($params{page}, $link);
27     +   my $linkHTML = htmllink($params{page}, $params{destpage}, $link);
28     +
29     +   return sprintf(gettext("edittemplate: %s registered for %s"),
30     +           $linkHTML, $params{match});
31      }
32      
33      sub formbuilder (@) {
34     @@ -89,6 +95,9 @@ sub formbuilder (@) {
35                                         if (pagespec_match($p, $pagespec, location => $registering_page)) {
36                                                 $form->field(name => "editcontent",
37                                                          value => filltemplate($pagestate{$registering_page}{edittemplate}{$pagespec}, $page));
38     +                                           $form->field(name => "type",
39     +                                                    value => pagetype($pagesources{$pagestate{$registering_page}{edittemplate}{$pagespec}}))
40     +                                                           if $pagesources{$pagestate{$registering_page}{edittemplate}{$pagespec}};
41                                                 return;
42                                         }
43                                 }
44