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.
5 Here's a patch[[!tag patch]] to achieve this (also in the "defaultmeta" branch of
6 my github ikiwiki fork):
8 diff --git a/IkiWiki/Plugin/meta.pm b/IkiWiki/Plugin/meta.pm
9 index b229592..a307db4 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);
20 @@ -302,6 +303,15 @@ sub match {
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};
33 package IkiWiki::PageSpec;
35 sub match_title ($$;@) {
36 @@ -324,4 +334,5 @@ sub match_copyright ($$;@) {
37 IkiWiki::Plugin::meta::match("copyright", @_);
42 diff --git a/doc/ikiwiki/directive/meta.mdwn b/doc/ikiwiki/directive/meta.mdwn
43 index 000f461..200c4b2 100644
44 --- a/doc/ikiwiki/directive/meta.mdwn
45 +++ b/doc/ikiwiki/directive/meta.mdwn
46 @@ -12,6 +12,12 @@ also specifies some additional sub-parameters.
47 The field values are treated as HTML entity-escaped text, so you can include
48 a quote in the text by writing `"` and so on.
50 +You can also define site-wide defaults for meta values by including them
51 +in your setup file, e.g.
53 + meta_copyright => "Copyright 2007 by Joey Hess",
54 + meta_license => "GPL v2+",