gitoria
All repositories: gitoria
9.9 KB
// components/codebrowser.hl — THE CODE BROWSER (ticket #9, gitoria#16), composed into the three code pages:// code.hl (/code, /code/<path>: the main branch), branch.hl (/branch/<name>[/<path>]), commit.hl// (/commit/<id>[/<path>]); `kind` ('code' | 'branch' | 'commit') and `rest` (the part after /<kind>/) come from the// page. Rendered on the SERVER with its content: the repo from the request's host, the tree / file / branches /// commits from git (lib/code.hl browseNow — hl:proc run() waits, hybriel#80) — in the first HTML and in every hl:web navigation.import { slugOfRequest } from '../lib/orgs.hl'import { userOfSession } from '../lib/users.hl'import { repoAt, ownsRepo } from '../lib/repos.hl'import { browseNow, makeMain } from '../lib/code.hl'import { withRefParts } from '../lib/tickets-helpers.hl'host = nullorepo = ''session = nullkind = 'code'rest = ''slug = slugOfRequest(host, orepo)repo = repoAt(slug, session)hasRepo = repo != nullcodeData = repo != null ? withRefParts(browseNow(slug, kind, rest, repo.branch, ownsRepo(slug, session)), repo.ticketsProject) : nullcodeShown = codeData != null && !codeData.isMessagecodeMessage = codeData != null && codeData.isMessagecodeText = codeData != null && codeData.isMessage ? codeData.message : ''codeError = ''View {codeView {if (hasRepo) {if (codeMessage) { p { id = "codemessage" class = "empty" codeText } }if (codeShown) {codeBrowser {codeHead {span { id = "codekind" class = "muted" codeData.kindLabel }strong { id = "coderef" codeData.refLabel }latestCommit {a { id = "commitlink" href = codeData.commitHref codeData.short }span { id = "commitsubject" for (pt of codeData.subjectParts) { if (pt.isText) { span { pt.text } } if (pt.isLink) { a { class = "ticketref" href = pt.href pt.text } } } }span { class = "muted" codeData.author }time { codeData.date }}}pathCrumbs { id = "crumbs" class = "crumbs"for (c of codeData.crumbs) {if (c.linked) { a { href = c.href c.name } span { class = "muted" "/" } }if (c.last) { strong { c.name } }}}if (codeData.isTree) {if (codeData.noEntries) { p { id = "noentries" class = "empty" "This folder is empty." } }ul { id = "entries"for (e of codeData.entries) {li {if (e.isDir) { a { class = "dir" href = e.href e.name } }if (e.isFile) { a { class = "file" href = e.href e.name } }if (e.isOther) { span { class = "file" e.name } }span { class = "muted" e.size }}}}}if (codeData.isFile) {codeFile { id = "codefile"p { class = "muted" codeData.fileSize }if (codeData.binary) { p { id = "binary" class = "empty" "This file is not text (or not UTF-8) — not shown." } }if (codeData.tooBig) { p { id = "toobig" class = "empty" "This file is too large to show here." } }ol { id = "lines"for (ln of codeData.lines) { li { code { ln.text } } }}if (codeData.truncated) { p { id = "linestruncated" class = "muted" "Only the first lines are shown." } }}}codeSide {section { id = "branches"h2 { "Branches" }ul {for (b of codeData.branches) {li {if (b.isCurrent) { strong { b.name } }if (b.notCurrent) { a { href = b.href b.name } }if (b.isDefault) { span { class = "muted" "main branch" } }if (b.canSet) { button { class = "quiet setmain" type = "button" value = b.name "Make main" on click(e) { emit setMain(e.target.value) } } }}}}p { id = "codeerror" class = "message" codeError }}section { id = "commits"h2 { "Latest commits" }ul {for (c of codeData.commits) {li {a { href = c.href c.short }span { for (pt of c.parts) { if (pt.isText) { span { pt.text } } if (pt.isLink) { a { class = "ticketref" href = pt.href pt.text } } } }span { class = "muted" c.author }time { c.date }}}}}}}}}}}// "Make main" (the owner): the face answers with the same view, read again with the new main branchon setMain(name) {codeError = ''r = emit server gitoriaSetBranch(slug, name, kind, rest)if (r == null || r.error != null) {codeError = r != null ? r.error : 'could not change the main branch'return null}codeData = r.resultcodeShown = !r.result.isMessagecodeMessage = r.result.isMessagecodeText = r.result.isMessage ? r.result.message : ''}on server gitoriaSetBranch(slugOf, name, kindOf, restOf, session) {if (session == null || repoAt(slugOf, session) == null) { return { error = 'could not change the main branch' } }if (kindOf != 'code' && kindOf != 'branch' && kindOf != 'commit') { return { error = 'could not change the main branch' } }if (restOf == null || hlTypeName(restOf) != 'String' || restOf.length > 500 || name == null || hlTypeName(name) != 'String') { return { error = 'could not change the main branch' } }u = userOfSession(session)if (u == null || !ownsRepo(slugOf, session)) { return { error = 'only the owner can change the main branch' } }return makeMain(u.id, slugOf, name, kindOf, restOf)}Style {codeView {display = 'grid'gap = '1rem'minWidth = '0''> *' {margin = '0'}}codeBrowser {display = 'grid'gap = '1rem'minWidth = '0''> *' {margin = '0'}}codeHead {display = 'grid'gap = '.3rem'minWidth = '0''> *' {margin = '0'}}codeFile {display = 'grid'gap = '.5rem'minWidth = '0''> *' {margin = '0'}}codeSide {display = 'grid'gap = '1rem'minWidth = '0'section {display = 'grid'gap = '.4rem'minWidth = '0''> *' {margin = '0'}}li {display = 'flex'flexWrap = 'wrap'alignItems = 'center'gap = '0 .8rem'margin = '0'padding = '0 .5rem'overflowWrap = 'anywhere'borderRadius = 'var(--radius-small)''> a:first-child' {font = '.9em/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace'}'> a' {display = 'inline-flex'alignItems = 'center'minWidth = '2.75rem'minHeight = '2.75rem'}'> strong' {display = 'inline-flex'alignItems = 'center'minWidth = '2.75rem'minHeight = '2.75rem'}}ul {display = 'grid'margin = '0'padding = '0'listStyle = 'none'}h2 {fontSize = '1.05rem'}'li:nth-child(odd)' {background = 'var(--color-background-sunken)'}}latestCommit {display = 'flex'flexWrap = 'wrap'gap = '0 .8rem'alignItems = 'center'minWidth = '0'padding = '.1rem .8rem .4rem'background = 'var(--color-surface)'borderRadius = 'var(--radius-large)''> a' {display = 'inline-flex'alignItems = 'center'minHeight = '2.75rem'}a {font = '.9em/1.4 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace'}'> a:first-child' {order = '1'}'> time' {order = '2'marginLeft = 'auto'}'> span:nth-child(2)' {order = '3'flex = '1 1 100%'minWidth = '0'paddingBlock = '.1rem'}'> span.muted' {order = '4'flex = '1 1 100%'fontSize = '.875rem'}}'path-crumbs:has(> strong:only-child)' {display = 'none'}#commits {li {'> a:first-child' {order = '1'}'> time' {order = '2'marginLeft = 'auto'}'> span:nth-child(2)' {order = '3'flex = '1 1 100%'minWidth = '0'paddingBlock = '.1rem'}'> span.muted' {order = '4'flex = '1 1 100%'fontSize = '.875rem'}}}pathCrumbs {display = 'flex'flexWrap = 'wrap'alignItems = 'center'gap = '0 .1rem'minWidth = '0'overflowWrap = 'anywhere'a {display = 'inline-flex'alignItems = 'center'justifyContent = 'center'minWidth = '2.75rem'minHeight = '2.75rem'padding = '0 .4rem'borderRadius = 'var(--radius-small)'hover {background = 'var(--color-surface)'}}}#entries {display = 'grid'margin = '0'padding = '0'listStyle = 'none'li {display = 'flex'alignItems = 'center'justifyContent = 'space-between'gap = '1rem'margin = '0'paddingRight = '.8rem'borderRadius = 'var(--radius-small)''> a' {flex = '1 1 auto'display = 'flex'alignItems = 'center'minWidth = '0'minHeight = '2.75rem'padding = '0 .8rem'overflowWrap = 'anywhere'}'> span.file' {flex = '1 1 auto'display = 'flex'alignItems = 'center'minWidth = '0'minHeight = '2.75rem'padding = '0 .8rem'overflowWrap = 'anywhere'}'> span.muted' {flex = 'none'whiteSpace = 'nowrap'fontSize = '.875rem'}}'li:nth-child(odd)' {background = 'var(--color-background-sunken)'}'a.dir' {fontWeight = '700'}'a.dir::after' {content = '"/"'}}#lines {margin = '0'padding = '.5rem 0'overflowX = 'auto'listStyle = 'none'counterReset = 'line'background = 'var(--color-background-sunken)'borderRadius = 'var(--radius-large)'font = '.875rem/1.5 ui-monospace, SFMono-Regular, Menlo, Consolas, monospace'li {counterIncrement = 'line'whiteSpace = 'pre'minHeight = '1.5em'margin = '0'padding = '0 .8rem 0 0'width = 'max-content'minWidth = '100%'}'li::before' {content = 'counter(line)'display = 'inline-block'width = '4ch'marginRight = '.8rem'paddingLeft = '.5rem'boxSizing = 'content-box'textAlign = 'right'color = 'var(--color-text-muted)'userSelect = 'none'}code {padding = '0'font = 'inherit'color = 'var(--color-text-strong)'background = 'transparent'}}@media {minWidth = '60rem'codeBrowser {gridTemplateColumns = 'minmax(0, 1fr) 18rem'alignItems = 'start'columnGap = '2rem''> *' {gridColumn = '1'}'> code-side' {gridColumn = '2'gridRow = '1 / span 4'}}}}
Branches
Latest commits
- 20fe13fagitoria#33: centralize login and tickets connection statemre
- 859754c0gitoria#29: retain the offline note and record the framework gapmre
- d140bc04gitoria#30: reproduce the upsert ordering constraintmre
- 6960e8f8gitoria#28: keep form values in bound component membersmre
- 0db27200gitoria#32: share character checks and environment lookupmre
- 452f6a1amission W60: logic clean-upsmre
- 1448c899log: cleanup, #49 GPTBot, tracker mentions on #36mre
- fcf95936log: v1.5.1 provenmre
- 22105420log: W51b livemre
- 7e8aabeareport: W51b pull source verificationmre
- 6c18de76fix: preserve pull sources across containing branchesmre
- fc36fa2elog: W51b pull source bugmre
- 56bc1220log: v1.5.1 livemre
- 845fc0aareport: W51mre
- 83127391fix: return v1.5.1 app and merge error detailsmre
- b07d0e97log: W51 v1.5.1 startedmre
- 0b417d06docs: apps-api v1.5 user tokens (#48, W49)mre
- d046940alog: vinzenz contract note sentmre
- db443456log: vinzenz note retry 2mre
- 802f229alog: kunibert repo ping provenmre