From c188a6387aec397639d5f5bd91622ca05fe4a34b Mon Sep 17 00:00:00 2001 From: diaco Date: Tue, 21 Jul 2026 14:31:22 +0330 Subject: [PATCH] Split travel and product-test via explicit report-type templates. Co-authored-by: Cursor --- README.md | 36 +++++++++++++++++++++++----- examples/product-test.qmd | 2 ++ examples/solvent-ms-product-test.qmd | 1 + examples/travel-report.qmd | 2 ++ filters/print-chrome.lua | 4 +++- styles/print.css | 2 +- templates/product-test.yml | 5 ++++ templates/travel.yml | 5 ++++ templates/typst/typst-show.typ | 3 +++ templates/typst/typst-template.typ | 5 ++-- 10 files changed, 55 insertions(+), 10 deletions(-) create mode 120000 examples/solvent-ms-product-test.qmd create mode 100644 templates/product-test.yml create mode 100644 templates/travel.yml diff --git a/README.md b/README.md index 454a292..261dfdb 100644 --- a/README.md +++ b/README.md @@ -22,6 +22,8 @@ uv pip install --python .venv-pdf/bin/python weasyprint ## Quick start +Always render from this project root so `_quarto.yml` applies (RTL CSS, filters, PDF post-render): + ```bash quarto render examples/travel-report.qmd quarto render examples/product-test.qmd @@ -29,12 +31,32 @@ quarto render examples/product-test.qmd Outputs land in `_output/` (HTML + PDF). PDF is produced by `scripts/html-to-pdf.py` in `project.post-render`. -## Report types +## Templates -| Type | Example | Notes | -| --- | --- | --- | -| Travel / mission | `examples/travel-report.qmd` | Set `purpose` (and usually `destinations`, `report-date`) so the PDF title block shows travel meta (مقصد، هدف مأموریت، تیم، تاریخ). | -| Product / raw-material test | `examples/product-test.qmd` | Omit `purpose`. Put general info, samples, formula, and results in the body as Markdown tables (ported from Typst helpers in `typst-templates`). `destinations` is optional sidebar text. | +Two named metadata templates (Typst-style explicit choice). Pick one via `metadata-files` in the `.qmd` frontmatter — that sets `report-type` and controls whether the travel meta block is injected. Document type is **not** inferred from `purpose`. + +| Template | File | `report-type` | Example | +| --- | --- | --- | --- | +| Travel / mission | `templates/travel.yml` | `travel` | `examples/travel-report.qmd` | +| Product / raw-material test | `templates/product-test.yml` | `product-test` | `examples/product-test.qmd` | + +### Start a new report + +1. Copy the matching example `.qmd` (keep its `metadata-files` line pointing at `templates/travel.yml` or `templates/product-test.yml`). +2. Fill frontmatter and body. +3. Render with `quarto render` from this repo root. + +### Travel fields + +Content for the PDF «اطلاعات کلی» block (only when using the travel template): + +- `purpose` — هدف مأموریت +- `destinations` — مقصد (also used on the sidebar) +- `report-date` — تاریخ + +### Product-test body + +Put general info, samples, formula, and results in the body as Markdown tables. `destinations` is optional sidebar text. No `purpose` field is needed. ## Project layout @@ -42,10 +64,12 @@ Outputs land in `_output/` (HTML + PDF). PDF is produced by `scripts/html-to-pdf _quarto.yml styles/report.css # HTML screen theme styles/print.css # PDF / print (typst-templates match) -filters/print-chrome.lua # title block + sidebar injection +filters/print-chrome.lua # title block + sidebar + travel meta scripts/html-to-pdf.py # WeasyPrint post-render assets/fonts/ assets/logo.png +templates/travel.yml +templates/product-test.yml examples/travel-report.qmd examples/product-test.qmd ``` diff --git a/examples/product-test.qmd b/examples/product-test.qmd index 9ca2555..5a6ee36 100644 --- a/examples/product-test.qmd +++ b/examples/product-test.qmd @@ -1,4 +1,6 @@ --- +metadata-files: + - ../templates/product-test.yml title: "گزارش تست مواد اولیه" subtitle: "دپارتمان جوهر" company: "کیمیا رازی" diff --git a/examples/solvent-ms-product-test.qmd b/examples/solvent-ms-product-test.qmd new file mode 120000 index 0000000..7d126d1 --- /dev/null +++ b/examples/solvent-ms-product-test.qmd @@ -0,0 +1 @@ +/home/diaco/OpenCloud/Kimia Razi/Reports/Raw Material/Solvent & Dispersant/1405/04/گزارش تست نمونه‌های آزمایشگاهی سلونت MS/product-test.qmd \ No newline at end of file diff --git a/examples/travel-report.qmd b/examples/travel-report.qmd index 4212279..13b6a32 100644 --- a/examples/travel-report.qmd +++ b/examples/travel-report.qmd @@ -1,4 +1,6 @@ --- +metadata-files: + - ../templates/travel.yml title: "گزارش مأموریت" subtitle: "دپارتمان جوهر" company: "کیمیا رازی" diff --git a/filters/print-chrome.lua b/filters/print-chrome.lua index 0c64519..bce38e0 100644 --- a/filters/print-chrome.lua +++ b/filters/print-chrome.lua @@ -141,6 +141,7 @@ function Meta(meta) local logo_path = resolve_logo_path(stringify(meta.logofile or "assets/logo.png")) local logo_uri = file_to_data_uri(logo_path) local destinations = escape_html(meta_list_join(meta.destinations, " - ")) + local report_type = stringify(meta["report-type"]) local purpose = stringify(meta.purpose) local report_date = escape_html(meta["report-date"] or meta.date or "") local authors = escape_html(author_names(meta)) @@ -190,8 +191,9 @@ function Meta(meta) ]], running_logo, company, subtitle) + -- Travel meta is gated on report-type (from templates/travel.yml), not on purpose. local travel = "" - if purpose ~= nil and purpose ~= "" then + if report_type == "travel" then travel = string.format([[