From 7589c4553414ed8b8567761ab82742691a59acd4 Mon Sep 17 00:00:00 2001 From: Lukas Lipavsky Date: Thu, 27 Jun 2013 12:59:05 +0100 Subject: add tag support to viewers --- IkiWiki/Plugin/album.pm | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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 +# Copyright © 2013 Lukas Lipavsky +# # 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'); -- cgit v1.2.3