+13
appview/pages/pages.go
+13
appview/pages/pages.go
···
79
79
"unescapeHtml": func(s string) template.HTML {
80
80
return template.HTML(s)
81
81
},
82
+
"nl2br": func(text string) template.HTML {
83
+
return template.HTML(strings.Replace(template.HTMLEscapeString(text), "\n", "<br>", -1))
84
+
},
85
+
"unwrapText": func(text string) string {
86
+
paragraphs := strings.Split(text, "\n\n")
87
+
88
+
for i, p := range paragraphs {
89
+
lines := strings.Split(p, "\n")
90
+
paragraphs[i] = strings.Join(lines, " ")
91
+
}
92
+
93
+
return strings.Join(paragraphs, "\n\n")
94
+
},
82
95
}
83
96
}
84
97
+12
-6
appview/pages/templates/repo/index.html
+12
-6
appview/pages/templates/repo/index.html
···
103
103
<div id="commit-message">
104
104
{{ $messageParts := splitN .Message "\n\n" 2 }}
105
105
<div class="text-base cursor-pointer">
106
-
{{ index $messageParts 0 }}
107
-
{{ if gt (len $messageParts) 1 }}
108
-
<div class="text-sm inline rounded-sm bg-gray-300 text-gray-700 px-1"
109
-
hx-on:click="this.nextElementSibling.classList.toggle('hidden')">...</div>
110
-
<div class="hidden mt-1 text-sm">{{ index $messageParts 1 }}</div>
111
-
{{ end }}
106
+
<div>
107
+
<div class="flex items-center gap-1">
108
+
<a href="/{{ $.RepoInfo.FullName }}/commit/{{ .Hash.String }}" class="inline no-underline hover:underline hover:text-sky-400">{{ index $messageParts 0 }}</a>
109
+
{{ if gt (len $messageParts) 1 }}
110
+
<button class="text-sm inline rounded-sm bg-gray-300 text-gray-700 px-1 w-fit hover:bg-gray-400"
111
+
hx-on:click="this.parentElement.nextElementSibling.classList.toggle('hidden')">…</button>
112
+
{{ end }}
113
+
</div>
114
+
{{ if gt (len $messageParts) 1 }}
115
+
<p class="hidden mt-1 text-sm cursor-text pb-2">{{ nl2br (unwrapText (index $messageParts 1)) }}</p>
116
+
{{ end }}
117
+
</div>
112
118
</div>
113
119
</div>
114
120