oficina / mapa Public

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

Plain git — no account needed to clone.

Download

Download this file

1{{define "head"}}{{with .Data.Run}}{{if .Refresh}}<meta http-equiv="refresh" content="5">{{end}}{{end}}{{end}}
2{{define "content"}}{{$d := .Data}}
3{{template "page-header" dict "Title" "Import from Notion" "Sub" "Copy pages from a Notion workspace into this team's Mapa."}}
4{{template "notice" $d.Notice}}
5{{template "form-error" $d.Error}}
6{{with $d.Run}}<section rst-stack rst-section mapa-import-run aria-labelledby="import-run">
7<div rst-stack role="status">
8<h2 id="import-run">{{if eq .State "surveying"}}Reading Notion{{else if eq .State "writing"}}Writing pages{{else if eq .State "done"}}Run complete{{else if eq .State "interrupted"}}Interrupted{{else if eq .State "stopped"}}Stopped{{else}}The import failed{{end}}</h2>
9{{if eq .State "surveying"}}<p>Pages read so far: {{number L .Surveyed}}. The total isn't known until every shared page has been read.</p>
10{{else if eq .State "writing"}}<p>{{number L .Written}} of {{number L .Total}} so far.</p>
11{{else if or (eq .State "interrupted") (eq .State "stopped")}}<p>{{if eq .State "interrupted"}}Mapa restarted during the import.{{else}}You stopped the import.{{end}} It had {{if .Total}}written {{number L .Written}} of {{number L .Total}} pages{{else}}read {{number L .Surveyed}} pages{{end}}. Resume carries on from there.</p>
12{{else if eq .State "done"}}<p>The report below shows how many pages were created, updated, kept, failed, and not imported.</p>
13{{else if eq .State "failed"}}<p>{{importFailure .Code}}</p>{{end}}
14{{if .Active}}<p mapa-meta>This page refreshes itself every five seconds. Closing it doesn't stop the import.</p>{{else if or (eq .State "surveying") (eq .State "writing")}}<p mapa-meta>Nothing has happened for a while. Stop it, then resume.</p>{{end}}
15</div>
16{{template "import-start" $d}}
17</section>{{else}}{{template "import-start" $d}}{{end}}
18{{with $d.Report}}{{template "import-report" .}}{{end}}
19{{if not $d.CanStop}}{{template "import-connection" $d}}{{end}}
20{{end}}
21
22{{define "import-start"}}{{if and .NoImages .CanStart}}<p mapa-meta>Images aren't set up in Mapa yet, so each image from Notion comes in as a line saying it wasn't imported. Run the import again once images are set up, and the pages nobody has edited get their pictures.</p>{{end}}
23{{with .Images}}{{if $.CanStart}}<p mapa-meta>Imported images count against the team's image allowance, now {{.Team}} used, and, until each page is written, against yours, now {{.Own}}. If either fills, the run stops fetching images and says so; raise it, or free some, and run again.</p>{{end}}{{end}}
24{{if or .CanStop .CanResume .CanStart .CanStartOver}}<div rst-actions mapa-import-actions>
25{{if .CanStop}}<form method="post" action="/import/notion/stop"><button rst-btn type="submit">Stop</button></form>{{end}}
26{{if .CanResume}}<form method="post" action="/import/notion/resume"><button rst-btn="primary" type="submit">Resume</button></form>{{end}}
27{{if .CanStartOver}}<form method="post" action="/import/notion/startover"><button rst-btn type="submit">Start over</button></form>{{end}}
28{{if .CanStart}}<form method="post" action="/import/notion/start"><button rst-btn="primary" type="submit">{{if .Run}}Run the import again{{else}}Start the import{{end}}</button></form>{{end}}
29</div>{{end}}{{end}}
30
31{{define "import-connection"}}<section rst-stack rst-section mapa-import-connection aria-labelledby="import-connection">
32<h2 id="import-connection">Connection</h2>
33{{if .Connected}}<p>Connected to {{if .Workspace}}the Notion workspace “{{.Workspace}}”{{else}}a Notion workspace{{end}}. Mapa holds its secret, sealed, and never shows it.</p>
34<div rst-actions><a rst-btn href="/import/notion/finish">Finish import…</a><a rst-btn href="/import/notion/disconnect">Disconnect…</a></div>
35<details><summary>Replace the secret</summary>{{template "import-token-form" .}}</details>
36{{else}}{{if .Finished}}<p><strong>The previous import was ended.</strong> Connecting again starts a new import. It has no record of what the last one wrote, so it would create a second copy of every page it finds.</p>{{end}}
37<p><strong>Everything you share with this integration becomes a team page that every member of this team can read.</strong> Share only what the whole team should have.</p>
38<ol>
39<li>In Notion, open the settings for connections and create a new internal integration called “Oficina import”.</li>
40<li>Under Capabilities, choose Read content only: no update, no insert, no comments. For user information, choose “Read user information without email addresses”.</li>
41<li>Share each top-level page you want with it. Pages inside them come too.</li>
42<li>Copy the integration's secret from Notion and paste it here.</li>
43</ol>
44{{template "import-token-form" .}}{{end}}
45{{if .Report}}<p mapa-meta><a href="/import/notion/forget">Forget the import…</a></p>{{end}}
46</section>{{end}}
47
48{{define "import-token-form"}}<form rst-form method="post" action="/import/notion/connect" autocomplete="off">
49{{template "field-text" dict "Name" "token" "Label" "Integration secret" "Type" "password" "Autocomplete" "off" "Required" true "Hint" "Mapa checks it with Notion once, then seals it. It reads; it never writes to Notion."}}
50{{template "form-foot" dict "Submit" "Connect"}}
51</form>{{end}}
52
53{{define "import-report"}}<section rst-stack rst-section mapa-import-report aria-labelledby="import-report">
54<h2 id="import-report">Report</h2>
55{{range .ImageFailures}}{{if eq .Label "images aren't set up in Mapa yet"}}<p mapa-notice role="status"><strong>No images were imported: images aren't set up in Mapa yet.</strong> Each one is a line in its page. Run the import again once images are set up.</p>{{end}}{{if hasSuffix .Label "allowance is full"}}<p mapa-notice role="status"><strong>Images stopped: {{.Label}}.</strong> Raise that allowance, or free some, and run the import again: the pages waiting for images are filled in.</p>{{end}}{{end}}
56{{with .Roots}}<p>Started from: {{range $i, $r := .}}{{if $i}}, {{end}}“{{$r}}”{{end}}.</p>{{end}}
57{{if or .Pinned .Unpinned}}<p mapa-import-pins>{{if not .Unpinned}}{{if eq .Pinned 1}}Pinned your top-level team page to your sidebar.{{else}}Pinned your {{number L .Pinned}} top-level team pages to your sidebar.{{end}}{{else if .Pinned}}Pinned {{number L .Pinned}} of your {{number L .Offered}} top-level team pages to your sidebar. Your sidebar holds {{number L .PinLimit}} pins.{{else if eq .Offered 1}}Your sidebar already holds {{number L .PinLimit}} pins, so your top-level team page wasn’t pinned. Unpin a page from sidebar first, then choose Pin to sidebar.{{else}}Your sidebar already holds {{number L .PinLimit}} pins, so your {{number L .Offered}} top-level team pages weren’t pinned. Unpin pages from sidebar first, then choose Pin to sidebar for each page.{{end}}</p>
58{{with .Unpinned}}<ul mapa-list>{{range .}}<li>{{if .Href}}<a href="{{.Href}}">{{.Title}}</a>{{else}}{{.Title}}{{end}}</li>{{end}}</ul>{{end}}{{end}}
59<dl rst-detail>
60<dt>Pages seen</dt><dd>{{number L .Seen}}</dd>
61<dt>Created</dt><dd>{{number L .Created}}</dd>
62<dt>Updated</dt><dd>{{number L .Updated}}{{if .Renamed}}, {{number L .Renamed}} renamed{{end}}</dd>
63<dt>Unchanged</dt><dd>{{number L .Unchanged}}</dd>
64<dt>Kept, because they were edited in Mapa</dt><dd>{{number L .KeptEdited}}</dd>
65<dt>Kept, because only their links were updated in Mapa</dt><dd>{{number L .KeptLinks}}</dd>
66<dt>Deleted in Mapa, not created again</dt><dd>{{number L .Gone}}</dd>
67<dt>Not found in Notion this time</dt><dd>{{if .SurveyDone}}{{number L .NotFound}}{{else}}Not known: reading Notion didn't finish{{end}}</dd>
68<dt>Could not be determined</dt><dd>{{number L .Undetermined}}</dd>
69<dt>Failed</dt><dd>{{number L .Failed}}{{range .FailedCodes}} ({{importFailure .Label}} {{number L .Count}}){{end}}</dd>
70<dt>Databases found</dt><dd>{{number L (len .Databases)}}{{with .Databases}}: {{range $i, $n := .}}{{if $i}}, {{end}}“{{$n}}”{{end}}. They move to Fichas later{{end}}</dd>
71<dt>Database rows shared directly</dt><dd>{{number L .Rows}}. Rows inside databases aren't counted until the databases move</dd>
72<dt>Images imported</dt><dd>{{number L .Images.Imported}}</dd>
73<dt>Images left as links</dt><dd>{{number L .Images.Links}}</dd>
74<dt>Images not imported</dt><dd>{{range $i, $c := .ImageFailures}}{{if $i}}; {{end}}{{$c.Label}}: {{number L $c.Count}}{{else}}0{{end}}</dd>
75<dt>Icons imported</dt><dd>{{number L .Icons}}</dd>
76<dt>Icons not imported</dt><dd>{{range $i, $c := .IconFailures}}{{if $i}}; {{end}}{{$c.Label}}: {{number L $c.Count}}{{else}}0{{end}}</dd>
77<dt>Banners imported</dt><dd>{{number L .Covers}}</dd>
78<dt>Banners not imported</dt><dd>{{range $i, $c := .CoverFailures}}{{if $i}}; {{end}}{{$c.Label}}: {{number L $c.Count}}{{else}}0{{end}}</dd>
79<dt>Links to pages not shared with the import</dt><dd>{{number L .Unshared}}</dd>
80<dt>Links still pointing at Notion</dt><dd>{{number L .Notion}}</dd>
81<dt>Text adjusted so Mapa reads it literally</dt><dd>{{number L .Neutralised}}</dd>
82<dt>Blocks written as a plain copy</dt><dd>{{number L .Fallbacks}}</dd>
83{{range .Losses}}<dt>{{.Label}}</dt><dd>{{number L .Count}}</dd>{{end}}
84</dl>
85{{template "import-list" dict "Title" "Titles changed to fit Mapa" "Pages" .Fitted}}
86{{template "import-list" dict "Title" "Pages kept" "Pages" .Kept}}
87{{template "import-list" dict "Title" "Pages that failed" "Pages" .FailedPages}}
88{{template "import-list" dict "Title" "Pages not found in Notion this time" "Pages" .NotFoundPages}}
89{{template "import-list" dict "Title" "Pages holding a note about something not imported" "Pages" .Placeholders}}
90{{template "import-list" dict "Title" "Pages from inside a database row, imported without the row" "Pages" .UnderRow}}
91</section>{{end}}
92
93{{define "import-list"}}{{with .Pages}}<h3>{{$.Title}}</h3><ul mapa-list>{{range .}}<li>{{if .Href}}<a href="{{.Href}}">{{.Title}}</a>{{else}}{{.Title}}{{end}}</li>{{end}}</ul>{{end}}{{end}}
94