Page viewer draws the Todo small lines template #76

Manually merged
jfro merged 1 commit from fix/75-todo-template-viewer into main 2026-11-11 16:54:34 +00:00
Owner

Closes #75. Refs #51.

A page on our Todo small lines template showed only its strokes in the page viewer. The viewer looks a page's drawing up by its template.value; built-in templates store their name there, but our template is a Methods-style TemplateType cloud item (Todos.Template, Remarkable.NewTemplate), and a page on it points at the item by id, so the name lookup missed.

Change

  • Templates.drawing/1: a page's template value to the drawing's name: a name we draw, or our todo item's id (current or any earlier, stale one, also inside a path like <id>.template, any case) -> "Todo small lines".
  • drawn?/1, svg/1, rules/1 and the viewer's template URL go through it, so the viewer fetches the shared Todo%20small%20lines.svg and draws it behind the strokes like a built-in template.
  • OCR unchanged: OCR.PageImage still renders strokes on white, without the template.
  • docs/todo-template.md step 4 updated.

Tests

  • test/rm_analyzer_web/components/remarkable_components_test.exs (new): page_preview draws the todo template for a page on its item id (and stale ids), still draws built-ins by name, leaves out unknown templates.
  • templates_test.exs: drawing/1 by name and id; svg/1/rules/1 match for id and name.
  • Both fail on main (97e46e8) and pass here. mix precommit: 1340 passed.

Screenshots (head dbfd26d, realistic todo page)

The example page holds only what a real todo page has: the template, the tablet's handwriting on the first rows (a title, two tasks, the first ticked by hand in its printed box), then three tasks write-back drew from the app on the next free rows. No typed text (the earlier example reused a fixture with an unrelated typed block, which overlapped the rules).

Desktop:

viewer desktop

390px:

viewer 390

Page close-up (desktop, 2x):

page desktop

Alignment (measured, no change needed)

  • In the viewer the template layer and the strokes image fill the same box: both 1404 page px wide scaled to the box, offset 0, strokes viewBox -702 0 1404 1872 (390px: 358x477 css px; desktop: 604x805).
  • The drawn rules are the rules write-back writes to: Templates.segments/1 gives the 31 rules at 258.5 + 52k, the same as Todos.Template.layout/0; measured off the screenshots, pitch 52.1-52.2 page px.
  • Written tasks: baseline 5 page px above the rule (Report.rule_lift, PR #65), fineliner 3 px wide, so the ink ends 3.5 page px above the rule. That's about 3 css px on desktop; at 390px the page is drawn at 0.25 css px per page px, so the gap is under 1 css px and anti-aliasing closes it. Letters with descenders (p in "plants") go below the rule, as handwriting does.

Open question

I couldn't read a real page from Jeremy's tablet, so the id form is inferred from how Methods templates sync. If the page stores something else (neither the name nor an id), the viewer will still miss it; the value from the page's .content would settle it.

Closes #75. Refs #51. A page on our **Todo small lines** template showed only its strokes in the page viewer. The viewer looks a page's drawing up by its `template.value`; built-in templates store their name there, but our template is a Methods-style `TemplateType` cloud item (`Todos.Template`, `Remarkable.NewTemplate`), and a page on it points at the item by id, so the name lookup missed. ## Change - `Templates.drawing/1`: a page's template value to the drawing's name: a name we draw, or our todo item's id (current or any earlier, stale one, also inside a path like `<id>.template`, any case) -> `"Todo small lines"`. - `drawn?/1`, `svg/1`, `rules/1` and the viewer's template URL go through it, so the viewer fetches the shared `Todo%20small%20lines.svg` and draws it behind the strokes like a built-in template. - OCR unchanged: `OCR.PageImage` still renders strokes on white, without the template. - `docs/todo-template.md` step 4 updated. ## Tests - `test/rm_analyzer_web/components/remarkable_components_test.exs` (new): `page_preview` draws the todo template for a page on its item id (and stale ids), still draws built-ins by name, leaves out unknown templates. - `templates_test.exs`: `drawing/1` by name and id; `svg/1`/`rules/1` match for id and name. - Both fail on main (97e46e8) and pass here. `mix precommit`: 1340 passed. ## Screenshots (head dbfd26d, realistic todo page) The example page holds only what a real todo page has: the template, the tablet's handwriting on the first rows (a title, two tasks, the first ticked by hand in its printed box), then three tasks write-back drew from the app on the next free rows. No typed text (the earlier example reused a fixture with an unrelated typed block, which overlapped the rules). Desktop: ![viewer desktop](https://git.knope.dev/attachments/1cceffc3-4936-41c1-b524-5eaed8b21ece) 390px: ![viewer 390](https://git.knope.dev/attachments/a9b2272f-c8c8-4112-adbb-8f211d07e2a5) Page close-up (desktop, 2x): ![page desktop](https://git.knope.dev/attachments/83193bed-6f3c-47a4-992e-b8930b00df3c) ## Alignment (measured, no change needed) - In the viewer the template layer and the strokes image fill the same box: both 1404 page px wide scaled to the box, offset 0, strokes viewBox `-702 0 1404 1872` (390px: 358x477 css px; desktop: 604x805). - The drawn rules are the rules write-back writes to: `Templates.segments/1` gives the 31 rules at 258.5 + 52k, the same as `Todos.Template.layout/0`; measured off the screenshots, pitch 52.1-52.2 page px. - Written tasks: baseline 5 page px above the rule (`Report.rule_lift`, PR #65), fineliner 3 px wide, so the ink ends 3.5 page px above the rule. That's about 3 css px on desktop; at 390px the page is drawn at 0.25 css px per page px, so the gap is under 1 css px and anti-aliasing closes it. Letters with descenders (p in "plants") go below the rule, as handwriting does. ## Open question I couldn't read a real page from Jeremy's tablet, so the id form is inferred from how Methods templates sync. If the page stores something else (neither the name nor an id), the viewer will still miss it; the value from the page's `.content` would settle it.
Page viewer draws the Todo small lines template (closes #75)
All checks were successful
CI / test (pull_request) Successful in 1m44s
dbfd26d57c
A page on our todo template, a Methods-style cloud item, points at the
item by id rather than by name, so the viewer's name lookup missed and
showed only the strokes. Templates.drawing/1 resolves a page's template
value to a drawing by name or by our todo item's id (current or earlier),
and drawn?/svg/rules and the viewer use it. OCR still leaves the template
out (OCR.PageImage).
jfro manually merged commit 2f8f2d0c62 into main 2026-11-11 16:54:34 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
jfro/rm-analyzer!76
No description provided.