aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukas Lipavsky <llipavsky@suse.com>2013-06-27 12:59:05 +0100
committerSimon McVittie <smcv@debian.org>2014-07-11 22:09:48 +0100
commit7589c4553414ed8b8567761ab82742691a59acd4 (patch)
tree5e409710a7c27d0b65cb44c85a5ec420d9d43244
parent7cc54e7f347c95733452ebfc22f33031f96854ca (diff)
downloadikiwiki-7589c4553414ed8b8567761ab82742691a59acd4.tar
ikiwiki-7589c4553414ed8b8567761ab82742691a59acd4.tar.gz
add tag support to viewers
-rw-r--r--IkiWiki/Plugin/album.pm14
1 files changed, 14 insertions, 0 deletions
diff --git a/IkiWiki/Plugin/album.pm b/IkiWiki/Plugin/album.pm
index 16de8eb97..13c4b4eaf 100644
--- a/IkiWiki/Plugin/album.pm
+++ b/IkiWiki/Plugin/album.pm
@@ -1,7 +1,10 @@
#!/usr/bin/perl
# Copyright © 2009-2011 Simon McVittie <http://smcv.pseudorandom.co.uk/>
+# Copyright © 2013 Lukas Lipavsky <lukas@lipavsky.cz>
+#
# Licensed under the GNU GPL, version 2, or any later version published by the
# Free Software Foundation
+
package IkiWiki::Plugin::album;
use warnings;
@@ -25,6 +28,7 @@ sub import {
IkiWiki::loadplugin("inline");
IkiWiki::loadplugin("trail");
IkiWiki::loadplugin("transient");
+ IkiWiki::loadplugin("tag");
}
sub getsetup () {
@@ -61,6 +65,7 @@ sub getsetup () {
# sort - as for inline
# sections - ref to array of pagespecs representing sections
# viewers - list of viewers' names
+# tags - list of tags that should be added to viewers
#
# Page state for image viewers:
#
@@ -288,6 +293,7 @@ sub preprocess_album {
my $album = $params{page};
my @viewers = scan_images($album);
+ my $tags = defined($params{tag}) ? $params{tag} : "";
# placeholder for the "remaining images" section
push @{$pagestate{$album}{album}{sections}}, ""
@@ -302,6 +308,7 @@ sub preprocess_album {
nexttemplate => $params{nexttemplate},
prevtemplate => $params{prevtemplate},
viewers => [@viewers],
+ tags => [split(' ', $tags)],
# in the render phase, we want to keep the sections that we
# accumulated during the scan phase, if any
sections => $pagestate{$album}{album}{sections},
@@ -456,6 +463,13 @@ sub preprocess_albumimage {
$img = htmllink($viewer, $params{destpage}, "/$image");
}
+ # Tags (always return "")
+ IkiWiki::Plugin::tag::preprocess_tag(
+ page => $viewer,
+ destpage => $params{destpage},
+ map { ($_ => 1) } @{$pagestate{$album}{album}{tags}},
+ );
+
my $viewertemplate = template(
$pagestate{$album}{album}{viewertemplate} or
'albumviewer.tmpl');