]> sipb.mit.edu Git - ikiwiki.git/blob - doc/plugins/contrib/album.mdwn
Assume that every page has been scanned by the time the scan phase ends
[ikiwiki.git] / doc / plugins / contrib / album.mdwn
1 [[!template id=plugin name=album author="[[Simon_McVittie|smcv]]"]]
2 [[!tag type/chrome]]
3
4 This plugin provides the [[ikiwiki/directive/album]] [[ikiwiki/directive]],
5 which turns a page into a photo album or image gallery, containing all
6 images attached to the album or its subpages. It also provides the
7 [[ikiwiki/directive/albumsection]] and [[ikiwiki/directive/albumimage]]
8 directives.
9
10 This plugin automatically enables the [[filecheck]], [[img]], [[inline]],
11 [[trail]] and [[transient]] plugins. The [[meta]] plugin is also
12 recommended.
13
14 ## Changing the templates
15
16 When a viewer page is generated or inlined into an album, the template can
17 contain these extra variables:
18
19 * `<TMPL_VAR ALBUM>` - page name of the album
20 * `<TMPL_VAR ALBUMURL>` - relative URL to the album
21 * `<TMPL_VAR ALBUMTITLE>` - title of the album, usually taken from
22   a [[ikiwiki/directive/meta]] directive
23 * `<TMPL_VAR CAPTION>` - caption for the image
24 * `<TMPL_VAR THUMBNAIL>` - a small [[ikiwiki/directive/img]] for the image
25 * `<TMPL_VAR IMAGEWIDTH>` - width of the full-size image in pixels
26 * `<TMPL_VAR IMAGEHEIGHT>` - height of the full-size image in pixels
27 * `<TMPL_VAR IMAGEFILESIZE>` - size of the image, e.g. `1.2 MiB`
28 * `<TMPL_VAR IMAGEFORMAT>` - format of the image, typically `JPEG`
29
30 The template for the viewer page can also contain:
31
32 * `<TMPL_VAR IMG>` - a large [[ikiwiki/directive/img]] to display the image
33 * `<TMPL_VAR PREV>` - a link to the previous viewer, typically with a
34   thumbnail
35 * `<TMPL_VAR NEXT>` - a link to the next viewer, typically with a
36   thumbnail
37
38 ## Including album entries elsewhere
39
40 To display images from elsewhere in the wiki with the same appearance as
41 an [[ikiwiki/directive/album]] or [[ikiwiki/directive/albumsection]],
42 you can use an [[ikiwiki/directive/inline]] with the `albumitem`
43 template:
44
45         \[[!inline pages="..." sort="-age" template="albumitem"]]
46
47 ----
48
49 [[!template id=gitbranch branch=smcv/album4 author="[[Simon_McVittie|smcv]]"]]
50
51 Available from [[smcv]]'s git repository, in the `album4` branch.
52 I've called it `album` to distinguish it from
53 [[contrib/gallery|plugins/contrib/gallery]], although `gallery` might well be
54 a better name for this functionality.
55
56 (The Summer of Code [[plugins/contrib/gallery]] plugin does the
57 next/previous UI in Javascript using Lightbox, which means that
58 individual photos can't be bookmarked in a meaningful way, and
59 the best it can do as a fallback for non-Javascript browsers
60 is to provide a direct link to the image.)
61
62 Updated, April 2012: rebased onto the version of [[trail]] that got merged
63
64 ## Manual installation
65
66 First, you need a version of ikiwiki with the [[trail]] plugin merged in
67 (version 3.20120203 or later).
68
69 Manual installation requires these files (use the "raw" link in gitweb
70 to download):
71
72 * [album.pm](http://git.pseudorandom.co.uk/smcv/ikiwiki.git/blob/album4:/IkiWiki/Plugin/album.pm)
73   in an `IkiWiki/Plugin` subdirectory of your configured `plugindir`
74 * [albumviewer.tmpl](http://git.pseudorandom.co.uk/smcv/ikiwiki.git/blob/album4:/templates/albumviewer.tmpl),
75   [albumitem.tmpl](http://git.pseudorandom.co.uk/smcv/ikiwiki.git/blob/album4:/templates/albumitem.tmpl),
76   [albumnext.tmpl](http://git.pseudorandom.co.uk/smcv/ikiwiki.git/blob/album4:/templates/albumnext.tmpl) and
77   [albumprev.tmpl](http://git.pseudorandom.co.uk/smcv/ikiwiki.git/blob/album4:/templates/albumprev.tmpl),
78    in your configured `templatedir`, or a `templates` subdirectory of your wiki repository
79 * the album-related bits from the end of the
80   [stylesheet](http://git.pseudorandom.co.uk/smcv/ikiwiki.git/blob/album4:/doc/style.css)
81   (put them in your local.css)
82
83 ## Demo
84
85 * [HTML page of thumbnails](http://ikialbum.hosted.pseudorandom.co.uk/album/)
86   as an entry point to the album
87 * Each thumbnail links to
88   [a "viewer" HTML page](http://ikialbum.hosted.pseudorandom.co.uk/album/img_0120/)
89   with a full size image, optional next/previous thumbnail links, and
90   optional [[plugins/comments]]
91
92 ## Bugs
93
94 * There's currently a hard-coded list of extensions that are treated as
95   images: `png`, `gif`, `jpg`, `jpeg` or `mov` files. More image and video
96   types could be added in future.
97
98 * Videos aren't currently handled very well; ideally, something like
99   totem-video-thumbnailer would be used.
100
101 * The plugin doesn't do anything special to handle albums that are subpages
102   of each other. If, say, `debconf` and `debconf/monday` are both albums,
103   then `debconf/monday/p100.jpg` will currently be assigned to one or the
104   other, arbitrarily. It should probably pick the closest (longest) album name.
105   (I'm not sure that it can do this reliably, though, since the scan stage
106   runs in an undefined order.)
107
108 * The plugin doesn't do anything special to handle photos with similar names.
109   If you have `p100.jpg` and `p100.png`, one will get a viewer page called
110   `p100` and the other will be ignored. (I'm not sure what we could do better,
111   though.)
112
113 * If there's no `albumimage` in a viewer page, one should probably be appended
114   automatically.
115
116 ## TODO
117
118 * The generated viewer page should extract as much metadata as possible from
119   the photo's EXIF tags (creation/modification dates, author, title, caption,
120   copyright). [[smcv]] has a half-written implementation which runs
121   `scanimage` hooks, and has an `exiftool` plugin using [[!cpan Image::ExifTool]]
122   as a reference implementation of that hook.
123
124 * There should be an option to reduce the size of photos and write them into
125   an underlay (perhaps just the transient underlay), for this workflow:
126
127   * your laptop's local ikiwiki has two underlays, `photos` and `webphotos`
128   * `photos` contains full resolution photos with EXIF tags
129   * for each photo that exists in `photos` but not in `webphotos`, the album
130     plugin automatically resamples it down to a web-compatible resolution
131     ([[smcv]] uses up to 640x640), optimizes it with `jpegoptim`, strips out
132     all EXIF tags, and and writes it into the corresponding location
133     in `webphotos`
134   * `webphotos` is what you rsync to the web server
135   * the web server's ikiwiki only has `webphotos` as an underlay
136
137 * Eventually, there could be a specialized CGI user interface to batch-edit
138   all the photos of an album (so for each photo, you get an edit box each for
139   title, author, copyright etc.) - this would work by making programmatic
140   edits to all the `albumimage` directives.