ShtukbaseStandard
package page→ /base/lenses.md

pages/base/lenses.md

91 lines, 5.3 KB. As a page.

  1. ---
  2. type: Page
  3. title: "Lenses"
  4. icon: "🔭"
  5. description: "Base lenses: HTML built from markdown. How they work, how to rebuild, what else to convert to lenses and what will never become a lens."
  6. toConvert: []
  7. notLenses: []
  8. skin: kit
  9. ---
  10. A lens is an HTML page that a program builds from the markdown of a base. We edit markdown, then rebuild the lens. We do not edit HTML by hand: the lens check will notice. In detail — the lens standard (`specs/lenses-standard.ru.md` of the Shtukbase standard project).
  11. Lenses are of two kinds: a view of records of one kind (in essence a collection view) and a lens over mixed records — a map, a diagram, a report.
  12. ## How a lens works
  13. The header is YAML in the first HTML comment of the file:
  14. | Field | Meaning |
  15. |---|---|
  16. | `type: Lens` | marks a lens |
  17. | `title`, `icon`, `description` | the name, the icon and one line about what it shows |
  18. | `lensType` | `schema` · `spec` · `map` · `diagram` · `report` · `board` · `gallery` |
  19. | `render` | `live` — the shell reads the built data `lib/data.js`; `static` — all the HTML is built by the generator |
  20. | `sources` | paths or masks of markdown sources from the base root |
  21. | `generator` | the build command, one line, from the repository root |
  22. | `template` | a lens set template or the path to your own template |
  23. | `sourcesHash`, `outputHash` | only for `static`: fingerprints of the sources and of the HTML, set by the generator |
  24. Which lenses a base has can be seen from the files themselves: the lens check prints the list, the gallery `lib/index.html` shows the pictures. We do not duplicate the list here so that it does not go stale.
  25. ## Templates
  26. A lens on a template is a file `<folder>/<name>.lens.md`: the header `type: Lens`, `title`, `icon`, `description`, `template` and the template's parameters; the text under the header is "About the lens", how to read the picture. Records are selected the same way everywhere: `from` — a folder, `type` — a record type, `where` — a condition on fields.
  27. | Template | What it shows |
  28. |---|---|
  29. | `canvas` | a canvas: areas with record cards and arrows along link fields |
  30. | `lanes` | lanes: records by a field's value, each in its own strip |
  31. | `types` | an ontology: record types and the links between them |
  32. | `nest` | nesting: records inside their parents |
  33. | `board` | a board: columns by the record's state (by the contour's phases) |
  34. | `custom` | your own layout on kit components |
  35. The gallery `lib/index.html` shows all the base's lenses as cards. A lens does not introduce its own colors, fonts or palette: everything comes from `lib/kit.css` and `lib/kit.js`.
  36. ## Lens style
  37. A lens style is a set of colors, shadows, corner radii and a font for the light and the dark theme. There are two: "Kit" (`kit`, the quiet Shtukbase style) and "Draft" (`keer`, an earlier product's style: graphite and champagne). Both lie in the package `kit-style`.
  38. - To change the style, use the button in the lens header, next to the theme button. The choice is remembered and applies to all the project's lenses.
  39. - The project's default style is the field `skin` in this page's header: `kit` or `keer`. After an edit — `build`.
  40. - To show a lens in the needed style by a link: `?skin=keer&theme=dark` in the address. This way the choice is not remembered.
  41. ## How to build and view
  42. Package actions, from the project root:
  43. - `build` — build `lib/`: the records' data, the kit, the gallery and the service lenses' data;
  44. - `check` — exit code 1 if `lib/` is out of date or missing;
  45. - `serve [port]` — open the project in a browser on `127.0.0.1`.
  46. The kit lies in the package itself: on install it goes to `.shtukbase/packages/lenses/kit/`. The style comes with the package `kit-style` (the pages `design/kit-style/`), which is installed together with lenses. Nothing needs installing separately: only Bun is needed. The variable `SHTUK_KIT` is needed only if you want to build lenses with another copy of the kit.
  47. ## Service lenses
  48. The package puts two lenses about the project itself:
  49. - `/base/packages.html` — "Project packages": what is installed, versions, sources, dependencies, actions and checks, norms and pages of each package;
  50. - `/base/checks.html` — "Project checks": all checks with the norm each one holds, and the norms that no check holds.
  51. `build` takes their data from `.shtukbase/packages.lock` and the packages' `package.md` and writes it to `lib/base/packages.data.js`. If you installed or updated a package, run `shtuk run lenses build` again.
  52. ## Two lists in the header
  53. HTML without a lens header is allowed only if it stands in one of the two lists in this page's header. The lens check reads them; HTML without a header outside the lists is an error.
  54. - `toConvert` — "convert to lenses", an allowed debt. A row: `{path, order, lensType, note}` — a path or mask from the base root, a number in the queue (1 — first), the future lens type, one line "what to build from". First what is read more often and goes stale more often. A converted lens is removed from the list.
  55. - `notLenses` — HTML that will not become a lens: the customer's sources as received, prototypes, exports of other systems. A row: `{path, note}`.
  56. The tables below are for reading; they are edited together with the header.
  57. ### Convert to lenses
  58. | Order | HTML | Type | What to build from |
  59. |---|---|---|---|
  60. ### Not lenses
  61. | HTML | Why |
  62. |---|---|