Lindenii Project Forge
Login

server

Lindenii Forge’s main backend daemon
Commit info
ID
3a1f109493d6a0e2aa5480c5db3e065108574f5a
Author
Runxi Yu <me@runxiyu.org>
Author date
Tue, 01 Apr 2025 22:29:23 +0800
Committer
Runxi Yu <me@runxiyu.org>
Committer date
Tue, 01 Apr 2025 22:46:55 +0800
Actions
Change /: in templates

Probably more nasty ones to come
{{/*
	SPDX-License-Identifier: AGPL-3.0-only
	SPDX-FileCopyrightText: Copyright (c) 2025 Runxi Yu <https://runxiyu.org>
*/}}
{{- define "footer" -}}
<a href="https://lindenii.runxiyu.org/forge/">Lindenii Forge</a>
{{ .global.forge_version }}
(<a href="/:/source/source.tar.gz">source</a>,
<a href="https://forge.lindenii.runxiyu.org/forge/:/repos/server/">upstream</a>,
<a href="/:/source/LICENSE">license</a>)
(<a href="/-/source/source.tar.gz">source</a>,
<a href="https://forge.lindenii.runxiyu.org/forge/-/repos/server/">upstream</a>,
<a href="/-/source/LICENSE">license</a>)
{{- end -}}
{{/*
	SPDX-License-Identifier: AGPL-3.0-only
	SPDX-FileCopyrightText: Copyright (c) 2025 Runxi Yu <https://runxiyu.org>
*/}}
{{- define "group_view" -}}
{{- if .subgroups -}}
	<table class="wide">
		<thead>
			<tr>
				<th colspan="2" class="title-row">Subgroups</th>
			</tr>
			<tr>
				<th scope="col">Name</th>
				<th scope="col">Description</th>
			</tr>
		</thead>
		<tbody>
			{{- range .subgroups -}}
				<tr>
					<td>
						<a href="{{- .Name | path_escape -}}/">{{- .Name -}}</a>
					</td>
					<td>
						{{- .Description -}}
					</td>
				</tr>
			{{- end -}}
		</tbody>
	</table>
{{- end -}}
{{- if .repos -}}
<table class="wide">
	<thead>
		<tr>
			<th colspan="2" class="title-row">Repos</th>
			<tr>
				<th scope="col">Name</th>
				<th scope="col">Description</th>
			</tr>
		</tr>
	</thead>
	<tbody>
		{{- range .repos -}}
			<tr>
				<td>
					<a href=":/repos/{{- .Name | path_escape -}}/">{{- .Name -}}</a>
					<a href="-/repos/{{- .Name | path_escape -}}/">{{- .Name -}}</a>
				</td>
				<td>
					{{- .Description -}}
				</td>
			</tr>
		{{- end -}}
	</tbody>
</table>
{{- end -}}
{{- end -}}
{{/*
	SPDX-License-Identifier: AGPL-3.0-only
	SPDX-FileCopyrightText: Copyright (c) 2025 Runxi Yu <https://runxiyu.org>
*/}}
{{- define "header" -}}
<header id="main-header">
	<div id="main-header-forge-title">
		<a href="/">{{- .global.forge_title -}}</a>
	</div>
	<nav id="breadcrumb-nav">
		{{- $path := "" -}}
		{{- $url_segments := .url_segments -}}
		{{- $dir_mode := .dir_mode -}}
		{{- $ref_type := .ref_type -}}
		{{- $ref := .ref_name -}}
		{{- $separator_index := .separator_index -}}
		{{- if eq $separator_index -1 -}}
			{{- $separator_index = len $url_segments -}}
		{{- end -}}
		{{- range $i := $separator_index -}}
			{{- $segment := index $url_segments $i -}}
			{{- $path = printf "%s/%s" $path $segment -}}
			<span class="breadcrumb-separator">/</span>
			<a href="{{ $path }}{{ if or (ne $i (minus (len $url_segments) 1)) $dir_mode }}/{{ end }}{{- if $ref_type -}}?{{- $ref_type -}}={{- $ref -}}{{- end -}}">{{ $segment }}</a>
		{{- end -}}
	</nav>
	<div id="main-header-user">
		{{- if ne .user_id_string "" -}}
			<a href="/:/users/{{- .user_id_string -}}">{{- .username -}}</a>
			<a href="/-/users/{{- .user_id_string -}}">{{- .username -}}</a>
		{{- else -}}
			<a href="/:/login/">Login</a>
			<a href="/-/login/">Login</a>
		{{- end -}}
	</div>
