Merge branch 'master' of ssh://git.ikiwiki.info/srv/git/ikiwiki.info
[ikiwiki] / doc / todo / using_meta_titles_for_parentlinks.html
1 It is possible to set a Page-Title in the meta-plugin, but that one isn't
2 reused in parentlinks. This patch may fix it.
3
4 **This patch may introduce some bugs, i need to investigate**
5
6
7 <ul>
8 <li> I give pagetitle the full path to a page.
9 <li> I redefine the 'pagetitle'-sub to deal with it.
10 <li> to maintain compatibility for IkiWikis without the meta-plugin, i added a 'basename' to the Original-pagetitle.
11 </ul>
12
13 <pre>
14 diff -c /usr/share/perl5/IkiWiki/Render.pm.distrib /usr/share/perl5/IkiWiki/Render.pm
15 *** /usr/share/perl5/IkiWiki/Render.pm.distrib  Wed Aug  6 07:34:55 2008
16 --- /usr/share/perl5/IkiWiki/Render.pm  Tue Aug 26 23:29:32 2008
17 ***************
18 *** 102,108 ****
19         $template->param(
20                 title => $page eq 'index' 
21                         ? $config{wikiname} 
22 !                       : pagetitle(basename($page)),
23                 wikiname => $config{wikiname},
24                 content => $content,
25                 backlinks => $backlinks,
26 --- 102,108 ----
27         $template->param(
28                 title => $page eq 'index' 
29                         ? $config{wikiname} 
30 !                       : pagetitle($page),
31                 wikiname => $config{wikiname},
32                 content => $content,
33                 backlinks => $backlinks,
34
35 diff -c /usr/share/perl5/IkiWiki/Plugin/parentlinks.pm.distrib /usr/share/perl5/IkiWiki/Plugin/parentlinks.pm
36 *** /usr/share/perl5/IkiWiki/Plugin/parentlinks.pm.distrib      Wed Aug  6 07:34:55 2008
37 --- /usr/share/perl5/IkiWiki/Plugin/parentlinks.pm      Tue Aug 26 23:19:43 2008
38 ***************
39 *** 44,50 ****
40                         "height_$height" => 1,
41                 };
42                 $path.="/".$dir;
43 !               $title=IkiWiki::pagetitle($dir);
44                 $i++;
45         }
46         return @ret;
47 --- 44,50 ----
48                         "height_$height" => 1,
49                 };
50                 $path.="/".$dir;
51 !               $title=IkiWiki::pagetitle($path);
52                 $i++;
53         }
54         return @ret;
55
56 diff -c /usr/share/perl5/IkiWiki.pm.distrib /usr/share/perl5/IkiWiki.pm
57 *** /usr/share/perl5/IkiWiki.pm.distrib Wed Aug  6 07:48:34 2008
58 --- /usr/share/perl5/IkiWiki.pm Tue Aug 26 23:47:30 2008
59 ***************
60 *** 792,797 ****
61 --- 792,799 ----
62         my $page=shift;
63         my $unescaped=shift;
64   
65 +       $page=basename($page);
66
67         if ($unescaped) {
68                 $page=~s/(__(\d+)__|_)/$1 eq '_' ? ' ' : chr($2)/eg;
69         }
70
71 diff -c /usr/share/perl5/IkiWiki/Plugin/meta.pm.distrib /usr/share/perl5/IkiWiki/Plugin/meta.pm
72 *** /usr/share/perl5/IkiWiki/Plugin/meta.pm.distrib     Wed Aug  6 07:34:55 2008
73 --- /usr/share/perl5/IkiWiki/Plugin/meta.pm     Tue Aug 26 23:30:58 2008
74 ***************
75 *** 3,8 ****
76 --- 3,9 ----
77   package IkiWiki::Plugin::meta;
78   
79   use warnings;
80 + no warnings 'redefine';
81   use strict;
82   use IkiWiki 2.00;
83   
84 ***************
85 *** 289,294 ****
86 --- 290,319 ----
87         }
88   } #}}}
89   
90 + sub IkiWiki::pagetitle ($;$) { #{{{
91 +       my $page=shift;
92 +       my $unescaped=shift;
93
94 +       if ($page =~ m#/#) {
95 +               $page =~ s#^/##;
96 +               $page =~ s#/index$##;
97 +               if ($pagestate{"$page/index"}{meta}{title}) {
98 +                       $page = $pagestate{"$page/index"}{meta}{title};
99 +               } else {
100 +                       $page = IkiWiki::basename($page);
101 +               }
102 +       }
103
104 +       if ($unescaped) {
105 +               $page=~s/(__(\d+)__|_)/$1 eq '_' ? ' ' : chr($2)/eg;
106 +       }
107 +       else {
108 +               $page=~s/(__(\d+)__|_)/$1 eq '_' ? ' ' : "&#$2;"/eg;
109 +       }
110
111 +       return $page;
112 + } #}}}
113
114   package IkiWiki::PageSpec;
115   
116   sub match_title ($$;@) { #{{{
117
118
119 </pre>