aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--IkiWiki/Plugin/edittemplate.pm19
-rw-r--r--doc/ikiwiki/directive/edittemplate.mdwn18
2 files changed, 34 insertions, 3 deletions
diff --git a/IkiWiki/Plugin/edittemplate.pm b/IkiWiki/Plugin/edittemplate.pm
index e3ce5e3d9..c2a8da29f 100644
--- a/IkiWiki/Plugin/edittemplate.pm
+++ b/IkiWiki/Plugin/edittemplate.pm
@@ -139,6 +139,25 @@ sub filltemplate ($$) {
$template->param(name => $page);
+ if ($template->query(name => 'uuid')) {
+ my $uuid;
+ if (open(my $fh, "<", "/proc/sys/kernel/random/uuid")) {
+ $uuid = <$fh>;
+ chomp $uuid;
+ close $fh;
+ }
+ else {
+ eval {
+ require UUID::Tiny;
+ $uuid = UUID::Tiny::create_uuid_as_string(UUID::Tiny::UUID_V4());
+ };
+ }
+ $template->param(uuid => $uuid);
+ }
+
+ my $time = time();
+ $template->param(time => IkiWiki::date_3339($time));
+
return $template->output;
}
diff --git a/doc/ikiwiki/directive/edittemplate.mdwn b/doc/ikiwiki/directive/edittemplate.mdwn
index a6f301dd3..6269f5dd8 100644
--- a/doc/ikiwiki/directive/edittemplate.mdwn
+++ b/doc/ikiwiki/directive/edittemplate.mdwn
@@ -27,8 +27,20 @@ something like:
Details:
The template page can also contain [[!cpan HTML::Template]] directives,
-like other ikiwiki [[templates]]. Currently only one variable is
-set: `<TMPL_VAR name>` is replaced with the name of the page being
-created.
+like other ikiwiki [[templates]].
+
+These variables might be set:
+
+* `<TMPL_VAR name>` is replaced with the name of the page being
+ created.
+
+* `<TMPL_VAR uuid>` is replaced with a version 4 (random) UUID
+ suitable for use in `\[[!meta guid="urn:uuid:<TMPL_VAR uuid>"]]`.
+ (Requires the `UUID::Tiny` Perl module if not running on Linux.)
+
+* `<TMPL_VAR time>` is replaced with the current (template generation)
+ time using a fixed format (RFC 3339, `%Y-%m-%dT%H:%M:%SZ`),
+ suitable for use in `\[[!meta date="<TMPL_VAR time>"]]`
+ (see [[meta]]) or `\[[!date "<TMPL_VAR time>"]]` (see [[date]]).
[[!meta robots="noindex, follow"]]