Browse Source

Merge pull request #13 from anthonyryan1/master

Shift table styling details onto the client
pull/25/head
Adrian Perez 10 years ago
parent
commit
a2d30629ed
  1. 15
      ngx_http_fancyindex_module.c
  2. 4
      template.h
  3. 10
      template.html

15
ngx_http_fancyindex_module.c

@ -569,12 +569,12 @@ make_content_buf(
* Genearated table rows are as follows, unneeded whitespace
* is stripped out:
*
* <tr class="X">
* <tr>
* <td><a href="U[?sort]">fname</a></td>
* <td>size</td><td>date</td>
* </tr>
*/
len += ngx_sizeof_ssz("<tr class=\"X\"><td><a href=\"")
len += ngx_sizeof_ssz("<tr><td><a href=\"")
+ entry[i].name.len + entry[i].escape /* Escaped URL */
+ ngx_sizeof_ssz("?C=x&amp;O=y") /* URL sorting arguments */
+ ngx_sizeof_ssz("\">")
@ -661,7 +661,7 @@ make_content_buf(
/* "Parent dir" entry, always first */
b->last = ngx_cpymem_ssz(b->last,
"<tr class=\"o\">"
"<tr>"
"<td><a href=\"../");
if (*sort_url_args) {
b->last = ngx_cpymem(b->last,
@ -676,14 +676,7 @@ make_content_buf(
/* Entries for directories and files */
for (i = 0; i < entries.nelts; i++) {
static const char _evenodd[] = { 'e', 'o' };
b->last = ngx_cpymem_ssz(b->last, "<tr class=\"");
*b->last++ = _evenodd[i & 0x01];
/*
* Alternative implementation:
* *b->last++ = (i & 0x01) ? 'e' : 'o';
*/
b->last = ngx_cpymem_ssz(b->last, "\"><td><a href=\"");
b->last = ngx_cpymem_ssz(b->last, "<tr><td><a href=\"");
if (entry[i].escape) {
ngx_fancyindex_escape_uri(b->last,

4
template.h

@ -13,7 +13,7 @@ static const u_char t01_head1[] = ""
"font-family:\"Bitstream Vera Sans\",\"Lucida Grande\","
"\"Lucida Sans Unicode\",Lucidux,Verdana,Lucida,sans-serif;"
"}"
"tr.e {"
"tr:nth-child(even) {"
"background:#f4f4f4;"
"}"
"th,td {"
@ -75,7 +75,7 @@ static const u_char t06_list1[] = ""
"<tbody>"
;
static const u_char t_parentdir_entry[] = ""
"<tr class=\"o\">"
"<tr>"
"<td><a href=\"../?C=N&amp;O=A\">Parent directory/</a></td>"
"<td>-</td>"
"<td>-</td>"

10
template.html

@ -12,7 +12,7 @@
font-family:"Bitstream Vera Sans","Lucida Grande",
"Lucida Sans Unicode",Lucidux,Verdana,Lucida,sans-serif;
}
tr.e {
tr:nth-child(even) {
background:#f4f4f4;
}
th,td {
@ -72,24 +72,24 @@
<tbody>
<!-- var t_parentdir_entry -->
<tr class="o">
<tr>
<td><a href="../?C=N&amp;O=A">Parent directory/</a></td>
<td>-</td>
<td>-</td>
</tr>
<!-- var NONE -->
<tr class="e">
<tr>
<td>test file 1</td>
<td>123kB</td>
<td>date</td>
</tr>
<tr class="o">
<tr>
<td>test file 2</td>
<td>321MB</td>
<td>date</td>
</tr>
<tr class="e">
<tr>
<td>test file 3</td>
<td>666</td>
<td>date</td>

Loading…
Cancel
Save