]> sipb.mit.edu Git - ikiwiki.git/blob - doc/plugins/contrib/album/discussion.mdwn
Merge branch 'master' into sipb
[ikiwiki.git] / doc / plugins / contrib / album / discussion.mdwn
1 thanks for this plugin.  it might help me in my application, which is to provide album/galleries which can be edited (ie. new images added, taken away, etc.) through web interface.
2
3 > That's my goal eventually, too. Perhaps you can help to
4 > design/write this plugin? At the moment I'm mostly
5 > waiting for a design "sanity check" from [[Joey]],
6 > but any feedback you can provide on the design would
7 > also be helpful. --[[smcv]]
8
9 i have two challenges: firstly, for installation, i'm not sure what all the files are that need to be downloaded (because of my setup i can't easily pull the repo).  so far i have Ikiwiki/Plugins/album.pm; ikiwiki-album; and 4 files in templates/  any others?
10
11 > Those are all the added files; ikiwiki-album isn't strictly
12 > needed (IkiWiki itself doesn't use that code, but you can
13 > use it to turn a directory full of images into correct
14 > input for the album plugin).
15 >
16 > You probably also want the album plugin's expanded version of
17 > style.css (or put its extra rules in your local.css).
18 > Without that, your albums will be quite ugly.
19 >
20 > There aren't currently any other files modified by my branch.
21 > --[[smcv]]
22
23 secondly: barring the CGI interface for editing the album, which would be great, is there at least a way to use attachment plugin or any other to manually add images and then create viewers for them?
24
25 > Images are just attachments, and viewers are pages (any supported
26 > format, but .html will be fastest to render). Attach each image,
27 > then write a page for each image containing the
28 > \[[!albumimage]] directive (usually it will *only* contain that
29 > directive).
30 >
31 > The script ikiwiki-album can help you to do this in a git/svn/etc.
32 > tree; doing it over the web will be a lot of work (until I get
33 > the CGI interface written), but it should already be possible!
34 >
35 > The structure is something like this:
36
37 > * album.mdwn (contains the \[[!album]] directive, and perhaps also
38 >   some \[[!albumsection]] directives)
39 > * album/a.jpg
40 > * album/a.html (contains the \[[!albumimage]] directive for a.jpg)
41 > * album/b.jpg
42 > * album/b.html (contains the \[[!albumimage]] directive for b.jpg)
43 >
44 > Have a look at ikiwiki-album to see how the directives are meant to
45 > work in practice.
46 >
47 > --[[smcv]]
48
49 i'm new to ikiwiki, apologies if this is dealt with elsewhere.  -brush
50
51 > This plugin is pretty ambitious, and is unfinished, so I'd recommend
52 > playing with  a normal IkiWiki installation for a bit, then trying
53 > out this plugin when you've mastered the basics of IkiWiki. --[[smcv]]
54
55 ----
56
57 You had wanted my feedback on the design of this. I have not looked at the
58 code or tried it yet, but here goes. --[[Joey]] 
59
60 * Needing to create the albumimage "viewer" pages for each photo
61   seems like it will become a pain. Everyone will need to come up
62   with their own automation for it, and then there's the question
63   of how to automate it when uploading attachments. -J
64
65 > There's already a script (ikiwiki-album) to populate a git
66 > checkout with skeleton "viewer" pages; I was planning to make a
67 > specialized CGI interface for albums after getting feedback from
68 > you (since the requirements for that CGI interface change depending
69 > on the implementation). I agree that this is ugly, though. -s
70
71 >> Would you accept a version where the albumimage "viewer" pages
72 >> could be 0 bytes long, at least until metadata gets added?
73 >>
74 >> The more I think about the "binaries as first-class pages" approach,
75 >> the more subtle interactions I notice with other plugins. I
76 >> think I'm up to needing changes to editpage, comments, attachment
77 >> and recentchanges, plus adjustments to img and Render (to reduce
78 >> duplication when thumbnailing an image with a strange extension
79 >> while simultaneously changing the extension, and to hardlink/copy
80 >> an image with a strange extension to a differing target filename
81 >> with the normal extension, respectively). -s
82
83 * With each viewer page having next/prev links, I can see how you
84   were having the scalability issues with ikiwiki's data structures
85   earlier! -J
86
87 > Yeah, I think they're a basic requirement from a UI point of view
88 > though (although they don't necessarily have to be full wikilinks).
89 > -s
90
91 >> I think that with the new dependency types system, the dependencies for
92 >> these can be presence dependencies, which will probably help with
93 >> avoiding rebuilds of a page if the next/prev page is changed.
94 >> (Unless you use img to make the thumbnails for those links, then it
95 >> would rebuild the thumbnails anyway. Have not looked at the code.) --[[Joey]]
96
97 * And doesn't each viewer page really depend on every other page in the
98   same albumsection? If a new page is added, the next/prev links
99   may need to be updated, for example. If so, there will be much
100   unnecessary rebuilding. -J
101
102 > albumsections are just a way to insert headings into the flow of
103 > photos, so they don't actually affect dependencies.
104 >
105 > One non-obvious constraint of ikiwiki's current design is that
106 > everything "off-page" necessary to build any page has to happen
107 > at scan time, which has caused a few strange design decisions,
108 > like the fact that each viewer controls what album it's in.
109 >
110 > It's difficult for the contents of the album to just be a
111 > pagespec, like for inline, because pagespecs can depend on
112 > metadata, which is gathered in arbitrary order at scan time;
113 > so the earliest you can safely apply a pagespec to the wiki
114 > contents to get a concrete list of pages is at rebuild time.
115 >
116 > (This stalled my attempt at a trail plugin, too.) -s
117
118 >> Not sure I understand why these need to look at pagespecs at scan time?
119 >> Also, note that it is fairly doable to detect if a pagespec uses such
120 >> metadata. Er, I mean, I have a cheezy hack in `add_depends` now that does
121 >> it to deal with a similar case. --[[Joey]] 
122
123 >>> I think I was misunderstanding how early you have to call `add_depends`?
124 >>> The critical thing I missed was that if you're scanning a page, you're
125 >>> going to rebuild it in a moment anyway, so it doesn't matter if you
126 >>> have no idea what it depends on until the rebuild phase. -s
127
128 * One thing I do like about having individual pages per image is
129   that they can each have their own comments, etc. -J
130
131 > Yes; also, they can be wikilinked. I consider those to be
132 > UI requirements. -s
133
134 * Seems possibly backwards that the albumimage controls what album
135   an image appears in. Two use cases -- 1: I may want to make a locked
136   album, but then anyone who can write to any other page on the wiki can
137   add an image to it. 2: I may want an image to appear in more than one
138   album. Think tags. So it seems it would be better to have the album
139   directive control what pages it includes (a la inline). -J
140
141 > I'm inclined to fix this by constraining images to be subpages of exactly
142 > one album: if they're subpages of 2+ nested albums then they're only
143 > considered to be in the deepest-nested one (i.e. longest URL), and if
144 > they're not in any album then that's a usage error. This would
145 > also make prev/next links sane.
146 >
147 > If you want to reference images from elsewhere in the wiki and display
148 > them as if in an album, then you can use an ordinary inline with
149 > the same template that the album would use, and I'll make sure the
150 > templates are set up so this works.
151 >
152 > (Implementation detail: this means that an image X/Y/Z/W/V, where X and
153 > Y are albums, Z does not exist and W exists but is not an album,
154 > would have a content dependency on Y, a presence dependency on Z
155 > and a content dependency on W.)
156 >
157 > Perhaps I should just restrict to having the album images be direct
158 > subpages of the album, although that would mean breaking some URLs
159 > on the existing website I'm doing all this work for... -s
160
161 * Putting a few of the above thoughts together, my ideal album system
162   seems to be one where I can just drop the images into a directory and
163   have them appear in the album index, as well as each generate their own wiki
164   page. Plus some way I can, later, edit metadata for captions,
165   etc. (Real pity we can't just put arbitrary metadata into the images
166   themselves.) This is almost pointing toward making the images first-class
167   wiki page sources. Hey, it worked for po! :) But the metadata and editing
168   problems probably don't really allow that. -J
169
170 > Putting a JPEG in the web form is not an option from my point of
171 > view :-) but perhaps there could just be a "web-editable" flag supplied
172 > by plugins, and things could be changed to respect it.
173
174 >> Replying to myself: would you accept patches to support
175 >> `hook(type => 'htmlize', editable => 0, ...)` in editpage? This would
176 >> essentially mean "this is an opaque binary: you can delete it
177 >> or rename it, and it might have its own special editing UI, but you
178 >> can never get it in a web form".
179 >>
180 >> On the other hand, that essentially means we need to reimplement
181 >> editpage in order to edit the sidecar files that contain the metadata.
182 >> Having already done one partial reimplementation of editpage (for
183 >> comments) I'm in no hurry to do another.
184 >>
185 >> I suppose another possibility would be to register hook
186 >> functions to be called by editpage when it loads and saves the
187 >> file. In this case, the loading hook would be to discard
188 >> the binary and use filter() instead, and the saving conversion
189 >> would be to write the edited content into the metadata sidecar
190 >> (creating it if necessary).
191 >>
192 >> I'd also need to make editpage (and also comments!) not allow the
193 >> creation of a file of type albumjpg, albumgif etc., which is something
194 >> I previously missed; and I'd need to make attachment able to
195 >> upload-and-rename.
196 >> -s
197
198 > In a way, what you really want for metadata is to have it in the album
199 > page, so you can batch-edit the whole lot by editing one file (this
200 > does mean that editing the album necessarily causes each of its viewers
201 > to be rebuilt, but in practice that happens anyway). -s
202
203 >> Replying to myself: in practice that *doesn't* happen anyway. Having
204 >> the metadata in the album page is somewhat harmful because it means
205 >> that changing the title of one image causes every viewer in the album
206 >> to be rebuilt, whereas if you have a metadata file per image, only
207 >> the album itself, plus the next and previous viewers, need
208 >> rebuilding. So, I think a file per image is the way to go.
209 >>
210 >> Ideally we'd have some way to "batch-edit" the metadata of all
211 >> images in an album at once, except that would make conflict
212 >> resolution much more complicated to deal with; maybe just
213 >> give up and scream about mid-air collisions in that case?
214 >> (That's apparently good enough for Bugzilla, but not really
215 >> for ikiwiki). -s
216
217 >> Yes, [all metadata in one file] would make some sense.. It also allows putting one image in
218 >> two albums, with different caption etc. (Maybe for different audiences.)
219 >> --[[Joey]]
220
221 >>> Eek. No, that's not what I had in mind at all; the metadata ends up
222 >>> in the "viewer" page, so it's necessarily the same for all albums. -s
223
224 >> It would probably be possible to add a new dependency type, and thus
225 >> make ikiwiki smart about noticing whether the metadata has actually
226 >> changed, and only update those viewers where it has. But the dependency
227 >> type stuff is still very new, and not plugin friendly .. so only just
228 >> possible, --[[Joey]] 
229
230 ----
231
232 Trying to use the "special extension" design:
233
234 Suppose that each viewer is a JPEG-or-GIF-or-something, with extension
235 ".albumimage". We have a gallery "memes" with three images, badger,
236 mushroom and snake.
237
238 > An alternative might be to use ".album.jpg", and ".album.gif"
239 > etc as the htmlize extensions. May need some fixes to ikiwiki to support
240 > that. --[[Joey]] 
241
242 >> foo.albumjpg (etc.) for images, and foo._albummeta (with
243 >> `keepextension => 1`) for sidecar metadata files, seems viable. -s
244
245 Files in git repo:
246
247 * index.mdwn
248 * memes.mdwn
249 * memes/badger.albumjpg (a renamed JPEG)
250 * memes/badger/comment_1._comment
251 * memes/badger/comment_2._comment
252 * memes/mushroom.albumgif (a renamed GIF)
253 * memes/mushroom._albummeta (sidecar file with metadata)
254 * memes/snake.albummov (a renamed video)
255
256 Files in web content:
257
258 * index.html
259 * memes/index.html
260 * memes/96x96-badger.jpg (from img)
261 * memes/96x96-mushroom.gif (from img)
262 * memes/96x96-snake.jpg (from img, hacked up to use totem-video-thumbnailer :-) )
263 * memes/badger/index.html (including comments)
264 * memes/badger.jpg
265 * memes/mushroom/index.html
266 * memes/mushroom.gif
267 * memes/snake/index.html
268 * memes/snake.mov
269
270 ispage("memes/badger") (etc.) must be true, to make the above rendering
271 happen, so albumimage needs to be a "page" extension.
272
273 To not confuse other plugins, album should probably have a filter() hook
274 that turns .albumimage files into HTML? That'd probably be a reasonable
275 way to get them rendered anyway.
276
277 > I guess that is needed to avoid preprocess, scan, etc trying to process
278 > the image, as well as eg, smiley trying to munge it in sanitize.
279 > --[[Joey]] 
280
281 >> As long as nothing has a filter() hook that assumes it's already
282 >> text... filters are run in arbitrary order. We seem to be OK so far
283 >> though.
284 >>
285 >> If this is the route I take, I propose to have the result of filter()
286 >> be the contents of the sidecar metadata file (empty string if none),
287 >> with the `\[[!albumimage]]` directive (which no longer requires
288 >> arguments) prepended if not already present. This would mean that
289 >> meta directives in the metadata file would work as normal, and it
290 >> would be possible to insert text both before and after the viewer
291 >> if desired. The result of filter() would also be a sensible starting
292 >> point for editing, and the result of editing could be diverted into
293 >> the metadata file. -s
294
295 do=edit&page=memes/badger needs to not put the JPG in a text box: somehow
296 divert or override the normal edit CGI by telling it that .albumimage
297 files are not editable in the usual way?
298
299 > Something I missed here is that editpage also needs to be told that
300 > creating new files of type albumjpg, albumgif etc. is not allowed
301 > either! -s
302
303 Every image needs to depend on, and link to, the next and previous images,
304 which is a bit tricky. In previous thinking about this I'd been applying
305 the overly strict constraint that the ordered sequence of pages in each
306 album must be known at scan time. However, that's not *necessarily* needed:
307 the album and each photo could collect an unordered superset of dependencies
308 at scan time, and at rebuild time that could be refined to be the exact set,
309 in order.
310
311 > Why do you need to collect this info at scan time? You can determine it
312 > at build time via `pagespec_match_list`, surely .. maybe with some
313 > memoization to avoid each image in an album building the same list.
314 > I sense that I may be missing a subtelty though. --[[Joey]] 
315
316 >> I think I was misunderstanding how early you have to call `add_depends`
317 >> as mentioned above. -s
318
319 Perhaps restricting to "the images in an album A must match A/*"
320 would be useful; then the unordered superset could just be "A/*". Your
321 "albums via tags" idea would be nice too though, particularly for feature
322 parity with e.g. Facebook: "photos of Joey" -> "tags/joey and albumimage()"
323 maybe?
324
325 If images are allowed to be considered to be part of more than one album,
326 then a pretty and usable UI becomes harder - "next/previous" expands into
327 "next photo in holidays/2009/germany / next photo in tagged/smcv / ..."
328 and it could get quite hard to navigate. Perhaps next/previous links could
329 be displayed only for the closest ancestor (in URL space) that is an
330 album, or something?
331
332 > Ugh, yeah, that is a problem. Perhaps wanting to support that was just
333 > too ambitious. --[[Joey]] 
334
335 >> I propose to restrict to having images be subpages of albums, as
336 >> described above. -s
337
338 Requiring renaming is awkward for non-technical Windows/Mac users, with both
339 platforms' defaults being to hide extensions; however, this could be
340 circumvented by adding some sort of hook in attachment to turn things into
341 a .albumimage at upload time, and declaring that using git/svn/... without
342 extensions visible is a "don't do that then" situation :-)
343
344 > Or extend `pagetype` so it can do the necessary matching without
345 > renaming. Maybe by allowing a subdirectory to be specified along
346 > with an extension. (Or allow specifying a full pagespec,
347 > but I hesitate to seriously suggest that.) --[[Joey]] 
348
349 >> I think that might be a terrifying idea for another day. If we can
350 >> mutate the extension during the `attach` upload, that'd be enough;
351 >> I don't think people who are skilled enough to use git/svn/...,
352 >> but not skilled enough to tell Explorer to show file extensions,
353 >> represent a major use case. -s
354
355 Ideally attachment could also be configured to upload into a specified
356 underlay, so that photos don't have to be in your source-code control
357 (you might want that, but I don't!).
358
359 > Replying to myself: perhaps best done as an orthogonal extension
360 > to attach? -s
361
362 > Yet another non-obvious thing this design would need to do is to find
363 > some way to have each change to memes/badger._albummeta show up as a
364 > change to memes/badger in `recentchanges`. -s
365
366 Things that would be nice, and are probably possible:
367
368 * make the "Edit page" link on viewers divert to album-specific CGI instead
369   of just failing or not appearing (probably possible via pagetemplate)
370
371 * some way to deep-link to memes/badger.jpg with a wikilink, without knowing a
372   priori that it's secretly a JPEG (probably harder than it looks - you'd
373   have to make a directive for it and it's probably not worth it)