8dfbbf71692d44de30327ffff37dc9f2ba37e5e1
[ikiwiki.git] / doc / plugins / contrib / album.mdwn
1 [[!template id=plugin name=album author="[[Simon_McVittie|smcv]]"]]
2 [[!template id=gitbranch branch=smcv/album2 author="[[Simon_McVittie|smcv]]"]]
3 [[!tag type/chrome]]
4
5 Available from [[smcv]]'s git repository, in the `album2` branch.
6 Older (pre-rebase) versions in `album`, `album-live` (the latter
7 was used on an actual website and didn't explode too much).
8
9 This plugin formats a collection of images into a photo album,
10 in the same way as many websites: good examples include the
11 PHP application [Gallery](http://gallery.menalto.com/), Flickr,
12 and Facebook's Photos "application".
13
14 I've called it `album` to distinguish it from
15 [[contrib/gallery|plugins/contrib/gallery]], although `gallery` might well be
16 a better name for this functionality.
17
18 The web UI I'm trying to achieve consists of one
19 [HTML page of thumbnails](http://ikialbum.hosted.pseudorandom.co.uk/album/)
20 as an entry point to the album, where each thumbnail links to
21 [a "viewer" HTML page](http://ikialbum.hosted.pseudorandom.co.uk/album/img_0120/)
22 with a full size image, next/previous thumbnail links, and
23 [[plugins/comments]].
24
25 (The Summer of Code [[plugins/contrib/gallery]] plugin does the
26 next/previous UI in Javascript using Lightbox, which means that
27 individual photos can't be bookmarked in a meaningful way, and
28 the best it can do as a fallback for non-Javascript browsers
29 is to provide a direct link to the image.)
30
31 <h2 id="album"><code>album</code> directive</h2>
32
33 Each page containing an `album` directive is treated as a photo album.
34
35 Every image attached to an album or its subpages is considered to be part of
36 the album. A "viewer" page, with the wiki's default page extension, will be
37 generated in the [[transient underlay|todo/transient_pages]] to display the
38 image, if there isn't already a page of the same name as the image: for
39 instance, if `debconf` is an album and `debconf/tuesday/p100.jpg` exists,
40 then `debconf/tuesday/p100.mdwn` might be created.
41
42 There's currently a hard-coded list of extensions that are treated as images:
43 `png`, `gif`, `jpg`, `jpeg` or `mov` files. More image and video types could
44 be added in future. Videos aren't currently handled very well;
45 ideally, something like totem-video-thumbnailer would be used.
46
47 The `album` directive also produces an [[ikiwiki/directive/inline]] which
48 automatically includes all the viewers for this album, except those that
49 will appear in an <a href="#albumsection">albumsection</a> (if every image
50 is in a section, then the `album` directive won't have any visible effect).
51
52 The `inline` is in `archive` and `quick` mode, but can include some
53 extra information about the images, including file size and a thumbnail made
54 using [[ikiwiki/directive/img]]). The default template is `albumitem.tmpl`,
55 which takes advantage of these things.
56
57 <h2 id="albumsection"><code>albumsection</code> directive</h2>
58
59 The `albumsection` directive is used to split an album into sections. It can
60 only appear on a page that also has the <a href="#album">album</a> directive.
61
62 The `filter` parameter is a [[ikiwiki/PageSpec]] against which viewer pages
63 are matched. The `albumsection` directive displays all the images that match
64 the filter, and the `album` directive displays any leftover images, like
65 this:
66
67     # Holiday photos
68
69     \[[!album]]
70     <!-- replaced with a list of any uncategorized photos, which might be
71          empty -->
72
73     ## People
74
75     \[[!albumsection filter="tagged(people)"]]
76     <!-- replaced with a list of photos tagged 'people', including
77          any that are also tagged 'landscapes' -->
78
79     ## Landscapes
80
81     \[[!albumsection filter="tagged(landscapes)"]]
82     <!-- replaced with a list of photos tagged 'landscapes', including
83          any that are also tagged 'people' -->
84
85 <h2 id="albumimage"><code>albumimage</code> directive</h2>
86
87 Each viewer page produced by the <a href="#album">album</a> directive
88 contains an `albumimage` directive, which is replaced by an
89 [[ikiwiki/directive/img]], wrapped in some formatting using a
90 template (by default it's `albumviewer.tmpl`). That template can also include
91 links to the next photo, the previous photo and the album it's in; the default
92 template has all of these.
93
94 The next/previous links are themselves implemented by evaluating a template,
95 either `albumnext.tmpl` or `albumprev.tmpl` by default.
96
97 The directive can also have parameters:
98
99 * `title`, `copyright` and `date` are short-cuts for the corresponding
100   [[ikiwiki/directive/meta]] directives
101
102 * `caption` sets a caption which is displayed in the album and viewer
103   pages
104
105 The viewer page can also have other contents before or after the actual
106 image viewer.
107
108 ## Bugs
109
110 * The plugin doesn't do anything special to handle albums that are subpages
111   of each other. If, say, `debconf` and `debconf/monday` are both albums,
112   then `debconf/monday/p100.jpg` will currently be assigned to one or the
113   other, arbitrarily. It should probably pick the closest (longest) album name.
114
115 * The plugin doesn't do anything special to handle photos with similar names.
116   If you have `p100.jpg` and `p100.png`, one will get a viewer page called
117   `p100` and the other will be ignored.
118
119 * If there's no `albumimage` in a viewer page, one should probably be appended
120   automatically.
121
122 * When editing a viewer page, rebuilding it seems to fail at the moment.
123   Probably related to:
124
125 * Integration with [[plugins/contrib/trail]] is new, untested and not
126   very well implemented. In particular, the prev/up/next links are
127   redundant with the ones from `trail`.
128
129 ## TODO
130
131 * The documentation should mention how to replicate the appearance of
132   `album` and `albumsection` using an `inline` of viewer pages,
133   elsewhere on the site.
134
135 * The documentation should mention all the template variables and
136   all the parameters.
137
138 * The generated viewer page should include most or all of the possible
139   parameters to the `albumimage` directive, with empty values, as a
140   template for editing.
141
142 * The generated viewer page should extract as much metadata as possible from
143   the photo's EXIF tags (creation/modification dates, author, title, caption,
144   copyright). [[smcv]] has a half-written implementation which runs
145   `scanimage` hooks, and has an `exiftool` plugin using [[!cpan Image::ExifTool]]
146   as a reference implementation of that hook.
147
148 * There should be an option to reduce the size of photos and write them into
149   an underlay (perhaps just the transient underlay), for this workflow:
150
151   * your laptop's local ikiwiki has two underlays, `photos` and `webphotos`
152   * `photos` contains full resolution photos with EXIF tags
153   * for each photo that exists in `photos` but not in `webphotos`, the album
154     plugin automatically resamples it down to a web-compatible resolution
155     ([[smcv]] uses up to 640x640), optimizes it with `jpegoptim`, strips out
156     all EXIF tags, and and writes it into the corresponding location
157     in `webphotos`
158   * `webphotos` is what you rsync to the web server
159   * the web server's ikiwiki only has `webphotos` as an underlay
160
161 * Eventually, there could be a specialized CGI user interface to batch-edit
162   all the photos of an album (so for each photo, you get an edit box each for
163   title, author, copyright etc.) - this would work by making programmatic
164   edits to all the `albumimage` directives.