1{{ define "title" }}Repositories — arche forge{{ end }}
2{{ define "srv_repo_list.html" }}{{ template "head" . }}
3<div class="container">
4 <h2 style="margin-bottom: 16px">Repositories</h2>
5 {{ if .Repos }}
6 <table>
7 <thead>
8 <tr>
9 <th>Name</th>
10 <th>Description</th>
11 <th>Visibility</th>
12 <th>Last commit</th>
13 <th>Created</th>
14 </tr>
15 </thead>
16 <tbody>
17 {{ range .Repos }}
18 <tr>
19 <td>
20 <a href="/{{.Name}}">{{.Name}}</a>
21 </td>
22 <td>{{.Description}}</td>
23 <td>
24 <span class="badge badge-{{.Visibility}}">{{.Visibility}}</span>
25 </td>
26 <td style="color: #888; font-size: 12px">{{.LastCommit}}</td>
27 <td style="color: #aaa; font-size: 12px">{{.CreatedAt}}</td>
28 </tr>
29 {{ end }}
30 </tbody>
31 </table>
32{{ else }}
33 <p style="color: #888">No repositories yet.</p>
34 {{ end }} {{ if .User }}{{ if .User.IsAdmin }}
35 <details style="margin-top: 24px">
36 <summary style="cursor: pointer; font-size: 13px; color: #555">Create repository</summary>
37 <form method="post"
38 action="/admin/repos"
39 style="margin-top: 10px"
40 id="create-repo-form">
41 <div class="field">
42 <label>Name</label>
43 <input type="text"
44 name="name"
45 id="repo-name"
46 pattern="[a-zA-Z0-9._-]+"
47 required />
48 </div>
49 <div class="field">
50 <label>Description</label>
51 <input type="text" name="description" id="repo-desc" />
52 </div>
53 <div class="field">
54 <label>Visibility</label>
55 <select name="visibility"
56 id="repo-vis"
57 style="padding: 5px;
58 border: 1px solid #ccc;
59 border-radius: 3px">
60 <option value="private">private</option>
61 <option value="public">public</option>
62 </select>
63 </div>
64 <button type="button" onclick="submitCreate()">Create</button>
65 </form>
66 </details>
67 <script>
68 function submitCreate() {
69 var form = document.getElementById("create-repo-form");
70 var data = new FormData(form);
71 fetch("/admin/repos", {
72 method: "POST",
73 body: new URLSearchParams(data),
74 }).then(function (r) {
75 if (r.ok) {
76 location.reload();
77 } else {
78 r.text().then(alert);
79 }
80 });
81 }
82 </script>
83 {{ end }}{{ end }}
84</div>
85{{ template "foot" . }} {{ end }}