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