aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--resources.go2
-rw-r--r--template_funcs.go8
-rw-r--r--templates/repo_index.html2
3 files changed, 10 insertions, 2 deletions
diff --git a/resources.go b/resources.go
index b7ccca6..afec157 100644
--- a/resources.go
+++ b/resources.go
@@ -13,7 +13,7 @@ var resources_fs embed.FS
var templates *template.Template
func load_templates() (err error) {
- templates, err = template.ParseFS(resources_fs, "templates/*")
+ templates, err = template.New("templates").Funcs(template.FuncMap{"first_line": first_line}).ParseFS(resources_fs, "templates/*")
return err
}
diff --git a/template_funcs.go b/template_funcs.go
new file mode 100644
index 0000000..3c5ca0b
--- /dev/null
+++ b/template_funcs.go
@@ -0,0 +1,8 @@
+package main
+
+import "strings"
+
+func first_line(s string) string {
+ before, _, _ := strings.Cut(s, "\n")
+ return before
+}
diff --git a/templates/repo_index.html b/templates/repo_index.html
index 776b84e..866a020 100644
--- a/templates/repo_index.html
+++ b/templates/repo_index.html
@@ -20,7 +20,7 @@
{{- range .commits }}
<tr>
<td class="commit-id">{{ slice .Hash.String 0 8 }}</td>
-<td class="commit-title">{{ .Message }}</td>
+<td class="commit-title">{{ .Message | first_line }}</td>
<td class="commit-author">
<a class="email-name" href="mailto:{{ .Author.Email }}">{{ .Author.Name }}</a>
</td>