archsight 0.5.0 → 0.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/docs/configuration.md +1 -0
- data/docs/index.md.erb +1 -0
- data/docs/pdf-export.md +6 -0
- data/docs/slide-decks.md +58 -0
- data/lib/archsight/assets.rb +37 -1
- data/lib/archsight/linter.rb +13 -0
- data/lib/archsight/pdf/document.rb +2 -1
- data/lib/archsight/pdf/markdown.rb +5 -2
- data/lib/archsight/pdf/theme.rb +26 -2
- data/lib/archsight/pdf/typst/archsight.typ +21 -0
- data/lib/archsight/resources/config.rb +26 -0
- data/lib/archsight/resources/page.rb +8 -0
- data/lib/archsight/slides.rb +88 -0
- data/lib/archsight/version.rb +1 -1
- data/lib/archsight/web/api/openapi/spec.yaml +82 -1
- data/lib/archsight/web/api/page_helpers.rb +2 -0
- data/lib/archsight/web/api/routes.rb +15 -0
- data/lib/archsight/web/public/vue/{DocPage-D3QtnrmO.js → DocPage-B2AVspsD.js} +1 -1
- data/lib/archsight/web/public/vue/{EditorPage-lZyG6dVt.js → EditorPage-BYSZG_O0.js} +1 -1
- data/lib/archsight/web/public/vue/{ErrorPage-BhdYGZJk.js → ErrorPage-eL_Woec4.js} +1 -1
- data/lib/archsight/web/public/vue/{GraphView-BvWAbUAl.css → GraphView-B_EJRCcO.css} +1 -1
- data/lib/archsight/web/public/vue/GraphView-YEiPBxPd.js +1 -0
- data/lib/archsight/web/public/vue/{HomePage-B7SaXVeb.js → HomePage-BeLTwv2y.js} +2 -2
- data/lib/archsight/web/public/vue/{InstanceRouter-BCKbW-Wp.css → InstanceRouter-B-iG7ps_.css} +1 -1
- data/lib/archsight/web/public/vue/InstanceRouter-DgvdUouW.js +1 -0
- data/lib/archsight/web/public/vue/KindList-BkYvYpnh.js +1 -0
- data/lib/archsight/web/public/vue/{KindList-yYcRT2BV.css → KindList-xB91PWox.css} +1 -1
- data/lib/archsight/web/public/vue/{PageView-CirIXjW6.js → PageView-B3SnDw9S.js} +1 -1
- data/lib/archsight/web/public/vue/{QueryError-BIJH6gQC.js → QueryError-DzGMgvyb.js} +1 -1
- data/lib/archsight/web/public/vue/{ResourceList-761vG1Jw.js → ResourceList-Cr9ExUDn.js} +1 -1
- data/lib/archsight/web/public/vue/{SearchResults-BPHa6yhK.js → SearchResults-D6tx3Atc.js} +1 -1
- data/lib/archsight/web/public/vue/{WikiPage-Bi7dzY2h.js → WikiPage-BhaaveRq.js} +2 -2
- data/lib/archsight/web/public/vue/graphviz.worker-mvAaBzAH.js +3 -0
- data/lib/archsight/web/public/vue/index-BP-NH0dn.css +1 -0
- data/lib/archsight/web/public/vue/{index-BF4zUlWZ.js → index-le1guGp1.js} +2 -2
- data/lib/archsight/web/public/vue/{useGraphviz-Dnm2pkon.js → useGraphviz-DFlxVG1U.js} +2 -2
- data/lib/archsight/web/public/vue/{usePanZoom-HxgEsqq2.js → usePanZoom-RxoG4Zu7.js} +1 -1
- data/lib/archsight/web/public/vue.html +2 -2
- metadata +23 -21
- data/lib/archsight/web/public/vue/GraphView-CoqAjFdR.js +0 -1
- data/lib/archsight/web/public/vue/InstanceRouter-DJJn9fhP.js +0 -1
- data/lib/archsight/web/public/vue/KindList-UqMajqbf.js +0 -1
- data/lib/archsight/web/public/vue/graphviz-1lWBhpEX.js +0 -3
- data/lib/archsight/web/public/vue/index-BO59Fbpf.css +0 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 931ae81cd7562b88a4be605ed42cde3edc97e88d5f1c5623872ba3c1ea6fc60a
|
|
4
|
+
data.tar.gz: d1c4069f44304777333c400a139ff698727b86a6af72a1706cafe32ba327a13d
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 663df3921270f629b6e8b50f403587077b69d0a601f169920b002cf52e799a522b86ad0b9196a739cad0a630b92cb57bff504744c342706e4419b44a27c1c666
|
|
7
|
+
data.tar.gz: ed596c265fba09d9f902432e391297ba9c8c41ba3da8ea4fddf99d17e67b4df69f67ff25be17cc610406b3e4fa247e7db96d9f49d8254c18469cd56aaa07ede5
|
data/docs/configuration.md
CHANGED
|
@@ -42,6 +42,7 @@ that is set but empty counts as not set.
|
|
|
42
42
|
| `pdf.timeout` | `ARCHSIGHT_PDF_TIMEOUT` | Seconds a PDF may take to typeset before it is cancelled. Default `60` |
|
|
43
43
|
| `pdf.remote_images` | `ARCHSIGHT_PDF_REMOTE_IMAGES` | `false` stops the PDF export from fetching images that a page embeds by URL (default: fetched, public hosts only) |
|
|
44
44
|
| `pdf.max_analyses` | `ARCHSIGHT_PDF_MAX_ANALYSES` | How many `![[Analysis/...]]` embeds one PDF may run (each can take as long as its own timeout). Default `5`; further ones are shown as a note |
|
|
45
|
+
| `slides.script_hosts` | `ARCHSIGHT_SLIDES_SCRIPT_HOSTS` | `https://` hosts (space or comma separated) from which an HTML [slide deck](/doc/slide-decks) may load scripts, styles and fonts. Default `https://unpkg.com https://cdn.jsdelivr.net https://cdnjs.cloudflare.com` |
|
|
45
46
|
| `import.cache_root` | `ARCHSIGHT_IMPORT_CACHE_ROOT` | Where the GitHub, GitLab and repository imports clone repositories, and what importers of the resources repository get as `cache_root` / `ARCHSIGHT_CACHE_DIR`. Default `~/.cache/archsight/git`; an import's own `import/config/cacheRoot` wins, see [Importers of the Resources Repository](/doc/import#importers-of-the-resources-repository). Every import makes sure the clones are not indexed by Spotlight (macOS): an empty `.metadata_never_index` in `~/.cache/archsight`, or in the cache root when it is elsewhere |
|
|
46
47
|
|
|
47
48
|
## Command line
|
data/docs/index.md.erb
CHANGED
|
@@ -9,6 +9,7 @@ Welcome to the Architecture Documentation System. This documentation covers how
|
|
|
9
9
|
- [Query Syntax](/doc/search) - Search and filter resources
|
|
10
10
|
- [Wiki Pages](/doc/pages) - Author markdown pages and arrange them in the sidebar tree
|
|
11
11
|
- [PDF Export](/doc/pdf-export) - Download pages and resources as PDF, with a Config for the look
|
|
12
|
+
- [Slide Decks](/doc/slide-decks) - Show a finished PDF or HTML deck on a page, listed in a Slides menu
|
|
12
13
|
- [Architecture Modeling](/doc/modeling) - How to model your architecture
|
|
13
14
|
- [REST API Documentation](/docs/api) - JSON API for programmatic access
|
|
14
15
|
- [Diagrams](/doc/diagram) - Render `.asd` diagram files to SVG
|
data/docs/pdf-export.md
CHANGED
|
@@ -56,6 +56,7 @@ Tags of the page (`tags:` in the frontmatter) or of a resource (`architecture/ta
|
|
|
56
56
|
| `pdf:landscape` | Landscape pages |
|
|
57
57
|
| `pdf:draft` | A "draft" watermark on every page |
|
|
58
58
|
| `pdf:no-graph` | Leave the dependency graph out of a resource's document |
|
|
59
|
+
| `pdf:no-breaks` | Ignore the page breaks before headings that the Config asks for (`pdf/break-before`, `pdf/keep-space`) |
|
|
59
60
|
| `pdf:template:<name>` | Use the pdf Config `<name>` instead of `default` |
|
|
60
61
|
| `version:<x>` | The document version in the header (else the page property `Version`, else `1`) |
|
|
61
62
|
|
|
@@ -100,6 +101,11 @@ spec: {}
|
|
|
100
101
|
| `pdf/header-meta` | Parts of the header line: `id, version, date, owner` |
|
|
101
102
|
| `pdf/lang` | Language of the fixed texts: `en` or `de` |
|
|
102
103
|
| `pdf/paper`, `pdf/margin` | `a4`, `a5` or `us-letter`; horizontal margin such as `16mm` |
|
|
104
|
+
| `pdf/break-before` | Heading levels that always start a new page, e.g. `1` or `1,2` |
|
|
105
|
+
| `pdf/keep-space` | `level:share` pairs: a heading of that level starts a new page when less than the share of the page is left, e.g. `2:30%` or `2:30%,3:20%` |
|
|
106
|
+
|
|
107
|
+
The first heading of a document never breaks (it follows the title block or the contents). A level in `pdf/break-before` needs no
|
|
108
|
+
share in `pdf/keep-space`. Without these settings headings flow as before (Typst keeps a heading with the text after it).
|
|
103
109
|
|
|
104
110
|
Values are checked when they are loaded (and by `archsight lint`): something that is not a colour, a font name or a length is
|
|
105
111
|
ignored and the default is used.
|
data/docs/slide-decks.md
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
# Slide Decks
|
|
2
|
+
|
|
3
|
+
A [page](/doc/pages) can show a finished slide deck above its text. Archsight does not make or render slides: the deck is
|
|
4
|
+
the file your slide tool produced, and the page is its summary. That works for every tool that can write a PDF or one
|
|
5
|
+
self-contained HTML page (Slidev, reveal.js, Marp, PowerPoint, Keynote, Google Slides, ...).
|
|
6
|
+
|
|
7
|
+
## Layout
|
|
8
|
+
|
|
9
|
+
One folder per deck, and one menu that lists them, so a large collection stays orderly:
|
|
10
|
+
|
|
11
|
+
```
|
|
12
|
+
resources/slides/
|
|
13
|
+
menu.yaml # a PageMenu "Slides": spec.contains.pages lists the decks in display order
|
|
14
|
+
2026-06-08-guardrails/
|
|
15
|
+
2026-06-08-guardrails.md # the page: frontmatter and a summary
|
|
16
|
+
deck.pdf # the deck (or deck.html)
|
|
17
|
+
cover.png # optional poster image
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
A deck page is an ordinary page: it is searchable, can link and embed, has an owner and tags, and is edited and exported
|
|
21
|
+
like any other. Page names are unique across the resources, so name the page after its folder rather than `index.md`.
|
|
22
|
+
Only `*.yaml` files are loaded, so the menu is `menu.yaml`. A deck missing from the menu appears under "Unsorted" and is
|
|
23
|
+
reported by `archsight lint`.
|
|
24
|
+
|
|
25
|
+
## Frontmatter
|
|
26
|
+
|
|
27
|
+
```yaml
|
|
28
|
+
---
|
|
29
|
+
title: Guardrails for the Target Picture
|
|
30
|
+
owner: Architecture Team
|
|
31
|
+
slides: deck.pdf # or deck.html, a file next to the page
|
|
32
|
+
cover: cover.png # optional; with a cover the page shows a poster and loads the deck on a click
|
|
33
|
+
---
|
|
34
|
+
The summary of the deck, in markdown.
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
`slides` and `cover` are resolved like images (relative to the page, never outside the resources directory). The page shows
|
|
38
|
+
the deck in a frame with **Full screen**, **Open** and **Download** links. The page's own PDF button still exports the
|
|
39
|
+
summary text. Without a cover the deck is shown right away.
|
|
40
|
+
|
|
41
|
+
## HTML decks run in a sandbox
|
|
42
|
+
|
|
43
|
+
An HTML deck is a program written by someone else, so it is served by `GET /api/v1/decks/<path>` (not as an image or asset)
|
|
44
|
+
and only with a `Content-Security-Policy` that starts with `sandbox allow-scripts` and has no `allow-same-origin`: the deck
|
|
45
|
+
cannot read the API, cookies or storage of Archsight, also when its file is opened on its own, and it cannot load data from
|
|
46
|
+
other hosts (`connect-src` allows only `blob:` and `data:`). Scripts, styles and fonts may be loaded from the hosts of
|
|
47
|
+
the setting `slides.script_hosts` (`ARCHSIGHT_SLIDES_SCRIPT_HOSTS`, `https://` hosts separated by spaces or commas), by default
|
|
48
|
+
`unpkg.com`, `cdn.jsdelivr.net` and `cdnjs.cloudflare.com`. Images
|
|
49
|
+
and media must be inside the file (`data:` or `blob:`).
|
|
50
|
+
|
|
51
|
+
PDF decks are served inline with `nosniff` and shown by the browser's own viewer.
|
|
52
|
+
|
|
53
|
+
## Making the file
|
|
54
|
+
|
|
55
|
+
- **Slidev:** `slidev export` for a PDF, or any tool that bundles the deck into one HTML file. A multi-file `dist/` folder
|
|
56
|
+
is not supported yet.
|
|
57
|
+
- **PowerPoint, Keynote, Google Slides:** export as PDF.
|
|
58
|
+
- Files are limited to 25 MB.
|
data/lib/archsight/assets.rb
CHANGED
|
@@ -34,6 +34,13 @@ module Archsight
|
|
|
34
34
|
".drawio" => "application/xml",
|
|
35
35
|
".asd" => "image/svg+xml" # served rendered, see the assets route
|
|
36
36
|
}.freeze
|
|
37
|
+
# Finished slide decks (see `page/slides`): a PDF, or one self-contained HTML page. They are served by their own door
|
|
38
|
+
# (`/api/v1/decks/<path>`), never as an image, because an HTML deck runs script (it is sandboxed when served).
|
|
39
|
+
DECK_TYPES = {
|
|
40
|
+
".pdf" => "application/pdf",
|
|
41
|
+
".html" => "text/html; charset=utf-8"
|
|
42
|
+
}.freeze
|
|
43
|
+
DECKS_PREFIX = "/api/v1/decks/"
|
|
37
44
|
DRAWIO = ".drawio"
|
|
38
45
|
ASD = ".asd"
|
|
39
46
|
|
|
@@ -105,8 +112,24 @@ module Archsight
|
|
|
105
112
|
# @param path [String] relative to the resources directory, as received (it is normalized here, so callers cannot forget to)
|
|
106
113
|
# @return [String, nil] absolute path, nil if there is no such servable asset
|
|
107
114
|
def file_for(path, resources_dir:)
|
|
115
|
+
servable(path, TYPES, resources_dir)
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
# Like #file_for for a slide deck (PDF or HTML)
|
|
119
|
+
def deck_file_for(path, resources_dir:)
|
|
120
|
+
servable(path, DECK_TYPES, resources_dir)
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
# Why a normalized path is not served as a deck: :type or :missing; nil if it is served
|
|
124
|
+
def deck_problem(path, resources_dir:)
|
|
125
|
+
return :type unless DECK_TYPES.key?(File.extname(path).downcase)
|
|
126
|
+
|
|
127
|
+
deck_file_for(path, resources_dir: resources_dir) ? nil : :missing
|
|
128
|
+
end
|
|
129
|
+
|
|
130
|
+
def servable(path, types, resources_dir)
|
|
108
131
|
normalized = normalize(path)
|
|
109
|
-
return nil unless normalized &&
|
|
132
|
+
return nil unless normalized && types.key?(File.extname(normalized).downcase)
|
|
110
133
|
|
|
111
134
|
root = File.realpath(resources_dir)
|
|
112
135
|
real = File.realpath(File.join(root, normalized))
|
|
@@ -119,6 +142,19 @@ module Archsight
|
|
|
119
142
|
TYPES.fetch(File.extname(path).downcase)
|
|
120
143
|
end
|
|
121
144
|
|
|
145
|
+
def deck_content_type(path)
|
|
146
|
+
DECK_TYPES.fetch(File.extname(path).downcase)
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
def html_deck?(path)
|
|
150
|
+
File.extname(path).casecmp?(".html")
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
# URL under which the API serves a normalized deck path
|
|
154
|
+
def deck_url_for(path)
|
|
155
|
+
DECKS_PREFIX + path.split("/").map { |segment| ERB::Util.url_encode(segment) }.join("/")
|
|
156
|
+
end
|
|
157
|
+
|
|
122
158
|
def drawio?(path)
|
|
123
159
|
File.extname(path).casecmp?(DRAWIO)
|
|
124
160
|
end
|
data/lib/archsight/linter.rb
CHANGED
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
require_relative "markdown"
|
|
4
4
|
require_relative "helpers"
|
|
5
|
+
require_relative "slides"
|
|
5
6
|
require_relative "linter/structure"
|
|
6
7
|
|
|
7
8
|
module Archsight
|
|
@@ -105,11 +106,23 @@ module Archsight
|
|
|
105
106
|
end
|
|
106
107
|
|
|
107
108
|
# Pages need exactly one menu and their [[links]] must resolve
|
|
109
|
+
# `slides:` and `cover:` of a page must point at files that are served
|
|
110
|
+
def validate_slides(page)
|
|
111
|
+
resources_dir = @database.path if @database.respond_to?(:path)
|
|
112
|
+
return unless resources_dir
|
|
113
|
+
|
|
114
|
+
Archsight::Slides.audit(page, resources_dir: resources_dir).each do |problem|
|
|
115
|
+
@errors << "#{page.path_ref}: Page '#{page.name}': #{problem}"
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
|
|
108
119
|
def validate_page(page)
|
|
109
120
|
menus = page.references.map { |r| r[:instance] }.select { |i| i.klass == "PageMenu" }.uniq
|
|
110
121
|
@errors << "#{page.path_ref}: Page '#{page.name}' is not contained in any PageMenu" if menus.empty? && !page.home?
|
|
111
122
|
@errors << "#{page.path_ref}: Page '#{page.name}' is contained in several PageMenus (#{menus.map(&:name).join(", ")})" if menus.length > 1
|
|
112
123
|
|
|
124
|
+
validate_slides(page)
|
|
125
|
+
|
|
113
126
|
links = Archsight::Helpers::WikiLinks.new(@database)
|
|
114
127
|
page.annotations["page/content"].to_s.gsub(Archsight::Helpers::Embeds::PATTERN, "").scan(Archsight::Helpers::WikiLinks::PATTERN).map { |match| match.first.strip }.each do |target|
|
|
115
128
|
next if links.resolve(target).is_a?(String)
|
|
@@ -26,6 +26,7 @@ module Archsight
|
|
|
26
26
|
# pdf:landscape landscape pages
|
|
27
27
|
# pdf:draft "draft" watermark
|
|
28
28
|
# pdf:no-graph leave the dependency graph out of a resource document
|
|
29
|
+
# pdf:no-breaks ignore the page breaks before headings that the Config asks for
|
|
29
30
|
# pdf:template:<name> pdf Config to use instead of `default`
|
|
30
31
|
# version:<x> document version (else the page property Version, else 1)
|
|
31
32
|
class Document
|
|
@@ -110,7 +111,7 @@ module Archsight
|
|
|
110
111
|
<<~TYPST
|
|
111
112
|
#import "archsight.typ": *
|
|
112
113
|
#import "theme.typ": theme
|
|
113
|
-
#show: doc.with(#{args}, classification: #{opt(classification)}, draft: #{@draft}, landscape: #{@tags.include?("pdf:landscape")})
|
|
114
|
+
#show: doc.with(#{args}, classification: #{opt(classification)}, draft: #{@draft}, landscape: #{@tags.include?("pdf:landscape")}, heading-breaks: #{!@tags.include?("pdf:no-breaks")})
|
|
114
115
|
#{front}
|
|
115
116
|
|
|
116
117
|
#{body}
|
|
@@ -168,8 +168,11 @@ module Archsight
|
|
|
168
168
|
@image&.call(src, alt) || "#emph[#{str(alt.empty? ? src : alt)}]"
|
|
169
169
|
end
|
|
170
170
|
|
|
171
|
-
# Plain text, in which wiki links, embeds and the macros of the wiki are replaced
|
|
172
|
-
|
|
171
|
+
# Plain text, in which wiki links, embeds and the macros of the wiki are replaced. A single newline in the source
|
|
172
|
+
# is a soft break, a space as in CommonMark (a string literal would keep it as a line break); `<br>`, a backslash
|
|
173
|
+
# or two trailing spaces are the hard breaks, which are their own nodes.
|
|
174
|
+
def text(source)
|
|
175
|
+
value = source.gsub(/[ \t]*\n[ \t]*/, " ")
|
|
173
176
|
out = +""
|
|
174
177
|
pos = 0
|
|
175
178
|
value.scan(INLINE) do
|
data/lib/archsight/pdf/theme.rb
CHANGED
|
@@ -28,7 +28,7 @@ module Archsight
|
|
|
28
28
|
LOGO_TYPES = %w[.svg .png].freeze
|
|
29
29
|
|
|
30
30
|
attr_reader :name, :colors, :fonts, :footer_text, :classification, :header_meta, :lang, :paper, :margin,
|
|
31
|
-
:logo, :logo_light, :font_dir
|
|
31
|
+
:logo, :logo_light, :font_dir, :break_before, :keep_space
|
|
32
32
|
|
|
33
33
|
# @param template [Archsight::Resources::Config, nil]
|
|
34
34
|
# @param resources_dir [String] logos and fonts are looked up below it
|
|
@@ -43,6 +43,8 @@ module Archsight
|
|
|
43
43
|
@lang = LANGS.include?(ann["pdf/lang"]) ? ann["pdf/lang"] : "en"
|
|
44
44
|
@paper = PAPERS.include?(ann["pdf/paper"]) ? ann["pdf/paper"] : "a4"
|
|
45
45
|
@margin = ann["pdf/margin"].to_s.match?(Resources::Config::LENGTH) ? ann["pdf/margin"] : DEFAULT_MARGIN
|
|
46
|
+
@break_before = heading_levels(ann["pdf/break-before"])
|
|
47
|
+
@keep_space = space_shares(ann["pdf/keep-space"], @break_before)
|
|
46
48
|
@logo = logo_file(ann["pdf/logo"], resources_dir)
|
|
47
49
|
@logo_light = logo_file(ann["pdf/logo-light"], resources_dir) || @logo
|
|
48
50
|
@font_dir = font_directory(ann["pdf/font-dir"], resources_dir)
|
|
@@ -74,13 +76,19 @@ module Archsight
|
|
|
74
76
|
"logo: #{logo ? Typst.lit(logo) : "none"}", "logo-light: #{logo_light ? Typst.lit(logo_light) : "none"}",
|
|
75
77
|
"footer-text: #{footer_text ? Typst.lit(footer_text) : "none"}",
|
|
76
78
|
"header-meta: (#{header_meta.map { |p| Typst.lit(p) }.join(", ")},)",
|
|
77
|
-
"lang: #{Typst.lit(lang)}", "paper: #{Typst.lit(paper)}", "margin: #{margin}"
|
|
79
|
+
"lang: #{Typst.lit(lang)}", "paper: #{Typst.lit(paper)}", "margin: #{margin}",
|
|
80
|
+
"break-before: #{array(break_before)}", "keep-space: #{array(keep_space.map { |level, share| "(#{level}, #{share})" })}"
|
|
78
81
|
]
|
|
79
82
|
"#let theme = (#{fields.join(", ")})\n"
|
|
80
83
|
end
|
|
81
84
|
|
|
82
85
|
private
|
|
83
86
|
|
|
87
|
+
# A Typst array of ready-made items; `()` is the empty one, `(x,)` has one item
|
|
88
|
+
def array(items)
|
|
89
|
+
items.empty? ? "()" : "(#{items.join(", ")},)"
|
|
90
|
+
end
|
|
91
|
+
|
|
84
92
|
def color(value, default)
|
|
85
93
|
value.to_s.strip.match?(Resources::Config::COLOR) ? value.to_s.strip : default
|
|
86
94
|
end
|
|
@@ -97,6 +105,22 @@ module Archsight
|
|
|
97
105
|
parts.empty? ? HEADER_PARTS : parts
|
|
98
106
|
end
|
|
99
107
|
|
|
108
|
+
# @return [Array<Integer>] the heading levels that start a new page
|
|
109
|
+
def heading_levels(value)
|
|
110
|
+
value.to_s.split(",").map(&:strip).grep(/\A[1-6]\z/).map(&:to_i).uniq.sort
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
# @return [Array<Array(Integer, Integer)>] [level, percent of the page that must be left]; a level that always
|
|
114
|
+
# breaks needs no share
|
|
115
|
+
def space_shares(value, always)
|
|
116
|
+
value.to_s.split(",").filter_map do |part|
|
|
117
|
+
match = part.strip.match(Resources::Config::KEEP_SPACE)
|
|
118
|
+
level = match && match[1].to_i
|
|
119
|
+
share = match && match[2].to_i
|
|
120
|
+
[level, share] if level && share.between?(1, 100) && !always.include?(level)
|
|
121
|
+
end.uniq(&:first)
|
|
122
|
+
end
|
|
123
|
+
|
|
100
124
|
def blank_to_nil(value)
|
|
101
125
|
text = value.to_s.strip
|
|
102
126
|
text.empty? ? nil : text
|
|
@@ -46,6 +46,7 @@
|
|
|
46
46
|
classification: none,
|
|
47
47
|
draft: false,
|
|
48
48
|
landscape: false,
|
|
49
|
+
heading-breaks: true,
|
|
49
50
|
body,
|
|
50
51
|
) = {
|
|
51
52
|
let t = labels.at(theme.lang)
|
|
@@ -87,6 +88,26 @@
|
|
|
87
88
|
show heading.where(level: 1): set text(size: 16pt)
|
|
88
89
|
show heading.where(level: 2): set text(size: 13pt)
|
|
89
90
|
show heading.where(level: 3): set text(size: 11pt)
|
|
91
|
+
// Page breaks before headings (theme: break-before = levels that always start a page, keep-space = (level, percent of
|
|
92
|
+
// the page that must be left)). The first heading follows the title block and stays there.
|
|
93
|
+
show heading: it => {
|
|
94
|
+
let first = query(selector(heading).before(it.location(), inclusive: false)).len() == 0
|
|
95
|
+
let share = theme.keep-space.find(p => p.at(0) == it.level)
|
|
96
|
+
if not heading-breaks or first or (it.level not in theme.break-before and share == none) {
|
|
97
|
+
it
|
|
98
|
+
} else if it.level in theme.break-before {
|
|
99
|
+
pagebreak(weak: true)
|
|
100
|
+
it
|
|
101
|
+
} else {
|
|
102
|
+
context {
|
|
103
|
+
let top = 22mm
|
|
104
|
+
let bottom = 16mm
|
|
105
|
+
let left = page.height - bottom - here().position().y
|
|
106
|
+
if left < (page.height - top - bottom) * share.at(1) / 100 { pagebreak(weak: true) }
|
|
107
|
+
}
|
|
108
|
+
it
|
|
109
|
+
}
|
|
110
|
+
}
|
|
90
111
|
show link: set text(fill: theme.accent)
|
|
91
112
|
// Tables have horizontal rules only: a stronger one under the header, a light one under every other row, no frame and
|
|
92
113
|
// no vertical lines; the first column is flush with the text. Tables that pass their own stroke keep it.
|
|
@@ -126,7 +126,22 @@ class Archsight::Resources::Config < Archsight::Resources::Base
|
|
|
126
126
|
validator: ->(value) { Archsight::Resources::Config.pattern_error(value, LENGTH, "a length such as 16mm") },
|
|
127
127
|
sidebar: false
|
|
128
128
|
|
|
129
|
+
annotation "pdf/break-before",
|
|
130
|
+
description: "Heading levels that always start a new page, comma-separated (e.g. 1, or 1,2). The first heading " \
|
|
131
|
+
"of a document stays on the first page. A page tag pdf:no-breaks switches the breaks off",
|
|
132
|
+
title: "New page before",
|
|
133
|
+
sidebar: false,
|
|
134
|
+
validator: ->(value) { Archsight::Resources::Config.break_before_error(value) }
|
|
135
|
+
annotation "pdf/keep-space",
|
|
136
|
+
description: "Heading levels that start a new page when less than the given share of the page is left, as " \
|
|
137
|
+
"level:share, comma-separated (e.g. 2:30% or 2:30%,3:20%)",
|
|
138
|
+
title: "Space a heading needs",
|
|
139
|
+
sidebar: false,
|
|
140
|
+
validator: ->(value) { Archsight::Resources::Config.keep_space_error(value) }
|
|
141
|
+
|
|
129
142
|
HEADER_PARTS = %w[id version date owner].freeze
|
|
143
|
+
HEADING_LEVELS = (1..6).to_a.freeze
|
|
144
|
+
KEEP_SPACE = /\A([1-6]):(\d{1,3})%?\z/
|
|
130
145
|
|
|
131
146
|
# Validator helpers: nil if the value is fine, else the message
|
|
132
147
|
def self.pattern_error(value, pattern, expected)
|
|
@@ -144,4 +159,15 @@ class Archsight::Resources::Config < Archsight::Resources::Base
|
|
|
144
159
|
unknown = value.to_s.split(",").map(&:strip) - HEADER_PARTS
|
|
145
160
|
unknown.empty? ? nil : "unknown part #{unknown.join(", ")}; use #{HEADER_PARTS.join(", ")}"
|
|
146
161
|
end
|
|
162
|
+
|
|
163
|
+
def self.break_before_error(value)
|
|
164
|
+
levels = value.to_s.split(",").map(&:strip)
|
|
165
|
+
bad = levels.grep_v(/\A[1-6]\z/)
|
|
166
|
+
bad.empty? ? nil : "expected heading levels 1 to 6 such as 1,2, not #{bad.join(", ")}"
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
def self.keep_space_error(value)
|
|
170
|
+
bad = value.to_s.split(",").map(&:strip).reject { |part| (m = part.match(KEEP_SPACE)) && m[2].to_i.between?(1, 100) }
|
|
171
|
+
bad.empty? ? nil : "expected level:share such as 2:30%, not #{bad.join(", ")}"
|
|
172
|
+
end
|
|
147
173
|
end
|
|
@@ -76,6 +76,14 @@ class Archsight::Resources::Page < Archsight::Resources::Base
|
|
|
76
76
|
title: "Properties",
|
|
77
77
|
format: :multiline,
|
|
78
78
|
sidebar: false
|
|
79
|
+
annotation "page/slides",
|
|
80
|
+
description: "Finished slide deck of the page: a .pdf or a self-contained .html file next to the page",
|
|
81
|
+
title: "Slides",
|
|
82
|
+
sidebar: false
|
|
83
|
+
annotation "page/cover",
|
|
84
|
+
description: "Cover image of the slide deck (a file next to the page)",
|
|
85
|
+
title: "Cover",
|
|
86
|
+
sidebar: false
|
|
79
87
|
annotation "page/content",
|
|
80
88
|
description: "Markdown body of the page",
|
|
81
89
|
title: "Content",
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require_relative "assets"
|
|
4
|
+
require_relative "user_config"
|
|
5
|
+
|
|
6
|
+
module Archsight
|
|
7
|
+
# The finished slide deck a page shows (`slides:` in its frontmatter): a PDF, or one self-contained HTML page made by
|
|
8
|
+
# any slide tool. Archsight does not render slides; it serves the file and embeds it next to the page's summary.
|
|
9
|
+
#
|
|
10
|
+
# An HTML deck is somebody else's script, so it is only ever served inside a sandbox: a Content-Security-Policy with
|
|
11
|
+
# `sandbox allow-scripts` (no `allow-same-origin`) gives it an opaque origin, which cannot reach the API or the
|
|
12
|
+
# storage of Archsight, also when the file is opened on its own. Scripts may come from the hosts of the setting
|
|
13
|
+
# `slides.script_hosts` (`ARCHSIGHT_SLIDES_SCRIPT_HOSTS`, space or comma separated), by default the common CDNs.
|
|
14
|
+
module Slides
|
|
15
|
+
DEFAULT_SCRIPT_HOSTS = %w[https://unpkg.com https://cdn.jsdelivr.net https://cdnjs.cloudflare.com].freeze
|
|
16
|
+
HOST = %r{\Ahttps://[A-Za-z0-9.-]+(:\d+)?\z}
|
|
17
|
+
|
|
18
|
+
module_function
|
|
19
|
+
|
|
20
|
+
# @return [Array<String>] the hosts an HTML deck may load scripts, styles and fonts from (`https://host` only)
|
|
21
|
+
def script_hosts
|
|
22
|
+
setting = UserConfig.setting("slides", "script_hosts")
|
|
23
|
+
return DEFAULT_SCRIPT_HOSTS unless setting
|
|
24
|
+
|
|
25
|
+
setting.to_s.split(/[\s,]+/).grep(HOST)
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
# @return [String] the Content-Security-Policy of an HTML deck
|
|
29
|
+
def csp(hosts = script_hosts)
|
|
30
|
+
list = hosts.join(" ")
|
|
31
|
+
[
|
|
32
|
+
"sandbox allow-scripts allow-popups",
|
|
33
|
+
"default-src 'none'",
|
|
34
|
+
"script-src 'unsafe-inline' 'unsafe-eval' blob: data: #{list}".strip,
|
|
35
|
+
"style-src 'unsafe-inline' blob: data: #{list}".strip,
|
|
36
|
+
"font-src data: blob: #{list}".strip,
|
|
37
|
+
"img-src data: blob:",
|
|
38
|
+
"media-src data: blob:",
|
|
39
|
+
"connect-src blob: data:"
|
|
40
|
+
].join("; ")
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
# The deck of a page for the API
|
|
44
|
+
# @return [Hash, nil] `{url:, filename:, type:, cover_url:}`, nil if the page has none or the reference is not servable
|
|
45
|
+
def for_page(page, resources_dir: Archsight.resources_dir)
|
|
46
|
+
reference = page.annotations["page/slides"].to_s.strip
|
|
47
|
+
return nil if reference.empty?
|
|
48
|
+
|
|
49
|
+
base = Assets.base_dir_for(page, resources_dir: resources_dir)
|
|
50
|
+
path = base && Assets.resolve_reference(reference, base)
|
|
51
|
+
return nil unless path && Assets.deck_problem(path, resources_dir: resources_dir).nil?
|
|
52
|
+
|
|
53
|
+
{ url: Assets.deck_url_for(path), filename: File.basename(path), type: Assets.html_deck?(path) ? "html" : "pdf",
|
|
54
|
+
cover_url: cover_url(page, base, resources_dir) }
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def cover_url(page, base, resources_dir)
|
|
58
|
+
reference = page.annotations["page/cover"].to_s.strip
|
|
59
|
+
path = !reference.empty? && Assets.resolve_reference(reference, base)
|
|
60
|
+
path && Assets.problem(path, resources_dir: resources_dir).nil? ? Assets.url_for(path) : nil
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
# Problems of the `page/slides` and `page/cover` references of a page, for the linter
|
|
64
|
+
# @return [Array<String>]
|
|
65
|
+
def audit(page, resources_dir:)
|
|
66
|
+
base = Assets.base_dir_for(page, resources_dir: resources_dir)
|
|
67
|
+
return [] unless base
|
|
68
|
+
|
|
69
|
+
[["page/slides", ->(path) { Assets.deck_problem(path, resources_dir: resources_dir) }, Assets::DECK_TYPES],
|
|
70
|
+
["page/cover", ->(path) { Assets.problem(path, resources_dir: resources_dir) }, Assets::TYPES]].filter_map do |key, check, types|
|
|
71
|
+
reference = page.annotations[key].to_s.strip
|
|
72
|
+
next if reference.empty?
|
|
73
|
+
|
|
74
|
+
problem(key, reference, base, check, types)
|
|
75
|
+
end
|
|
76
|
+
end
|
|
77
|
+
|
|
78
|
+
def problem(key, reference, base, check, types)
|
|
79
|
+
path = Assets.resolve_reference(reference, base)
|
|
80
|
+
return "#{key} #{reference.inspect} is not a path inside the resources directory" unless path
|
|
81
|
+
|
|
82
|
+
case check.call(path)
|
|
83
|
+
when :type then "#{key} #{reference.inspect} must be #{types.keys.join(", ")}"
|
|
84
|
+
when :missing then "#{key} #{reference.inspect} does not exist (#{path})"
|
|
85
|
+
end
|
|
86
|
+
end
|
|
87
|
+
end
|
|
88
|
+
end
|
data/lib/archsight/version.rb
CHANGED
|
@@ -336,6 +336,65 @@ paths:
|
|
|
336
336
|
error: NotFound
|
|
337
337
|
message: Page 'nope' not found
|
|
338
338
|
|
|
339
|
+
/api/v1/decks/{path}:
|
|
340
|
+
get:
|
|
341
|
+
summary: Get a slide deck (PDF or self-contained HTML)
|
|
342
|
+
description: |
|
|
343
|
+
Serves the finished slide deck of a page (`slides:` in its frontmatter): a `.pdf` or one self-contained
|
|
344
|
+
`.html` file made by any slide tool. Archsight does not render slides, it serves the file and embeds it next
|
|
345
|
+
to the page. The URL is part of `slides.url` of `GET /api/v1/pages/{name}`.
|
|
346
|
+
|
|
347
|
+
The same boundary as the assets applies: regular files inside the resources directory, at most 25 MB, a path
|
|
348
|
+
that is outside, missing or of another type gets the same `404`.
|
|
349
|
+
|
|
350
|
+
An HTML deck is script of its author, so it is only ever served with a `Content-Security-Policy` that starts
|
|
351
|
+
with `sandbox allow-scripts` (no `allow-same-origin`): the deck cannot reach the API or the storage of
|
|
352
|
+
Archsight, also when the file is opened on its own. Scripts, styles and fonts may come from the hosts of the
|
|
353
|
+
setting `slides.script_hosts` (default: common CDNs).
|
|
354
|
+
operationId: getDeck
|
|
355
|
+
tags:
|
|
356
|
+
- Assets
|
|
357
|
+
parameters:
|
|
358
|
+
- name: path
|
|
359
|
+
in: path
|
|
360
|
+
required: true
|
|
361
|
+
description: Path relative to the resources directory, with a literal `/` between the segments
|
|
362
|
+
schema:
|
|
363
|
+
type: string
|
|
364
|
+
example: slides/example-deck/deck.pdf
|
|
365
|
+
responses:
|
|
366
|
+
'200':
|
|
367
|
+
description: The deck
|
|
368
|
+
headers:
|
|
369
|
+
Content-Security-Policy:
|
|
370
|
+
description: Only on HTML decks, the sandbox policy
|
|
371
|
+
schema:
|
|
372
|
+
type: string
|
|
373
|
+
X-Content-Type-Options:
|
|
374
|
+
description: Always `nosniff`
|
|
375
|
+
schema:
|
|
376
|
+
type: string
|
|
377
|
+
content:
|
|
378
|
+
application/pdf:
|
|
379
|
+
schema:
|
|
380
|
+
type: string
|
|
381
|
+
format: binary
|
|
382
|
+
text/html:
|
|
383
|
+
schema:
|
|
384
|
+
type: string
|
|
385
|
+
'404':
|
|
386
|
+
description: No such deck
|
|
387
|
+
content:
|
|
388
|
+
application/json:
|
|
389
|
+
schema:
|
|
390
|
+
$ref: '#/components/schemas/Error'
|
|
391
|
+
'413':
|
|
392
|
+
description: The file is larger than 25 MB
|
|
393
|
+
content:
|
|
394
|
+
application/json:
|
|
395
|
+
schema:
|
|
396
|
+
$ref: '#/components/schemas/Error'
|
|
397
|
+
|
|
339
398
|
/api/v1/status/{colour}/{text}:
|
|
340
399
|
get:
|
|
341
400
|
summary: Get the lozenge of a status macro
|
|
@@ -2211,9 +2270,26 @@ components:
|
|
|
2211
2270
|
type: string
|
|
2212
2271
|
description: Name of the page the menu opens, present when it opens one; the crumb links to it
|
|
2213
2272
|
|
|
2273
|
+
PageSlides:
|
|
2274
|
+
type: object
|
|
2275
|
+
description: The finished slide deck of a page (`slides:` in the frontmatter), shown next to the page's summary
|
|
2276
|
+
required: [url, filename, type, cover_url]
|
|
2277
|
+
properties:
|
|
2278
|
+
url:
|
|
2279
|
+
type: string
|
|
2280
|
+
description: Where the deck is served, `/api/v1/decks/<path>`
|
|
2281
|
+
filename:
|
|
2282
|
+
type: string
|
|
2283
|
+
type:
|
|
2284
|
+
type: string
|
|
2285
|
+
enum: [pdf, html]
|
|
2286
|
+
cover_url:
|
|
2287
|
+
type: [string, 'null']
|
|
2288
|
+
description: The cover image (`cover:` in the frontmatter) as an asset URL
|
|
2289
|
+
|
|
2214
2290
|
PageResponse:
|
|
2215
2291
|
type: object
|
|
2216
|
-
required: [name, title, status, author, owner, created, updated, properties, links, tags, toc, breadcrumb, html, backlinks]
|
|
2292
|
+
required: [name, title, status, author, owner, created, updated, properties, links, tags, slides, toc, breadcrumb, html, backlinks]
|
|
2217
2293
|
properties:
|
|
2218
2294
|
name:
|
|
2219
2295
|
type: string
|
|
@@ -2263,6 +2339,11 @@ components:
|
|
|
2263
2339
|
type: array
|
|
2264
2340
|
items:
|
|
2265
2341
|
type: string
|
|
2342
|
+
slides:
|
|
2343
|
+
oneOf:
|
|
2344
|
+
- $ref: '#/components/schemas/PageSlides'
|
|
2345
|
+
- type: 'null'
|
|
2346
|
+
description: The slide deck of the page, null if it has none or the file cannot be served
|
|
2266
2347
|
toc:
|
|
2267
2348
|
type: array
|
|
2268
2349
|
description: Headings of the body; empty unless the frontmatter has `toc` `yes`
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require_relative "../../page_tree"
|
|
4
|
+
require_relative "../../slides"
|
|
4
5
|
|
|
5
6
|
module Archsight; end
|
|
6
7
|
module Archsight::Web; end
|
|
@@ -43,6 +44,7 @@ module Archsight::Web::API::PageHelpers
|
|
|
43
44
|
properties: page.properties.map { |key, value| { key: key, value: value, html: inline_markdown(value, page) } },
|
|
44
45
|
links: annotations.select { |key, _| key.start_with?("link/") }.transform_keys { |key| key.delete_prefix("link/") },
|
|
45
46
|
tags: Archsight::Resources::Page.annotation_matching("page/tags")&.value_for(page) || [],
|
|
47
|
+
slides: Archsight::Slides.for_page(page),
|
|
46
48
|
toc: annotations["page/toc"] == "yes" ? Archsight::PageTree.toc(body) : [],
|
|
47
49
|
breadcrumb: tree.breadcrumb(page),
|
|
48
50
|
html: markdown(body, base: Archsight::Assets.base_dir_for(page, resources_dir: Archsight.resources_dir), page: page),
|
|
@@ -185,6 +185,21 @@ module Archsight::Web::API::Routes
|
|
|
185
185
|
send_file file, type: type, disposition: :inline
|
|
186
186
|
end
|
|
187
187
|
|
|
188
|
+
# GET /api/v1/decks/*path - The finished slide deck of a page (`slides:` in its frontmatter), a PDF or one
|
|
189
|
+
# self-contained HTML page. Same boundary as the assets (only these two types, only inside the resources directory,
|
|
190
|
+
# everything else the same 404). An HTML deck runs script, so it is only ever served with a sandbox policy.
|
|
191
|
+
get "/api/v1/decks/*" do
|
|
192
|
+
file = Archsight::Assets.deck_file_for(params["splat"].first, resources_dir: Archsight.resources_dir)
|
|
193
|
+
json_error("Deck not found", status: 404, error_type: "NotFound") unless file
|
|
194
|
+
json_error("Deck is too large", status: 413, error_type: "PayloadTooLarge") if File.size(file) > Archsight::Assets::MAX_BYTES
|
|
195
|
+
|
|
196
|
+
headers "X-Content-Type-Options" => "nosniff"
|
|
197
|
+
headers "Content-Security-Policy" => Archsight::Slides.csp if Archsight::Assets.html_deck?(file)
|
|
198
|
+
cache_control :public, :must_revalidate, max_age: 0
|
|
199
|
+
etag "#{File.mtime(file).to_i}-#{File.size(file)}"
|
|
200
|
+
send_file file, type: Archsight::Assets.deck_content_type(file), disposition: :inline
|
|
201
|
+
end
|
|
202
|
+
|
|
188
203
|
# GET /api/v1/status/:colour/*text - The lozenge of a `{status:colour text}` macro, generated on the fly. The
|
|
189
204
|
# URL fully determines the SVG, so it is cached for good.
|
|
190
205
|
get "/api/v1/status/:colour/*" do
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{B as e,L as t,R as n,X as r,it as i,p as a,t as o,tt as s}from"./index-
|
|
1
|
+
import{B as e,L as t,R as n,X as r,it as i,p as a,t as o,tt as s}from"./index-le1guGp1.js";import{t as c}from"./WikiPage-BhaaveRq.js";var l={key:1},u={__name:`DocPage`,props:{filename:String},setup(u){let d=u,f=i(null);function p(e,t){let n=new DOMParser().parseFromString(e,`text/html`).body,r=n.querySelector(`:scope > article`)||n,i=r.querySelector(`h1`),a=i?.textContent.trim()||t.split(`/`).pop().replace(/[-_]/g,` `);i?.remove();let o=[...r.querySelectorAll(`h2[id], h3[id], h4[id]`)].map(e=>({level:Number(e.tagName[1]),id:e.id,text:e.textContent.trim()})),s=[{title:`Documentation`}];return t.startsWith(`resources/`)&&s.push({title:`Resource types`}),{title:a,html:r.innerHTML,toc:o.length>=2?o:[],breadcrumb:s}}async function m(){let e=await a(d.filename);f.value=e?p(e,d.filename):{title:`Not found`,html:`<p>Documentation not found.</p>`,toc:[],breadcrumb:[{title:`Documentation`}]},o(f.value.title)}return s(()=>d.filename,m,{immediate:!0}),(i,a)=>f.value?(r(),n(c,{key:0,title:f.value.title,html:f.value.html,breadcrumb:f.value.breadcrumb,toc:f.value.toc},null,8,[`title`,`html`,`breadcrumb`,`toc`])):(r(),e(`article`,l,[...a[0]||=[t(`p`,null,`Loading...`,-1)]]))}};export{u as default};
|