forked from tangled.org/core
Monorepo for Tangled — https://tangled.org

even better commit messages

anirudh.fi 13be45b7 5e314cec

verified
Changed files
+25 -6
appview
pages
templates
repo
+13
appview/pages/pages.go
···
"unescapeHtml": func(s string) template.HTML {
return template.HTML(s)
},
+
"nl2br": func(text string) template.HTML {
+
return template.HTML(strings.Replace(template.HTMLEscapeString(text), "\n", "<br>", -1))
+
},
+
"unwrapText": func(text string) string {
+
paragraphs := strings.Split(text, "\n\n")
+
+
for i, p := range paragraphs {
+
lines := strings.Split(p, "\n")
+
paragraphs[i] = strings.Join(lines, " ")
+
}
+
+
return strings.Join(paragraphs, "\n\n")
+
},
}
}
+12 -6
appview/pages/templates/repo/index.html
···
<div id="commit-message">
{{ $messageParts := splitN .Message "\n\n" 2 }}
<div class="text-base cursor-pointer">
-
{{ index $messageParts 0 }}
-
{{ if gt (len $messageParts) 1 }}
-
<div class="text-sm inline rounded-sm bg-gray-300 text-gray-700 px-1"
-
hx-on:click="this.nextElementSibling.classList.toggle('hidden')">...</div>
-
<div class="hidden mt-1 text-sm">{{ index $messageParts 1 }}</div>
-
{{ end }}
+
<div>
+
<div class="flex items-center gap-1">
+
<a href="/{{ $.RepoInfo.FullName }}/commit/{{ .Hash.String }}" class="inline no-underline hover:underline hover:text-sky-400">{{ index $messageParts 0 }}</a>
+
{{ if gt (len $messageParts) 1 }}
+
<button class="text-sm inline rounded-sm bg-gray-300 text-gray-700 px-1 w-fit hover:bg-gray-400"
+
hx-on:click="this.parentElement.nextElementSibling.classList.toggle('hidden')">&hellip;</button>
+
{{ end }}
+
</div>
+
{{ if gt (len $messageParts) 1 }}
+
<p class="hidden mt-1 text-sm cursor-text pb-2">{{ nl2br (unwrapText (index $messageParts 1)) }}</p>
+
{{ end }}
+
</div>
</div>
</div>