gitoria
All repositories: gitoria
3.8 KB
// components/repohead.hl — THE HEAD OF EVERY REPO VIEW (gitoria#16): the repo's name, description and the// nav (Readme · Code · Pull requests · Releases · Tickets · Settings), or "No such repository". Composed into each repo// page (readme, code, branch, commit, pulls, releases, tickets). The repo comes from the request's host// (`host = null`, hybriel#74) on the SERVER: this is in the first HTML and follows every hl:web navigation.import { repoAt, NL } from '../repos.hl'import { isEmptyNow } from '../git.hl'import { slugOfHost, publicUrl, hostOnly } from '../users.hl'import { sshEnabled, sshUrl } from '../sshkeys.hl'host = null// onCodePage (gitoria#20): only code.hl sets this true — the "Add code" help stands only on the Code page of an// empty repository, never on Readme / Pull requests / Releases / Tickets / Settings, and never once there is a commit.onCodePage = falseslug = slugOfHost(host)repo = repoAt(slug)hasRepo = repo != nullisMissing = repo == nullmainHref = publicUrl + '/'// HOW TO ADD CODE (gitoria#7, gitoria#20): the clone address and the exact git commands, for a new folder and for an// existing one; plain text on the Code page while nothing is pushed yet. The password is an access token (main page).cloneUrl = repo != null ? repo.address + repo.slug + '.git' : ''tokensHref = publicUrl + '/#tokens'sshKeysHref = publicUrl + '/#sshkeys'emptyRepo = repo != null && isEmptyNow(slug)showAddCode = onCodePage && emptyReponewCommands = 'echo "# ' + slug + '" >> README.md' + NL + 'git init -b main' + NL + 'git add README.md' + NL + 'git commit -m "first commit"' + NL + 'git remote add origin ' + cloneUrl + NL + 'git push -u origin main'existingCommands = 'git remote add origin ' + cloneUrl + NL + 'git branch -M main' + NL + 'git push -u origin main'cloneCommand = 'git clone ' + cloneUrl// SSH (only when the sshd container is set up, sshkeys.hl): the same commands with the ssh address; the key comes from the main pageshowSsh = sshEnabled && repo != nullsshAddress = repo != null ? sshUrl(hostOnly, repo.slug) : ''sshCloneCommand = 'git clone ' + sshAddresssshCommands = 'git remote add origin ' + sshAddress + NL + 'git push -u origin main'View {repoHead {if (hasRepo) {h1 { id = "reponame" repo.slug }if (repo.described) { p { id = "repodescription" repo.description } }p { class = "muted" "All repositories: " a { id = "toall" href = mainHref "gitoria" } }repoNav { id = "reponav"a { id = "navhome" href = "/" "Readme" }a { id = "navcode" href = "/code" "Code" }a { id = "navpulls" href = "/pulls" "Pull requests" }a { id = "navreleases" href = "/releases" "Releases" }a { id = "navtickets" href = "/tickets" "Tickets" }a { id = "navsettings" href = "/settings" "Settings" }}}if (showAddCode) {addCode { id = "addcode"h2 { "Add code to this repository" }h2 { "Clone it" }pre { id = "clonecommand" cloneCommand }h2 { "Push a new project" }pre { id = "newcommands" newCommands }h2 { "Push an existing project" }pre { id = "existingcommands" existingCommands }if (showSsh) {h2 { "Or over SSH" }pre { id = "sshclonecommand" sshCloneCommand }pre { id = "sshcommands" sshCommands }p { class = "muted" "Add your public key under " a { id = "tosshkeys" href = sshKeysHref "SSH keys" } " on the main page after you log in; only the owner can push." }}p { class = "muted" "Reading needs no login. To push you must be the owner of this repository: git asks for a user name (anything) and a password — that is an access token, made under " a { id = "totokens" href = tokensHref "Access tokens" } " on the main page after you log in." }}}if (isMissing) {h1 { id = "missing" "No such repository" }p { class = "muted" "Nobody has created this address yet. " a { id = "toall" href = mainHref "All repositories" } }}}}
Branches
- mainmain branch