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