List for cgit developers and users
 help / color / mirror / Atom feed
* [PATCH (resend) 0/5] improve rendering w/o CSS reliance
@ 2021-03-19 20:23 Eric Wong
  2021-03-19 20:23 ` [PATCH 3/5] ui-log: improve decoration display for browsers without CSS Eric Wong
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Eric Wong @ 2021-03-19 20:23 UTC (permalink / raw)
  To: cgit

Rebased againsg commit bd6f5683f6cde4212364354b3139c1d521f40f39
("tests: t0107: support older and/or non-GNU tar")

Here are a few changes to improve rendering for people with
low-end machines using text-based browsers (w3m, lynx) or
lightweight GUI browsers such as dillo, which has incomplete CSS
support.

The only incompatible (with existing CSS customisations) change
might be the one to use <pre> instead of <div> for commit-msg.
I'm not sure how much of a stable interface the CSS styles are
expected to be for this project.

Eric Wong (5):
  ui-shared: improve pageheader display on text-based browsers
  ui-{commit,tag}: use <pre> for commit-msg
  ui-log: improve decoration display for browsers without CSS
  ui-diff: preserve spaces w/o CSS on context lines
  ui-{tree,repolist}: improve button spacing for browsers w/o CSS

 cgit.css              |  8 --------
 html.c                | 46 +++++++++++++++++++++++++++++++++++++++++++
 html.h                |  1 +
 tests/t0105-commit.sh |  2 +-
 ui-commit.c           |  4 ++--
 ui-diff.c             |  5 +----
 ui-log.c              |  5 +++++
 ui-repolist.c         |  2 ++
 ui-shared.c           | 15 +++++++++++---
 ui-tag.c              |  4 ++--
 ui-tree.c             | 12 ++++++++---
 11 files changed, 81 insertions(+), 23 deletions(-)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 3/5] ui-log: improve decoration display for browsers without CSS
  2021-03-19 20:23 [PATCH (resend) 0/5] improve rendering w/o CSS reliance Eric Wong
@ 2021-03-19 20:23 ` Eric Wong
  2021-03-19 20:23 ` [PATCH 4/5] ui-diff: preserve spaces w/o CSS on context lines Eric Wong
  2021-03-19 20:23 ` [PATCH 5/5] ui-{tree, repolist}: improve button spacing for browsers w/o CSS Eric Wong
  2 siblings, 0 replies; 4+ messages in thread
From: Eric Wong @ 2021-03-19 20:23 UTC (permalink / raw)
  To: cgit

Text-based browsers without CSS support show all the decorations
bunched together without spacing.  Rely on a whitespace instead
of CSS support.

Signed-off-by: Eric Wong <e@80x24.org>
---
 cgit.css | 1 -
 ui-log.c | 5 +++++
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/cgit.css b/cgit.css
index f9549a1..6ab28a1 100644
--- a/cgit.css
+++ b/cgit.css
@@ -708,7 +708,6 @@ div#cgit div.commit-subject a.tag-deco,
 div#cgit div.commit-subject a.tag-annotated-deco,
 div#cgit div.commit-subject a.remote-deco,
 div#cgit div.commit-subject a.deco {
-	margin-left: 1em;
 	font-size: 75%;
 }
 
