Skip to content

Refactor gallery generator with class-based architecture#50

Merged
jordanplanders merged 1 commit into
mainfrom
claude/tender-jones-88997b
May 7, 2026
Merged

Refactor gallery generator with class-based architecture#50
jordanplanders merged 1 commit into
mainfrom
claude/tender-jones-88997b

Conversation

@jordanplanders

Copy link
Copy Markdown
Contributor

Introduces gallery_generator_v2.py alongside the original (kept for reference).

New classes:

  • BookRepo: owns all remote fetching for one CSV row — normalizes fields, fetches _config.yml / chapter_meta.yml / TOC / thumbnail, runs chapter normalization, and accumulates master tags
  • GalleryCard (ABC): shared truncation helper and abstract render()
  • RepoCard(GalleryCard): built from BookRepo via from_book_repo(); handles published badge from the CSV boolean (not from aggregated tags)
  • ChapterCard(GalleryCard): built from BookRepo + normalized chapter dict; per-language badge colors; computes tag_class_str before removing 'notebook'

Key behavioral contracts preserved:

  • published stays a separate bool; BookRepo.tags never contains it
  • standalone detection uses substring check ('standalone' in content_type)
  • empty-title repos are skipped before card creation
  • modal HTML is still discarded; only the static backdrop is written

Also fixes a silent mutation bug where the original panel functions popped keys from the live tags dict reference.

Introduces gallery_generator_v2.py alongside the original (kept for reference).

New classes:
- BookRepo: owns all remote fetching for one CSV row — normalizes fields,
  fetches _config.yml / chapter_meta.yml / TOC / thumbnail, runs chapter
  normalization, and accumulates master tags
- GalleryCard (ABC): shared truncation helper and abstract render()
- RepoCard(GalleryCard): built from BookRepo via from_book_repo(); handles
  published badge from the CSV boolean (not from aggregated tags)
- ChapterCard(GalleryCard): built from BookRepo + normalized chapter dict;
  per-language badge colors; computes tag_class_str before removing 'notebook'

Key behavioral contracts preserved:
- published stays a separate bool; BookRepo.tags never contains it
- standalone detection uses substring check ('standalone' in content_type)
- empty-title repos are skipped before card creation
- modal HTML is still discarded; only the static backdrop is written

Also fixes a silent mutation bug where the original panel functions popped
keys from the live tags dict reference.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@jordanplanders jordanplanders merged commit 292d17a into main May 7, 2026
2 checks passed
@jordanplanders jordanplanders deleted the claude/tender-jones-88997b branch May 7, 2026 21:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant