"GOT", but the "O" is a cute, smiling pufferfish. Index | Thread | Search

From:
Omar Polo <op@omarpolo.com>
Subject:
Re: gotwebd: foldable briefs?
To:
Mark Jamsek <mark@jamsek.com>
Cc:
Tracey Emery <tracey@traceyemery.net>, Kyle Ackerman <kackerman0102@gmail.com>, gameoftrees@openbsd.org
Date:
Thu, 07 Dec 2023 15:11:51 +0100

Download raw body.

Thread
On 2023/12/02 12:05:06 +1100, Mark Jamsek <mark@jamsek.com> wrote:
> Tracey Emery <tracey@traceyemery.net> wrote:
> > On Fri, Dec 01, 2023 at 08:55:17PM +0100, Omar Polo wrote:
> > > I'm a bit unsure about this.  It's nice since it makes the full commit
> > > message accessible in the briefs pages, and doesn't depend on javascript
> > > (just a plain <details> tag.)  Most (all?) text browsers however don't
> > > understand it and so this diffs adds some "noise" (the three dots) to
> > > the briefs page.
> > > 
> > > I have this too on my instance:
> > > <https://got.omarpolo.com/?action=summary&path=got.git>
> > > 
> > > (the aria-hidden attribute is just to make screen reader & co ignoring
> > > the three dots that are only decorative.)
> > 
> > I don't mind this. It could be handy. Let's wait for more feedback.
> 
> Nice, op! I actually like this too.
> 
> It's super handy to be able to view the full log message for extra
> context before entering the diff action. This also works with vimium,
> which is brilliant! I'm less keen on the [...] suffix but we need some
> mechanism to expand the collapsible and it's far from a deal breaker.
> 
> The noise in my text browser (w3m) is super minimal; it's actually a
> nice indication that the message is in effect truncated. And it's less
> of an eyesore than the [...] in chromium. I noticed that safari also
> prefixes the collapsed message with a black right-pointing triangle
> (U+25B6) that changes to a black down-pointing triangle (U+25BC) when
> the message is expanded, which I prefer to the [...] suffix. It would
> be good if we could force that everywhere rather than the [...].
> 
> In either case, this adds value for quite a minimal change so ok for me

after thinking some more on this, here's a slightly different approach.
Keep the browser arrow icon and drop the custom [...].  my fear was that
the arrow icon was not enough to discover it (and partially to copy
codeberg UI that has a [...] button), but it doesn't seem bad:

https://got.omarpolo.com/?action=summary&path=got.git

as a bonus, it doesn't add noise to text browsers :)

ok?

diff /home/op/w/got
commit - 6ecb0b8c6b2aa36b6af31c856909b1ddccdb301c
path + /home/op/w/got
blob - 65256f74800294b5cafb9831a20db2e5715f568b
file + gotwebd/files/htdocs/gotwebd/gotweb.css
--- gotwebd/files/htdocs/gotwebd/gotweb.css
+++ gotwebd/files/htdocs/gotwebd/gotweb.css
@@ -213,6 +213,15 @@ header.subtitle h2 {
 	}
 }
 
+.briefs_log summary {
+	cursor: pointer;
+}
+
+/* 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;
blob - bbcaa81e086ae388fea68770a80f18d48f3b28df
file + gotwebd/pages.tmpl
--- gotwebd/pages.tmpl
+++ gotwebd/pages.tmpl
@@ -354,7 +354,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,
@@ -392,9 +392,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++;
+	}
     !}
     <div class='brief'>
       <p class='brief_meta'>
@@ -406,15 +409,29 @@ nextsep(char *s, char **t)
           {{ rc->committer }}
         </span>
       </p>
-      <p class="briefs_log">
-        <a href="{{ render gotweb_render_url(tp->tp_arg, &diff_url) }}">
-          {{ rc->commit_msg }}
-        </a>
-        {{ if rc->refs_str }}
-          {{ " " }} <span class="refs_str">({{ rc->refs_str }})</span>
-        {{ end }}
-        </a>
-      </p>
+      {{ if body && *body != '\0' }}
+        <details class="briefs_log">
+          <summary>
+            <a href="{{ render gotweb_render_url(tp->tp_arg, &diff_url) }}">
+              {{ rc->commit_msg }}
+            </a>
+            {{ if rc->refs_str }}
+              {{ " " }} <span class="refs_str">({{ rc->refs_str }})</span>
+            {{ end }}
+          </summary>
+          {{ "\n" }}
+          <p>{{ body }}</p>
+        </details>
+      {{ else }}
+        <p class="briefs_log">
+          <a href="{{ render gotweb_render_url(tp->tp_arg, &diff_url) }}">
+            {{ rc->commit_msg }}
+          </a>
+          {{ if rc->refs_str }}
+            {{ " " }} <span class="refs_str">({{ rc->refs_str }})</span>
+          {{ end }}
+        </p>
+      {{ end }}
     </div>
     <div class="navs_wrapper">
       <div class="navs">