85 lines
1.7 KiB
Python
85 lines
1.7 KiB
Python
"""generator data model.
|
|
|
|
Per functional-design entities (unit: generator): MastheadConfig, Issue,
|
|
Article, Page, Column, ColumnItem, Photo. The filesystem is the content store;
|
|
the generator resolves and flows them into a classic multi-page broadsheet.
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from dataclasses import dataclass, field
|
|
from typing import Literal
|
|
|
|
SectionKind = Literal[
|
|
"article", "photo", "pullquote", "factbox", "funnies", "schedule", "wellwish"
|
|
]
|
|
|
|
|
|
@dataclass
|
|
class MastheadConfig:
|
|
"""Dynamic masthead/metadata read from config.json (US7, BR1.2)."""
|
|
|
|
title: str
|
|
couple_names: str
|
|
date_line: str
|
|
issue_number: str
|
|
volume: str
|
|
|
|
|
|
@dataclass
|
|
class Article:
|
|
"""A parsed content article (US5, NFR7). The filesystem content dir is the store."""
|
|
|
|
article_id: str
|
|
type: str
|
|
headline: str
|
|
body: str
|
|
byline: str = ""
|
|
section: str = ""
|
|
|
|
|
|
@dataclass
|
|
class Photo:
|
|
"""An auto-balanced embedded photo (US4, BR3.1)."""
|
|
|
|
photo_id: str
|
|
src: str # local embedded asset
|
|
caption: str = ""
|
|
credit: str = ""
|
|
|
|
|
|
@dataclass
|
|
class ColumnItem:
|
|
"""A placed item in a column (article, photo, pull quote, funnies, ...)."""
|
|
|
|
item_id: str
|
|
kind: SectionKind
|
|
source_ref: str
|
|
|
|
|
|
@dataclass
|
|
class Column:
|
|
"""A filled column box within a page (BR2.1)."""
|
|
|
|
column_index: int
|
|
items: list[ColumnItem] = field(default_factory=list)
|
|
|
|
|
|
@dataclass
|
|
class Page:
|
|
"""One flowed A4 page with page number + running header (US1, BR2.1)."""
|
|
|
|
page_number: int
|
|
columns: list[Column]
|
|
running_header: str = ""
|
|
|
|
|
|
@dataclass
|
|
class Issue:
|
|
"""The resolved newspaper issue (US1/US2/US7)."""
|
|
|
|
issue_id: str
|
|
masthead: MastheadConfig
|
|
articles: list[Article]
|
|
pages: list[Page]
|