diff --git a/ui-log.c b/ui-log.c
index 6914f75..3679c0a 100644
--- a/ui-log.c
+++ b/ui-log.c
@@ -67,6 +67,7 @@ void show_commit_decorations(struct commit *commit)
 	while (deco) {
 		struct object_id peeled;
 		int is_annotated = 0;
+
 		strlcpy(buf, prettify_refname(deco->name), sizeof(buf));
 		switch(deco->type) {
 		case DECORATION_NONE:
@@ -74,11 +75,13 @@ void show_commit_decorations(struct commit *commit)
 			 * don't display anything. */
 			break;
 		case DECORATION_REF_LOCAL:
+			html(" ");
 			cgit_log_link(buf, NULL, "branch-deco", buf, NULL,
 				ctx.qry.vpath, 0, NULL, NULL,
 				ctx.qry.showmsg, 0);
 			break;
 		case DECORATION_REF_TAG:
+			html(" ");
 			if (!peel_ref(deco->name, &peeled))
 				is_annotated = !oidcmp(&commit->object.oid, &peeled);
 			cgit_tag_link(buf, NULL, is_annotated ? "tag-annotated-deco" : "tag-deco", buf);
@@ -86,12 +89,14 @@ void show_commit_decorations(struct commit *commit)
 		case DECORATION_REF_REMOTE:
 			if (!ctx.repo->enable_remote_branches)
 				break;
+			html(" ");
 			cgit_log_link(buf, NULL, "remote-deco", NULL,
 				oid_to_hex(&commit->object.oid),
 				ctx.qry.vpath, 0, NULL, NULL,
 				ctx.qry.showmsg, 0);
 			break;
 		default:
+			html(" ");
 			cgit_commit_link(buf, NULL, "deco", ctx.qry.head,
 					oid_to_hex(&commit->object.oid),
 					ctx.qry.vpath);

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 4/5] ui-diff: preserve spaces w/o CSS on context lines
  2021-03-19 20:23 [PATCH (resend) 0/5] improve rendering w/o CSS reliance Eric Wong
  2021-03-19 20:23 ` [PATCH 3/5] ui-log: improve decoration display for browsers without CSS Eric Wong
@ 2021-03-19 20:23 ` Eric Wong
  2021-03-19 20:23 ` [PATCH 5/5] ui-{tree, repolist}: improve button spacing for browsers w/o CSS Eric Wong
  2 siblings, 0 replies; 4+ messages in thread
From: Eric Wong @ 2021-03-19 20:23 UTC (permalink / raw)
  To: cgit

We need to use a non-breaking space entity to preserve
spacing for browsers without CSS support.

Signed-off-by: Eric Wong <e@80x24.org>
---
 html.c    | 46 ++++++++++++++++++++++++++++++++++++++++++++++
 html.h    |  1 +
 ui-diff.c |  5 +----
 3 files changed, 48 insertions(+), 4 deletions(-)

diff --git a/html.c b/html.c
index 7f81965..138c649 100644
--- a/html.c
+++ b/html.c
@@ -156,6 +156,52 @@ ssize_t html_ntxt(const char *txt, size_t len)
 	return slen;
 }
 
+ssize_t html_ntxt_pre(const char *txt, size_t len)
+{
+	const char *t = txt;
+	ssize_t slen;
+	int prev = 0;
+
+	if (len > SSIZE_MAX)
+		return -1;
+
+	slen = (ssize_t) len;
+	while (t && *t && slen--) {
+		int c = *t;
+		if (c == '<' || c == '>' || c == '&' || c == ' ' || c == '\t') {
+			html_raw(txt, t - txt);
+			if (c == '>')
+				html("&gt;");
+			else if (c == '<')
+				html("&lt;");
+			else if (c == '&')
+				html("&amp;");
+			else if (c == ' ') {
+				if (!prev || prev == ' ' || prev == '\t') {
+					html("&#160;");
+					/* next byte can be unescaped ' ' */
+					c = 160;
+				} else {
+					html(" ");
+				}
+			} else if (c == '\t') {
+				html("&#160;&#160;&#160;&#160;"
+				     "&#160;&#160;&#160;&#160;");
+				/* next byte can be unescaped ' ' */
+				c = 160;
+			}
+			txt = t + 1;
+		}
+		prev = c;
+		t++;
+	}
+	if (t != txt)
+		html_raw(txt, t - txt);
+	return slen;
+}
+
+
+
 void html_attrf(const char *fmt, ...)
 {
 	va_list ap;
diff --git a/html.h b/html.h
index fa4de77..4479b8e 100644
--- a/html.h
+++ b/html.h
@@ -20,6 +20,7 @@ extern void html_attrf(const char *format,...);
 
 extern void html_txt(const char *txt);
 extern ssize_t html_ntxt(const char *txt, size_t len);
+extern ssize_t html_ntxt_pre(const char *txt, size_t len);
 extern void html_attr(const char *txt);
 extern void html_url_path(const char *txt);
 extern void html_url_arg(const char *txt);
diff --git a/ui-diff.c b/ui-diff.c
index 5ed5990..a0f2bb7 100644
--- a/ui-diff.c
+++ b/ui-diff.c
@@ -222,7 +222,6 @@ static void cgit_print_diffstat(const struct object_id *old_oid,
 static void print_line(char *line, int len)
 {
 	char *class = "ctx";
-	char c = line[len-1];
 
 	if (line[0] == '+')
 		class = "add";
@@ -232,10 +231,8 @@ static void print_line(char *line, int len)
 		class = "hunk";
 
 	htmlf("<div class='%s'>", class);
-	line[len-1] = '\0';
-	html_txt(line);
+	html_ntxt_pre(line, len - 1);
 	html("</div>");
-	line[len-1] = c;
 }
 
 static void header(const struct object_id *oid1, char *path1, int mode1,

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 5/5] ui-{tree, repolist}: improve button spacing for browsers w/o CSS
  2021-03-19 20:23 [PATCH (resend) 0/5] improve rendering w/o CSS reliance Eric Wong
  2021-03-19 20:23 ` [PATCH 3/5] ui-log: improve decoration display for browsers without CSS Eric Wong
  2021-03-19 20:23 ` [PATCH 4/5] ui-diff: preserve spaces w/o CSS on context lines Eric Wong
@ 2021-03-19 20:23 ` Eric Wong
  2 siblings, 0 replies; 4+ messages in thread
From: Eric Wong @ 2021-03-19 20:23 UTC (permalink / raw)
  To: cgit

For browsers on low-end machines running browsers without CSS
support, the default tree view displayed "logplain" when it
should be "log plain".  Stop relying on CSS and add a space
in between elements to improve accessibility.

Signed-off-by: Eric Wong <e@80x24.org>
---
 cgit.css      |  1 -
 ui-repolist.c |  2 ++
 ui-tree.c     | 12 +++++++++---
 3 files changed, 11 insertions(+), 4 deletions(-)

diff --git a/cgit.css b/cgit.css
index 6ab28a1..4ccd5ad 100644
--- a/cgit.css
+++ b/cgit.css
@@ -575,7 +575,6 @@ div#cgit table.list td.reposection {
 
 div#cgit a.button {
 	font-size: 80%;
-	padding: 0em 0.5em;
 }
 
 div#cgit a.primary {