</header>
{{- end -}}
{{/*
	SPDX-License-Identifier: AGPL-3.0-only
	SPDX-FileCopyrightText: Copyright (c) 2025 Runxi Yu <https://runxiyu.org>
*/}}
{{- define "index" -}}
<!DOCTYPE html>
<html lang="en">
	<head>
		{{- template "head_common" . -}}
		<title>Index &ndash; {{ .global.forge_title -}}</title>
	</head>
	<body class="index">
		{{- template "header" . -}}
		<div class="padding-wrapper">
			<table class="wide">
				<thead>
					<tr>
						<th colspan="2" class="title-row">Groups</th>
					</tr>
					<tr>
						<th scope="col">Name</th>
						<th scope="col">Description</th>
					</tr>
				</thead>
				<tbody>
					{{- range .groups -}}
						<tr>
							<td>
								<a href="{{- .Name | path_escape -}}/">{{- .Name -}}</a>
							</td>
							<td>
								{{- .Description -}}
							</td>
						</tr>
					{{- end -}}
				</tbody>
			</table>
			<table class="wide">
				<thead>
					<tr>
						<th colspan="2" class="title-row">
							Info
						</th>
					</tr>
				</thead>
				<tbody>
					<tr>
						<th scope="row">SSH public key</th>
						<td><code>{{- .global.server_public_key_string -}}</code></td>
					</tr>
					<tr>
						<th scope="row">SSH fingerprint</th>
						<td><code>{{- .global.server_public_key_fingerprint -}}</code></td>
					</tr>
					<tr>
						<th scope="row">Memory usage</th>
						<td>Allocated {{ .mem }} <a href="/:/gc/" class="btn btn-danger">Run the garbage collector</a></td>
						<td>Allocated {{ .mem }} <a href="/-/gc/" class="btn btn-danger">Run the garbage collector</a></td>
					</tr>
				</tbody>
			</table>
		</div>
		<footer>
			{{- template "footer" . -}}
		</footer>
	</body>
</html>
{{- end -}}
{{/*
	SPDX-License-Identifier: AGPL-3.0-only
	SPDX-FileCopyrightText: Copyright (c) 2025 Runxi Yu <https://runxiyu.org>
*/}}
{{- define "repo_tree_file" -}}
{{- $root := . -}}
<!DOCTYPE html>
<html lang="en">
	<head>
		{{- template "head_common" . -}}
		<link rel="stylesheet" href="/:/static/chroma.css" />
		<link rel="stylesheet" href="/-/static/chroma.css" />
		<title>/{{ .path_spec }} &ndash; {{ .repo_name }} &ndash; {{ template "group_path_plain" .group_path }} &ndash; {{ .global.forge_title -}}</title>
	</head>
	<body class="repo-tree-file">
		{{- template "header" . -}}
		<div class="repo-header">
			<h2>{{- .repo_name -}}</h2>
			<ul class="nav-tabs-standalone">
				<li class="nav-item">
					<a class="nav-link" href="../{{- template "ref_query" $root -}}">Summary</a>
				</li>
				<li class="nav-item">
					<a class="nav-link active" href="../tree/{{- template "ref_query" $root -}}">Tree</a>
				</li>
				<li class="nav-item">
					<a class="nav-link" href="../log/{{- template "ref_query" $root -}}">Log</a>
				</li>
				<li class="nav-item">
					<a class="nav-link" href="../branches/">Branches</a>
				</li>
				<li class="nav-item">
					<a class="nav-link" href="../tags/">Tags</a>
				</li>
				<li class="nav-item">
					<a class="nav-link" href="../contrib/">Merge requests</a>
				</li>
				<li class="nav-item">
					<a class="nav-link" href="../settings/">Settings</a>
				</li>
			</ul>
		</div>
		<div class="repo-header-extension">
			<div class="repo-header-extension-content">
				{{- .repo_description -}}
			</div>
		</div>
		<div class="padding">
			<p>
				/{{ .path_spec }} (<a href="/{{ template "group_path_plain" .group_path }}/:/repos/{{ .repo_name }}/raw/{{ .path_spec }}{{- template "ref_query" $root -}}">raw</a>)
				/{{ .path_spec }} (<a href="/{{ template "group_path_plain" .group_path }}/-/repos/{{ .repo_name }}/raw/{{ .path_spec }}{{- template "ref_query" $root -}}">raw</a>)
			</p>
			{{- .file_contents -}}
		</div>
		<footer>
			{{- template "footer" . -}}
		</footer>
	</body>
</html>
{{- end -}}