[prev in list] [next in list] [prev in thread] [next in thread] 

List:       cgit
Subject:    Re: [BUG] cgit W3 validator fail
From:       Daniel Campbell <dlcampbell () gmx ! com>
Date:       2018-10-20 9:12:33
Message-ID: 20181020091233.GC4977 () clocktown
[Download RAW message or body]

[Attachment #2 (multipart/signed)]

[Attachment #4 (multipart/mixed)]


On Thu, Oct 18, 2018 at 10:27:29AM +0300, Anast Gramm wrote:
> Hello. I recently got into some html "programming" and found out
> about the w3 validator service https://validator.w3.org/
> 
> Upon running it on a cgit site I own an error occurred:
> 
> > The summary attribute on the table element is obsolete.
> > Consider describing the structure of the table in a caption element
> > or in a figure element containing the table; or, simplify the
> > structure of the table so that no description is needed.
> 
> A quick grep through the code showed some lines containing the obsolete
> html.
> 
> Should the summary attribute be moved into a caption or
> should it be removed all together?

The summary attribute is deprecated in HTML 5. Earlier versions may
still support it. I checked the source on various pages in my cgit
installation and they seem to contain generic information like
"repository info", "repository list", and so on. These same tables
already have CSS classes applied, though one could choose to style the
two differently with CSS(3) rules like:

	table[summary="repository info"] {
		color: #f00;
	}

I wrote two patches to fix this: the first patch simply removes the
"summary='...'" parts, and the second adds classes (where needed) so
that style writers that used the above method to style can still target
the same elements, retaining specificity and shortening their selectors.

I have attached the patches to this e-mail for review.

~Daniel
-- 


["0001-ui-remove-summary-attribute-from-table-elements.patch" (text/x-diff)]

From 69c64b0e24bc4d00e9a1ef1178555c2ccdfd9ac4 Mon Sep 17 00:00:00 2001
From: Daniel Campbell <dlcampbell@gmx.com>
Date: Sat, 20 Oct 2018 01:59:47 -0700
Subject: [PATCH 1/2] ui: remove 'summary' attribute from table elements

The 'summary' attribute is deprecated in HTML 5.

Signed-off-by: Daniel Campbell <dlcampbell@gmx.com>
---
 ui-commit.c   | 2 +-
 ui-diff.c     | 8 ++++----
 ui-repolist.c | 2 +-
 ui-summary.c  | 2 +-
 ui-tree.c     | 6 +++---
 5 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/ui-commit.c b/ui-commit.c
index 995cb93..3897101 100644
--- a/ui-commit.c
+++ b/ui-commit.c
@@ -45,7 +45,7 @@ void cgit_print_commit(char *hex, const char *prefix)
 
 	cgit_print_layout_start();
 	cgit_print_diff_ctrls();
-	html("<table summary='commit info' class='commit-info'>\n");
+	html("<table class='commit-info'>\n");
 	html("<tr><th>author</th><td>");
 	cgit_open_filter(ctx.repo->email_filter, info->author_email, "commit");
 	html_txt(info->author);
diff --git a/ui-diff.c b/ui-diff.c
index e33e9fb..5c9011f 100644
--- a/ui-diff.c
+++ b/ui-diff.c
@@ -113,7 +113,7 @@ static void print_fileinfo(struct fileinfo *info)
 	}
 	htmlf("%d", info->added + info->removed);
 	html("</td><td class='graph'>");
-	htmlf("<table summary='file diffstat' width='%d%%'><tr>", (max_changes > 100 ? 100 : max_changes));
+	htmlf("<table width='%d%%'><tr>", (max_changes > 100 ? 100 : max_changes));
 	htmlf("<td class='add' style='width: %.1f%%;'/>",
 	      info->added * 100.0 / max_changes);
 	htmlf("<td class='rem' style='width: %.1f%%;'/>",
@@ -202,7 +202,7 @@ static void cgit_print_diffstat(const struct object_id *old_oid,
 		html("')");
 	}
 	html("</div>");
-	html("<table summary='diffstat' class='diffstat'>");
+	html("<table class='diffstat'>");
 	max_changes = 0;
 	cgit_diff_tree(old_oid, new_oid, inspect_filepair, prefix,
 		       ctx.qry.ignorews);
@@ -485,9 +485,9 @@ void cgit_print_diff(const char *new_rev, const char *old_rev,
 		return;
 
 	if (use_ssdiff) {
-		html("<table summary='ssdiff' class='ssdiff'>");
+		html("<table class='ssdiff'>");
 	} else {
-		html("<table summary='diff' class='diff'>");
+		html("<table class='diff'>");
 		html("<tr><td>");
 	}
 	cgit_diff_tree(old_rev_oid, new_rev_oid, filepair_cb, prefix,
diff --git a/ui-repolist.c b/ui-repolist.c
index 41424c0..2f884e7 100644
--- a/ui-repolist.c
+++ b/ui-repolist.c
@@ -293,7 +293,7 @@ void cgit_print_repolist(void)
 	else if (ctx.cfg.section_sort)
 		sort_repolist("section");
 
-	html("<table summary='repository list' class='list nowrap'>");
+	html("<table class='list nowrap'>");
 	for (i = 0; i < cgit_repolist.count; i++) {
 		ctx.repo = &cgit_repolist.repos[i];
 		if (!is_visible(ctx.repo))
diff --git a/ui-summary.c b/ui-summary.c
index 8e81ac4..73b3732 100644
--- a/ui-summary.c
+++ b/ui-summary.c
@@ -50,7 +50,7 @@ void cgit_print_summary(void)
 		columns++;
 
 	cgit_print_layout_start();
-	html("<table summary='repository info' class='list nowrap'>");
+	html("<table class='list nowrap'>");
 	cgit_print_branches(ctx.cfg.summary_branches);
 	htmlf("<tr class='nohover'><td colspan='%d'>&nbsp;</td></tr>", columns);
 	cgit_print_tags(ctx.cfg.summary_tags);
diff --git a/ui-tree.c b/ui-tree.c
index e6b3074..be25918 100644
--- a/ui-tree.c
+++ b/ui-tree.c
@@ -22,7 +22,7 @@ static void print_text_buffer(const char *name, char *buf, unsigned long size)
 	unsigned long lineno, idx;
 	const char *numberfmt = "<a id='n%1$d' href='#n%1$d'>%1$d</a>\n";
 
-	html("<table summary='blob content' class='blob'>\n");
+	html("<table class='blob'>\n");
 
 	if (ctx.cfg.enable_tree_linenumbers) {
 		html("<tr><td class='linenumbers'><pre>");
@@ -66,7 +66,7 @@ static void print_binary_buffer(char *buf, unsigned long size)
 	unsigned long ofs, idx;
 	static char ascii[ROWLEN + 1];
 
-	html("<table summary='blob content' class='bin-blob'>\n");
+	html("<table class='bin-blob'>\n");
 	html("<tr><th>ofs</th><th>hex dump</th><th>ascii</th></tr>");
 	for (ofs = 0; ofs < size; ofs += ROWLEN, buf += ROWLEN) {
 		htmlf("<tr><td class='right'>%04lx</td><td class='hex'>", ofs);
@@ -264,7 +264,7 @@ static int ls_item(const struct object_id *oid, struct strbuf *base,
 static void ls_head(void)
 {
 	cgit_print_layout_start();
-	html("<table summary='tree listing' class='list'>\n");
+	html("<table class='list'>\n");
 	html("<tr class='nohover'>");
 	html("<th class='left'>Mode</th>");
 	html("<th class='left'>Name</th>");
-- 
2.19.1


["0002-ui-add-classes-to-supplement-missing-summary-info.patch" (text/x-diff)]

From 968a46b11ce8e6b2321bef2421681618d88a5dba Mon Sep 17 00:00:00 2001
From: Daniel Campbell <dlcampbell@gmx.com>
Date: Sat, 20 Oct 2018 02:04:56 -0700
Subject: [PATCH 2/2] ui: add classes to supplement missing summary info

The prior 'summary' attributes could be used in CSS 3 to style elements.
This commit adds classes to make up for the loss of these attributes, so
style writers can adapt their styles without losing specificity.

Signed-off-by: Daniel Campbell <dlcampbell@gmx.com>
---
 ui-diff.c     | 2 +-
 ui-repolist.c | 2 +-
 ui-summary.c  | 2 +-
 ui-tree.c     | 2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/ui-diff.c b/ui-diff.c
index 5c9011f..1d7054f 100644
--- a/ui-diff.c
+++ b/ui-diff.c
@@ -113,7 +113,7 @@ static void print_fileinfo(struct fileinfo *info)
 	}
 	htmlf("%d", info->added + info->removed);
 	html("</td><td class='graph'>");
-	htmlf("<table width='%d%%'><tr>", (max_changes > 100 ? 100 : max_changes));
+	htmlf("<table class='diffstat' width='%d%%'><tr>", (max_changes > 100 ? 100 : max_changes));
 	htmlf("<td class='add' style='width: %.1f%%;'/>",
 	      info->added * 100.0 / max_changes);
 	htmlf("<td class='rem' style='width: %.1f%%;'/>",
diff --git a/ui-repolist.c b/ui-repolist.c
index 2f884e7..52f29db 100644
--- a/ui-repolist.c
+++ b/ui-repolist.c
@@ -293,7 +293,7 @@ void cgit_print_repolist(void)
 	else if (ctx.cfg.section_sort)
 		sort_repolist("section");
 
-	html("<table class='list nowrap'>");
+	html("<table class='repo-list list nowrap'>");
 	for (i = 0; i < cgit_repolist.count; i++) {
 		ctx.repo = &cgit_repolist.repos[i];
 		if (!is_visible(ctx.repo))
diff --git a/ui-summary.c b/ui-summary.c
index 73b3732..d451b5e 100644
--- a/ui-summary.c
+++ b/ui-summary.c
@@ -50,7 +50,7 @@ void cgit_print_summary(void)
 		columns++;
 
 	cgit_print_layout_start();
-	html("<table class='list nowrap'>");
+	html("<table class='repo-info list nowrap'>");
 	cgit_print_branches(ctx.cfg.summary_branches);
 	htmlf("<tr class='nohover'><td colspan='%d'>&nbsp;</td></tr>", columns);
 	cgit_print_tags(ctx.cfg.summary_tags);
diff --git a/ui-tree.c b/ui-tree.c
index be25918..9134838 100644
--- a/ui-tree.c
+++ b/ui-tree.c
@@ -264,7 +264,7 @@ static int ls_item(const struct object_id *oid, struct strbuf *base,
 static void ls_head(void)
 {
 	cgit_print_layout_start();
-	html("<table class='list'>\n");
+	html("<table class='tree-list list'>\n");
 	html("<tr class='nohover'>");
 	html("<th class='left'>Mode</th>");
 	html("<th class='left'>Name</th>");
-- 
2.19.1


["signature.asc" (application/pgp-signature)]

_______________________________________________
CGit mailing list
CGit@lists.zx2c4.com
https://lists.zx2c4.com/mailman/listinfo/cgit


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic