summaryrefslogtreecommitdiff
path: root/packages/gallery
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--packages/gallery/lektor_gallery.py21
1 files changed, 2 insertions, 19 deletions
diff --git a/packages/gallery/lektor_gallery.py b/packages/gallery/lektor_gallery.py
index b2f5e9f..779aa38 100644
--- a/packages/gallery/lektor_gallery.py
+++ b/packages/gallery/lektor_gallery.py
@@ -238,10 +238,7 @@ def select_cached_layout(
return min(
candidates,
key=lambda candidate: (
- final_score(
- candidate,
- target_ratio=target_ratio,
- ),
+ abs(log(candidate.ratio / target_ratio)) + structure_score(candidate),
candidate.signature,
),
)
@@ -398,7 +395,7 @@ def build_candidates(
all_indices,
subset_size,
):
- mask = mask_for(indices)
+ mask = sum(1 << index for index in indices)
first_bit = mask & -mask
generated: dict[float, Node] = {}
@@ -426,11 +423,6 @@ def build_candidates(
return candidates[(1 << count) - 1]
-def mask_for(indices) -> int:
- """Return the bit mask representing a sequence of image indices."""
- return sum(1 << index for index in indices)
-
-
def combine_partitions(
generated: dict[float, Node],
first_candidates: Sequence[Node],
@@ -599,15 +591,6 @@ def structure_score(node: Node) -> float:
)
-def final_score(
- node: Node,
- *,
- target_ratio: float,
-) -> float:
- """Score a complete layout against the requested gallery ratio."""
- return abs(log(node.ratio / target_ratio)) + structure_score(node)
-
-
class GalleryPlugin(Plugin):
name = "Gallery"
description = "Static aspect-ratio-aware image gallery layouts."