diff --git a/ui-repolist.c b/ui-repolist.c
index 529a203..591929b 100644
--- a/ui-repolist.c
+++ b/ui-repolist.c
@@ -353,8 +353,10 @@ void cgit_print_repolist(void)
 		if (ctx.cfg.enable_index_links) {
 			html("<td>");
 			cgit_summary_link("summary", NULL, "button", NULL);
+			html(" ");
 			cgit_log_link("log", NULL, "button", NULL, NULL, NULL,
 				      0, NULL, NULL, ctx.qry.showmsg, 0);
+			html(" ");
 			cgit_tree_link("tree", NULL, "button", NULL, NULL, NULL);
 			html("</td>");
 		}
diff --git a/ui-tree.c b/ui-tree.c
index 1e4efb2..f561d8b 100644
--- a/ui-tree.c
+++ b/ui-tree.c
@@ -245,15 +245,21 @@ static int ls_item(const struct object_id *oid, struct strbuf *base,
 	cgit_log_link("log", NULL, "button", ctx.qry.head,
 		      walk_tree_ctx->curr_rev, fullpath.buf, 0, NULL, NULL,
 		      ctx.qry.showmsg, 0);
-	if (ctx.repo->max_stats)
+	if (ctx.repo->max_stats) {
+		html(" ");
 		cgit_stats_link("stats", NULL, "button", ctx.qry.head,
 				fullpath.buf);
-	if (!S_ISGITLINK(mode))
+	}
+	if (!S_ISGITLINK(mode)) {
+		html(" ");
 		cgit_plain_link("plain", NULL, "button", ctx.qry.head,
 				walk_tree_ctx->curr_rev, fullpath.buf);
-	if (!S_ISDIR(mode) && ctx.repo->enable_blame)
+	}
+	if (!S_ISDIR(mode) && ctx.repo->enable_blame) {
+		html(" ");
 		cgit_blame_link("blame", NULL, "button", ctx.qry.head,
 				walk_tree_ctx->curr_rev, fullpath.buf);
+	}
 	html("</td></tr>\n");
 	free(name);
 	strbuf_release(&fullpath);

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2021-03-19 20:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-03-19 20:23 [PATCH (resend) 0/5] improve rendering w/o CSS reliance Eric Wong
2021-03-19 20:23 ` [PATCH 3/5] ui-log: improve decoration display for browsers without CSS Eric Wong
2021-03-19 20:23 ` [PATCH 4/5] ui-diff: preserve spaces w/o CSS on context lines Eric Wong
2021-03-19 20:23 ` [PATCH 5/5] ui-{tree, repolist}: improve button spacing for browsers w/o CSS Eric Wong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).