]> sipb.mit.edu Git - ikiwiki.git/blob - doc/todo/allow_site-wide_meta_definitions/current-patch.mdwn
c5e37e76e13ddb38a25e5aa1a04a83f43a5238ca
[ikiwiki.git] / doc / todo / allow_site-wide_meta_definitions / current-patch.mdwn
1 diff --git a/IkiWiki/Plugin/meta.pm b/IkiWiki/Plugin/meta.pm
2 index 6fe9cda..c4079fd 100644
3 --- a/IkiWiki/Plugin/meta.pm
4 +++ b/IkiWiki/Plugin/meta.pm
5 @@ -13,6 +13,7 @@ sub import {
6         hook(type => "needsbuild", id => "meta", call => \&needsbuild);
7         hook(type => "preprocess", id => "meta", call => \&preprocess, scan => 1);
8         hook(type => "pagetemplate", id => "meta", call => \&pagetemplate);
9 +       hook(type => "scan", id => "meta", call => \&scan);
10  }
11  
12  sub getsetup () {
13 @@ -305,6 +306,17 @@ sub match {
14         }
15  }
16  
17 +sub scan() {
18 +       my %params = @_;
19 +       my $page = $params{page};
20 +       if($config{"meta_defaults"}) {
21 +               foreach my $default (@{$config{"meta_defaults"}}) {
22 +                       preprocess(%$default, page => $page,
23 +                               destpage => $page, preview => 0);
24 +               }
25 +       }
26 +}
27 +
28  package IkiWiki::PageSpec;
29  
30  sub match_title ($$;@) {
31 diff --git a/IkiWiki/Setup.pm b/IkiWiki/Setup.pm
32 index 8a25ecc..e4d50c9 100644
33 --- a/IkiWiki/Setup.pm
34 +++ b/IkiWiki/Setup.pm
35 @@ -51,7 +51,13 @@ sub merge ($) {
36                                         $config{$c}=$setup{$c};
37                                 }
38                                 else {
39 -                                       $config{$c}=[map { IkiWiki::possibly_foolish_untaint($_) } @{$setup{$c}}]
40 +                                       $config{$c}=[map {
41 +                                               if(ref $_ eq 'HASH') {
42 +                                                       $_
43 +                                               } else {
44 +                                                       IkiWiki::possibly_foolish_untaint($_)
45 +                                               }
46 +                                       } @{$setup{$c}}];
47                                 }
48                         }
49                         elsif (ref $setup{$c} eq 'HASH') {
50 diff --git a/doc/ikiwiki/directive/meta.mdwn b/doc/ikiwiki/directive/meta.mdwn
51 index 000f461..8d34ee4 100644
52 --- a/doc/ikiwiki/directive/meta.mdwn
53 +++ b/doc/ikiwiki/directive/meta.mdwn
54 @@ -12,6 +12,16 @@ also specifies some additional sub-parameters.
55  The field values are treated as HTML entity-escaped text, so you can include
56  a quote in the text by writing `"` and so on.
57  
58 +You can also define site-wide defaults for meta values by including them
59 +in your setup file. The key used is `meta_defaults` and the value is a list
60 +of hashes, one per meta directive. e.g.:
61 +
62 +       meta_defaults = [
63 +               { copyright => "Copyright 2007 by Joey Hess" },
64 +               { license   => "GPL v2+" },
65 +               { link => "somepage", rel => "site entrypoint", },
66 +       ],
67 +
68  Supported fields:
69  
70  * title