chiark / gitweb /
summary |
shortlog | log |
commit |
commitdiff |
tree
first ⋅ prev ⋅ next
Mark Wooding [Tue, 24 Dec 2024 13:10:12 +0000 (13:10 +0000)]
mason/dhandler: Trap errors from module imports.
Notice errors from module imports by doing it the hard way in `eval',
and actually stop the process if there are problems.
Mark Wooding [Tue, 24 Dec 2024 13:09:16 +0000 (13:09 +0000)]
mason/.perl-libs/TrivGal.pm (clean_temp_files: Rewrite without `autodie'.
The `kill' call here would fail with `autodie', and, because the module
invokes `clean_temp_files' at load time, this causes it to be marked as
broken and all later loads will also fail.
Rewrite the function with `autodie' switched off and check for errors
by hand.
Mark Wooding [Thu, 22 Jun 2023 11:15:59 +0000 (12:15 +0100)]
static/tgal.js (keyevent): Discard key events with spurious modifiers.
Allow shift with `^', `<' and `>' because they require that on common
keyboard layouts (though not always), and because pressing shift gives a
different result if it's not needed; forbid modifiers with cursor keys,
space, and backspace.
Mark Wooding [Thu, 22 Jun 2023 11:14:19 +0000 (12:14 +0100)]
static/tgal.js (keydown): Delete redundant case.
We've done that one already.
Mark Wooding [Wed, 21 Jun 2023 10:15:12 +0000 (11:15 +0100)]
mason/.perl-lib/TrivGal.pm: Simplify the image-type machinery.
This was really only needed for the benefit of Imlib2, which needed to
be told what kind of output image file to make. GraphicsMagick doesn't
have this deficiency. The MIME type stuff was never used at all.
Mark Wooding [Wed, 21 Jun 2023 10:14:48 +0000 (11:14 +0100)]
mason/.perl-lib/TrivGal.pm: Use GraphicsMagick rather than Imlib2.
The most important difference is that GM preserves EXIF data. This
means we don't have to explicitly rotate and/or flip the image.
Mark Wooding [Wed, 21 Jun 2023 09:57:05 +0000 (10:57 +0100)]
mason/dhandler (.view), static/tgal.css: Use SVG arrows.
Rather than the single-guillemets and the rather dodgy heuristics to
centre them in their spaces.
Also add title texts, for whatever accessibility benefit they might
offer.
Mark Wooding [Wed, 21 Jun 2023 09:55:23 +0000 (10:55 +0100)]
mason/dhandler (.contact), static/tgal.css: Adaptive thumbnail sizes.
Scale the thumbnails according to the window width. I think this is the
most useful thing to do here.
Mark Wooding [Wed, 21 Jun 2023 09:51:34 +0000 (10:51 +0100)]
mason/dhandler (.contact): Determine the `count' strings in advance.
Rather than saving the raw statistics and determining the presentation
later, just work out the presentation early.
We're going to have multiple sizes of thumbnails in contact pages soon,
and determining the presentation for each thumbnail size would be
pointless.
Mark Wooding [Wed, 21 Jun 2023 09:43:07 +0000 (10:43 +0100)]
mason/dhandler (.image), static/tgal.css: Adaptive view scaling.
The view now picks an appropriately scaled image from the backend. The
selection is rather imperfect, because it's based on the window size,
with guesses at the size of the furniture, but it seems to work OK.
Mark Wooding [Wed, 21 Jun 2023 09:40:57 +0000 (10:40 +0100)]
mason/dhandler (.image): Slight reformatting.
Mark Wooding [Wed, 21 Jun 2023 09:33:42 +0000 (10:33 +0100)]
mason/.perl-lib/TrivGal.pm (%SIZE): Modify and extend the available sizes.
I want to support fetching main view images scaled adaptively for the
window size. This involves having many more image sizes. I considered
abolishing the `%SIZE' list, but realized that this wouldn't work
because `Image::scale' needs to pass back a size name in its lazy-
thumbnailing query string.
Instead, just add lots of new sizes. The scale factor is about 3/2 in
each case. Making the factor more-or-less uniform involved changing a
couple of existing sizes: `bigthumb' shrunk a little from 228 to 216;
`view' used to be 1200, but is replaced by `medium', which is
significantly smaller at 1080. I know that `small' and `embed' are
already used externally, and have preserved these names and their
values (though the values already fit well into the sequence, so this
wasn't a hardship).
I'd have preferred to have more mall words and fewer big words in the
list, but I was constrained by the existing value of `small'. It seems
that there are just more words for being very big than being very small
anyway.
Mark Wooding [Wed, 21 Jun 2023 09:24:41 +0000 (10:24 +0100)]
mason/.perl-lib/TrivGal.pm (Image): Factour out EXIF metadata processing.
Pull out the EXIF scanning into a new private method `_getexif'. This
now sets `rot' and `flip' slots so that `scale' can fix up the image
properly, but it also sets `wd' and `ht' correctly for the use of
external clients.
Mark Wooding [Wed, 21 Jun 2023 09:15:19 +0000 (10:15 +0100)]
mason/.perl-lib/TrivGal.pm (Image::scale): Sink parsing the path name.
This is more logically associated with the output stage.
Mark Wooding [Wed, 21 Jun 2023 09:09:45 +0000 (10:09 +0100)]
mason/.perl-lib/TrivGal.pm: Explicitly ignore values from `split_path'.
We frequently don't want all of the returns from `split_path'; indeed, I
think the BASE name is only used in one place. Explicitly ignore these
by assigning to `undef' to make it clear what we do care about.
Mark Wooding [Wed, 21 Jun 2023 09:05:15 +0000 (10:05 +0100)]
mason/.perl-lib/TrivGal.pm (Image::scale): Restructure the control flow.
Now every path sets `$url' and then we return it at the end. I'd hoped
to eliminate the multiple calls to `apply_escapes', but the query string
makes that rather annoying without introducing it as a concept
throughout the function, which seems even uglier.
Mark Wooding [Tue, 20 Jun 2023 22:51:10 +0000 (23:51 +0100)]
mason/.perl-lib/TrivGal.pm (Image::scale): Factor out thumbnail path tail.
Mark Wooding [Tue, 20 Jun 2023 20:19:09 +0000 (21:19 +0100)]
mason/.perl-lib/TrivGal.pm (Image::scale): Check size much earlier.
We check whether the original image is small enough to be used as-is
rather than making a scaled-down version, but currently we do that very
late, when we're actually about to try scaling it. That's obviously a
bad idea. Instead, check early now that we have a library that can find
an image's size without costly decoding. In particular, this is now
done /before/ we decide whether to hand off via the `?scale=...' lazy
thumbnailer, which is important because, in the case where the image is
small, we'll never actually make the thumbnail and we'll always pay the
redirection penalty.
This will actually slow down handling of large images; but they're kinda
inevitably a bit slow. Besides, `Image::Size' is surprisingly fast.
Mark Wooding [Tue, 20 Jun 2023 20:09:32 +0000 (21:09 +0100)]
mason/.perl-lib/TrivGal.pm (Image): Use `Image::Size' to find image size.
Using `Image::Imlib2' means that we don't learn the size without fully
decoding the image and using up lots of memory. The `Image::Size'
package will determine the image size by reading it out of the file
without decoding, so it's much faster.
Of course, that doesn't matter much yet, because we're only using it
/after/ we decode the image. Hmm...
Mark Wooding [Tue, 20 Jun 2023 20:05:19 +0000 (21:05 +0100)]
mason/.perl-lib/TrivGal.pm (Image): Stash `imgpath' in an object slot.
We'll want it in more places, so it makes sense not to write the
computation out each time.
Mark Wooding [Tue, 20 Jun 2023 20:14:53 +0000 (21:14 +0100)]
mason/.perl-lib/TrivGal.pm (Image::scale): Escape original image URL.
Somehow missed this one the first time around.
Mark Wooding [Sat, 17 Jun 2023 14:35:02 +0000 (15:35 +0100)]
mason/dhandler, static/tgal.css: Add option to download zipfiles.
This might turn out to be a terrible mistake.
Mark Wooding [Sat, 17 Jun 2023 14:33:47 +0000 (15:33 +0100)]
mason/dhandler: Make `.breadcrumbs' be a filter.
Then we can put options near the end.
Mark Wooding [Sat, 17 Jun 2023 14:30:48 +0000 (15:30 +0100)]
mason/dhandler: Use the correct attribute to encourage lazy loading.
I don't know how I got this one wrong. It doesn't work properly even
so. More to come on this.
Mark Wooding [Sat, 17 Jun 2023 14:30:02 +0000 (15:30 +0100)]
mason/dhandler: Apply both URL and HTML escaping to links.
Mark Wooding [Thu, 15 Jun 2023 16:29:58 +0000 (17:29 +0100)]
mason/dhandler (.contact): Report the number of subfolders and images.
Mark Wooding [Thu, 15 Jun 2023 16:28:05 +0000 (17:28 +0100)]
mason/dhandler (.contact): Nudge index-scanning loop to focus on top level.
If, say, we want to do something else with the direct contents of the
directory, then it would be nice if this were easy. Pull the variable
declarations out, pull an initial priming call to `listdir' out, and
move the inner `listdir' to the end of the loop.
Mark Wooding [Tue, 13 Jun 2023 00:02:03 +0000 (01:02 +0100)]
mason/.perl-lib/TrivGal.pm: Make cache directories world-unreadable.
Otherwise you can use the automatically generated indices in the cache
tree to deduce the names of the hidden folders in the main image tree.
Mark Wooding [Mon, 12 Jun 2023 10:47:20 +0000 (11:47 +0100)]
mason/.perl-lib/TrivGal.pm: Add a couple more size options.
These are useful when images are embedded into documents such as blog
articles.
Mark Wooding [Mon, 12 Jun 2023 10:46:07 +0000 (11:46 +0100)]
mason/.perl-lib/TrivGal.pm: Introduce a `-' flag to hide an entry.
This is only useful if the entry is /also/ an index: it allows an index
page to designate an image that's in a different folder.
Mark Wooding [Mon, 12 Jun 2023 10:44:41 +0000 (11:44 +0100)]
mason/.perl-lib/TrivGal.pm (listdir): Refactor how the index flag is set.
Match a collection of flag characters, though only `!' is currently
recognized, and then set the flags based on what we see.
Mark Wooding [Mon, 12 Jun 2023 10:38:51 +0000 (11:38 +0100)]
mason/.perl-lib/TrivGal.pm, mason/dhandler: Rescale images lazily.
If `TrivGal::Image::scale' can't find an existing scaled image, then by
default it just returns immediately with a `?scale=...' link. The code
acting on this parameter now passes an additional FORCEP argument to
`TrivGal::Image::scale' to get it to actually generate the scaled
version. Once the scaled version exists, `TrivGal::Image::scale'
returns a direct link to it rather than the `?scale=...' link, which
saves a redirect round trip.
This has two main effects.
* Firstly, and most importantly, it allows the main HTML to be served
up immediately, without waiting for the (rather time-consuming)
image scaling to happen; and it also allows the scaling to happen
with a certain amount of parallelism.
* Secondly, it also isolates failures (e.g., due to exceeding memory
limits) to individual images.
Mark Wooding [Mon, 12 Jun 2023 10:37:17 +0000 (11:37 +0100)]
mason/dhandler (.image): Generate thumbnails more memory-efficiently.
As threatened in the previous commit, we now load each image once,
generate all of the necessary rescaled versions, and move on. This
includes the main view image.
Mark Wooding [Mon, 12 Jun 2023 10:33:57 +0000 (11:33 +0100)]
mason/dhandler (.thumbnail + callers): Pass in pre-scaled thumbnail.
The objective here is to give the caller control over the order in which
image scaling occurs. In particular, by loading an image once and
generating the required scaled versions, we can potentially save a lot
of memory, which is a significant factor when dealing with full-size
DSLR images.
Mark Wooding [Mon, 12 Jun 2023 10:30:35 +0000 (11:30 +0100)]
mason/dhandler (.contact): Recurse into first folder to find index image.
This isn't always the best choice, but it's better than the plain folder
icon.
Mark Wooding [Mon, 12 Jun 2023 10:25:28 +0000 (11:25 +0100)]
mason/.perl-lib/TrivGal.pm (listdir): Delete redundant package qualifier.
Mark Wooding [Sun, 11 Jun 2023 17:47:45 +0000 (18:47 +0100)]
mason/dhandler (.image): Compare references rather than filenames.
... for determining whether this is the focus image.
Mark Wooding [Sun, 11 Jun 2023 17:42:02 +0000 (18:42 +0100)]
mason/.perl-lib/TrivGal.pm (Image::scale): Return encoded URL.
Also, apply HTML-encoding as necessary, because I'd failed to do that.
Mark Wooding [Sun, 11 Jun 2023 17:07:08 +0000 (18:07 +0100)]
mason/dhandler (.contact): Strip out the multiple-size machinery.
Also, use the same size consistently throughout.
Mark Wooding [Sun, 11 Jun 2023 16:58:27 +0000 (17:58 +0100)]
mason/dhandler (.contact): Reformat a overly-long line.
Mark Wooding [Sun, 11 Jun 2023 16:55:33 +0000 (17:55 +0100)]
mason/dhandler (.contact): Slightly reformat trailing-`/' redirect code.
Mark Wooding [Sun, 11 Jun 2023 16:51:46 +0000 (17:51 +0100)]
mason/.perl-lib/TrivGal.pm: Append `/' to folder names.
Probably pedantically technical. I was considering doing this anyway,
and then noticed that folders listed in an index file (a) must have a
trailing `/' to be recognized as a folder, and (b) this doesn't get
removed in the generated contact page.
Mark Wooding [Sun, 11 Jun 2023 16:48:42 +0000 (17:48 +0100)]
mason/.perl-lib/TrivGal.pm (Image::scale): Put `-' in temporary file name.
After all, this what `clean_temp_files' is looking for.
Mark Wooding [Sun, 11 Jun 2023 16:45:31 +0000 (17:45 +0100)]
mason/.perl-lib/TrivGal.pm (listdir): Set item before setting index.
Otherwise we set the index to the /previous/ item, which doesn't go so
well. I don't know why I never noticed this before.
Mark Wooding [Sun, 11 Jun 2023 15:35:10 +0000 (16:35 +0100)]
mason/.perl-lib/TrivGal.pm: Expand a couple of compicated regices.
Yes, that is the correct plural. Fight me.
Mark Wooding [Sun, 11 Jun 2023 15:29:37 +0000 (16:29 +0100)]
mason/.perl-lib/TrivGal.pm (listdir): Anchor regex to line start.
I don't think this is actually a problem, because the pattern
irrefutably matches at the start of the line anyway. But for form's
sake, it should be properly anchored.
Mark Wooding [Sun, 11 Jun 2023 15:26:49 +0000 (16:26 +0100)]
mason/.perl-lib/TrivGal.pm: Settle on `#' as the emergency regex delimiter.
Mark Wooding [Sun, 11 Jun 2023 10:06:47 +0000 (11:06 +0100)]
mason/.perl-lib/TrivGal.pm: Remove spurious `$e'.
Must have been a copy-and-paste from below.
Mark Wooding [Sun, 11 Jun 2023 10:05:33 +0000 (11:05 +0100)]
mason/.perl-lib/TrivGal.pm: Fix image flipping again, but properly.
Brown paper bag time.
Mark Wooding [Fri, 9 Jun 2023 21:12:00 +0000 (22:12 +0100)]
mason/dhandler: Add a `scale' parameter to images.
Just ensures that a cached thumbnail of the requested size exists and
redirects to it. Useful for references from other pages.
Mark Wooding [Fri, 9 Jun 2023 21:10:55 +0000 (22:10 +0100)]
mason/dhandler: Build the image a little earlier.
Just in case we have another use for it in mind. Maybe.
Mark Wooding [Fri, 9 Jun 2023 21:11:46 +0000 (22:11 +0100)]
mason/dhandler: Pass arguments to the subcomponent.
Mark Wooding [Fri, 9 Jun 2023 21:11:28 +0000 (22:11 +0100)]
mason/dhandler: Delete stray debugging code.
Mark Wooding [Fri, 9 Jun 2023 21:09:39 +0000 (22:09 +0100)]
mason/.perl-lib/TrivGal.pm: Flip the image correctly when asked.
Mark Wooding [Thu, 12 May 2022 10:52:07 +0000 (11:52 +0100)]
mason/dhandler: Announce source code through `X-AGPL-Source' HTTP header.
Mark Wooding [Thu, 12 May 2022 10:51:42 +0000 (11:51 +0100)]
mason/dhandler, mason/.perl-lib/TrivGal: Publish and use `$SRCURL'.
Mark Wooding [Thu, 12 May 2022 10:44:26 +0000 (11:44 +0100)]
mason/dhandler: Add a `license' relationship to the AGPL link.
There's also a `license' relation on the Creative Commons link in my
custom footer. Let's hope this isn't too confusing.
Mark Wooding [Fri, 29 Apr 2022 16:50:33 +0000 (17:50 +0100)]
mason/.perl-lib/TrivGal.pm: Handle EXIF `Orientation'.
Apparently Imlib2 doesn't do this for me. :-( OpenCamera hard-rotates
its images rather than using EXIF metadata, so I didn't notice before,
but my Nikon cameras don't do this.
Mark Wooding [Fri, 29 Apr 2022 16:49:44 +0000 (17:49 +0100)]
mason/.perl-lib/TrivGal.pm: Fix behaviour for `unreadable' directories.
They can be listed in the parent, but their contents is secret.
Mark Wooding [Fri, 24 Dec 2021 17:50:56 +0000 (17:50 +0000)]
Introduce multiple thumbnail strips, and select one in a sensible way.
Significantly, there are now multiple thumbnail strips and `focus'
thumbnails, so we need to be more intelligent about scrolling them.
Mark Wooding [Fri, 24 Dec 2021 17:32:57 +0000 (17:32 +0000)]
mason/dhandler, static/tgal.css: Embrace idea of multiple thumbnail sets.
Rather than a single row of thumbnails, the code is now structured so
that it might have several at the same time, with different sizes. CSS
media queries can control which one actually gets displayed.
Internally, we make two passes over a directory, fetching the images the
first time through, and making scaled thumbnails afterwards, and
introduce loops over the available sizes (though currently there's only
the one).
We're actually just making the same display as before, so there's still
no functional change.
Mark Wooding [Fri, 24 Dec 2021 17:28:03 +0000 (17:28 +0000)]
mason/{.perl-lib/TrivGal,dhandler}: Make an image object.
The objective here is to separate image loading from scaling, so that we
can make several scaled output images without having to load and decode
the original image each time.
The `.thumbnail' module now takes an image object rather than a
pathname. There's no functional change.
Mark Wooding [Thu, 23 Dec 2021 19:53:43 +0000 (19:53 +0000)]
Embrace the idea of multiple thumbnail sizes.
This is all prep work for a forthcoming change.
* Rename the `thumb' sized to be `bigthumb', contemplating other
thumbnail sizes.
* Pass a `$size' argument to the `.thumbnail' module.
* Attach the thumbnail size name as an additional class to the
`figure' and `figcaption' classes. (We'll add it to `thumbstrip'
and `gallery' too, later.)
Mark Wooding [Wed, 22 Dec 2021 18:25:06 +0000 (18:25 +0000)]
mason/dhandler: Remove pointless `/' concatenation from `join_paths' call.
Mark Wooding [Wed, 22 Dec 2021 18:19:06 +0000 (18:19 +0000)]
mason/.perl-lib/TrivGal.pm: Remove final `;' after `package' blocks.
Mark Wooding [Sat, 18 Dec 2021 12:59:09 +0000 (12:59 +0000)]
mason/dhandler: Mark thumbnail images as loading lazily.
Mark Wooding [Thu, 23 Dec 2021 21:59:36 +0000 (21:59 +0000)]
static/tgal.css: Use flex layout for folder galleries.
Space the elements evenly in each row. Alas, it's hard to arrange for
lines to be broken so that each row has about the same number of items,
so that's a project for later.
Mark Wooding [Thu, 23 Dec 2021 21:51:56 +0000 (21:51 +0000)]
static/tgal.css: Explicitly centre text in `figcaption'.
Don't rely on this being set up in some parent element -- 'cos it won't
be.
Mark Wooding [Sat, 18 Dec 2021 14:00:51 +0000 (14:00 +0000)]
mason/dhandler, static/tgal.css: Use `figure' and `figcaption' elements.
Mark Wooding [Sat, 18 Dec 2021 13:59:34 +0000 (13:59 +0000)]
mason/dhandler, static/tgal.css: Use `thumb' class, not `pic'.
I don't know what I was thinking.
Mark Wooding [Sat, 25 Dec 2021 16:07:01 +0000 (16:07 +0000)]
static/tgal.css: Adjust the height of the arrows again.
*sigh*. I really want a better approach for this.
Mark Wooding [Thu, 23 Dec 2021 21:57:16 +0000 (21:57 +0000)]
static/tgal.css: Centre the thumbstrip horizontally if it's short.
Using `justify-content' clips thumbnails on the left, if there are too
many to fit. Instead, (a) set `max-width' rather than `width', and use
`align-self' to centre in the outer flex box.
Mark Wooding [Thu, 23 Dec 2021 20:44:24 +0000 (20:44 +0000)]
static/tgal.css: Remove pointless `white-space: normal'.
No longer neended now that `thumbstrip' uses flex layout.
Mark Wooding [Thu, 16 Dec 2021 02:32:33 +0000 (02:32 +0000)]
static/tgal.css: Use flex layout for the thumbnail strip.
Using flow layout respects the whitespace between the thumbnails, which
leaves me with an annoying choice between strictly-correct rendering and
moderately well-formatted source text.
Mark Wooding [Thu, 16 Dec 2021 01:11:09 +0000 (01:11 +0000)]
static/tgal.css: Enlarge the left/right arrow boxes.
I wish I could arrange to have them centred automatically, but I don't
know how to do that. I've tried the obvious things, and they cause the
buttons to come out near the centre, but slightly offset -- by an amount
dependent on the font. Making the arrows be images won't work properly
with Dark Reader or similar extensions.
Mark Wooding [Wed, 15 Dec 2021 12:35:30 +0000 (12:35 +0000)]
Initial commit.