]> sipb.mit.edu Git - ikiwiki.git/blob - doc/todo/Allow_filenames_that_are_all_type.mdwn
comments (finally)
[ikiwiki.git] / doc / todo / Allow_filenames_that_are_all_type.mdwn
1 This is a [[patch]] to allow filenames that are just the type.  The best example of this is wanting to
2 pass a `Makefile` through one of the [[todo/syntax_highlighting/]] plugins.  With this patch,
3 if the plugin can process files of type `.Makefile` then it will also process `Makefile`.
4
5 I put this patch on the [[todo/syntax_highlighting/]] page a while ago, but it seemed to get
6 lost because it didn't have its own bug to track it.  Now it does :).  -- [[Will]]
7
8 > This changes `pagename()`, but what about `pagetype()`?
9 > Many things in ikiwiki check if `pagetype($file)` returns
10 > true to see if it's a page, etc. --[[Joey]] 
11
12 >> I think this patch is complete.  It does not change `pagename()`, it
13 >> changes `pagetype()` (the diff is fairly old - line numbers may have
14 >> changed).
15 >>
16 >> Before this patch, `pagetype()` required a `.` in the page name.  With
17 >> this patch it doesn't, as long as the extension is being kept.  This allows
18 >> the filename to be all extension.  `pagename()` relies on `pagetype()`
19 >> to detect the type.  `pagename()` also removes the extension on some
20 >> pages, but this patch only affects pages where the extension isn't
21 >> removed.
22 >>
23 >> So, yeah, I think this patch is complete. :)  -- [[Will]]
24
25 >>> Thanks, [[applied|done]], but I added a noextension parameter,
26 >>> since having keepextension allow files with no extension didn't make
27 >>> sense. Also, made it work for pages in subdirs.. --[[Joey]] 
28
29     diff --git a/IkiWiki.pm b/IkiWiki.pm
30     index 8d728c9..1bd46a9 100644
31     --- a/IkiWiki.pm
32     +++ b/IkiWiki.pm
33     @@ -618,6 +618,8 @@ sub pagetype ($) {
34         
35         if ($page =~ /\.([^.]+)$/) {
36                 return $1 if exists $hooks{htmlize}{$1};
37     +   } elsif ($hooks{htmlize}{$page}{keepextension}) {
38     +           return $page;
39         }
40         return;
41      }