[prev in list] [next in list] [prev in thread] [next in thread]
List: busybox
Subject: [PATCH 3/4] httpd_indexcgi.c simplify style
From: Sergey Ponomarev <stokito () gmail ! com>
Date: 2021-08-23 13:41:16
Message-ID: 20210823134117.49807-2-stokito () gmail ! com
[Download RAW message or body]
Simplify generated HTML and make it shorter.
Instead of adding a column's class to each <DT> we can use with CSS nth-child(column_num).
We can get rid of <COL> and use CSS to set width.
The tr.hdr and tr.foot used to set bg-color but we can set it to all <TH>.
Also fix rows zebra: tr:nth-child(even) to make the first row after header white.
Signed-off-by: Sergey Ponomarev <stokito@gmail.com>
---
networking/httpd_indexcgi.c | 39 ++++++++++++++++++-------------------
1 file changed, 19 insertions(+), 20 deletions(-)
diff --git a/networking/httpd_indexcgi.c b/networking/httpd_indexcgi.c
index 34429e9c5..548f982ef 100644
--- a/networking/httpd_indexcgi.c
+++ b/networking/httpd_indexcgi.c
@@ -92,10 +92,12 @@ httpd_indexcgi.c -o index.cgi
"border-collapse:collapse" \
"}" \
"th {" \
+ "text-align:left;" \
"border-width:1px;" /* 1px 1px 1px 1px; */ \
"padding:1px;" /* 1px 1px 1px 1px; */ \
"border-style:solid;" /* solid solid solid solid; */ \
- "border-color:black" /* black black black black; */ \
+ "border-color:black;" /* black black black black; */ \
+ "background-color:#eee5de" \
"}" \
"td {" \
/* top right bottom left */ \
@@ -105,17 +107,15 @@ httpd_indexcgi.c -o index.cgi
"border-color:black;" /* black black black black; */ \
"white-space:nowrap" \
"}" \
-"tr:nth-child(odd) { background-color:#ffffff }" \
-"tr.hdr { background-color:#eee5de }" \
-"tr.foot { background-color:#eee5de }" \
-"th.cnt { text-align:left }" \
-"th.sz { text-align:right }" \
-"th.dt { text-align:right }" \
-"td.sz { text-align:right }" \
-"td.dt { text-align:right }" \
-"col.nm { width:98% }" \
-"col.sz { width:1% }" \
-"col.dt { width:1% }" \
+"tr:nth-child(even) { background-color:#ffffff }" \
+"td:nth-child(1) {" \
+ "text-align:left;" \
+ "width:98%" \
+"}" \
+"td:nth-child(2), td:nth-child(3) {" \
+ "text-align:right;" \
+ "width:1%" \
+"}" \
"</style>" \
typedef struct dir_list_t {
@@ -322,8 +322,7 @@ int main(int argc, char *argv[])
fmt_str(
"</h1>" "\n"
"<table>" "\n"
- "<col class=nm><col class=sz><col class=dt>" "\n"
- "<tr class=hdr><th class=cnt>Name<th class=sz>Size<th class=dt>Last modified" "\n");
+ "<tr><th>Name<th>Size<th>Last modified" "\n");
count_dirs = 0;
count_files = 0;
@@ -340,7 +339,7 @@ int main(int argc, char *argv[])
} else
goto next;
- fmt_str("<tr><td class=nm><a href='");
+ fmt_str("<tr><td><a href='");
fmt_url(cdir->dl_name); /* %20 etc */
if (S_ISDIR(cdir->dl_mode))
*dst++ = '/';
@@ -348,10 +347,10 @@ int main(int argc, char *argv[])
fmt_html(cdir->dl_name); /* < etc */
if (S_ISDIR(cdir->dl_mode))
*dst++ = '/';
- fmt_str("</a><td class=sz>");
+ fmt_str("</a><td>");
if (S_ISREG(cdir->dl_mode))
fmt_ull(cdir->dl_size);
- fmt_str("<td class=dt>");
+ fmt_str("<td>");
ptm = gmtime(&cdir->dl_mtime);
fmt_04u(1900 + ptm->tm_year); *dst++ = '-';
fmt_02u(ptm->tm_mon + 1); *dst++ = '-';
@@ -365,14 +364,14 @@ int main(int argc, char *argv[])
cdir++;
}
- fmt_str("<tr class=foot><th class=cnt>Files: ");
+ fmt_str("<tr><th>Files: ");
fmt_ull(count_files);
/* count_dirs - 1: we don't want to count ".." */
fmt_str(", directories: ");
fmt_ull(count_dirs - 1);
- fmt_str("<th class=sz>");
+ fmt_str("<th>");
fmt_ull(size_total);
- fmt_str("<th class=dt>\n");
+ fmt_str("<th>\n");
/* "</table></body></html>" - why bother? */
guarantee(BUFFER_SIZE * 2); /* flush */
--
2.30.2
_______________________________________________
busybox mailing list
busybox@busybox.net
http://lists.busybox.net/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic