1 # Bloxsom Plugin: ImageGallery
2 # Author: Fletcher T. Penney
7 # --- Configurable variables ----
9 # URL for images directory - will be added to beginning of images for the web browser to find them
10 $images_url = "/images/galleries";
12 # Filepath for images directory
13 # This gets added to the gallery to find the files
14 # NOTE: This is a change in behavior from version 0.1
15 $images_path = "$blosxom::datadir/../images/galleries";
18 # Default thumbnail sub-directory name
19 $thumbdir="thumbnails";
21 # Default image sub-directory name
24 # Default comments sub-directory name
25 $commentsdir="comments";
27 # Default number of columns
30 # HTML Code for gallery pieces
33 $galleryrowstart = "";
37 $gallerycolstart = qq!<div class="image">\n!;
39 $gallerycolend = "</div>\n";
44 # Message to display in category view
45 $gallerymessage = "<br/>You must click on the individual story to see the images. Try the \"permanent link\" button.";
47 # HTML Code for single image view
49 $imagehead = qq!<div class="single-image">\n!;
51 $imagefoot = qq!</div>\n!;
54 # Extensions for valid image types to display
55 $imagetypes = "jpg|gif|png";
57 # -------------------------------
67 $path_noflavour = $blosxom::path_info;
68 if ($path_noflavour !~ s/\.[^\.]*$//) {
69 $path_noflavour =~ s/\/$//;
70 $path_noflavour .= "\/index";
71 $path_noflavour =~ s/^([^\/])/$1/;
73 $path_noflavour =~ s/^\/*//;
81 my ($pkg, $path, $filename, $story_ref, $title_ref, $body_ref) = @_;
83 if ($$body_ref =~ /<!-- imagegallery\s*(\S*)\s*-->/i) {
84 $gallerypath= $1 . "\/" if $1 ne "";
86 $gallerypath =~ s/\/\//\//g;
91 if (($path_noflavour =~ /index$/) || ($path_noflavour =~ /\/$/)) {
92 $gallery = "<br/> You must view this story individually to <a href=\"$blosxom::url$path/$filename.$blosxom::flavour\">see the images</a>.)";
94 if ($blosxom::flavour eq "rss") {
95 $gallery = "<br> You must view this story individually to <a href="$blosxom::url$path/$filename.$blosxom::flavour" see the images</a>.)";
100 $gallery_url = "$images_url/$gallerypath";
101 $gallerypath = "$images_path/$gallerypath";
103 # If this is a request for a single photo, display it, and exit
104 if (CGI::param("image")) {
105 $imagefile = CGI::param("image");
106 $gallery = $imagehead;
107 $gallery.= "<img src=\"$gallery_url" . "$imagesdir/$imagefile\" alt=\"Imagegallery - $imagefile\" />";
108 $gallery .= $imagefoot;
110 # Try and read comments
111 $imagefile =~ s/($imagetypes)$/txt/i;
112 open (COMMENT, "<$gallerypath/$commentsdir/$imagefile");
113 $comments = join '', <COMMENT>;
118 # Now, find out how many images there are, and where
122 $File::Find::name =~ /($imagetypes)$/i
124 push (@images, $File::Find::name)
125 ;}, $gallerypath . $imagesdir);
128 @images = sort @images;
130 # Now fill out gallery
131 if (scalar(@images) > 0) {
132 $gallery = $galleryhead . $galleryrowstart;
134 foreach $image (@images) {
136 if ($count gt $columns) {
138 $gallery.= $galleryrowend . $galleryrowstart;
140 $image =~ s/$images_path/$images_url/;
142 $thumb =~ s/(.*)$imagesdir/$1$thumbdir/;
145 $imagefile =~ s/.*?([^\/]*)$/$1/;
147 $gallery.= qq!$gallerycolstart
148 <a href="$blosxom::url/$path_noflavour.$blosxom::flavour?image=$imagefile">
149 <img src="$thumb" alt="Thumbnail"/><p>$imagefile</p></a>
153 $gallery.= $galleryrowend . $galleryfoot;
156 $gallery = "No images to display... <br/>";
169 Documentation is Pending!!