summaryrefslogtreecommitdiffstats
path: root/internal
diff options
context:
space:
mode:
Diffstat (limited to 'internal')
-rw-r--r--internal/templates/templates.go91
1 files changed, 90 insertions, 1 deletions
diff --git a/internal/templates/templates.go b/internal/templates/templates.go
index 8f25f8f..b68a504 100644
--- a/internal/templates/templates.go
+++ b/internal/templates/templates.go
@@ -185,8 +185,24 @@ var codeCaddyTemplate = `{{.BaseDomain}} {
185 } 185 }
186 } 186 }
187 187
188 @cgitassets path /cgit/*
189 handle @cgitassets {
190 root * /usr/share/cgit
191 uri strip_prefix /cgit
192 file_server
193 }
194
188 handle { 195 handle {
189 respond "not found" 404 196 reverse_proxy unix//run/fcgiwrap.socket {
197 transport fastcgi {
198 env SCRIPT_FILENAME /usr/lib/cgit/cgit.cgi
199 env QUERY_STRING {query}
200 env REQUEST_METHOD {method}
201 env PATH_INFO {path}
202 env HTTP_HOST {host}
203 env SERVER_NAME {host}
204 }
205 }
190 } 206 }
191} 207}
192` 208`
@@ -239,6 +255,79 @@ func CodeCaddy(data map[string]string) (string, error) {
239 return renderTemplate("code-caddy", codeCaddyTemplate, data) 255 return renderTemplate("code-caddy", codeCaddyTemplate, data)
240} 256}
241 257
258var cgitrcTemplate = `virtual-root=/
259css=/cgit/cgit.css
260logo=/cgit/cgit.png
261header=/opt/ship/cgit-header.html
262scan-path=/srv/git/
263export-ok=git-daemon-export-ok
264enable-http-clone=0
265clone-url=https://{{.BaseDomain}}/$CGIT_REPO_URL
266root-title={{.BaseDomain}}
267root-desc=
268remove-suffix=.git
269`
270
271var cgitHeaderTemplate = `<style>
272body, table, td, th, div#cgit { background: #1a1a2e; color: #ccc; }
273a { color: #7aa2f7; }
274a:hover { color: #9ecbff; }
275table.list tr:hover td { background: #222244; }
276table.list td, table.list th { border-bottom: 1px solid #333; }
277th { background: #16213e; }
278td.commitgraph .column1 { color: #7aa2f7; }
279td.commitgraph .column2 { color: #9ece6a; }
280td.logheader { background: #16213e; }
281div#header { background: #16213e; border-bottom: 1px solid #333; }
282div#header .sub { color: #888; }
283table.tabs { border-bottom: 1px solid #333; }
284table.tabs td a { color: #ccc; }
285table.tabs td a.active { color: #fff; background: #1a1a2e; border: 1px solid #333; border-bottom: 1px solid #1a1a2e; }
286div.footer { color: #555; }
287div.footer a { color: #555; }
288div.diffstat-header { background: #16213e; }
289table.diffstat { border-bottom: 1px solid #333; }
290table.diffstat td.graph span.graph-moreremoved { background: #f7768e; }
291table.diffstat td.graph span.graph-moreadded { background: #9ece6a; }
292table.diffstat td.graph span.graph-removed { background: #f7768e; }
293table.diffstat td.graph span.graph-added { background: #9ece6a; }
294table.diff { background: #131320; border: 1px solid #333; }
295div.diff td { font-family: monospace; }
296div.head { color: #ccc; background: #16213e; padding: 2px 4px; }
297div.hunk { color: #7aa2f7; background: #1a1a3e; padding: 2px 4px; }
298div.add { color: #9ece6a; background: #1a2e1a; padding: 2px 4px; }
299div.del { color: #f7768e; background: #2e1a1a; padding: 2px 4px; }
300table.diff td.add { color: #9ece6a; background: #1a2e1a; }
301table.diff td.del { color: #f7768e; background: #2e1a1a; }
302table.diff td.hunk { color: #7aa2f7; background: #1a1a3e; }
303table.diff td { border: none; background: #1a1a2e; }
304table.blob td.lines { color: #ccc; }
305table.blob td.linenumbers { background: #16213e; }
306table.blob td.linenumbers a { color: #555; }
307table.blob td.linenumbers a:hover { color: #7aa2f7; }
308table.ssdiff td.add { color: #9ece6a; background: #1a2e1a; }
309table.ssdiff td.del { color: #f7768e; background: #2e1a1a; }
310table.ssdiff td { border-right: 1px solid #333; }
311table.ssdiff td.hunk { color: #7aa2f7; background: #1a1a3e; }
312table.ssdiff td.head { background: #16213e; border-bottom: 1px solid #333; }
313table.ssdiff td.foot { background: #16213e; border-top: 1px solid #333; }
314table.ssdiff td.lineno { background: #16213e; color: #555; }
315pre { color: #ccc; }
316input, textarea, select { background: #222; color: #ccc; border: 1px solid #444; }
317img#logo { display: none; }
318</style>
319`
320
321// CgitRC generates the /etc/cgitrc config file
322func CgitRC(data map[string]string) (string, error) {
323 return renderTemplate("cgitrc", cgitrcTemplate, data)
324}
325
326// CgitHeader generates the cgit header HTML file (dark theme)
327func CgitHeader() string {
328 return cgitHeaderTemplate
329}
330
242// DockerService generates a systemd unit for a Docker-based app 331// DockerService generates a systemd unit for a Docker-based app
243func DockerService(data map[string]string) (string, error) { 332func DockerService(data map[string]string) (string, error) {
244 return renderTemplate("docker-service", dockerServiceTemplate, data) 333 return renderTemplate("docker-service", dockerServiceTemplate, data)