summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--IkiWiki/Plugin/meta.pm11
-rw-r--r--debian/changelog7
-rw-r--r--doc/ikiwiki/directive/meta.mdwn11
3 files changed, 29 insertions, 0 deletions
diff --git a/IkiWiki/Plugin/meta.pm b/IkiWiki/Plugin/meta.pm
index 1a9f94a12..eebe3460f 100644
--- a/IkiWiki/Plugin/meta.pm
+++ b/IkiWiki/Plugin/meta.pm
@@ -179,6 +179,17 @@ sub preprocess (@) {
'" title="'.encode_entities($title).
"\" type=\"text/css\" />", $page, $destpage);
}
+ elsif ($key eq 'script') {
+ my $defer=exists $params{defer} ? ' defer="defer"' : '';
+ my $async=exists $params{async} ? ' async="async"' : '';
+ my $js=bestlink($page, $value.".js");
+ if (! length $js) {
+ error gettext("script not found");
+ }
+ push @{$metaheaders{$page}}, scrub('<script src="'.urlto($js, $page).
+ '"' . $defer . $async . ' type="text/javascript" />',
+ $page, $destpage);
+ }
elsif ($key eq 'openid') {
my $delegate=0; # both by default
if (exists $params{delegate}) {
diff --git a/debian/changelog b/debian/changelog
index 0eaff10fc..1f73523a4 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -1,3 +1,10 @@
+ikiwiki (3.20110329) UNRELEASED; urgency=low
+
+ * meta: Allow adding javascript to pages. Only when htmlscrubber is
+ disabled, naturally. (Thanks, Giuseppe Bilotta)
+
+ -- Joey Hess <joeyh@debian.org> Mon, 28 Mar 2011 13:08:23 -0400
+
ikiwiki (3.20110328) unstable; urgency=low
* Yaml formatted setup files are now produced by default.
diff --git a/doc/ikiwiki/directive/meta.mdwn b/doc/ikiwiki/directive/meta.mdwn
index 50aaf66be..9c2147264 100644
--- a/doc/ikiwiki/directive/meta.mdwn
+++ b/doc/ikiwiki/directive/meta.mdwn
@@ -82,6 +82,17 @@ Supported fields:
[[!iki plugins/htmlscrubber desc=htmlscrubber]] plugin is enabled,
since it can be used to insert unsafe content.
+* script
+
+ Adds a script to a page. The script is treated as a wiki link to
+ a `.js` file in the wiki, so it cannot be used to add links to external
+ scripts. The optional `defer` and `async` keywords can be used to set
+ the corresponding HTML4 and HTML5 script options. Example:
+
+ \[[!meta script=somescript defer async]]
+
+ The tag is subject to scrubbing as with the stylesheet and link fields.
+
* openid
Adds html &lt;link&gt; tags to perform OpenID delegation to an external