Outdated egg!
This is an egg for CHICKEN 4, the unsupported old release. You're almost certainly looking for the CHICKEN 5 version of this egg, if it exists.
If it does not exist, there may be equivalent functionality provided by another egg; have a look at the egg index. Otherwise, please consider porting this egg to the current version of CHICKEN.
phoghorn
TOC »
Description
A thumbnail gallery library for spiffy.
Author
Requirements
Requires spiffy, sxml-transforms, uri-common, imlib2 and epeg. You will also need to install sxml-fu to make use of it.
Documentation
Phoghorn is a web-based image gallery with built-in automatic thumbnail generator for spiffy the webserver.
Its features are:
- Easy to use (just drop a bunch of files in a directory underneath the designated photos dir)
- Configurable
- Does not require a database
- Uses CSS for styling, so its look is easily changed
- Leverages imlib2 for maximum image file type support and epeg for extra-speedy JPEG handling.
- Built with SXML for clean and semantic source markup, with all benefits of a functional programming style.
Usage
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.ws or 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 sxml-transforms uri-common sxml-pagination sxml-shortcuts) (define content `((html (head (title "Showing gallery: " ,(current-gallery))) (body (phoghorn-gallery))))) (define (output-html content . rules) (SRV:send-reply (fold (lambda (ruleset content) (pre-post-order content ruleset)) content rules))) ;; We want bigger pages (parameterize ((page-size 40) (base-uri (request-uri (current-request)))) (output-html content phoghorn-rules pagination-rules shortcut-rules universal-conversion-rules))
Phoghorn generates output that must be processed by the pagination-rules and shortcut-rules from the sxml-fu egg, hence the complicated output statement.
In the zoomed-in page (save this as zoomed.ssp):
(use phoghorn sxml-transforms sxml-shortcuts) (define content `((html (head (title "Showing photo: " ,(current-entry-filename)) (body (phoghorn-zoomed-entry)))))) (define (output-html content . rules) (SRV:send-reply (fold (lambda (ruleset content) (pre-post-order content ruleset)) content rules))) ;; The shortcut-rules and the pagination-rules are mandatory, by the way (output-html content phoghorn-rules shortcut-rules universal-conversion-rules)
Configuration
Phoghorn can be customised to the max. The following SRFI-39 parameters are supported, in addition to the configuration options for sxml-fu's pagination rules (which phoghorn uses internally):
Directory and file settings
- gallery-dir #!optional directory-nameparameter
The directory under which the galleries can be found, relative to the index page. Defaults to "galleries".
- gallery-url #!optional url-stringparameter
The page that shows gallery listings with thumbnail entries. Defaults to "index.ssp"
- zoomed-url #!optional url-stringparameter
The webpage that serves the zoomed-in views on images. Defaults to "zoomed.ssp"
- thumb-dir #!optional directory-nameparameter
The name of the directory under which thumnail versions of the images in the parent directory are stored. Defaults to "thumbs".
Variable control
- gallery-var #!optional symbolparameter
The name of the GET parameter that contains the gallery the user wishes to view. Defaults to gallery.
- entry-var #!optional symbolparameter
The name of the GET parameter that contains the entry the user wishes to view (when zoomed). Defaults to entry.
Thumbnail generation
- max-thumb-dimensions #!optional numberparameter
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.
Defaults to 100.
Presentational options
- movie-image #!optional url-stringparameter
The image file to display when a movie is in the gallery. Defaults to "/pics/movie.jpg".
- root-gallery-name #!optional stringparameter
The title of the topmost gallery. All subgalleries have a title that is equal to the directory name. Defaults to "Galleries".
Procedures
You can use these procedures 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.
- gallery-contentsprocedure
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.
- thumbnail gallery entryprocedure
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 thumbs directory as determined by thumb-dir if necessary.
- thumbnail/epeg gallery entryprocedure
Epeg-specific version of thumbnail. Note: the source image must be a jpeg.
- thumbnail/imlib2 gallery entryprocedure
Imlib2-specific version of thumbnail.
Note: the source image must be of a type understood by imlib2.
- galleries-up-to galleryprocedure
Returns a list of all the galleries from the root gallery up to the specified gallery.
- prev-entry entry entriesprocedure
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.
- next-entry entry entriesprocedure
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. You can override the default phoghorn transformation rules for these tags, or generate these tags yourself and have phoghorn transform them for you.
[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.
Changelog
- 2.3 Port to Chicken 4 and Spiffy 4.
- 2.2 Update to new version of Spiffy - (current-workdir) now means something else so phoghorn >= 2.2 _does not work_ with Spiffy < 3.9
- 2.1 Update to new version of spiffy-utils.
- 2.0 Complete rewrite in SXML.
- 1.2 Update to latest versions of epeg and imlib2.
- 1.1.1 Changed .setup script to reflect new distribution of syntax-case.
- 1.1 Fix small bug (a let statement was closed a little too early.
- 1.0 initial release.
License
Copyright (c) 2005-2009, Peter Bex All rights reserved. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 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. Neither the name of the author nor the names of its 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.