]> scripts.mit.edu Git - www/ikiwiki.git/blob - doc/patchqueue/index.html_allowed.mdwn
revive the original index.html patches, which are for the source side, not
[www/ikiwiki.git] / doc / patchqueue / index.html_allowed.mdwn
1 Instead of having files foo.html "in front of" foo/, I prefer to have 
2 foo/index.html.
3
4 I independently implemented a similar, but smaller patch.
5 (It's smaller because I only care about rendering; not CGI, for example.)
6 The key to this patch is that "A/B/C" is treated as equivalent
7 to "A/B/C/index".
8 Here it is:  --Per Bothner
9
10     --- IkiWiki/Render.pm~  2007-01-11 15:01:51.000000000 -0800
11     +++ IkiWiki/Render.pm   2007-02-02 22:24:12.000000000 -0800
12     @@ -60,9 +60,9 @@
13             foreach my $dir (reverse split("/", $page)) {
14                     if (! $skip) {
15                             $path.="../";
16     -                       unshift @ret, { url => $path.htmlpage($dir), page => pagetitle($dir) };
17     +                       unshift @ret, { url => abs2rel(htmlpage(bestlink($page, $dir)), dirname($page)), page => pagetitle($dir) };
18                     }
19     -               else {
20     +               elsif ($dir ne "index") {
21                             $skip=0;
22                     }
23             }
24
25     --- IkiWiki.pm~ 2007-01-12 12:47:09.000000000 -0800
26     +++ IkiWiki.pm  2007-02-02 18:02:16.000000000 -0800
27     @@ -315,6 +315,12 @@
28                     elsif (exists $pagecase{lc $l}) {
29                             return $pagecase{lc $l};
30                      }
31     +               else {
32     +                   my $lindex = $l . "/index";
33     +                   if (exists $links{$lindex}) {
34     +                       return $lindex;
35     +               }
36     +               }
37              } while $cwd=~s!/?[^/]+$!!;
38      
39             if (length $config{userdir} && exists $links{"$config{userdir}/".lc($link)}) {
40
41 Note I handle setting the url; slightly differently.
42 Also note that an initial "index" is ignored.  I.e. a
43 page "A/B/index.html" is treated as "A/B".
44
45 > Actually, your patch is shorter because it's more elegant and better :)
46 > I'm withdrawing my old patch, because yours is much more in line with
47 > ikiwiki's design and architecture.
48 > I would like to make one suggestion to your patch, which is:
49
50     diff -urX ignorepats clean-ikidev/IkiWiki/Plugin/inline.pm ikidev/IkiWiki/Plugin/inline.pm
51     --- clean-ikidev/IkiWiki/Plugin/inline.pm   2007-02-25 12:26:54.099113000 -0800
52     +++ ikidev/IkiWiki/Plugin/inline.pm 2007-02-25 14:55:21.163340000 -0800
53     @@ -154,7 +154,7 @@
54                         $link=htmlpage($link) if defined $type;
55                         $link=abs2rel($link, dirname($params{destpage}));
56                         $template->param(pageurl => $link);
57     -                   $template->param(title => pagetitle(basename($page)));
58     +                   $template->param(title => titlename($page));
59                         $template->param(ctime => displaytime($pagectime{$page}));
60
61                         if ($actions) {
62     @@ -318,7 +318,7 @@
63                 my $pcontent = absolute_urls(get_inline_content($p, $page), $url);
64
65                 $itemtemplate->param(
66     -                   title => pagetitle(basename($p), 1),
67     +                   title => titlename($p, 1),
68                         url => $u,
69                         permalink => $u,
70                         date_822 => date_822($pagectime{$p}),
71     diff -urX ignorepats clean-ikidev/IkiWiki/Render.pm ikidev/IkiWiki/Render.pm
72     --- clean-ikidev/IkiWiki/Render.pm  2007-02-25 12:26:54.745833000 -0800
73     +++ ikidev/IkiWiki/Render.pm        2007-02-25 14:54:01.564715000 -0800
74     @@ -110,7 +110,7 @@
75         $template->param(
76                 title => $page eq 'index'
77                         ? $config{wikiname}
78     -                   : pagetitle(basename($page)),
79     +                   : titlename($page),
80                 wikiname => $config{wikiname},
81                 parentlinks => [parentlinks($page)],
82                 content => $content,
83     diff -urX ignorepats clean-ikidev/IkiWiki.pm ikidev/IkiWiki.pm
84     --- clean-ikidev/IkiWiki.pm 2007-02-25 12:26:58.812850000 -0800
85     +++ ikidev/IkiWiki.pm       2007-02-25 15:05:22.328852000 -0800
86     @@ -192,6 +192,12 @@
87         return $untainted;
88      } #}}}
89
90     +sub titlename($;@) { #{{{
91     +   my $page = shift;
92     +   $page =~ s!/index$!!;
93     +   return pagetitle(basename($page), @_);
94     +} #}}}
95     +
96      sub basename ($) { #{{{
97         my $file=shift;
98
99
100 > This way foo/index gets "foo" as its title, not "index". --Ethan