argh, wrong diff again. third time lucky.
[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..3132257 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,15 @@ sub match {
21         }
22      }
23      
24     +sub scan() {
25     +   my %params = @_;
26     +   my $page = $params{page};
27     +    foreach my $type (map { s/^meta_//; $_ } grep /^meta_/, keys %config) {
28     +           $pagestate{$page}{meta}{$type} = $config{"meta_$type"}
29     +                   unless defined $pagestate{$page}{meta}{$type};
30     +   }
31     +}
32     +
33      package IkiWiki::PageSpec;
34      
35      sub match_title ($$;@) {
36     diff --git a/doc/ikiwiki/directive/meta.mdwn b/doc/ikiwiki/directive/meta.mdwn
37     index 000f461..200c4b2 100644
38     --- a/doc/ikiwiki/directive/meta.mdwn
39     +++ b/doc/ikiwiki/directive/meta.mdwn
40     @@ -12,6 +12,12 @@ also specifies some additional sub-parameters.
41      The field values are treated as HTML entity-escaped text, so you can include
42      a quote in the text by writing `"` and so on.
43      
44     +You can also define site-wide defaults for meta values by including them
45     +in your setup file, e.g.
46     +
47     +   meta_copyright => "Copyright 2007 by Joey Hess",
48     +   meta_license   => "GPL v2+",
49     +
50      Supported fields:
51      
52      * title
53
54 -- [[Jon]]