update diff (one redundant hunk removed)
[ikiwiki] / doc / todo / allow_site-wide_meta_definitions.mdwn
1 I'd like to define [[plugins/meta]] values to apply across all pages
2 site-wide unless the pages define their own: default values for meta
3 definitions essentially.
4
5 Here's a patch[[!tag patch]] to achieve this (also in the "defaultmeta" branch of
6 my github ikiwiki fork):
7
8     diff --git a/IkiWiki/Plugin/meta.pm b/IkiWiki/Plugin/meta.pm
9     index b229592..2894e08 100644
10     --- a/IkiWiki/Plugin/meta.pm
11     +++ b/IkiWiki/Plugin/meta.pm
12     @@ -13,6 +13,7 @@ sub import {
13         hook(type => "needsbuild", id => "meta", call => \&needsbuild);
14         hook(type => "preprocess", id => "meta", call => \&preprocess, scan => 1);
15         hook(type => "pagetemplate", id => "meta", call => \&pagetemplate);
16     +   hook(type => "scan", id => "meta", call => \&scan);
17      }
18      
19      sub getsetup () {
20     @@ -302,6 +303,20 @@ sub match {
21         }
22      }
23      
24     +my @metatypes = qw/title description license copyright link
25     +                              author authorurl date permalink stylesheet
26     +                              openid redir robots guid updated/;
27     +
28     +sub scan() {
29     +   my %params = @_;
30     +   my $page = $params{page};
31     +
32     +   foreach my $type (grep { exists $config{"meta_$_"} } @metatypes) {
33     +           $pagestate{$page}{meta}{$type} = $config{"meta_$type"}
34     +                   unless defined $pagestate{$page}{meta}{$type};
35     +   }
36     +}
37     +
38      package IkiWiki::PageSpec;
39      
40      sub match_title ($$;@) {
41     diff --git a/doc/ikiwiki/directive/meta.mdwn b/doc/ikiwiki/directive/meta.mdwn
42     index 000f461..200c4b2 100644
43     --- a/doc/ikiwiki/directive/meta.mdwn
44     +++ b/doc/ikiwiki/directive/meta.mdwn
45     @@ -12,6 +12,12 @@ also specifies some additional sub-parameters.
46      The field values are treated as HTML entity-escaped text, so you can include
47      a quote in the text by writing `"` and so on.
48      
49     +You can also define site-wide defaults for meta values by including them
50     +in your setup file, e.g.
51     +
52     +   meta_copyright => "Copyright 2007 by Joey Hess",
53     +   meta_license   => "GPL v2+",
54     +
55      Supported fields:
56      
57      * title
58
59 -- [[Jon]]