Description

A thumbnail gallery library for spiffy

Author

Peter Bex

Version

Requires

Download

phoghorn.egg

Documentation

Phoghorn is a web-based image gallery with built-in automatic thumbnail generator for spiffy the webserver.

Its features are:

Use

By default, phoghorn assumes there is a directory called galleries in the directory from which you call its functions (ie, the same directory in which you placed index.ssp). It will create thumbnails on-the-fly when there aren't any yet, and only for those pictures on the page that is currently being viewed. By default, these will be placed in the thumbs directory under the gallery's directory.

In the main page (save this as index.ssp):

(use phoghorn spiffy-utils)

(define content
  `((html
     (head (title "Showing gallery: " ,(get-var (gallery-var))))
     (body
      (phoghorn-gallery)))))

;; We want bigger pages
(parameterize ((page-size 40))
  (output-html content phoghorn-rules pagination-rules shortcut-rules universal-conversion-rules))

In the zoomed-in page (save this as zoomed.ssp):

(use phoghorn spiffy-utils)

(define content
  `((html
     (head (title "Showing photo: " , (get-var (entry-var)))
     (body
       (phoghorn-zoomed-entry))))))

;; The shortcut-rules and the pagination-rules are mandatory, by the way
(output-html content phoghorn-rules pagination-rules shortcut-rules universal-conversion-rules)

Configuration

Phoghorn can be customised to the max. The following SRFI parameters are supported, in addition to the configuration options for spiffy-utils pagination (which phoghorn uses internally):

Directory and file settings
parameter: (gallery-dir) [default: "galleries"]
The directory under which the galleries can be found, relative to the index page.
parameter: (gallery-url) [default: "index.ssp"]
The page that shows gallery listings with thumbnail entries.
parameter: (zoomed-url) [default: "zoomed.ssp"]
The webpage that serves the zoomed-in views on images.
parameter: (thumb-dir) [default: "thumbs"]
The name of the directory under which thumnail versions of the images in the parent directory are stored.

Variable control

parameter: (gallery-var) [default: "gallery"]
The name of the GET parameter that contains the gallery the user wishes to view.
parameter: (entry-var) [default: "entry"]
The name of the GET parameter that contains the entry the user wishes to view (when zoomed).
Thumbnail generation
parameter: (max-thumb-dimensions) [default: 100]
Maximum width or height of a thumbnail.The smaller of the two will get scaled by the same factor as the larger, which will be shrunk into this size. In other words, it maintains the aspect ratio of the original picture in the thumb.
Presentational options
parameter: (movie-image) [default: "/pics/movie.jpg"]
The image file to display when a movie is in the gallery.
parameter: (root-gallery-name) [default: "Galleries"]
The title of the topmost gallery. All subgalleries have a title that is equal to the directory name.

Functions

You can use these functions if you want more control over the way your gallery is output, ie using it more as a library than as a complete thumbnail gallery package.

procedure: (gallery-contents)
Get the contents of the currently selected gallery (as determined by gallery-var).Returns two values: The first value is a list of subgalleries in that gallery, the second value is a list of entries (ie, pictures) in that gallery.
procedure: (thumbnail gallery entry)
Returns a link to the thumbnail picture of the selected entry under the selected gallery. Chooses thumbnail/epeg or thumbnail/imlib2 based on the entry file. Side-effects: creates the thumbnail if it does not exist and creates the thumb-dirif necessary.
procedure: (thumbnail/epeg gallery entry)
Epeg-specific version of thumbnail. Note: the source image must be a jpeg.
procedure: (thumbnail/imlib2 gallery entry)
Imlib2-specific version of thumbnail. Note: the source image must be of a type understood by imlib2.
procedure: (galleries-up-to gallery)
Returns a list of all the galleries from the root gallery up to the specified gallery.
procedure: (prev-entry entry entries)
Return the filename of the previous entry in the entries list, as seen from the selected entry. Returns #f if this is the first entry in the list.
procedure: (next-entry entry entries)
Return the filename of the next entry in the entries list, as seen from the selected entry. Returns #f if this is the last entry in the list.

tags

This section describes the SXML tags that are available when you use phoghorn-rules.

tag: (phoghorn-gallery)
Output the current gallery, including links to its subgalleries (if any) and entry thumbnails (if any). Also shows breadcrumb links.
tag: (gallery-entries entries)
Shows an unordered list of the paginated entries, headed by a pagination list.
tag: (gallery-list galleries)
Shows an unordered list of (sub)galleries.
tag: (gallery-link gallery)
Generates a link to the given gallery. If gallery is #f, a link to the root gallery with (root-gallery-name) as the link title is generated.
tag: (gallery-entry gallery entry)
Generates a link to the zoomed version of entry with the (generated if necessary) thumbnail.
tag: (zoomed-url gallery entry)
Generates a link to zoomed-url with the gallery and entry as parameters. (using link-to).
tag: (phoghorn-breadcrumbs gallery)
Generate breadcrumb links from the root gallery up to the selected gallery.
tag: (phoghorn-zoomed-entry)
Show the currently zoomed entry picture full-size. Includes navigation to the next and previous entry and breadcrumbs.
tag: (entry-navigation)
Generate navigation to the next and previous entry link in the current gallery, relative to the currently selected entry as determined from gallery-var and entry-var.
tag: (zoomed-picture gallery entry)
The zoomed entry picture in the selected gallery.

License

Copyright (c) 2005 - 2008, Peter Bex (peter.bex@xs4all.nl)
All rights reserved.

Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
   notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
   notice, this list of conditions and the following disclaimer in the
   documentation and/or other materials provided with the distribution.
3. Neither the name of author nor the names of any contributors may
   be used to endorse or promote products derived from this software
   without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.