oficina / base Public

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

Plain git — no account needed to clone.

Download

Download this file

1{{/* The chat behind "Ask Base anything": docked beside Home, and /ask. Every state's block is drawn and the one for .State shows; the panel's script moves between them. */}}
2{{define "ask-head"}}<div class="ask-head"><h2 id="ask-title">Ask Base</h2></div>{{end}}
3{{/* Docked on Home: on a wide screen the X closes it (posting open=0, kept for the member); on a phone it closes the full-screen chat. */}}{{define "ask-panel"}}<aside id="ask-panel" class="ask-panel glass" aria-labelledby="ask-title" data-ask data-state="{{.State}}">
4<div class="ask-head"><h2 id="ask-title"><span class="mark" aria-hidden="true"></span>Ask Base</h2><form class="dock-close" method="post" action="/ask/dock"><input type="hidden" name="open" value="0"><button class="round close" type="submit" data-ask-close aria-label="Close"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M6 6l12 12M18 6L6 18"/></svg></button></form></div>
5{{template "ask-body" .}}</aside>{{end}}
6{{/* A card, drawn from its fields alone: the question, a link per link, a button per option (its label, posting its value) while it is open, and the line saying how it ended. The panel's script draws the same (ask.js, addCard). */}}
7{{define "ask-card"}}<li class="msg card card-{{.Kind}}" data-card="{{.ID}}" data-revision="{{.Revision}}"{{with .Job}} data-for="{{.}}"{{end}}><p>{{.Question}}</p>
8{{- range .Links}}<p>{{if eq .Rel "oficina_connect"}}<a class="card-link" href="{{.URL}}">{{.Label}}</a>{{else}}<a class="card-link" href="{{.URL}}" target="_blank" rel="noopener">{{.Label}}</a>{{end}}</p>{{end}}
9{{- if and .Open .Options}}<form class="choices" method="post" action="/ask/cards/{{.ID}}/answer"><input type="hidden" name="revision" value="{{.Revision}}"><input type="hidden" name="key" value="{{newKey}}">{{range .Options}}<button class="btn ghost" type="submit" name="choice" value="{{.Value}}">{{.Label}}</button>{{end}}</form>{{end}}
10{{- with .Result}}<p class="card-state">{{.}}</p>{{end}}</li>{{end}}
11{{/* An open connect card, drawn as a button (ask.go, connectOffer): the Oficina mark and "Connect Oficina", going to Base's own connect page in this tab, and a line saying what connecting unlocks. It ends the Assistant's newest reply, or with none stands on its own. The panel's script draws the same (ask.js, offer). */}}
12{{define "ask-offer"}}<a class="btn connect-btn" href="{{.URL}}"><img class="connect-mark" src="{{asset "static/oficina/equipo.svg"}}" alt="">Connect Oficina</a><p class="connect-line">Calendar, Docs, Sheets and more</p>{{end}}
13{{/* A job, a pill: its state's mark, the title and its status, and once there is something to see (ready, done) the link to it. The summary opens the job view (without scripts, in place). The cards that belong to the job hang under it while they wait on the person; once ended they are listed in its view. The panel's script draws the same (ask.js, addJob). */}}
14{{define "ask-job"}}<li class="job" data-job="{{.ID}}" data-revision="{{.Revision}}" data-state="{{.State}}">
15<div class="pill"><details class="job-toggle"><summary class="pill-main" aria-label="{{.Question}}, {{.Result}}"><span class="state-mark" aria-hidden="true">{{template "ask-mark" .State}}</span><span class="pill-title">{{.Question}}</span><span class="pill-stage">{{.Result}}</span></summary>{{template "ask-jobview" .}}</details>
16{{- if or (eq .State "ready") (eq .State "done")}}{{with .Go}}<a class="pill-link" href="{{.URL}}" target="_blank" rel="noopener">{{.Label}}</a>{{end}}{{end}}</div>
17<ol class="job-cards">{{range .OpenCards}}{{template "ask-card" .}}{{end}}</ol></li>{{end}}
18{{/* A job state's mark: working has none (the mark turns, in CSS); the rest are still icons: paused a clock (it carries on by itself), stopped a square (it waits for the person). ask.js has the same paths (marks), and so does the native app (BaseIcon). */}}
19{{define "ask-mark"}}{{if eq . "asking"}}<svg viewBox="0 0 24 24"><path d="M9.2 9.2a2.9 2.9 0 0 1 5.6 1c0 2-2.8 2.4-2.8 4.3M12 18.2h.01"/></svg>{{else if eq . "ready"}}<svg viewBox="0 0 24 24"><path d="M8 16L16 8M9.5 8H16v6.5"/></svg>{{else if eq . "done"}}<svg viewBox="0 0 24 24"><path d="M6 12.5l4 4 8-9"/></svg>{{else if eq . "paused"}}<svg viewBox="0 0 24 24"><path d="M19.2 12a7.2 7.2 0 1 1-14.4 0a7.2 7.2 0 1 1 14.4 0zM12 8.6V12l2.4 1.6"/></svg>{{else if eq . "stopped"}}<svg viewBox="0 0 24 24"><path d="M9 7.5h6a1.5 1.5 0 0 1 1.5 1.5v6a1.5 1.5 0 0 1-1.5 1.5H9a1.5 1.5 0 0 1-1.5-1.5V9A1.5 1.5 0 0 1 9 7.5z"/></svg>{{end}}{{end}}
20{{/* The job view, opened from the pill: its title, the status, one sentence more, for a paused job that offers it "Carry on now" (assistant.job.carry_on, with assistant.job.carry_on_note under it: copy review 2026-11-24), and for a stopped one held while building was off, once it is on again, the same button with no note (abilities plan AD4) posting the card's revision, the job's cards that have ended (each its question and how it ended: ask-jobcard), when it started, and once there is something to see the link to it. The title links to the job's own page in Equipo (Card.Equipo, "Open in Equipo" as its tooltip, an arrow on hover and focus): the only place the chat links there, never a step the person must take. Without scripts it opens in place under the pill; the panel's script makes it a popover beside the pill, or a sheet on a phone, and shows Close (ask.js, jobView). */}}
21{{define "ask-jobview"}}<section class="jobview" aria-label="{{.Question}}"><header><span class="state-mark" aria-hidden="true">{{template "ask-mark" .State}}</span>
22<h3>{{with .Equipo}}<a class="jv-title" href="{{.URL}}" title="{{.Label}}" target="_blank" rel="noopener">{{$.Question}}<svg viewBox="0 0 24 24" aria-hidden="true"><path d="M9 6h9v9M18 6L7 17"/></svg></a>{{else}}{{.Question}}{{end}}</h3>
23<button class="round" type="button" data-job-close aria-label="Close" hidden><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M6 6l12 12M18 6L6 18"/></svg></button></header>
24<p class="jv-stage">{{.Result}}</p>{{with .Detail}}<p class="jv-detail">{{.}}</p>{{end}}
25{{- if and (or (eq .State "paused") (eq .State "stopped")) .CarryOn}}<form class="jv-act" method="post" action="/ask/cards/{{.ID}}/carry_on"><input type="hidden" name="revision" value="{{.Revision}}"><input type="hidden" name="key" value="{{newKey}}"><button class="btn ghost" type="submit">Carry on now</button>{{if eq .State "paused"}}<small>Uses your other plan, at no extra cost.</small>{{end}}<p class="jv-error" role="status"></p></form>{{end}}<ol class="jv-cards">{{range .EndedCards}}{{template "ask-jobcard" .}}{{end}}</ol>{{with .StartedAt}}<p class="jv-started">{{startedText .}}</p>{{end}}
26{{- if or (eq .State "ready") (eq .State "done")}}{{with .Go}}<a class="jv-go" href="{{.URL}}" target="_blank" rel="noopener">{{.Label}}</a>{{end}}{{end}}</section>{{end}}
27{{/* A job's card that has ended, in its view: the question and how it ended, nothing to press. The panel's script draws the same (ask.js, addCard). */}}
28{{define "ask-jobcard"}}<li class="jv-card" data-card="{{.ID}}" data-revision="{{.Revision}}" data-for="{{.Job}}"><p class="jv-q">{{.Question}}</p><p class="jv-result">{{.Result}}</p></li>{{end}}
29{{/* A person's files, above their words: thumbnails first, each a link to the image itself, then a pill per other file (its mark, name and size), a download. Both come from Base's own /ask/attachments, never Equipo's. Without scripts a thumbnail opens the image; the panel's script opens it in a viewer instead, and draws the same row (ask-attach.js, filesRow). */}}
30{{define "ask-files"}}<div class="files" role="group" aria-label="Attached files">{{range .}}{{if eq .Kind "image"}}<a class="thumb" href="/ask/attachments/{{.ID}}" data-attachment="{{.ID}}"><img loading="lazy" src="/ask/attachments/{{.ID}}/preview" alt="{{.Name}}"{{if and .Width .Height}} width="{{.Width}}" height="{{.Height}}"{{end}}></a>{{end}}{{end}}{{range .}}{{if ne .Kind "image"}}<a class="file" href="/ask/attachments/{{.ID}}" download aria-label="{{.Name}}, {{fileSize .Size}}. Download">{{template "ask-file-mark"}}<span class="file-name">{{.Name}}</span><span class="file-size">{{fileSize .Size}}</span></a>{{end}}{{end}}</div>{{end}}
31{{/* A file's mark: a page with its corner folded. ask-attach.js has the same path (fileMark). */}}
32{{define "ask-file-mark"}}<svg class="file-mark" viewBox="0 0 24 24" aria-hidden="true"><path d="M14 3.5H7.5a2 2 0 0 0-2 2v13a2 2 0 0 0 2 2h9a2 2 0 0 0 2-2V8zM14 3.5V8h4.5"/></svg>{{end}}
33{{/* A lookup under the Assistant's reply: its answer (lookupMarkdown: lists, bold and italics, never a link), then a quiet Sources line (copy ask.sources) with each source's title as a link opening in a new tab, and its host after it. The panel's script draws the same (ask.js, addLookup), and so does the app. */}}
34{{define "ask-lookup"}}<div class="lookup"><div class="lookup-answer">{{lookupAnswer .Answer}}</div><p class="lookup-sources"><span class="lookup-label">Sources</span>{{range .Sources}}<span class="source"><a href="{{.URL}}" target="_blank" rel="noopener noreferrer nofollow">{{or .Title (sourceHost .URL)}}</a><span class="source-host">{{sourceHost .URL}}</span></span>{{end}}</p></div>{{end}}
35{{define "ask-body"}}<div class="ask-note" data-when="connect"{{if not (.Shows "connect")}} hidden{{end}}>
36<p>Set up Ask Base to start asking.</p>
37<form method="post" action="/ask/connect"><input type="hidden" name="next" value="{{.Next}}"><button class="btn" type="submit">Set up Ask Base</button></form>
38</div>
39<div class="ask-note" data-when="pending"{{if not (.Shows "pending")}} hidden{{end}}>
40<p>You started setting up Ask Base. Approve it to start asking.</p>
41<a class="btn" href="/ask/connect?next={{.Next}}">Finish setting up</a>
42</div>
43<div class="ask-note" data-when="reconnect"{{if not (.Shows "reconnect")}} hidden{{end}}>
44<p>Ask Base needs setting up again.</p>
45<form method="post" action="/ask/connect"><input type="hidden" name="next" value="{{.Next}}"><button class="btn" type="submit">Set it up again</button></form>
46</div>
47<div class="ask-note" data-when="unavailable"{{if not (.Shows "unavailable")}} hidden{{end}}>
48<p>Ask Base isn't answering. Try again in a minute.</p>
49</div>
50<div class="ask-chat" data-when="ready norunner oldrunner"{{if not (.Shows "ready norunner oldrunner")}} hidden{{end}}>
51<div class="log"><ol class="thread" role="log" aria-label="Conversation"{{with .Zone}} data-zone="{{.}}"{{end}} data-mark="{{asset "static/oficina/equipo.svg"}}">
52{{range .Messages}}{{if eq .Role "person"}}<li class="msg person" data-id="{{.ID}}">{{with .Attachments}}{{template "ask-files" .}}{{end}}{{with .Text}}{{$.RichPerson .}}{{end}}</li>{{else}}<li class="msg coordinator" data-id="{{.ID}}">{{$.Rich .Text}}{{range .Lookups}}{{template "ask-lookup" .}}{{end}}{{range $.OffersAt .ID}}<div class="connect-offer" data-card="{{.ID}}" data-revision="{{.Revision}}">{{template "ask-offer" .}}</div>{{end}}</li>{{end}}
53{{end}}{{with .Notice}}<li class="ask-notice" data-after="{{$.NoticeAfter}}">{{.}}</li>
54{{end}}{{range .Jobs}}{{template "ask-job" .}}
55{{end}}{{range .LooseCards}}{{template "ask-card" .}}
56{{end}}{{range .LooseOffers}}<li class="connect-offer loose" data-card="{{.ID}}" data-revision="{{.Revision}}">{{template "ask-offer" .}}</li>
57{{end}}</ol>
58<button class="jump" type="button" hidden>Jump to latest</button></div>
59<p class="ask-empty" data-empty{{if or .Messages .Jobs .Cards .Unread .Notice}} hidden{{end}}>Ask about your work, or ask Base to get something done.</p>
60{{with .Problem}}<p class="ask-problem" role="alert">{{.}}</p>{{end}}
61{{/* Without a runner that can answer, the conversation shows and says so; what the person wrote stays in the field. */}}<p class="ask-problem ask-runner" data-when="norunner"{{if not (.Shows "norunner")}} hidden{{end}} role="alert">Ask Base isn't set up for you yet. <a href="{{.Equipo}}" target="_blank" rel="noopener">Finish setting it up</a>, then try again.</p>
62<p class="ask-problem ask-runner" data-when="oldrunner"{{if not (.Shows "oldrunner")}} hidden{{end}} role="alert">Ask Base needs an update first. <a href="{{.Equipo}}" target="_blank" rel="noopener">Update it</a>, then try again.</p>
63<div class="ask-foot">
64<p class="ask-status" role="status">{{.Status}}</p>
65</div>
66{{/* The composer: Send (an arrow) and, while a turn runs, Stop (a square) sit inside the field's end. Stop posts the cancel form beside it. Without scripts Send always shows; the panel's script hides it while the field is empty, and while a turn runs. Password managers are told it is no login (autocomplete off, and 1Password's, LastPass's and Dashlane's own marks); spell-check and the keyboard are untouched. */}}<form class="cancel" id="ask-cancel" method="post" action="{{with .Turn}}/ask/turns/{{.ID}}/cancel{{else}}/ask{{end}}"><input type="hidden" name="key" value="{{newKey}}"></form>
67{{/* The composer's words for files (copy review 13, pending) are on it as data-w-*, for ask-attach.js, which adds the paperclip, the chips and the viewer only with scripts, and only while the snapshot says can_attach (data-can-attach); data-attach is its module. */}}<form class="composer" method="post" action="/ask/messages" data-attach="{{asset "static/ask-attach.js"}}"{{if .CanAttach}} data-can-attach{{end}} data-w-attach="Attach files" data-w-drop="Drop files to attach them" data-w-uploading="Uploading…" data-w-remove="Remove {name}" data-w-failed="Couldn’t upload. Try again." data-w-too-many="You can attach up to 5 files to a message." data-w-pdf="Ask can’t read PDFs yet." data-w-unavailable="Files can’t be read right now. Remove them to send your message without them." data-w-stale="This file has expired. Attach it again." data-w-too-large="This file is over the 10 MB limit." data-w-type="Attach images (PNG, JPEG, WebP or GIF) or text, Markdown, CSV, JSON or PDF files." data-w-heic="HEIC photos can’t be read yet. Share it as a JPEG and try again." data-w-pixels="This image is too large. Use one no larger than 12,000 pixels on a side and 40 megapixels in all." data-w-limit="Too many files are waiting to send. Send or remove some first." data-w-busy="Too many uploads at once. Try again in a moment." data-w-attached="{name} attached" data-w-not-attached="{name} not attached: {reason}" data-w-files="Attached files" data-w-pill="{name}, {size}. Download" data-w-close="Close"><input type="hidden" name="key" value="{{.Key}}"><label class="sr-only" for="ask-text">Message</label><div class="field"><textarea class="input" id="ask-text" name="text" rows="1" required maxlength="16000" placeholder="Ask Base anything" autocomplete="off" data-1p-ignore data-lpignore="true" data-form-type="other">{{.Text}}</textarea><div class="actions"><button class="send" type="submit" aria-label="Send" title="Send"><svg viewBox="0 0 24 24" aria-hidden="true"><path d="M12 19V5M6 11l6-6 6 6"/></svg></button><button class="stop" type="submit" form="ask-cancel" aria-label="Stop" title="Stop"{{if not .Turn}} hidden{{end}}><svg viewBox="0 0 24 24" aria-hidden="true"><rect x="6.5" y="6.5" width="11" height="11" rx="2"/></svg></button></div></div></form>
68</div>{{end}}
69