aboutsummaryrefslogtreecommitdiff
path: root/templates
diff options
context:
space:
mode:
authorRunxi Yu <me@runxiyu.org>2024-07-27 08:00:00 +0800
committerRunxi Yu <me@runxiyu.org>2024-07-27 08:00:00 +0800
commit7386392b8cd08e73e4f5fa6080e8f4fcf20831f6 (patch)
tree73330ee296f398b7720312a942bc9d524ece9857 /templates
parenttemplates/file.html: Remove line numbers (diff)
downloadlegitrx-7386392b8cd08e73e4f5fa6080e8f4fcf20831f6.tar.gz
legitrx-7386392b8cd08e73e4f5fa6080e8f4fcf20831f6.tar.zst
legitrx-7386392b8cd08e73e4f5fa6080e8f4fcf20831f6.zip
Some more HTML sanities
Diffstat (limited to 'templates')
-rw-r--r--templates/404.html8
-rw-r--r--templates/500.html4
-rw-r--r--templates/commit.html185
-rw-r--r--templates/file.html4
-rw-r--r--templates/head.html38
-rw-r--r--templates/index.html9
-rw-r--r--templates/log.html21
-rw-r--r--templates/nav.html14
-rw-r--r--templates/refs.html35
-rw-r--r--templates/repo-header.html5
-rw-r--r--templates/repo.html36
-rw-r--r--templates/tree.html55
12 files changed, 199 insertions, 215 deletions
diff --git a/templates/404.html b/templates/404.html
index dd8c813..3a68101 100644
--- a/templates/404.html
+++ b/templates/404.html
@@ -4,10 +4,10 @@
<title>404 Not Found</title>
{{ template "head" . }}
<body>
- {{ template "nav" . }}
- <main>
- <h1>404 Not Found</h1>
- </main>
+ {{ template "nav" . }}
+ <main>
+ <h1>404 Not Found</h1>
+ </main>
</body>
</html>
{{ end }}
diff --git a/templates/500.html b/templates/500.html
index 6217541..77bb9ab 100644
--- a/templates/500.html
+++ b/templates/500.html
@@ -1,12 +1,12 @@
{{ define "500" }}
<!DOCTYPE html>
<html>
- <title>500</title>
+ <title>500 Internal Server Error</title>
{{ template "head" . }}
<body>
{{ template "nav" . }}
<main>
- <h3>500 &mdash; something broke!</h3>
+ <h1>500 Internal Server Error</h1>
</main>
</body>
</html>
diff --git a/templates/commit.html b/templates/commit.html
index c592523..c556fa8 100644
--- a/templates/commit.html
+++ b/templates/commit.html
@@ -1,105 +1,106 @@
{{ define "commit" }}
<!DOCTYPE html>
<html>
-{{ template "head" . }}
-{{ template "repoheader" . }}
-<body>
- {{ template "nav" . }}
- <main>
- <section class="commit">
- <pre>{{- .commit.Message -}}</pre>
- <div class="commit-info">
- {{ .commit.Author.Name }} <a href="mailto:{{ .commit.Author.Email }}" class="commit-email">{{ .commit.Author.Email}}</a>
- <div>{{ .commit.Author.When.Format "Mon, 02 Jan 2006 15:04:05 -0700" }}</div>
- </div>
-
- <div>
- <strong>commit</strong>
- <p>
- <a href="/{{ .name }}/commit/{{ .commit.This }}" class="commit-hash">
- {{ .commit.This }}
- </a>
- </p>
- </div>
-
- {{ if .commit.Parent }}
- <div>
- <strong>parent</strong>
- <p>
- <a href="/{{ .name }}/commit/{{ .commit.Parent }}" class="commit-hash">
- {{ .commit.Parent }}
- </a>
- </p>
- </div>
- {{ end }}
-
- <div class="diff-stat">
- <div>
- {{ .stat.FilesChanged }} files changed,
- {{ .stat.Insertions }} insertions(+),
- {{ .stat.Deletions }} deletions(-)
+ {{ template "head" . }}
+ <body>
+ {{ template "repoheader" . }}
+ {{ template "nav" . }}
+ <main>
+ <section class="commit">
+ <pre>{{- .commit.Message -}}</pre>
+ <div class="commit-info">
+ {{ .commit.Author.Name }}
+ <a href="mailto:{{ .commit.Author.Email }}" class="commit-email">{{ .commit.Author.Email }}</a>
+ <div>{{ .commit.Author.When.Format "Mon, 02 Jan 2006 15:04:05 -0700" }}</div>
</div>
+
<div>
- <br />
- <strong>jump to</strong>
- {{ range .diff }}
- <ul>
- <li><a href="#{{ .Name.New }}">{{ .Name.New }}</a></li>
- </ul>
- {{ end }}
+ <strong>commit</strong>
+ <p>
+ <a href="/{{ .name }}/commit/{{ .commit.This }}" class="commit-hash">
+ {{ .commit.This }}
+ </a>
+ </p>
+ </div>
+
+ {{ if .commit.Parent }}
+ <div>
+ <strong>parent</strong>
+ <p>
+ <a href="/{{ .name }}/commit/{{ .commit.Parent }}" class="commit-hash">
+ {{ .commit.Parent }}
+ </a>
+ </p>
+ </div>
+ {{ end }}
+
+ <div class="diff-stat">
+ <div>
+ {{ .stat.FilesChanged }} files changed,
+ {{ .stat.Insertions }} insertions(+),
+ {{ .stat.Deletions }} deletions(-)
+ </div>
+ <div>
+ <br />
+ <strong>Jump to:</strong>
+ {{ range .diff }}
+ <ul>
+ <li><a href="#{{ .Name.New }}">{{ .Name.New }}</a></li>
+ </ul>
+ {{ end }}
+ </div>
</div>
- </div>
- </section>
- <section>
- {{ $repo := .name }}
- {{ $this := .commit.This }}
- {{ $parent := .commit.Parent }}
- {{ range .diff }}
+ </section>
+ <section>
+ {{ $repo := .name }}
+ {{ $this := .commit.This }}
+ {{ $parent := .commit.Parent }}
+ {{ range .diff }}
<div id="{{ .Name.New }}">
<div class="diff">
- {{ if .IsNew }}
- <span class="diff-type">A</span>
- {{ end }}
- {{ if .IsDelete }}
- <span class="diff-type">D</span>
- {{ end }}
- {{ if not (or .IsNew .IsDelete) }}
- <span class="diff-type">M</span>
- {{ end }}
- {{ if .Name.Old }}
- <a href="/{{ $repo }}/blob/{{ $parent }}/{{ .Name.Old }}">{{ .Name.Old }}</a>
- {{ if .Name.New }}
- &#8594;
- <a href="/{{ $repo }}/blob/{{ $this }}/{{ .Name.New }}">{{ .Name.New }}</a>
- {{ end }}
- {{ else }}
- <a href="/{{ $repo }}/blob/{{ $this }}/{{ .Name.New }}">{{ .Name.New }}</a>
- {{- end -}}
- {{ if .IsBinary }}
- <p>Not showing binary file.</p>
- {{ else }}
- <pre>
- {{- range .TextFragments -}}
- <p>{{- .Header -}}</p>
- {{- range .Lines -}}
- {{- if eq .Op.String "+" -}}
- <span class="diff-add">{{ .String }}</span>
+ {{ if .IsNew }}
+ <span class="diff-type">A</span>
+ {{ end }}
+ {{ if .IsDelete }}
+ <span class="diff-type">D</span>
+ {{ end }}
+ {{ if not (or .IsNew .IsDelete) }}
+ <span class="diff-type">M</span>
+ {{ end }}
+ {{ if .Name.Old }}
+ <a href="/{{ $repo }}/blob/{{ $parent }}/{{ .Name.Old }}">{{ .Name.Old }}</a>
+ {{ if .Name.New }}
+ &#8594;
+ <a href="/{{ $repo }}/blob/{{ $this }}/{{ .Name.New }}">{{ .Name.New }}</a>
+ {{ end }}
+ {{ else }}
+ <a href="/{{ $repo }}/blob/{{ $this }}/{{ .Name.New }}">{{ .Name.New }}</a>
{{- end -}}
- {{- if eq .Op.String "-" -}}
- <span class="diff-del">{{ .String }}</span>
+ {{ if .IsBinary }}
+ <p>Not showing binary file.</p>
+ {{ else }}
+ <pre>
+ {{- range .TextFragments -}}
+ <p>{{- .Header -}}</p>
+ {{- range .Lines -}}
+ {{- if eq .Op.String "+" -}}
+ <span class="diff-add">{{ .String }}</span>
+ {{- end -}}
+ {{- if eq .Op.String "-" -}}
+ <span class="diff-del">{{ .String }}</span>
+ {{- end -}}
+ {{- if eq .Op.String " " -}}
+ <span class="diff-noop">{{ .String }}</span>
+ {{- end -}}
+ {{- end -}}
+ {{- end -}}
+ </pre>
{{- end -}}
- {{- if eq .Op.String " " -}}
- <span class="diff-noop">{{ .String }}</span>
- {{- end -}}
- {{- end -}}
- {{- end -}}
- {{- end -}}
- </pre>
- </div>
+ </div>
</div>
- {{ end }}
- </section>
- </main>
-</body>
+ {{ end }}
+ </section>
+ </main>
+ </body>
</html>
{{ end }}
diff --git a/templates/file.html b/templates/file.html
index 758f68a..7dd5b86 100644
--- a/templates/file.html
+++ b/templates/file.html
@@ -2,13 +2,13 @@
<!DOCTYPE html>
<html>
{{ template "head" . }}
- {{ template "repoheader" . }}
<body>
+ {{ template "repoheader" . }}
{{ template "nav" . }}
<main>
<p>{{ .path }} (<a style="color: gray" href="?raw=true">view raw</a>)</p>
<div class="file-wrapper">
- <pre>{{- .content -}}</pre>
+ <pre>{{- .content -}}</pre>
</div>
</main>
</body>
diff --git a/templates/head.html b/templates/head.html
index b5be55d..f2a3bda 100644
--- a/templates/head.html
+++ b/templates/head.html
@@ -1,32 +1,30 @@
{{ define "head" }}
- <head>
- <meta charset="utf-8">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <link rel="stylesheet" href="/static/style.css" type="text/css">
- <link rel="icon" type="image/png" size="32x32" href="/static/legit.png">
- {{ if .parent }}
+<head>
+ <meta charset="utf-8" />
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
+ <link rel="stylesheet" href="/static/style.css" type="text/css" />
+ <link rel="icon" type="image/png" size="32x32" href="/static/legit.png" />
+ {{ if .parent }}
<title>{{ .meta.Title }} &mdash; {{ .name }} ({{ .ref }}): {{ .parent }}/</title>
-
- {{ else if .path }}
+ {{ else if .path }}
<title>{{ .meta.Title }} &mdash; {{ .name }} ({{ .ref }}): {{ .path }}</title>
- {{ else if .files }}
+ {{ else if .files }}
<title>{{ .meta.Title }} &mdash; {{ .name }} ({{ .ref }})</title>
- {{ else if .commit }}
+ {{ else if .commit }}
<title>{{ .meta.Title }} &mdash; {{ .name }}: {{ .commit.This }}</title>
- {{ else if .branches }}
+ {{ else if .branches }}
<title>{{ .meta.Title }} &mdash; {{ .name }}: refs</title>
- {{ else if .commits }}
+ {{ else if .commits }}
{{ if .log }}
- <title>{{ .meta.Title }} &mdash; {{ .name }}: log</title>
+ <title>{{ .meta.Title }} &mdash; {{ .name }}: log</title>
{{ else }}
- <title>{{ .meta.Title }} &mdash; {{ .name }}</title>
+ <title>{{ .meta.Title }} &mdash; {{ .name }}</title>
{{ end }}
- {{ else }}
+ {{ else }}
<title>{{ .meta.Title }}</title>
- {{ end }}
- {{ if and .servername .gomod }}
+ {{ end }}
+ {{ if and .servername .gomod }}
<meta name="go-import" content="{{ .servername}}/{{ .name }} git https://{{ .servername }}/{{ .name }}">
- {{ end }}
- <!-- other meta tags here -->
- </head>
+ {{ end }}
+</head>
{{ end }}
diff --git a/templates/index.html b/templates/index.html
index 52830d9..f803942 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -2,12 +2,11 @@
<!DOCTYPE html>
<html>
{{ template "head" . }}
-
- <header>
- <h1>{{ .meta.Title }}</h1>
- <h2>{{ .meta.Description }}</h2>
- </header>
<body>
+ <header>
+ <h1>{{ .meta.Title }}</h1>
+ <h2>{{ .meta.Description }}</h2>
+ </header>
<main>
<div class="index">
{{ range .info }}
diff --git a/templates/log.html b/templates/log.html
index 4312d66..f4d15c7 100644
--- a/templates/log.html
+++ b/templates/log.html
@@ -1,23 +1,22 @@
{{ define "log" }}
<!DOCTYPE html>
<html>
-{{ template "head" . }}
-
- {{ template "repoheader" . }}
+ {{ template "head" . }}
<body>
+ {{ template "repoheader" . }}
{{ template "nav" . }}
<main>
{{ $repo := .name }}
<div class="log">
{{ range .commits }}
- <div>
- <div><a href="/{{ $repo }}/commit/{{ .Hash.String }}" class="commit-hash">{{ slice .Hash.String 0 8 }}</a></div>
- <pre>{{ .Message }}</pre>
- </div>
- <div class="commit-info">
- {{ .Author.Name }} <a href="mailto:{{ .Author.Email }}" class="commit-email">{{ .Author.Email }}</a>
- <div>{{ .Author.When.Format "Mon, 02 Jan 2006 15:04:05 -0700" }}</div>
- </div>
+ <div>
+ <div><a href="/{{ $repo }}/commit/{{ .Hash.String }}" class="commit-hash">{{ slice .Hash.String 0 8 }}</a></div>
+ <pre>{{ .Message }}</pre>
+ </div>
+ <div class="commit-info">
+ {{ .Author.Name }} <a href="mailto:{{ .Author.Email }}" class="commit-email">{{ .Author.Email }}</a>
+ <div>{{ .Author.When.Format "Mon, 02 Jan 2006 15:04:05 -0700" }}</div>
+ </div>
{{ end }}
</div>
</main>
diff --git a/templates/nav.html b/templates/nav.html
index 3d40495..51a1e92 100644
--- a/templates/nav.html
+++ b/templates/nav.html
@@ -1,14 +1,14 @@
{{ define "nav" }}
- <nav>
- <ul>
- {{ if .name }}
+<nav>
+ <ul>
+ {{ if .name }}
<li><a href="/{{ .name }}">summary</a>
<li><a href="/{{ .name }}/refs">refs</a>
- {{ if .ref }}
+ {{ if .ref }}
<li><a href="/{{ .name }}/tree/{{ .ref }}/">tree</a>
<li><a href="/{{ .name }}/log/{{ .ref }}">log</a>
- {{ end }}
{{ end }}
- </ul>
- </nav>
+ {{ end }}
+ </ul>
+</nav>
{{ end }}
diff --git a/templates/refs.html b/templates/refs.html
index f121d3e..0138791 100644
--- a/templates/refs.html
+++ b/templates/refs.html
@@ -1,14 +1,13 @@
{{ define "refs" }}
<!DOCTYPE html>
<html>
-{{ template "head" . }}
-
- {{ template "repoheader" . }}
+ {{ template "head" . }}
<body>
+ {{ template "repoheader" . }}
{{ template "nav" . }}
<main>
{{ $name := .name }}
- <h3>branches</h3>
+ <h3>Branches</h3>
<div class="refs">
{{ range .branches }}
<div>
@@ -20,20 +19,20 @@
{{ end }}
</div>
{{ if .tags }}
- <h3>tags</h3>
- <div class="refs">
- {{ range .tags }}
- <div>
- <strong>{{ .Name }}</strong>
- <a href="/{{ $name }}/tree/{{ .Name }}/">browse</a>
- <a href="/{{ $name }}/log/{{ .Name }}">log</a>
- <a href="/{{ $name }}/archive/{{ .Name }}.tar.gz">tar.gz</a>
- {{ if .Message }}
- <pre>{{ .Message }}</pre>
- </div>
- {{ end }}
- {{ end }}
- </div>
+ <h3>Tags</h3>
+ <div class="refs">
+ {{ range .tags }}
+ <div>
+ <strong>{{ .Name }}</strong>
+ <a href="/{{ $name }}/tree/{{ .Name }}/">browse</a>
+ <a href="/{{ $name }}/log/{{ .Name }}">log</a>
+ <a href="/{{ $name }}/archive/{{ .Name }}.tar.gz">tar.gz</a>
+ {{ if .Message }}
+ <pre>{{ .Message }}</pre>
+ </div>
+ {{ end }}
+ {{ end }}
+ </div>
{{ end }}
</main>
</body>
diff --git a/templates/repo-header.html b/templates/repo-header.html
index e0b293a..7be2d65 100644
--- a/templates/repo-header.html
+++ b/templates/repo-header.html
@@ -1,10 +1,9 @@
{{ define "repoheader" }}
<header>
<h2>
- <a href="/">all repos</a>
- &mdash; {{ .displayname }}
+ <a href="/">all repos</a> &mdash; {{ .displayname }}
{{ if .ref }}
- <span class="ref">@ {{ .ref }}</span>
+ <span class="ref">@ {{ .ref }}</span>
{{ end }}
</h2>
<h3 class="desc">{{ .desc }}</h3>
diff --git a/templates/repo.html b/templates/repo.html
index a9f4a49..6bcc294 100644
--- a/templates/repo.html
+++ b/templates/repo.html
@@ -1,37 +1,33 @@
{{ define "repo" }}
<!DOCTYPE html>
<html>
-{{ template "head" . }}
-
-{{ template "repoheader" . }}
-
+ {{ template "head" . }}
<body>
+ {{ template "repoheader" . }}
{{ template "nav" . }}
<main>
{{ $repo := .name }}
<div class="log">
{{ range .commits }}
- <div>
- <div><a href="/{{ $repo }}/commit/{{ .Hash.String }}" class="commit-hash">{{ slice .Hash.String 0 8 }}</a></div>
- <pre>{{ .Message }}</pre>
- </div>
- <div class="commit-info">
- {{ .Author.Name }} <a href="mailto:{{ .Author.Email }}" class="commit-email">{{ .Author.Email }}</a>
- <div>{{ .Author.When.Format "Mon, 02 Jan 2006 15:04:05 -0700" }}</div>
- </div>
+ <div>
+ <div><a href="/{{ $repo }}/commit/{{ .Hash.String }}" class="commit-hash">{{ slice .Hash.String 0 8 }}</a></div>
+ <pre>{{ .Message }}</pre>
+ </div>
+ <div class="commit-info">
+ {{ .Author.Name }} <a href="mailto:{{ .Author.Email }}" class="commit-email">{{ .Author.Email }}</a>
+ <div>{{ .Author.When.Format "Mon, 02 Jan 2006 15:04:05 -0700" }}</div>
+ </div>
{{ end }}
</div>
-{{- if .readme }}
- <article class="readme">
- {{- .readme -}}
- </article>
-{{- end -}}
+ {{- if .readme }}
+ <article class="readme">
+ {{- .readme -}}
+ </article>
+ {{- end -}}
<div class="clone-url">
<strong>clone</strong>
- <pre>
-git clone https://{{ .servername }}/{{ .name }}
- </pre>
+ <pre>git clone https://{{ .servername }}/{{ .name }}</pre>
</div>
</main>
</body>
diff --git a/templates/tree.html b/templates/tree.html
index 6e48dc1..6634a5c 100644
--- a/templates/tree.html
+++ b/templates/tree.html
@@ -1,54 +1,47 @@
{{ define "tree" }}
<!DOCTYPE html>
<html>
-
-{{ template "head" . }}
-
- {{ template "repoheader" . }}
+ {{ template "head" . }}
<body>
+ {{ template "repoheader" . }}
{{ template "nav" . }}
<main>
{{ $repo := .name }}
{{ $ref := .ref }}
{{ $parent := .parent }}
-
<div class="tree">
{{ if $parent }}
- <div></div>
- <div></div>
- <div><a href="/{{ $repo }}/tree/{{ $ref }}/{{ .dotdot }}">..</a></div>
+ <div><a href="/{{ $repo }}/tree/{{ $ref }}/{{ .dotdot }}">..</a></div>
{{ end }}
{{ range .files }}
- {{ if not .IsFile }}
- <div class="mode">{{ .Mode }}</div>
- <div class="size">{{ .Size }}</div>
- <div>
- {{ if $parent }}
- <a href="/{{ $repo }}/tree/{{ $ref }}/{{ $parent }}/{{ .Name }}">{{ .Name }}/</a>
- {{ else }}
- <a href="/{{ $repo }}/tree/{{ $ref }}/{{ .Name }}">{{ .Name }}/</a>
+ {{ if not .IsFile }}
+ <div class="mode">{{ .Mode }}</div>
+ <div class="size">{{ .Size }}</div>
+ <div>
+ {{ if $parent }}
+ <a href="/{{ $repo }}/tree/{{ $ref }}/{{ $parent }}/{{ .Name }}">{{ .Name }}/</a>
+ {{ else }}
+ <a href="/{{ $repo }}/tree/{{ $ref }}/{{ .Name }}">{{ .Name }}/</a>
+ {{ end }}
+ </div>
{{ end }}
- </div>
- {{ end }}
{{ end }}
{{ range .files }}
- {{ if .IsFile }}
- <div class="mode">{{ .Mode }}</div>
- <div class="size">{{ .Size }}</div>
- <div>
- {{ if $parent }}
- <a href="/{{ $repo }}/blob/{{ $ref }}/{{ $parent }}/{{ .Name }}">{{ .Name }}</a>
- {{ else }}
- <a href="/{{ $repo }}/blob/{{ $ref }}/{{ .Name }}">{{ .Name }}</a>
+ {{ if .IsFile }}
+ <div class="mode">{{ .Mode }}</div>
+ <div class="size">{{ .Size }}</div>
+ <div>
+ {{ if $parent }}
+ <a href="/{{ $repo }}/blob/{{ $ref }}/{{ $parent }}/{{ .Name }}">{{ .Name }}</a>
+ {{ else }}
+ <a href="/{{ $repo }}/blob/{{ $ref }}/{{ .Name }}">{{ .Name }}</a>
+ {{ end }}
+ </div>
{{ end }}
- </div>
- {{ end }}
{{ end }}
</div>
<article>
- <pre>
- {{- if .readme }}{{ .readme }}{{- end -}}
- </pre>
+ <pre>{{- if .readme }}{{ .readme }}{{- end -}}</pre>
</article>
</main>
</body>