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