Add web SVG generator, container, and Kubernetes manifests
- Flask app (web/) generates M1730 scale SVGs from a form; embeds GOST typ A font as base64 so output is self-contained - Dockerfile builds the app into git.baumann.gr/adebaumann/m1730-generator - k8s/ deploys as a ClusterIP service for NPM to proxy at works.adebaumann.com/M1730-generator/ Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
# CLAUDE.md
|
||||
|
||||
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
||||
|
||||
## Project Overview
|
||||
|
||||
SVG scale artwork for M1730 analog meters. The scales are designed in Inkscape (v1.4.3) using the **ГОСТ тип А** (GOST type A) font, a Russian technical drafting standard typeface.
|
||||
|
||||
All canvas dimensions are **157.18373 mm × 26.683672 mm**. The coordinate origin is offset: `transform="translate(-37.352226,-90.454928)"` is applied to `layer1` in all files, so absolute SVG coordinates start around x=37, y=90 rather than 0,0.
|
||||
|
||||
## File Roles
|
||||
|
||||
The three SVG files represent layers of the same design, intended to be combined or used separately:
|
||||
|
||||
- **`M1730-Scale_template.svg`** — Inkscape working template. Contains the background rect+cutout path, the zero tick mark, an end tick mark, the "U" axis label, numeric labels `0` and `X` (placeholder for the full-scale value), and a `5mA` range label. Also contains a `<rect id="rect5">` inside `<defs>` used as a text flow shape (`shape-inside:url(#rect5)`) for the title text block (`id="text5"`).
|
||||
- **`M1730-Scale_paths.svg`** — Paths-only version: all tick marks as `<path>` elements, no text nodes (or text converted to paths). Used for cutting/printing workflows where fonts must not be embedded as live text.
|
||||
- **`M1730-Scale_text.svg`** — Text-overlay version: tick mark paths plus live `<text>` elements for numeric labels. The `sodipodi:docname` is `M1730-Scale.svg`, suggesting this is the "final" named file.
|
||||
|
||||
## Key Design Parameters
|
||||
|
||||
- Stroke colors: `#1a1a1a` (dark near-black) for all scale lines and text; fill `#f9f9f9` for the background panel, `#ffffff` for tick mark strokes.
|
||||
- Major tick stroke-width: `0.555`; border stroke-width: `0.184`.
|
||||
- Scale bar (the colored strip below tick marks): `y` range 107.547–113.746 mm absolute, `x` range 58.444–183.644.
|
||||
- Zero tick at absolute x=60.844; full-scale tick at x=180.251.
|
||||
|
||||
## Web Generator (`web/`)
|
||||
|
||||
A Flask app that generates scale SVGs from a form. The venv lives at the repo root.
|
||||
|
||||
```
|
||||
source .venv/bin/activate
|
||||
cd web && python app.py # runs on http://localhost:5000
|
||||
```
|
||||
|
||||
`app.py` has one route (`GET /`) serving the form and one (`POST /generate`) that returns SVG. All SVG geometry is computed in `generate_svg()` using the same coordinate constants as the hand-drawn files. The form exposes: unit label, min/max values, major tick intervals, minor ticks per interval, number of numeric labels, and range label.
|
||||
|
||||
The ГОСТ тип А font is loaded at startup from `/usr/local/share/fonts/г/ГОСТ_тип_А.ttf` and embedded as base64 in every generated SVG so output files are self-contained.
|
||||
|
||||
## Container & Kubernetes
|
||||
|
||||
```
|
||||
docker build -t m1730-scale:latest .
|
||||
```
|
||||
|
||||
`fonts/ГОСТ_тип_А.ttf` must exist in the repo root before building (copy from `/usr/local/share/fonts/г/`). The image runs gunicorn on port 5000.
|
||||
|
||||
```
|
||||
kubectl apply -f k8s/
|
||||
```
|
||||
|
||||
NPM should proxy `https://works.adebaumann.com/M1730-generator/` → `http://m1730-generator/` **with the prefix stripped** (trailing slash on `proxy_pass`). The frontend uses a relative `fetch('generate', ...)` URL so it works correctly under any subpath.
|
||||
|
||||
## Editing SVG files directly
|
||||
|
||||
Open files in **Inkscape**. There is no build, lint, or test tooling — changes are made directly to the SVG XML or via Inkscape's GUI. When modifying tick positions or labels, keep all three files consistent.
|
||||
Reference in New Issue
Block a user