From 1154d0c0f452240fdb333aa24b55166fc6bbed16 Mon Sep 17 00:00:00 2001 From: Omar Polo Date: Fri, 8 Dec 2023 17:01:27 +0000 Subject: [PATCH] gotwebd: add foldable commit briefs with input/ok from jamsek, tracey and Kyle Ackerman, thanks! --- gotwebd/files/htdocs/gotwebd/gotweb.css | 18 +++++++++++++ gotwebd/pages.tmpl | 47 ++++++++++++++++++++++++--------- 2 files changed, 52 insertions(+), 13 deletions(-) diff --git a/gotwebd/files/htdocs/gotwebd/gotweb.css b/gotwebd/files/htdocs/gotwebd/gotweb.css index 31f9fb49..295f7f57 100755 --- a/gotwebd/files/htdocs/gotwebd/gotweb.css +++ b/gotwebd/files/htdocs/gotwebd/gotweb.css @@ -213,6 +213,24 @@ header.subtitle h2 { } } +.briefs_log summary { + cursor: pointer; +} + +.briefs_toggle { + display: inline-block; + padding: 3px 4px; + padding: 0px 4px; + border: 1px solid #222; + border-radius: 3px; + user-select: none; +} + +/* work around .commits being unusable here */ +.briefs_log > p { + white-space: pre-wrap; +} + .tag_age, .tag_name, .tag_log { display: inline-block; vertical-align: middle; diff --git a/gotwebd/pages.tmpl b/gotwebd/pages.tmpl index 163adf4f..a55f8da7 100644 --- a/gotwebd/pages.tmpl +++ b/gotwebd/pages.tmpl @@ -355,7 +355,7 @@ nextsep(char *s, char **t) struct repo_commit *rc; struct repo_dir *repo_dir = t->repo_dir; struct gotweb_url diff_url, patch_url, tree_url; - char *tmp; + char *tmp, *body; diff_url = (struct gotweb_url){ .action = DIFF, @@ -393,9 +393,12 @@ nextsep(char *s, char **t) if (tmp) *tmp = '\0'; - tmp = strchr(rc->commit_msg, '\n'); - if (tmp) - *tmp = '\0'; + body = strchr(rc->commit_msg, '\n'); + if (body) { + *body++ = '\0'; + while (*body == '\n') + body++; + } !}

@@ -407,15 +410,33 @@ nextsep(char *s, char **t) {{ rc->committer }}

-

- - {{ rc->commit_msg }} - - {{ if rc->refs_str }} - {{ " " }} ({{ rc->refs_str }}) - {{ end }} - -

+ {{ if body && *body != '\0' }} +
+ + + {{ rc->commit_msg }} + + {{ if rc->refs_str }} + {{ " " }} ({{ rc->refs_str }}) + {{ end }} + {{ " " }} + + + {{ "\n" }} +

{{ body }}

+
+ {{ else }} +

+ + {{ rc->commit_msg }} + + {{ if rc->refs_str }} + {{ " " }} ({{ rc->refs_str }}) + {{ end }} +

+ {{ end }}