PlaidWeb / Publ

Flexible publishing system for the web
http://publ.beesbuzz.biz/
MIT License
40 stars 4 forks source link

Provide mechanism for a unique per-imageset gallery ID #530

Open fluffy-critter opened 1 year ago

fluffy-critter commented 1 year ago

Expected Behavior

Provide some mechanism for allowing each image set to have its own unique gallery ID. For example, if you have an entry like:

Entry-ID: 12345

![{256,256}](foo.jpg | bar.jpg | baz.jpg)

![{256,256}](qwer.jpg | poiu.jpg | asdf.jpg)

the resulting HTML would be something like:

<p><a href="foo.jpg" data-lightbox="12345.1"><img src="foo-256x256.jpg"></a>
<a href="bar.jpg" data-lightbox="12345.1"><img src="bar-256x256.jpg"></a>
<a href="baz.jpg" data-lightbox="12345.1"><img src="baz-256x256.jpg"></a></p>

<p><a href="qwer.jpg" data-lightbox="12345.2"><img src="qwer-256x256.jpg"></a>
<a href="poiu.jpg" data-lightbox="12345.2"><img src="poiu-256x256.jpg"></a>
<a href="asdf.jpg" data-lightbox="12345.2"><img src="asdf-256x256.jpg"></a></p>

Current Behavior

Having separate image sets requires hand-authoring the gallery ID.

Possible Solution

In the most general sense, allow the gallery option to take a Union[Callable,str] and if it's a Callable, call the function (but only at the start of the element render). Then provide a usable function like autoincrement that just provides an auto-incrementing gallery ID (as this doesn't have to be stable across pageviews, it just needs to be unique per lightbox on any given page).

Steps to Reproduce (for bugs)

1. 2. 3. 4.

Context