]> sipb.mit.edu Git - ikiwiki.git/blob - doc/todo/modify_page_filename_in_plugin.mdwn
two comments ui suggestions
[ikiwiki.git] / doc / todo / modify_page_filename_in_plugin.mdwn
1 I'm writing a plugin to wikify c/c++ code.
2
3 By default ikiwiki generates xxx.html for a file called xxx.c.
4
5 The problem is that I occasionally have xxx.c and xxx.h in the same directory and there's a filename collision.
6
7 My solution is to allow plugins to provide a hook that sets the pagename. --[[/users/bstpierre]]
8
9     --- /usr/share/perl5/IkiWiki.pm.ORIG    2008-10-03 14:12:50.000000000 -0400
10     +++ /usr/share/perl5/IkiWiki.pm 2008-10-07 11:57:26.000000000 -0400
11     @@ -196,11 +196,32 @@
12
13      sub pagename ($) {
14             my $file=shift;
15
16             my $type=pagetype($file);
17     +
18     +   if(defined $type &&
19     +      exists $hooks{pagename} &&
20     +      exists $hooks{pagename}{$type}) {
21     +
22     +      return $hooks{pagename}{$type}{call}($file);
23     +
24     +   } else {
25     +
26             my $page=$file;
27             $page=~s/\Q.$type\E*$// if defined $type;
28             return $page;
29     +   }
30      }
31
32      sub htmlpage ($) {
33