commit cb3a5e53721b03d2d12c0ebe227f1a41dc9656f8
parent e6f348c72809abb38667448dd6f7fcf12db432a3
Author: Hiltjo Posthuma <hiltjo@codemadness.org>
Date:   Sat,  6 Aug 2016 13:05:45 +0200

sfeed_frames, sfeed_html: don't use HTML tables

reasons:
- HTML table rendering is extremely slow (invalidate because of resizing cells etc).
- whitespace wrapping does not work properly in ancient browsers, links(1).

Diffstat:
Msfeed_frames.c | 16++++------------
Msfeed_html.c | 15++++-----------
Mstyle.css | 18+-----------------
3 files changed, 9 insertions(+), 40 deletions(-)

diff --git a/sfeed_frames.c b/sfeed_frames.c @@ -138,7 +138,6 @@ printfeed(FILE *fpitems, FILE *fpin, struct feed *f) fputs("</a></h2>\n", fpitems); } - fputs("<table cellpadding=\"0\" cellspacing=\"0\">\n", fpitems); while ((linelen = getline(&line, &linesize, fpin)) > 0) { if (line[linelen - 1] == '\n') line[--linelen] = '\0'; @@ -216,17 +215,11 @@ printfeed(FILE *fpitems, FILE *fpin, struct feed *f) totalnew += isnew; f->totalnew += isnew; f->total++; - if (isnew) - fputs("<tr class=\"n\">", fpitems); - else - fputs("<tr>", fpitems); - fputs("<td nowrap valign=\"top\">", fpitems); - fprintf(fpitems, "%04d-%02d-%02d %02d:%02d ", + fprintf(fpitems, "%04d-%02d-%02d&nbsp;%02d:%02d ", tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min); - fputs("</td><td nowrap valign=\"top\">", fpitems); if (isnew) fputs("<b><u>", fpitems); fputs("<a href=\"", fpitems); @@ -236,9 +229,8 @@ printfeed(FILE *fpitems, FILE *fpin, struct feed *f) fputs("</a>", fpitems); if (isnew) fputs("</u></b>", fpitems); - fputs("</td></tr>\n", fpitems); + fputs("\n", fpitems); } - fputs("</table>\n", fpitems); } int @@ -271,7 +263,7 @@ main(int argc, char *argv[]) err(1, "fopen: items.html"); fputs("<html><head><link rel=\"stylesheet\" type=\"text/css\" href=\"../style.css\" />" "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=UTF-8\" /></head>" - "<body class=\"frame\"><div id=\"items\">", fpitems); + "<body class=\"frame\"><div id=\"items\"><pre>", fpitems); if (argc == 1) { if (!(feeds[0] = calloc(1, sizeof(struct feed)))) @@ -293,7 +285,7 @@ main(int argc, char *argv[]) fclose(fp); } } - fputs("\n</div></body>\n</html>", fpitems); /* div items */ + fputs("</pre>\n</div></body>\n</html>", fpitems); /* div items */ if (showsidebar) { fputs("<html><head>" diff --git a/sfeed_html.c b/sfeed_html.c @@ -31,7 +31,6 @@ printfeed(FILE *fp, struct feed *f) xmlencode(f->name, stdout); fputs("</a></h2>\n", stdout); } - fputs("<table cellpadding=\"0\" cellspacing=\"0\">\n", stdout); while ((linelen = getline(&line, &linesize, fp)) > 0) { if (line[linelen - 1] == '\n') @@ -51,15 +50,9 @@ printfeed(FILE *fp, struct feed *f) f->totalnew += isnew; f->total++; - if (isnew) - fputs("<tr class=\"n\">", stdout); - else - fputs("<tr>", stdout); - fputs("<td nowrap valign=\"top\">", stdout); - fprintf(stdout, "%04d-%02d-%02d&nbsp;%02d:%02d", + fprintf(stdout, "%04d-%02d-%02d&nbsp;%02d:%02d ", tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min); - fputs("</td><td nowrap valign=\"top\">", stdout); if (isnew) fputs("<b><u>", stdout); if (islink) { @@ -72,9 +65,8 @@ printfeed(FILE *fp, struct feed *f) fputs("</a>", stdout); if (isnew) fputs("</u></b>", stdout); - fputs("</td></tr>\n", stdout); + fputs("\n", stdout); } - fputs("</table>\n", stdout); } int @@ -110,6 +102,7 @@ main(int argc, char *argv[]) fputs("\t\t<div id=\"items\">\n", stdout); else fputs("\t\t<div id=\"items\" class=\"nosidebar\">\n", stdout); + fputs("<pre>", stdout); if (argc == 1) { if (!(feeds[0] = calloc(1, sizeof(struct feed)))) @@ -132,7 +125,7 @@ main(int argc, char *argv[]) fclose(fp); } } - fputs("</div>\n", stdout); /* div items */ + fputs("</pre>\n</div>\n", stdout); /* div items */ if (showsidebar) { fputs("\t<div id=\"sidebar\">\n\t\t<ul>\n", stdout); diff --git a/style.css b/style.css @@ -26,7 +26,7 @@ h2 { #sidebar a { padding: 5px 3px 5px 10px; } -#sidebar a, #items a { +#sidebar a { display: block; } #sidebar a, #items h2 a { @@ -35,11 +35,6 @@ h2 { div#items { padding: 0 15px; } -div#items table tr td { - white-space: nowrap; - font-size: 9pt; - padding: 1px; -} body.noframe div#sidebar { position: fixed; top: 0; @@ -69,14 +64,3 @@ body.frame .content { font-family: sans; font-size: medium; } -/* show only new when body has newonly class */ -body.newonly tr, -body.newonly li { - display: none; -} -body.newonly li.n { - display: list-item; -} -body.newonly tr.n { - display: table-row; -}