]> sipb.mit.edu Git - ikiwiki.git/blob - doc/todo/index.html_allowed.mdwn
document new rcs reversion support functions
[ikiwiki.git] / doc / todo / index.html_allowed.mdwn
1 This page used to be used for two patches, one of which is applied
2 providing the usedirs option for output. The remaining patch, discussed
3 below, concerns wanting to use foo/index.mdwn source files and get an
4 output page name of foo, rather than foo/index. --[[Joey]]
5
6 [[!tag patch]]
7
8 ---
9
10 I independently implemented a similar, but smaller patch.
11 (It's smaller because I only care about rendering; not CGI, for example.)
12 The key to this patch is that "A/B/C" is treated as equivalent
13 to "A/B/C/index".
14 Here it is:  --Per Bothner
15
16     --- IkiWiki/Render.pm~  2007-01-11 15:01:51.000000000 -0800
17     +++ IkiWiki/Render.pm   2007-02-02 22:24:12.000000000 -0800
18     @@ -60,9 +60,9 @@
19             foreach my $dir (reverse split("/", $page)) {
20                     if (! $skip) {
21                             $path.="../";
22     -                       unshift @ret, { url => $path.htmlpage($dir), page => pagetitle($dir) };
23     +                       unshift @ret, { url => abs2rel(htmlpage(bestlink($page, $dir)), dirname($page)), page => pagetitle($dir) };
24                     }
25     -               else {
26     +               elsif ($dir ne "index") {
27                             $skip=0;
28                     }
29             }
30
31     --- IkiWiki.pm~ 2007-01-12 12:47:09.000000000 -0800
32     +++ IkiWiki.pm  2007-02-02 18:02:16.000000000 -0800
33     @@ -315,6 +315,12 @@
34                     elsif (exists $pagecase{lc $l}) {
35                             return $pagecase{lc $l};
36                      }
37     +               else {
38     +                   my $lindex = $l . "/index";
39     +                   if (exists $links{$lindex}) {
40     +                       return $lindex;
41     +               }
42     +               }
43              } while $cwd=~s!/?[^/]+$!!;
44      
45             if (length $config{userdir} && exists $links{"$config{userdir}/".lc($link)}) {
46
47 Note I handle setting the url; slightly differently.
48 Also note that an initial "index" is ignored.  I.e. a
49 page "A/B/index.html" is treated as "A/B".
50
51 > Actually, your patch is shorter because it's more elegant and better :)
52 > I'm withdrawing my old patch, because yours is much more in line with
53 > ikiwiki's design and architecture.
54 > I would like to make one suggestion to your patch, which is:
55
56     diff -urX ignorepats clean-ikidev/IkiWiki/Plugin/inline.pm ikidev/IkiWiki/Plugin/inline.pm
57     --- clean-ikidev/IkiWiki/Plugin/inline.pm   2007-02-25 12:26:54.099113000 -0800
58     +++ ikidev/IkiWiki/Plugin/inline.pm 2007-02-25 14:55:21.163340000 -0800
59     @@ -154,7 +154,7 @@
60                         $link=htmlpage($link) if defined $type;
61                         $link=abs2rel($link, dirname($params{destpage}));
62                         $template->param(pageurl => $link);
63     -                   $template->param(title => pagetitle(basename($page)));
64     +                   $template->param(title => titlename($page));
65                         $template->param(ctime => displaytime($pagectime{$page}));
66
67                         if ($actions) {
68     @@ -318,7 +318,7 @@
69                 my $pcontent = absolute_urls(get_inline_content($p, $page), $url);
70
71                 $itemtemplate->param(
72     -                   title => pagetitle(basename($p), 1),
73     +                   title => titlename($p, 1),
74                         url => $u,
75                         permalink => $u,
76                         date_822 => date_822($pagectime{$p}),
77     diff -urX ignorepats clean-ikidev/IkiWiki/Render.pm ikidev/IkiWiki/Render.pm
78     --- clean-ikidev/IkiWiki/Render.pm  2007-02-25 12:26:54.745833000 -0800
79     +++ ikidev/IkiWiki/Render.pm        2007-02-25 14:54:01.564715000 -0800
80     @@ -110,7 +110,7 @@
81         $template->param(
82                 title => $page eq 'index'
83                         ? $config{wikiname}
84     -                   : pagetitle(basename($page)),
85     +                   : titlename($page),
86                 wikiname => $config{wikiname},
87                 parentlinks => [parentlinks($page)],
88                 content => $content,
89     diff -urX ignorepats clean-ikidev/IkiWiki.pm ikidev/IkiWiki.pm
90     --- clean-ikidev/IkiWiki.pm 2007-02-25 12:26:58.812850000 -0800
91     +++ ikidev/IkiWiki.pm       2007-02-25 15:05:22.328852000 -0800
92     @@ -192,6 +192,12 @@
93         return $untainted;
94      }
95
96     +sub titlename($;@) {
97     +   my $page = shift;
98     +   $page =~ s!/index$!!;
99     +   return pagetitle(basename($page), @_);
100     +}
101     +
102      sub basename ($) {
103         my $file=shift;
104
105
106 > This way foo/index gets "foo" as its title, not "index". --Ethan
107
108 I took another swing at this and subverted the dominant paradigm. Here goes:
109
110 <pre>
111 diff -ru ikiwiki-2.4/IkiWiki.pm ikiwiki/IkiWiki.pm
112 --- ikiwiki-2.4/IkiWiki.pm      2007-06-26 15:01:57.000000000 -0700
113 +++ ikiwiki/IkiWiki.pm  2007-07-25 15:58:00.990749000 -0700
114 @@ -239,6 +239,7 @@
115         my $type=pagetype($file);
116         my $page=$file;
117         $page=~s/\Q.$type\E*$// if defined $type;
118 +       $page=~s/\/index$// if $page =~ /\/index$/;
119         return $page;
120  }
121  
122 </pre>
123
124 This just makes it so that all files named foo/index become pages called foo, which is the desired effect. I haven't tested everything so far, so be careful! But you can see it working at http://ikidev.betacantrips.com/one/ again, as before. --Ethan
125
126 [[done]], the indexpages setting enables this.