Support analog photo dates and correct gallery years
This commit is contained in:
@@ -25,7 +25,7 @@ romania = [
|
||||
(OLD[4], 2), (OLD[4], 3), (OLD[4], 4), (OLD[0], 0), (OLD[3], 0),
|
||||
]
|
||||
ungrouped = [(OLD[2], 2), (OLD[2], 3)]
|
||||
ordered = armenia + romania + ungrouped
|
||||
ordered = romania + armenia + ungrouped
|
||||
assert len(ordered) == len(set(ordered)) == 18
|
||||
|
||||
collection_groups = [
|
||||
@@ -112,13 +112,31 @@ collection_groups = [
|
||||
|
||||
paris = "85a558a3fcf582e6f0637d6927bb5a074de422f30a389ab9589630b9c163fc0e"
|
||||
paris_lille = "e013523e4dda324d603c89f93ef3e83abbcd82cb11a16f85e53b670e8613d34f"
|
||||
geneva = "18a628ae4ea72d0f9a68de6acfbc698449fe10e49ecf990a8ddced0b2e32949d"
|
||||
iranian_memorial = "bf23ab31ef7b33150e9e99cb31f14b1bc27bc8143293a32bb1d4ac2193a493c6"
|
||||
foto_64 = "1bb19ce5b6a5570ddda1754bb77583dbfb2b4c534ee88e85a69f511ab47b1a14"
|
||||
uploaded_highlight_groups = [
|
||||
(
|
||||
"Iranian Martyrs’ Memorial Cemetery",
|
||||
datetime(2025, 9, 19, 21, 43, 42, tzinfo=timezone.utc),
|
||||
[(iranian_memorial, index) for index in range(2)],
|
||||
),
|
||||
(
|
||||
"Geneva",
|
||||
datetime(2025, 9, 19, 21, 42, 30, tzinfo=timezone.utc),
|
||||
[(geneva, index) for index in range(3)],
|
||||
),
|
||||
(
|
||||
"Paris & Lille",
|
||||
datetime(2026, 9, 19, 21, 41, 30, tzinfo=timezone.utc),
|
||||
datetime(2025, 9, 19, 21, 41, 30, tzinfo=timezone.utc),
|
||||
[(paris_lille, index) for index in range(13)] +
|
||||
[(paris, index) for index in range(10)],
|
||||
),
|
||||
(
|
||||
"Foto 64",
|
||||
datetime(2026, 9, 19, 12, 20, 30, tzinfo=timezone.utc),
|
||||
[(foto_64, index) for index in range(4)],
|
||||
),
|
||||
]
|
||||
|
||||
anchors = {armenia[0]: "Armenia", romania[0]: "Romania"}
|
||||
@@ -132,7 +150,7 @@ for job in OLD:
|
||||
if batch:
|
||||
batch.unlink()
|
||||
|
||||
start = datetime(2026, 9, 19, 12, 29, 33, tzinfo=timezone.utc)
|
||||
start = datetime(2026, 9, 19, 12, 40, 33, tzinfo=timezone.utc)
|
||||
for position, (job, index) in enumerate(ordered):
|
||||
title = f"photo-{job}-{index:02}"
|
||||
if (job, index) == first_for_job[job]:
|
||||
@@ -167,7 +185,7 @@ for folder, group_start, anchor, filenames in collection_groups:
|
||||
content = re.sub(r"^anchor:.*\n", "", content, flags=re.MULTILINE)
|
||||
if position == 0:
|
||||
content = content.replace("categories: art\n", "categories: art\nanchor: " +
|
||||
json.dumps(anchor) + "\n", 1)
|
||||
json.dumps(anchor, ensure_ascii=False) + "\n", 1)
|
||||
path.write_text(content)
|
||||
|
||||
for anchor, group_start, photos in uploaded_highlight_groups:
|
||||
@@ -180,8 +198,8 @@ for anchor, group_start, photos in uploaded_highlight_groups:
|
||||
content = re.sub(r"^anchor:.*\n", "", content, flags=re.MULTILINE)
|
||||
if position == 0:
|
||||
content = content.replace("categories: art\n", "categories: art\nanchor: " +
|
||||
json.dumps(anchor) + "\n", 1)
|
||||
elif index == 0:
|
||||
json.dumps(anchor, ensure_ascii=False) + "\n", 1)
|
||||
elif index == 0 and f'id="photo-{job}"' not in content:
|
||||
# Removing this batch's old highlight must not remove its published
|
||||
# receipt target from the rendered gallery.
|
||||
content = content.replace("---\n\n", f'---\n\n<div id="photo-{job}"></div>\n\n', 1)
|
||||
|
||||
@@ -82,10 +82,22 @@ class PhotoHighlightTests(unittest.TestCase):
|
||||
anchor.group(1) if anchor else None, content))
|
||||
records.sort(reverse=True)
|
||||
grouped = [record for record in records if record[1] in ARMENIA + ROMANIA]
|
||||
self.assertEqual([record[1] for record in grouped], ARMENIA + ROMANIA)
|
||||
self.assertEqual(grouped[0][2], "Armenia")
|
||||
self.assertEqual(grouped[7][2], "Romania")
|
||||
self.assertIn("Transmission of Flesh by Erfan Ashourioun", grouped[2][3])
|
||||
self.assertEqual([record[1] for record in grouped], ROMANIA + ARMENIA)
|
||||
self.assertEqual(grouped[0][2], "Romania")
|
||||
self.assertEqual(grouped[9][2], "Armenia")
|
||||
self.assertIn("Transmission of Flesh by Erfan Ashourioun", grouped[11][3])
|
||||
|
||||
def test_2026_highlights_follow_supplied_chronology(self):
|
||||
anchors = {}
|
||||
for path in ART.glob("*photo-*.md"):
|
||||
content = path.read_text()
|
||||
anchor = re.search(r'^anchor: "([^"]+)"', content, re.MULTILINE)
|
||||
if anchor and anchor.group(1) in {"Foto 64", "Armenia", "Romania"}:
|
||||
date = datetime.fromisoformat(re.search(
|
||||
r'^date: "([^"]+)"', content, re.MULTILINE).group(1))
|
||||
anchors[anchor.group(1)] = date
|
||||
self.assertLess(anchors["Foto 64"], anchors["Armenia"])
|
||||
self.assertLess(anchors["Armenia"], anchors["Romania"])
|
||||
|
||||
def test_existing_collection_highlight_starts(self):
|
||||
for anchor, filenames in COLLECTIONS:
|
||||
@@ -123,8 +135,36 @@ class PhotoHighlightTests(unittest.TestCase):
|
||||
[(PARIS_LILLE, index) for index in range(13)] +
|
||||
[(PARIS, index) for index in range(10)])
|
||||
self.assertEqual(anchors, ["Paris & Lille"])
|
||||
self.assertTrue(all(date.year == 2025 for date, _, _ in records))
|
||||
former_paris = (ART / f"2026-09-19-photo-{PARIS}-00.md").read_text()
|
||||
self.assertIn(f'<div id="photo-{PARIS}"></div>', former_paris)
|
||||
self.assertEqual(former_paris.count(f'<div id="photo-{PARIS}"></div>'), 1)
|
||||
|
||||
def test_recent_analog_highlights_use_2025_in_supplied_order(self):
|
||||
groups = (
|
||||
("bf23ab31ef7b33150e9e99cb31f14b1bc27bc8143293a32bb1d4ac2193a493c6",
|
||||
2, "Iranian Martyrs’ Memorial Cemetery"),
|
||||
("18a628ae4ea72d0f9a68de6acfbc698449fe10e49ecf990a8ddced0b2e32949d",
|
||||
3, "Geneva"),
|
||||
)
|
||||
newest = []
|
||||
for job, count, anchor in groups:
|
||||
records = []
|
||||
anchors = []
|
||||
for index in range(count):
|
||||
content = (ART / f"2026-09-19-photo-{job}-{index:02}.md").read_text()
|
||||
date = datetime.fromisoformat(re.search(
|
||||
r'^date: "([^"]+)"', content, re.MULTILINE).group(1))
|
||||
records.append(date)
|
||||
anchors.extend(re.findall(r'^anchor: "([^"]+)"', content, re.MULTILINE))
|
||||
self.assertTrue(all(date.year == 2025 for date in records))
|
||||
self.assertEqual(anchors, [anchor])
|
||||
newest.append(max(records))
|
||||
paris_date = datetime.fromisoformat(re.search(
|
||||
r'^date: "([^"]+)"',
|
||||
(ART / f"2026-09-19-photo-{PARIS_LILLE}-00.md").read_text(),
|
||||
re.MULTILINE).group(1))
|
||||
self.assertGreater(newest[0], newest[1])
|
||||
self.assertGreater(newest[1], paris_date)
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user