oficina / mapa Public

Clone
git clone https://amadan.net/oficina/mapa

Plain git — no account needed to clone.

Download

Download this file

1{{/* Shared partials, parsed into every page. Not named with a leading
2 underscore: go:embed silently skips such files. */}}
3
4{{/* mapa-linked: a backlink or mention group. Keys: Items ([]Linked),
5 Heading, Empty, Target (the page's id, for "Link it"; 0 for none). */}}
6{{define "mapa-linked"}}
7<section mapa-linked rst-stack rst-section aria-labelledby="{{.ID}}">
8<h2 id="{{.ID}}">{{.Heading}}</h2>
9{{if .Items}}{{$target := .Target}}
10<ul mapa-sources>
11{{range .Items}}<li><a href="{{.Href}}" mapa-source>{{if .Look}}{{pageIcon .Look ""}}{{end}}{{.Label}}</a>
12{{$source := .Public}}{{range .Contexts}}<div mapa-context>{{.HTML}}
13{{if $target}}<form method="post" action="/p/{{$target}}/mentions" mapa-link-it><input type="hidden" name="grammar" value="{{grammar}}"><input type="hidden" name="source" value="{{$source}}"><input type="hidden" name="block" value="{{.Block}}"><button rst-btn type="submit">Link it</button></form>{{end}}
14</div>{{end}}</li>
15{{end}}</ul>
16{{else}}<p mapa-meta>{{.Empty}}</p>{{end}}
17</section>
18{{end}}
19
20{{/* mapa-editor: the scriptless editor. Keys: Body, Error. */}}
21{{define "mapa-editor"}}
22<div rst-field>
23<label rst-field-label mapa-sr for="body">Page text</label>
24<textarea rst-textarea mapa-editor id="body" name="body" rows="18" spellcheck="true"{{if .Error}} aria-invalid="true" aria-describedby="body-error"{{end}}>{{.Body}}</textarea>
25<small rst-field-hint>Markdown. Link a page with [[Its title]]; a date like [[2026-11-12]] opens your own daily note.</small>
26{{if .Error}}<small rst-field-error id="body-error" role="alert">{{.Error}}</small>{{end}}
27</div>
28{{with .Upload}}<fieldset mapa-upload-field aria-describedby="image-hint">
29<legend mapa-sr>Add an image</legend>
30<label mapa-sr for="image-alt">Describe it for people who can't see it</label>
31<input rst-input type="text" id="image-alt" name="alt" maxlength="1000" placeholder="Describe it for people who can't see it">
32<label mapa-sr for="image-file">Image file: PNG, JPEG, GIF or WebP, up to 10 MB</label>
33<input type="file" id="image-file" name="file" accept="image/png,image/jpeg,image/gif,image/webp">
34<button rst-btn type="submit" formaction="{{.}}" formenctype="multipart/form-data">Upload and insert</button>
35<small rst-field-hint id="image-hint">The image goes at the end of the page, and Save keeps it. An image copied from another page shows as not available here: upload it instead.</small>
36</fieldset>{{end}}
37{{end}}
38
39{{/* The alt field comes before the file, so it is read first: a file
40 refused for its size still leaves what was typed (Fable L5). */}}
41{{/* mapa-page-images: "Images on this page" (images §3.3, §4.4), each
42 with Open and Remove. Keys: Images ([]ListedImage), Back (where
43 Remove returns). */}}
44{{define "mapa-page-images"}}{{if .Images}}<section mapa-page-images rst-stack rst-section aria-labelledby="page-images-title">
45<h2 id="page-images-title">Images on this page</h2>
46<ul>{{range .Images}}<li><span>{{.Label}}</span> <a href="/i/{{.ID}}">Open</a> <a href="/i/{{.ID}}/remove?back={{$.Back}}">Remove from Mapa</a></li>{{end}}</ul>
47<p mapa-meta>Removing an image takes it out of Mapa everywhere, History included. A browser that has already shown it may keep its own copy for up to an hour.</p>
48</section>{{end}}{{end}}
49
50{{/* mapa-unsaved: the draft bar (§5, level-up §6.8). The page shows
51 the person's unsaved text, or with Saved (?saved=1) the committed
52 text. Keys: Draft (DraftView), Save, Discard (form actions), Href
53 (the page, for "Show the saved version"; "" where nothing is saved
54 yet), Saved. */}}
55{{define "mapa-unsaved"}}
56<div mapa-unsaved rst-section role="status">
57<p><strong>Unsaved changes</strong> from <time datetime="{{.Draft.Updated.Format "2006-01-02T15:04:05Z07:00"}}" title="{{stamp .Draft.Updated}}">{{ago .Draft.Updated}}</time>. {{if .Saved}}You're seeing the saved version.{{else}}You're seeing your unsaved version.{{end}}</p>
58<form method="post" action="{{.Save}}"><input type="hidden" name="version" value="{{.Draft.Version}}"><button rst-btn="primary" type="submit">Save</button></form>
59<form method="post" action="{{.Discard}}"><input type="hidden" name="version" value="{{.Draft.Version}}"><button rst-btn type="submit">Discard</button></form>
60{{with .Href}}{{if $.Saved}}<a rst-btn href="{{.}}">Show your unsaved version</a>{{else}}<a rst-btn href="{{.}}?saved=1">Show the saved version</a>{{end}}{{end}}
61</div>
62{{end}}
63
64{{/* mapa-island: the editor's data (level-up §6.8), JSON written by
65 encoding/json, which escapes <, >, & and U+2028/9, and the editor's
66 bundle, a module, so deferred (§6.2). The editor mounts on the
67 <article mapa-body rst-section> that follows. */}}
68{{define "mapa-island"}}{{with .}}<script type="application/json" id="mapa-editor">{{.}}</script>
69<script type="module" src="{{editor}}"></script>
70{{end}}{{end}}
71
72{{/* mapa-editing: "Ana is editing", team pages only (§5). */}}
73{{define "mapa-editing"}}{{with .}}<p mapa-meta mapa-editing>{{range $i, $who := .}}{{if $i}}, {{end}}{{$who}}{{end}} {{if eq (len .) 1}}is{{else}}are{{end}} editing this page.</p>{{end}}{{end}}
74
75{{/* mapa-doc-head: the page's kicker and its large title (level-up
76 §4.1). The kicker says what kind of page this is and who can open
77 it; Edit as Markdown opens the textarea, the floor without script
78 (§6.10).
79 Keys: Page (PageView), Last (*LastEdit or nil), Edit (href, or ""
80 on the editor itself), Day (*dayPill, daily notes), Rename (the
81 rename POST, on a team page the editor mounts on; "" elsewhere).
82 With Rename, the editor's script makes the title's text editable
83 in place (editor/title.mjs, build note 78); without script it is
84 the plain heading it always was. */}}
85{{define "mapa-doc-head"}}{{$page := .Page}}<header mapa-page-head rst-page-header>
86<div mapa-doc-kicker>
87{{- if eq $page.Kind "page"}}<span>{{icon "users"}}Team page</span>
88{{- else if eq $page.Kind "daily"}}<span>{{icon "lock"}}Your note. Only you can open it.</span>
89{{- else}}<span>{{icon "lock"}}Scratch. Only you can open it.</span>{{end}}
90{{- with .Last}}<span>Edited by {{.Who}} {{editedWhen .At}}</span>{{end}}
91{{- with $page.From}}<span mapa-from>{{.}}</span>{{end}}
92{{- with $page.Aliases}}<span mapa-also>Also called {{range $i, $a := .}}{{if $i}}, {{end}}{{$a.Title}}{{end}}</span>{{end}}
93{{- with .Edit}}<span mapa-actions><a mapa-doc-edit href="{{.}}">{{icon "pencil"}}Edit as Markdown</a></span>{{end}}
94{{- with .Day}}<span mapa-phone-only>{{template "mapa-day-pill" .}}</span>{{end}}
95</div>
96{{with .Look}}{{template "mapa-look-row" dict "Href" . "Page" $page "Banner" $.Banner}}{{end}}
97{{if .Rename}}<h1 mapa-title mapa-rename="{{.Rename}}">{{with $page.Look}}{{pageIcon . ""}}{{end}}<span mapa-title-text>{{$page.Label}}</span></h1>
98{{- else}}<h1 mapa-title>{{with $page.Look}}{{pageIcon . ""}}{{end}}{{if eq $page.Kind "daily"}}{{dayTitle $page.Date}}<span mapa-title-faint>{{dayYear $page.Date}}</span>{{else}}{{$page.Label}}{{end}}</h1>{{end}}
99</header>{{end}}
100
101{{/* mapa-banner: a team page's band (columns and icons spec §3.2): a
102 fixed height, the picture cropped to cover at its stored position.
103 Decoration, so alt="". Data: BannerView. */}}
104{{define "mapa-banner"}}{{$b := .Banner}}<div mapa-banner data-y="{{$b.Y}}"{{with .Look}} data-mapa-look-href="{{.}}"{{end}}><img src="{{$b.Src}}" alt="" width="{{$b.Width}}" height="{{$b.Height}}" decoding="async" fetchpriority="high">
105{{- with .Look}}<div mapa-banner-tools><a rst-btn href="{{.}}#banner" data-mapa-banner="reposition">Reposition</a><a rst-btn href="{{.}}#banner" data-mapa-banner="change">Change banner</a><a rst-btn href="{{.}}#banner" data-mapa-banner="remove">Remove banner</a></div>{{end}}</div>{{end}}
106
107{{/* mapa-look-row: above a team page's title, Add icon and Add banner
108 (§2.5). Its height is always reserved; its controls are links to
109 the scriptless look page, which mapa.js turns into the picker and
110 the file chooser. Keys: Href, Page, Banner. */}}
111{{define "mapa-look-row"}}<div mapa-look-row data-mapa-look-href="{{.Href}}" data-mapa-emoji="{{emojiHref}}">
112<a mapa-look-act href="{{.Href}}#icon" data-mapa-look="icon">{{if .Page.Look}}Change icon{{else}}Add icon{{end}}</a>
113<a mapa-look-act href="{{.Href}}#banner" data-mapa-look="banner">{{if .Banner}}Change banner{{else}}Add banner{{end}}</a>
114<p id="mapa-look-said" role="status" mapa-sr></p>
115</div>{{end}}
116