Some checks failed
Build & Push Docker / build (push) Has been cancelled
- Block model: nové volitelné pole 'url' (Optional[str]) - Frontend: URL input v modálu pro přidání/editaci bloku - PDF generátor: c.linkURL() – celý blok je klikatelný odkaz - sample.json: ukázkový blok s URL - index.html: dokumentace URL pole - .github/copilot-instructions.md: přidány Copilot instrukce
3.1 KiB
3.1 KiB
Copilot instructions for scenar-creator
Big picture (read this first)
- This is a single FastAPI service that serves both API and static frontend (no separate frontend build step).
- Entry point:
app/main.pymounts/staticand servesindex.htmlat/. - API boundary is under
app/api/(/api/health,/api/validate,/api/sample,/api/generate-pdf). - Core domain object is
ScenarioDocumentinapp/models/event.py(JSON-first design, no DB). - PDF rendering is the main backend logic in
app/core/pdf_generator.py(ReportLab canvas, A4 landscape timetable).
Data model and domain rules (project-specific)
- Multi-day events use
event.date_from+event.date_to; keep backward compatibility with legacyevent.date. blocks[].dateis always a concrete day (YYYY-MM-DD) even for multi-day events.- Overnight blocks are valid:
end <= startmeans crossing midnight. This rule exists in frontend canvas and backend PDF. series_idgroups blocks created by “add to all days”; deleting a series removes all blocks with matchingseries_id.program_types[].idmust match eachblocks[].type_id; unknown types are validation errors.
Frontend architecture conventions
- Frontend is vanilla JS globals loaded in order from
index.html:API->Canvas-> import/export helpers ->App. App.stateis the source of truth (event,program_types,blocks) inapp/static/js/app.js.- Canvas timeline is horizontal time axis with 15-minute snapping (
Canvas.GRID_MINUTES = 15) inapp/static/js/canvas.js. - Drag/resize behavior: native pointer drag for move + interact.js resize handle for duration updates.
- UI copy and date labels are Czech (e.g.,
Pondělí (20.2)), so preserve localization in new UI text.
Backend conventions
- Keep API handlers thin; place formatting/rendering logic in
app/core/. - Raise
ScenarsErrorfrom core logic and translate to HTTP 422 in API (app/api/pdf.py). - PDF generator handles:
- legend from
program_types - optional responsible person text inside blocks
- notes as superscript markers + optional page 2 note listing
- legend from
- Czech diacritics in PDFs rely on LiberationSans registration with Helvetica fallback.
Developer workflows
- Local run:
uvicorn app.main:app --reload --port 8080 - Tests:
python3 -m pytest tests/ -v - Container image includes required fonts (
fonts-liberation) inDockerfile; do not remove unless PDF text rendering is reworked. - Health endpoint for local/container checks:
/api/health.
Testing patterns to preserve
- API tests use
fastapi.testclient.TestClient(tests/test_api.py). - PDF tests assert magic header
%PDF-and page count with regex (tests/test_pdf.py). - Keep coverage for overnight blocks, multi-day ranges, legacy
event.date, andseries_idbehavior when changing models/UI.
High-impact files
app/core/pdf_generator.py— timeline layout math, fonts, notes page logic.app/static/js/canvas.js— drag/resize + time-range computation.app/static/js/app.js— modal save/delete logic, series expansion, document import/export shape.app/models/event.py— schema contract used by both API and frontend JSON.