]> sipb.mit.edu Git - ikiwiki.git/blob - doc/todo/allow_site-wide_meta_definitions.mdwn
Advertise my 'among' branch for review
[ikiwiki.git] / doc / todo / allow_site-wide_meta_definitions.mdwn
1 [[!tag plugins/meta patch]]
2
3 I'd like to define [[plugins/meta]] values to apply across all pages
4 site-wide unless the pages define their own: default values for meta
5 definitions essentially.
6
7 Here's a patch to achieve this (also in the "defaultmeta" branch of
8 my github ikiwiki fork):
9
10     diff --git a/IkiWiki/Plugin/meta.pm b/IkiWiki/Plugin/meta.pm
11     index b229592..3132257 100644
12     --- a/IkiWiki/Plugin/meta.pm
13     +++ b/IkiWiki/Plugin/meta.pm
14     @@ -13,6 +13,7 @@ sub import {
15         hook(type => "needsbuild", id => "meta", call => \&needsbuild);
16         hook(type => "preprocess", id => "meta", call => \&preprocess, scan => 1);
17         hook(type => "pagetemplate", id => "meta", call => \&pagetemplate);
18     +   hook(type => "scan", id => "meta", call => \&scan);
19      }
20      
21      sub getsetup () {
22     @@ -302,6 +303,15 @@ sub match {
23         }
24      }
25      
26     +sub scan() {
27     +   my %params = @_;
28     +   my $page = $params{page};
29     +    foreach my $type (map { s/^meta_//; $_ } grep /^meta_/, keys %config) {
30     +           $pagestate{$page}{meta}{$type} = $config{"meta_$type"}
31     +                   unless defined $pagestate{$page}{meta}{$type};
32     +   }
33     +}
34     +
35      package IkiWiki::PageSpec;
36      
37      sub match_title ($$;@) {
38     diff --git a/doc/ikiwiki/directive/meta.mdwn b/doc/ikiwiki/directive/meta.mdwn
39     index 000f461..200c4b2 100644
40     --- a/doc/ikiwiki/directive/meta.mdwn
41     +++ b/doc/ikiwiki/directive/meta.mdwn
42     @@ -12,6 +12,12 @@ also specifies some additional sub-parameters.
43      The field values are treated as HTML entity-escaped text, so you can include
44      a quote in the text by writing `"` and so on.
45      
46     +You can also define site-wide defaults for meta values by including them
47     +in your setup file, e.g.
48     +
49     +   meta_copyright => "Copyright 2007 by Joey Hess",
50     +   meta_license   => "GPL v2+",
51     +
52      Supported fields:
53      
54      * title
55
56 -- [[Jon]]
57
58 > This doesn't support multiple-argument meta directives like
59 > `link=x rel=y`, or meta directives with special side-effects like
60 > `updated`.
61 >
62 > The first could be solved (if you care) by a syntax like this:
63 >
64 >     meta_defaults => [
65 >         { copyright => "© me" },
66 >         { link => "about:blank", rel => "silly", },
67 >     ]
68 >
69 > The second could perhaps be solved by invoking `meta::preprocess` from within
70 > `scan` (which might be a simplification anyway), although this is complicated
71 > by the fact that some (but not all!) meta headers are idempotent.
72
73 > --[[smcv]]