Compare commits

..

10 commits

Author SHA1 Message Date
8a356a18f5
feat: last update date 2024-03-14 11:12:59 +01:00
0b0fe824c0
feat: parse markdown 2024-03-14 10:58:02 +01:00
97df2dcc44
feat: readme file 2024-03-14 03:11:59 +01:00
441fe260ff
fix: change default date format 2024-03-13 23:35:50 +01:00
16d899a438
fix: file count 2024-03-13 23:31:50 +01:00
41ffd40bf6
feat: add title/icon 2024-03-13 23:25:57 +01:00
eafbce8352
small fixes 2024-03-13 22:35:27 +01:00
8ec3c8bdfd
feat: clickable path display 2024-03-13 16:17:45 +01:00
f31b92df37
feat: use caddy template 2024-03-13 13:07:39 +01:00
Adrian Perez de Castro
cbc0d3fca4 CI: Update mainline and stable Nginx versions for testing 2023-01-20 15:31:11 +02:00
10 changed files with 2248 additions and 208 deletions

View file

@ -11,9 +11,9 @@ jobs:
compiler: [gcc, clang] compiler: [gcc, clang]
nginx: nginx:
# Mainline # Mainline
- 1.21.6 - 1.23.3
# Stable. # Stable.
- 1.20.2 - 1.22.1
# First version with loadable module support. # First version with loadable module support.
- 1.9.15 - 1.9.15
# Oldest supported version. # Oldest supported version.

13
compile_flags.txt Normal file
View file

@ -0,0 +1,13 @@
-I/home/thetadev/test/ngx-fancyindex/nginx-1.25.4/src/core
-I/home/thetadev/test/ngx-fancyindex/nginx-1.25.4/src/event
-I/home/thetadev/test/ngx-fancyindex/nginx-1.25.4/src/event/quic
-I/home/thetadev/test/ngx-fancyindex/nginx-1.25.4/src/event/modules
-I/home/thetadev/test/ngx-fancyindex/nginx-1.25.4/src/http
-I/home/thetadev/test/ngx-fancyindex/nginx-1.25.4/src/http/v2
-I/home/thetadev/test/ngx-fancyindex/nginx-1.25.4/src/http/v3
-I/home/thetadev/test/ngx-fancyindex/nginx-1.25.4/src/http/modules
-I/home/thetadev/test/ngx-fancyindex/nginx-1.25.4/src/mail
-I/home/thetadev/test/ngx-fancyindex/nginx-1.25.4/src/misc
-I/home/thetadev/test/ngx-fancyindex/nginx-1.25.4/src/os/unix
-I/home/thetadev/test/ngx-fancyindex/nginx-1.25.4/src/stream
-I/home/thetadev/test/ngx-fancyindex/nginx-1.25.4/objs

1
config
View file

@ -1,5 +1,6 @@
# vim:ft=sh: # vim:ft=sh:
ngx_addon_name=ngx_http_fancyindex_module ngx_addon_name=ngx_http_fancyindex_module
ngx_module_libs="-lmarkdown"
if [ "$ngx_module_link" = DYNAMIC ] ; then if [ "$ngx_module_link" = DYNAMIC ] ; then
ngx_module_type=HTTP ngx_module_type=HTTP

View file

@ -18,11 +18,13 @@
* *
* SPDX-License-Identifier: BSD-2-Clause * SPDX-License-Identifier: BSD-2-Clause
*/ */
#include <ngx_config.h> #include <ngx_config.h>
#include <ngx_core.h> #include <ngx_core.h>
#include <ngx_http.h> #include <ngx_http.h>
#include <ngx_log.h> #include <ngx_log.h>
#include "ngx_string.h"
#include <mkdio.h>
#include "template.h" #include "template.h"
@ -48,6 +50,8 @@ static const char *long_month[] = {
"August", "September", "October", "November", "December", "August", "September", "October", "November", "December",
}; };
#define MKD_FLAGS MKD_TOC | MKD_IDANCHOR | MKD_AUTOLINK
#define DATETIME_FORMATS(F_, t) \ #define DATETIME_FORMATS(F_, t) \
F_ ('a', 3, "%3s", short_weekday[((t)->ngx_tm_wday + 6) % 7]) \ F_ ('a', 3, "%3s", short_weekday[((t)->ngx_tm_wday + 6) % 7]) \
@ -168,6 +172,9 @@ typedef struct {
ngx_fancyindex_headerfooter_conf_t header; ngx_fancyindex_headerfooter_conf_t header;
ngx_fancyindex_headerfooter_conf_t footer; ngx_fancyindex_headerfooter_conf_t footer;
ngx_str_t title;
ngx_str_t icon_href;
} ngx_http_fancyindex_loc_conf_t; } ngx_http_fancyindex_loc_conf_t;
#define NGX_HTTP_FANCYINDEX_SORT_CRITERION_NAME 0 #define NGX_HTTP_FANCYINDEX_SORT_CRITERION_NAME 0
@ -330,6 +337,7 @@ typedef struct {
ngx_uint_t escape; ngx_uint_t escape;
ngx_uint_t escape_html; ngx_uint_t escape_html;
ngx_uint_t dir; ngx_uint_t dir;
ngx_uint_t link;
time_t mtime; time_t mtime;
off_t size; off_t size;
} ngx_http_fancyindex_entry_t; } ngx_http_fancyindex_entry_t;
@ -353,6 +361,8 @@ static int ngx_libc_cdecl
static int ngx_libc_cdecl static int ngx_libc_cdecl
ngx_http_fancyindex_cmp_entries_mtime_asc(const void *one, const void *two); ngx_http_fancyindex_cmp_entries_mtime_asc(const void *one, const void *two);
static size_t ngx_http_fancyindex_num_places (size_t n);
static ngx_int_t ngx_http_fancyindex_error(ngx_http_request_t *r, static ngx_int_t ngx_http_fancyindex_error(ngx_http_request_t *r,
ngx_dir_t *dir, ngx_str_t *name); ngx_dir_t *dir, ngx_str_t *name);
@ -376,7 +386,7 @@ static uintptr_t
* above). * above).
*/ */
static ngx_inline ngx_buf_t* static ngx_inline ngx_buf_t*
make_header_buf(ngx_http_request_t *r, const ngx_str_t css_href) make_header_buf(ngx_http_request_t *r, ngx_http_fancyindex_loc_conf_t *alcf)
ngx_force_inline; ngx_force_inline;
@ -487,6 +497,20 @@ static ngx_command_t ngx_http_fancyindex_commands[] = {
offsetof(ngx_http_fancyindex_loc_conf_t, time_format), offsetof(ngx_http_fancyindex_loc_conf_t, time_format),
NULL }, NULL },
{ ngx_string("fancyindex_title"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
ngx_conf_set_str_slot,
NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_fancyindex_loc_conf_t, title),
NULL },
{ ngx_string("fancyindex_icon_href"),
NGX_HTTP_MAIN_CONF|NGX_HTTP_SRV_CONF|NGX_HTTP_LOC_CONF|NGX_CONF_TAKE1,
ngx_conf_set_str_slot,
NGX_HTTP_LOC_CONF_OFFSET,
offsetof(ngx_http_fancyindex_loc_conf_t, icon_href),
NULL },
ngx_null_command ngx_null_command
}; };
@ -527,6 +551,18 @@ static const ngx_str_t css_href_pre =
ngx_string("<link rel=\"stylesheet\" href=\""); ngx_string("<link rel=\"stylesheet\" href=\"");
static const ngx_str_t css_href_post = static const ngx_str_t css_href_post =
ngx_string("\" type=\"text/css\"/>\n"); ngx_string("\" type=\"text/css\"/>\n");
static const ngx_str_t favicon_pre =
ngx_string("<link rel=\"icon\" type=\"image/x-icon\" href=\"");
static const ngx_str_t favicon_post =
ngx_string("\">\n");
static const ngx_str_t img_icon_pre =
ngx_string("<img src=\"");
static const ngx_str_t img_icon_post =
ngx_string("\" alt=\"\" height=\"32\" width=\"32\">");
static const ngx_str_t footer_pre =
ngx_string("<footer class=\"markup\">");
static const ngx_str_t footer_post =
ngx_string("</footer>");
#ifdef NGX_ESCAPE_URI_COMPONENT #ifdef NGX_ESCAPE_URI_COMPONENT
@ -625,21 +661,29 @@ ngx_fancyindex_escape_filename(u_char *dst, u_char *src, size_t size)
static ngx_inline ngx_buf_t* static ngx_inline ngx_buf_t*
make_header_buf(ngx_http_request_t *r, const ngx_str_t css_href) make_header_buf(ngx_http_request_t *r, ngx_http_fancyindex_loc_conf_t *alcf)
{ {
ngx_buf_t *b; ngx_buf_t *b;
size_t blen = r->uri.len size_t blen = ngx_sizeof_ssz(t01_head1)
+ ngx_sizeof_ssz(t01_head1)
+ ngx_sizeof_ssz(t02_head2) + ngx_sizeof_ssz(t02_head2)
+ r->uri.len
+ ngx_sizeof_ssz(t03_head3) + ngx_sizeof_ssz(t03_head3)
+ ngx_sizeof_ssz(t04_body1) + ngx_sizeof_ssz(t04_body1);
;
if (alcf->title.len) {
blen += alcf->title.len + 1;
}
if (css_href.len) { if (alcf->icon_href.len) {
blen += favicon_pre.len
+ alcf->icon_href.len
+ favicon_post.len;
}
if (alcf->css_href.len) {
blen += css_href_pre.len \ blen += css_href_pre.len \
+ css_href.len \ + alcf->css_href.len \
+ css_href_post.len + css_href_post.len;
;
} }
if ((b = ngx_create_temp_buf(r->pool, blen)) == NULL) if ((b = ngx_create_temp_buf(r->pool, blen)) == NULL)
@ -647,13 +691,25 @@ make_header_buf(ngx_http_request_t *r, const ngx_str_t css_href)
b->last = ngx_cpymem_ssz(b->last, t01_head1); b->last = ngx_cpymem_ssz(b->last, t01_head1);
if (css_href.len) { if (alcf->icon_href.len) {
b->last = ngx_cpymem_str(b->last, favicon_pre);
b->last = ngx_cpymem_str(b->last, alcf->icon_href);
b->last = ngx_cpymem_str(b->last, favicon_post);
}
if (alcf->css_href.len) {
b->last = ngx_cpymem_str(b->last, css_href_pre); b->last = ngx_cpymem_str(b->last, css_href_pre);
b->last = ngx_cpymem_str(b->last, css_href); b->last = ngx_cpymem_str(b->last, alcf->css_href);
b->last = ngx_cpymem_str(b->last, css_href_post); b->last = ngx_cpymem_str(b->last, css_href_post);
} }
b->last = ngx_cpymem_ssz(b->last, t02_head2); b->last = ngx_cpymem_ssz(b->last, t02_head2);
if (alcf->title.len) {
b->last = ngx_cpymem_str(b->last, alcf->title);
*b->last++ = ' ';
}
b->last = ngx_cpymem_str(b->last, r->uri); b->last = ngx_cpymem_str(b->last, r->uri);
b->last = ngx_cpymem_ssz(b->last, t03_head3); b->last = ngx_cpymem_ssz(b->last, t03_head3);
b->last = ngx_cpymem_ssz(b->last, t04_body1); b->last = ngx_cpymem_ssz(b->last, t04_body1);
@ -673,7 +729,7 @@ make_content_buf(
const char *sort_url_args = ""; const char *sort_url_args = "";
off_t length; off_t length;
size_t len, root, allocated, escape_html; size_t len, root, allocated, n_files=0, n_dirs=0;
int64_t multiplier; int64_t multiplier;
u_char *filename, *last; u_char *filename, *last;
ngx_tm_t tm; ngx_tm_t tm;
@ -683,6 +739,9 @@ make_content_buf(
ngx_str_t path; ngx_str_t path;
ngx_dir_t dir; ngx_dir_t dir;
ngx_buf_t *b; ngx_buf_t *b;
u_char *readme_path = NULL;
u_char readme_md = 0;
off_t readme_file_len = 0;
static const char *sizes[] = { "EiB", "PiB", "TiB", "GiB", "MiB", "KiB", "B" }; static const char *sizes[] = { "EiB", "PiB", "TiB", "GiB", "MiB", "KiB", "B" };
static const int64_t exbibyte = 1024LL * 1024LL * 1024LL * static const int64_t exbibyte = 1024LL * 1024LL * 1024LL *
@ -702,6 +761,8 @@ make_content_buf(
} }
path.data[path.len] = '\0'; path.data[path.len] = '\0';
r->headers_out.last_modified_time = 0;
ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, ngx_log_debug1(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
"http fancyindex: \"%s\"", path.data); "http fancyindex: \"%s\"", path.data);
@ -845,12 +906,32 @@ make_content_buf(
entry->name.len); entry->name.len);
entry->dir = ngx_de_is_dir(&dir); entry->dir = ngx_de_is_dir(&dir);
entry->link = ngx_de_is_link(&dir);
entry->mtime = ngx_de_mtime(&dir); entry->mtime = ngx_de_mtime(&dir);
entry->size = ngx_de_size(&dir); entry->size = ngx_de_size(&dir);
entry->utf_len = (r->headers_out.charset.len == 5 && entry->utf_len = (r->headers_out.charset.len == 5 &&
ngx_strncasecmp(r->headers_out.charset.data, (u_char*) "utf-8", 5) == 0) ngx_strncasecmp(r->headers_out.charset.data, (u_char*) "utf-8", 5) == 0)
? ngx_utf8_length(entry->name.data, entry->name.len) ? ngx_utf8_length(entry->name.data, entry->name.len)
: len; : len;
if (entry->dir) n_dirs += 1;
else n_files += 1;
if (ngx_strncasecmp(entry->name.data, (u_char*) "README", 6) == 0 && (entry->name.len == 6 || entry->name.data[6] == '.')) {
if (!readme_path || ngx_strcmp(readme_path, filename) > 0) {
// readme_path = filename;
if ((readme_path = ngx_palloc(r->pool, allocated)) == NULL)
return ngx_http_fancyindex_error(r, &dir, &path);
ngx_cpystrn(readme_path, filename, allocated);
readme_file_len = entry->size;
readme_md = entry->name.len > 6 && ngx_strncasecmp(entry->name.data + 6, (u_char*) ".md", 3) == 0;
}
}
if (entry->mtime > r->headers_out.last_modified_time) {
r->headers_out.last_modified_time = entry->mtime;
}
} }
if (ngx_close_dir(&dir) == NGX_ERROR) { if (ngx_close_dir(&dir) == NGX_ERROR) {
@ -858,33 +939,55 @@ make_content_buf(
ngx_close_dir_n " \"%s\" failed", &path); ngx_close_dir_n " \"%s\" failed", &path);
} }
if (readme_path) {
ngx_log_debug3(NGX_LOG_DEBUG_HTTP, r->connection->log, 0,
"HTTP fancyindex README: %s, MD%d, len: %d", readme_path, readme_md, readme_file_len);
}
/* /*
* Calculate needed buffer length. * Calculate needed buffer length.
*/ */
escape_html = ngx_escape_html(NULL, r->uri.data, r->uri.len); len = ngx_sizeof_ssz(t06_list1)
+ ngx_sizeof_ssz(t06_list2)
+ ngx_sizeof_ssz(t06_list3)
+ ngx_sizeof_ssz(t_parentdir_entry)
+ ngx_sizeof_ssz(t07_list2)
+ ngx_fancyindex_timefmt_calc_size (&alcf->time_format) * entries.nelts
+ ngx_http_fancyindex_num_places(n_dirs)
+ ngx_http_fancyindex_num_places(n_files);
if (alcf->show_path) if (alcf->show_path) {
len = r->uri.len + escape_html len += ngx_sizeof_ssz(t05_body2)
+ ngx_sizeof_ssz(t05_body2) + ngx_sizeof_ssz("<h1><a href=\"/\">/</a>")
+ ngx_sizeof_ssz(t06_list1) + ngx_sizeof_ssz("</h1>")
+ ngx_sizeof_ssz(t_parentdir_entry) + ngx_sizeof_ssz(t05_body3);
+ ngx_sizeof_ssz(t07_list2)
+ ngx_fancyindex_timefmt_calc_size (&alcf->time_format) * entries.nelts if (alcf->icon_href.len) {
; len += img_icon_pre.len
else + alcf->icon_href.len
len = r->uri.len + escape_html + img_icon_post.len;
+ ngx_sizeof_ssz(t06_list1) }
+ ngx_sizeof_ssz(t_parentdir_entry)
+ ngx_sizeof_ssz(t07_list2) ngx_uint_t last_slash = 0;
+ ngx_fancyindex_timefmt_calc_size (&alcf->time_format) * entries.nelts for (i = 1; i < r->uri.len; i++) {
; u_char c = r->uri.data[i];
if (c == '/') {
len += ngx_sizeof_ssz("<a href=\"")
+ ngx_sizeof_ssz("\">")
+ ngx_sizeof_ssz("</a>/")
+ ngx_escape_uri(NULL, r->uri.data, i, NGX_ESCAPE_URI)
+ ngx_escape_html(NULL, r->uri.data + last_slash + 1, i - last_slash - 1);
last_slash = i;
}
}
}
/* /*
* If we are a the root of the webserver (URI = "/" --> length of 1), * If we are a the root of the webserver (URI = "/" --> length of 1),
* do not display the "Parent Directory" link. * do not display the "Parent Directory" link.
*/ */
if (r->uri.len == 1) { if (r->uri.len == 1 || alcf->hide_parent) {
len -= ngx_sizeof_ssz(t_parentdir_entry); len -= ngx_sizeof_ssz(t_parentdir_entry);
} }
@ -899,19 +1002,34 @@ make_content_buf(
* <td>size</td><td>date</td> * <td>size</td><td>date</td>
* </tr> * </tr>
*/ */
len += ngx_sizeof_ssz("<tr><td colspan=\"2\" class=\"link\"><a href=\"") len += ngx_sizeof_ssz("<tr class=\"file\"><td><a href=\"")
+ entry[i].name.len + entry[i].escape /* Escaped URL */ + entry[i].name.len + entry[i].escape /* Escaped URL */
+ ngx_sizeof_ssz("?C=x&amp;O=y") /* URL sorting arguments */ + ngx_sizeof_ssz("?C=x&amp;O=y") /* URL sorting arguments */
+ ngx_sizeof_ssz("\" title=\"") + ngx_sizeof_ssz("\"><svg width=\"1.5em\" height=\"1em\" version=\"1.1\" viewBox=\"0 0 317 259\"><use xlink:href=\"#")
+ ngx_sizeof_ssz("\"></use></svg><span class=\"name\">")
+ entry[i].name.len + entry[i].utf_len + entry[i].escape_html + entry[i].name.len + entry[i].utf_len + entry[i].escape_html
+ ngx_sizeof_ssz("\">") + ngx_sizeof_ssz("</span></a></td><td>")
+ entry[i].name.len + entry[i].utf_len + entry[i].escape_html
+ ngx_sizeof_ssz("</a></td><td class=\"size\">")
+ 20 /* File size */ + 20 /* File size */
+ ngx_sizeof_ssz("</td><td class=\"date\">") /* Date prefix */ + ngx_sizeof_ssz("</td><td>") /* Date prefix */
+ ngx_sizeof_ssz("</td></tr>\n") /* Date suffix */ + ngx_sizeof_ssz("</td></tr>\n") /* Date suffix */
+ 2 /* CR LF */ + 2 /* CR LF */
; ;
if (entry[i].dir) len += ngx_sizeof_ssz("folder");
else len += ngx_sizeof_ssz("file");
if (entry[i].link) len += ngx_sizeof_ssz("-shortcut");
}
char *readme_md_content;
if (readme_file_len) {
if (readme_md) {
FILE *md_file = fopen((char *)readme_path, "r");
MMIOT *mkd = mkd_in(md_file, MKD_FLAGS);
mkd_compile(mkd, MKD_FLAGS);
readme_file_len = mkd_document(mkd, &readme_md_content);
fclose(md_file);
ngx_log_debug2(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "converted %s, len=%d", readme_path, readme_file_len);
}
len += footer_pre.len + readme_file_len + footer_post.len;
} }
if ((b = ngx_create_temp_buf(r->pool, len)) == NULL) if ((b = ngx_create_temp_buf(r->pool, len)) == NULL)
@ -1046,13 +1164,41 @@ make_content_buf(
} }
/* Display the path, if needed */ /* Display the path, if needed */
if (alcf->show_path){ if (alcf->show_path) {
b->last = last = (u_char *) ngx_escape_html(b->last, r->uri.data, r->uri.len);
b->last = ngx_cpymem_ssz(b->last, t05_body2); b->last = ngx_cpymem_ssz(b->last, t05_body2);
if (alcf->icon_href.len) {
b->last = ngx_cpymem_str(b->last, img_icon_pre);
b->last = ngx_cpymem_str(b->last, alcf->icon_href);
b->last = ngx_cpymem_str(b->last, img_icon_post);
}
b->last = ngx_cpymem_ssz(b->last, "<h1><a href=\"/\">/</a>");
ngx_uint_t last_slash = 0;
for (i = 1; i < r->uri.len; i++) {
u_char c = r->uri.data[i];
if (c == '/') {
b->last = ngx_cpymem_ssz(b->last, "<a href=\"");
b->last = (u_char *) ngx_escape_uri(b->last, r->uri.data, i, NGX_ESCAPE_URI);
b->last = ngx_cpymem_ssz(b->last, "\">");
b->last = (u_char *) ngx_escape_html(b->last, r->uri.data + last_slash + 1, i - last_slash - 1);
b->last = ngx_cpymem_ssz(b->last, "</a>/");
last_slash = i;
}
}
b->last = ngx_cpymem_ssz(b->last, "</h1>");
b->last = ngx_cpymem_ssz(b->last, t05_body3);
} }
/* Open the <table> tag */ /* Open the <table> tag */
b->last = ngx_cpymem_ssz(b->last, t06_list1); b->last = ngx_cpymem_ssz(b->last, t06_list1);
b->last = ngx_sprintf(b->last, "%d", n_dirs);
b->last = ngx_cpymem_ssz(b->last, t06_list2);
b->last = ngx_sprintf(b->last, "%d", n_files);
b->last = ngx_cpymem_ssz(b->last, t06_list3);
tp = ngx_timeofday(); tp = ngx_timeofday();
@ -1060,23 +1206,23 @@ make_content_buf(
if (r->uri.len > 1 && alcf->hide_parent == 0) { if (r->uri.len > 1 && alcf->hide_parent == 0) {
b->last = ngx_cpymem_ssz(b->last, b->last = ngx_cpymem_ssz(b->last,
"<tr>" "<tr>"
"<td colspan=\"2\" class=\"link\"><a href=\"../"); "<td><a href=\"../");
if (*sort_url_args) { if (*sort_url_args) {
b->last = ngx_cpymem(b->last, b->last = ngx_cpymem(b->last,
sort_url_args, sort_url_args,
ngx_sizeof_ssz("?C=N&amp;O=A")); ngx_sizeof_ssz("?C=N&amp;O=A"));
} }
b->last = ngx_cpymem_ssz(b->last, b->last = ngx_cpymem_ssz(b->last,
"\">Parent directory/</a></td>" "\"><span class=\"goup\">Parent directory</span></a></td>"
"<td class=\"size\">-</td>" "<td class=\"size\">&mdash;</td>"
"<td class=\"date\">-</td>" "<td class=\"date\">&mdash;</td>"
"</tr>" "</tr>"
CRLF); CRLF);
} }
/* Entries for directories and files */ /* Entries for directories and files */
for (i = 0; i < entries.nelts; i++) { for (i = 0; i < entries.nelts; i++) {
b->last = ngx_cpymem_ssz(b->last, "<tr><td colspan=\"2\" class=\"link\"><a href=\""); b->last = ngx_cpymem_ssz(b->last, "<tr class=\"file\"><td><a href=\"");
if (entry[i].escape) { if (entry[i].escape) {
ngx_fancyindex_escape_filename(b->last, ngx_fancyindex_escape_filename(b->last,
@ -1098,23 +1244,20 @@ make_content_buf(
} }
} }
*b->last++ = '"'; b->last = ngx_cpymem_ssz(b->last, "\"><svg width=\"1.5em\" height=\"1em\" version=\"1.1\" viewBox=\"0 0 317 259\"><use xlink:href=\"#");
b->last = ngx_cpymem_ssz(b->last, " title=\"");
b->last = (u_char *) ngx_escape_html(b->last, entry[i].name.data, entry[i].name.len); if (entry[i].dir) b->last = ngx_cpymem_ssz(b->last, "folder");
*b->last++ = '"'; else b->last = ngx_cpymem_ssz(b->last, "file");
*b->last++ = '>'; if (entry[i].link) b->last = ngx_cpymem_ssz(b->last, "-shortcut");
b->last = ngx_cpymem_ssz(b->last, "\"></use></svg><span class=\"name\">");
len = entry[i].utf_len; len = entry[i].utf_len;
b->last = (u_char *) ngx_escape_html(b->last, entry[i].name.data, entry[i].name.len); b->last = (u_char *) ngx_escape_html(b->last, entry[i].name.data, entry[i].name.len);
last = b->last - 3; last = b->last - 3;
if (entry[i].dir) { b->last = ngx_cpymem_ssz(b->last, "</span></a></td><td>");
*b->last++ = '/';
len++;
}
b->last = ngx_cpymem_ssz(b->last, "</a></td><td class=\"size\">");
if (alcf->exact_size) { if (alcf->exact_size) {
if (entry[i].dir) { if (entry[i].dir) {
@ -1143,7 +1286,7 @@ make_content_buf(
} }
ngx_gmtime(entry[i].mtime + tp->gmtoff * 60 * alcf->localtime, &tm); ngx_gmtime(entry[i].mtime + tp->gmtoff * 60 * alcf->localtime, &tm);
b->last = ngx_cpymem_ssz(b->last, "</td><td class=\"date\">"); b->last = ngx_cpymem_ssz(b->last, "</td><td>");
b->last = ngx_fancyindex_timefmt(b->last, &alcf->time_format, &tm); b->last = ngx_fancyindex_timefmt(b->last, &alcf->time_format, &tm);
b->last = ngx_cpymem_ssz(b->last, "</td></tr>"); b->last = ngx_cpymem_ssz(b->last, "</td></tr>");
@ -1154,6 +1297,44 @@ make_content_buf(
/* Output table bottom */ /* Output table bottom */
b->last = ngx_cpymem_ssz(b->last, t07_list2); b->last = ngx_cpymem_ssz(b->last, t07_list2);
// Readme file
if (readme_file_len) {
b->last = ngx_cpymem_str(b->last, footer_pre);
if (readme_md) {
b->last = ngx_cpymem(b->last, readme_md_content, readme_file_len);
} else {
ngx_file_t file;
ngx_memzero(&file, sizeof(ngx_file_t));
file.fd = ngx_open_file(readme_path, NGX_FILE_RDONLY, NGX_FILE_OPEN, 0);
if (file.fd == NGX_INVALID_FILE) {
ngx_log_error(NGX_LOG_ALERT, r->connection->log, ngx_errno,
"cannot open readme file \"%V\"", readme_path);
return NGX_ERROR;
}
file.log = r->connection->log;
ngx_log_debug(NGX_LOG_DEBUG_HTTP, r->connection->log, 0, "opened file %d", file);
ssize_t n = readme_file_len;
while (n > 0) {
ssize_t rbts = ngx_read_file(&file,
b->last + file.offset,
n,
file.offset);
if (rbts == NGX_ERROR) {
ngx_close_file(file.fd);
ngx_log_error(NGX_LOG_ALERT, r->connection->log, ngx_errno,
"cannot read readme file \"%V\"", readme_path);
return NGX_ERROR;
}
b->last += rbts;
n -= rbts;
}
}
b->last = ngx_cpymem_str(b->last, footer_post);
}
*pb = b; *pb = b;
return NGX_OK; return NGX_OK;
} }
@ -1264,7 +1445,7 @@ add_builtin_header:
out[0].buf->last = alcf->header.local.data + alcf->header.local.len; out[0].buf->last = alcf->header.local.data + alcf->header.local.len;
} else { } else {
/* Prepare a buffer with the contents of the builtin header. */ /* Prepare a buffer with the contents of the builtin header. */
out[0].buf = make_header_buf(r, alcf->css_href); out[0].buf = make_header_buf(r, alcf);
} }
} }
@ -1282,8 +1463,8 @@ add_builtin_header:
out[last].buf->pos = alcf->footer.local.data; out[last].buf->pos = alcf->footer.local.data;
out[last].buf->last = alcf->footer.local.data + alcf->footer.local.len; out[last].buf->last = alcf->footer.local.data + alcf->footer.local.len;
} else { } else {
out[last].buf->pos = (u_char*) t08_foot1; out[last].buf->pos = (u_char*) t08_foot;
out[last].buf->last = (u_char*) t08_foot1 + sizeof(t08_foot1) - 1; out[last].buf->last = (u_char*) t08_foot + sizeof(t08_foot) - 1;
} }
out[last-1].buf->last_in_chain = 0; out[last-1].buf->last_in_chain = 0;
@ -1344,8 +1525,8 @@ add_builtin_header:
if (out[0].buf == NULL) if (out[0].buf == NULL)
return NGX_ERROR; return NGX_ERROR;
out[0].buf->memory = 1; out[0].buf->memory = 1;
out[0].buf->pos = (u_char*) t08_foot1; out[0].buf->pos = (u_char*) t08_foot;
out[0].buf->last = (u_char*) t08_foot1 + sizeof(t08_foot1) - 1; out[0].buf->last = (u_char*) t08_foot + sizeof(t08_foot) - 1;
out[0].buf->last_in_chain = 1; out[0].buf->last_in_chain = 1;
out[0].buf->last_buf = 1; out[0].buf->last_buf = 1;
/* Directly send out the builtin footer */ /* Directly send out the builtin footer */
@ -1447,6 +1628,15 @@ ngx_http_fancyindex_error(ngx_http_request_t *r, ngx_dir_t *dir, ngx_str_t *name
return NGX_HTTP_INTERNAL_SERVER_ERROR; return NGX_HTTP_INTERNAL_SERVER_ERROR;
} }
static size_t ngx_http_fancyindex_num_places (size_t n) {
int r = 1;
while (n > 9) {
n /= 10;
r++;
}
return r;
}
static void * static void *
ngx_http_fancyindex_create_loc_conf(ngx_conf_t *cf) ngx_http_fancyindex_create_loc_conf(ngx_conf_t *cf)
@ -1508,7 +1698,7 @@ ngx_http_fancyindex_merge_loc_conf(ngx_conf_t *cf, void *parent, void *child)
ngx_conf_merge_str_value(conf->footer.path, prev->footer.local, ""); ngx_conf_merge_str_value(conf->footer.path, prev->footer.local, "");
ngx_conf_merge_str_value(conf->css_href, prev->css_href, ""); ngx_conf_merge_str_value(conf->css_href, prev->css_href, "");
ngx_conf_merge_str_value(conf->time_format, prev->time_format, "%Y-%b-%d %H:%M"); ngx_conf_merge_str_value(conf->time_format, prev->time_format, "%F %H:%M");
ngx_conf_merge_ptr_value(conf->ignore, prev->ignore, NULL); ngx_conf_merge_ptr_value(conf->ignore, prev->ignore, NULL);
ngx_conf_merge_value(conf->hide_symlinks, prev->hide_symlinks, 0); ngx_conf_merge_value(conf->hide_symlinks, prev->hide_symlinks, 0);

309
t/README.md Normal file
View file

@ -0,0 +1,309 @@
# Markdown: Syntax
* [Overview](#Overview)
* [Philosophy](#Philosophy)
* [Block Elements](#Block-Elements)
* [Paragraphs and Line Breaks](#Paragraphs-and-Line-Breaks)
* [Headers](#Headers)
* [Blockquotes](#Blockquotes)
* [Lists](#Lists)
* [Code Blocks](#Code-Blocks)
* [Horizontal Rules](#Horizontal-Rules)
* [Span Elements](#Span-Elements)
* [Links](#Links)
* [Emphasis](#Emphasis)
* [Code](#Code)
* [Table](#Table)
----
## Overview
### Philosophy
Markdown is intended to be as easy-to-read and easy-to-write as is feasible.
Readability, however, is emphasized above all else. A Markdown-formatted
document should be publishable as-is, as plain text, without looking
like it's been marked up with tags or formatting instructions. While
Markdown's syntax has been influenced by several existing text-to-HTML
filters -- including [Setext](http://docutils.sourceforge.net/mirror/setext.html), [atx](http://www.aaronsw.com/2002/atx/), [Textile](http://textism.com/tools/textile/), [reStructuredText](http://docutils.sourceforge.net/rst.html),
[Grutatext](http://www.triptico.com/software/grutatxt.html), and [EtText](http://ettext.taint.org/doc/) -- the single biggest source of
inspiration for Markdown's syntax is the format of plain text email.
## Block Elements
### Paragraphs and Line Breaks
A paragraph is simply one or more consecutive lines of text, separated
by one or more blank lines. (A blank line is any line that looks like a
blank line -- a line containing nothing but spaces or tabs is considered
blank.) Normal paragraphs should not be indented with spaces or tabs.
The implication of the "one or more consecutive lines of text" rule is
that Markdown supports "hard-wrapped" text paragraphs. This differs
significantly from most other text-to-HTML formatters (including Movable
Type's "Convert Line Breaks" option) which translate every line break
character in a paragraph into a `<br />` tag.
When you *do* want to insert a `<br />` break tag using Markdown, you
end a line with two or more spaces, then type return.
### Headers
Markdown supports two styles of headers, [Setext] [1] and [atx] [2].
Optionally, you may "close" atx-style headers. This is purely
cosmetic -- you can use this if you think it looks better. The
closing hashes don't even need to match the number of hashes
used to open the header. (The number of opening hashes
determines the header level.)
### Blockquotes
Markdown uses email-style `>` characters for blockquoting. If you're
familiar with quoting passages of text in an email message, then you
know how to create a blockquote in Markdown. It looks best if you hard
wrap the text and put a `>` before every line:
> This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,
> consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.
> Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.
>
> Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse
> id sem consectetuer libero luctus adipiscing.
Markdown allows you to be lazy and only put the `>` before the first
line of a hard-wrapped paragraph:
> This is a blockquote with two paragraphs. Lorem ipsum dolor sit amet,
consectetuer adipiscing elit. Aliquam hendrerit mi posuere lectus.
Vestibulum enim wisi, viverra nec, fringilla in, laoreet vitae, risus.
> Donec sit amet nisl. Aliquam semper ipsum sit amet velit. Suspendisse
id sem consectetuer libero luctus adipiscing.
Blockquotes can be nested (i.e. a blockquote-in-a-blockquote) by
adding additional levels of `>`:
> This is the first level of quoting.
>
> > This is nested blockquote.
>
> Back to the first level.
Blockquotes can contain other Markdown elements, including headers, lists,
and code blocks:
> ## This is a header.
>
> 1. This is the first list item.
> 2. This is the second list item.
>
> Here's some example code:
>
> return shell_exec("echo $input | $markdown_script");
Any decent text editor should make email-style quoting easy. For
example, with BBEdit, you can make a selection and choose Increase
Quote Level from the Text menu.
### Lists
Markdown supports ordered (numbered) and unordered (bulleted) lists.
Unordered lists use asterisks, pluses, and hyphens -- interchangably
-- as list markers:
* Red
* Green
* Blue
is equivalent to:
+ Red
+ Green
+ Blue
and:
- Red
- Green
- Blue
Ordered lists use numbers followed by periods:
1. Bird
2. McHale
3. Parish
It's important to note that the actual numbers you use to mark the
list have no effect on the HTML output Markdown produces. The HTML
Markdown produces from the above list is:
If you instead wrote the list in Markdown like this:
1. Bird
1. McHale
1. Parish
or even:
3. Bird
1. McHale
8. Parish
you'd get the exact same HTML output. The point is, if you want to,
you can use ordinal numbers in your ordered Markdown lists, so that
the numbers in your source match the numbers in your published HTML.
But if you want to be lazy, you don't have to.
To make lists look nice, you can wrap items with hanging indents:
* Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,
viverra nec, fringilla in, laoreet vitae, risus.
* Donec sit amet nisl. Aliquam semper ipsum sit amet velit.
Suspendisse id sem consectetuer libero luctus adipiscing.
But if you want to be lazy, you don't have to:
* Lorem ipsum dolor sit amet, consectetuer adipiscing elit.
Aliquam hendrerit mi posuere lectus. Vestibulum enim wisi,
viverra nec, fringilla in, laoreet vitae, risus.
* Donec sit amet nisl. Aliquam semper ipsum sit amet velit.
Suspendisse id sem consectetuer libero luctus adipiscing.
List items may consist of multiple paragraphs. Each subsequent
paragraph in a list item must be indented by either 4 spaces
or one tab:
1. This is a list item with two paragraphs. Lorem ipsum dolor
sit amet, consectetuer adipiscing elit. Aliquam hendrerit
mi posuere lectus.
Vestibulum enim wisi, viverra nec, fringilla in, laoreet
vitae, risus. Donec sit amet nisl. Aliquam semper ipsum
sit amet velit.
2. Suspendisse id sem consectetuer libero luctus adipiscing.
It looks nice if you indent every line of the subsequent
paragraphs, but here again, Markdown will allow you to be
lazy:
* This is a list item with two paragraphs.
This is the second paragraph in the list item. You're
only required to indent the first line. Lorem ipsum dolor
sit amet, consectetuer adipiscing elit.
* Another item in the same list.
To put a blockquote within a list item, the blockquote's `>`
delimiters need to be indented:
* A list item with a blockquote:
> This is a blockquote
> inside a list item.
To put a code block within a list item, the code block needs
to be indented *twice* -- 8 spaces or two tabs:
* A list item with a code block:
<code goes here>
### Code Blocks
Pre-formatted code blocks are used for writing about programming or
markup source code. Rather than forming normal paragraphs, the lines
of a code block are interpreted literally. Markdown wraps a code block
in both `<pre>` and `<code>` tags.
To produce a code block in Markdown, simply indent every line of the
block by at least 4 spaces or 1 tab.
This is a normal paragraph:
This is a code block.
Here is an example of AppleScript:
tell application "Foo"
beep
end tell
A code block continues until it reaches a line that is not indented
(or the end of the article).
Within a code block, ampersands (`&`) and angle brackets (`<` and `>`)
are automatically converted into HTML entities. This makes it very
easy to include example HTML source code using Markdown -- just paste
it and indent it, and Markdown will handle the hassle of encoding the
ampersands and angle brackets. For example, this:
<div class="footer">
&copy; 2004 Foo Corporation
</div>
Regular Markdown syntax is not processed within code blocks. E.g.,
asterisks are just literal asterisks within a code block. This means
it's also easy to use Markdown to write about Markdown's own syntax.
```
tell application "Foo"
beep
end tell
```
## Span Elements
### Links
Markdown supports two style of links: *inline* and *reference*.
In both styles, the link text is delimited by [square brackets].
To create an inline link, use a set of regular parentheses immediately
after the link text's closing square bracket. Inside the parentheses,
put the URL where you want the link to point, along with an *optional*
title for the link, surrounded in quotes. For example:
This is [an example](http://example.com/) inline link.
[This link](http://example.net/) has no title attribute.
### Emphasis
Markdown treats asterisks (`*`) and underscores (`_`) as indicators of
emphasis. Text wrapped with one `*` or `_` will be wrapped with an
HTML `<em>` tag; double `*`'s or `_`'s will be wrapped with an HTML
`<strong>` tag. E.g., this input:
*single asterisks*
_single underscores_
**double asterisks**
__double underscores__
### Code
To indicate a span of code, wrap it with backtick quotes (`` ` ``).
Unlike a pre-formatted code block, a code span indicates code within a
normal paragraph. For example:
Use the `printf()` function.
### Table
| Item | Price | # In stock |
|--------------|-----------|------------|
| Juicy Apples | 1.99 | *7* |
| Bananas | **1.89** | 5234 |
| Tomatoes | **1.89** | 5234 |

3
t/README.txt Normal file
View file

@ -0,0 +1,3 @@
<h1>Hello World</h1>
Hello World, this is me ;-)

View file

View file

@ -2,91 +2,622 @@
static const u_char t01_head1[] = "" static const u_char t01_head1[] = ""
"<!DOCTYPE html>" "<!DOCTYPE html>"
"<html>" "<html>"
"<head>" " <head>"
"<meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\">" " <meta http-equiv=\"content-type\" content=\"text/html; charset=utf-8\" />"
"<meta name=\"viewport\" content=\"width=device-width\">" " <meta name=\"viewport\" content=\"width=device-width\" />"
"<style type=\"text/css\">" " <style type=\"text/css\">"
"body,html {" "* {"
"background:#fff;" " padding: 0;"
"font-family:\"Bitstream Vera Sans\",\"Lucida Grande\"," " margin: 0;"
"\"Lucida Sans Unicode\",Lucidux,Verdana,Lucida,sans-serif;" " --color-secondary: #dedede;"
" --color-text-light: gray;"
"}" "}"
"table {" "body {"
"table-layout: fixed;" " font-family: sans-serif;"
"}" " text-rendering: optimizespeed;"
"tr:nth-child(even) {" " background-color: #f5f5f5;"
"background:#f4f4f4;"
"}"
"th,td {"
"padding:0.1em 0.5em;"
"}"
"th {"
"text-align:left;"
"font-weight:bold;"
"background:#eee;"
"border-bottom:1px solid #aaa;"
"}"
"#list {"
"border:1px solid #aaa;"
"width:100%;"
"}" "}"
"a {" "a {"
"color:#a33;" " color: #006ed3;"
" text-decoration: none;"
"}" "}"
"a:hover {" "a:hover {"
"color:#e33;" " color: #319cff;"
"}" "}"
".link {" "header,"
"white-space: nowrap;" "#summary {"
"text-overflow: '>';" " padding: 0 20px;"
"overflow: hidden;" "}"
"header {"
" display: flex;"
" flex-direction: row;"
" gap: 1em;"
" padding-top: 25px;"
" padding-bottom: 15px;"
" background-color: #f2f2f2;"
"}"
"header h1 {"
" font-size: 20px;"
" font-weight: normal;"
" white-space: nowrap;"
" overflow-x: hidden;"
" text-overflow: ellipsis;"
" color: #999;"
"}"
"header h1 a {"
" color: #000;"
" margin: 0 4px;"
"}"
"header h1 a:hover, footer a:hover {"
" text-decoration: underline;"
"}"
"header h1 a:first-child {"
" margin: 0;"
"}"
"main {"
" display: block;"
"}"
".meta {"
" font-size: 12px;"
" font-family: Verdana, sans-serif;"
" border-bottom: 1px solid #9c9c9c;"
" padding-top: 10px;"
" padding-bottom: 10px;"
"}"
".meta-item {"
" margin-right: 1em;"
"}"
"#filter {"
" padding: 4px;"
" border: 1px solid #ccc;"
"}"
"#list {"
" width: 100%;"
" border-collapse: collapse;"
"}"
"#list tr {"
" border-bottom: 1px dashed #dadada;"
"}"
"#list tbody tr:hover {"
" background-color: #ffffec;"
"}"
"#list th,"
"#list td {"
" text-align: left;"
" padding: 10px 0;"
"}"
"#list th {"
" padding-top: 15px;"
" padding-bottom: 15px;"
" font-size: 16px;"
" white-space: nowrap;"
"}"
"#list th a {"
" color: black;"
"}"
"#list th svg {"
" vertical-align: middle;"
"}"
"#list td {"
" white-space: nowrap;"
" font-size: 14px;"
"}"
"#list td:nth-child(1),"
"#list th:nth-child(1) {"
" padding-left: 20px;"
" width: 80%;"
"}"
"#list td:nth-child(2),"
"#list th:nth-child(2) {"
" padding: 0 20px 0 20px;"
"}"
"#list th:nth-child(3),"
"#list td:nth-child(3) {"
" text-align: right;"
" padding-right: 20px;"
"}"
"#list td:nth-child(1) svg {"
" position: absolute;"
"}"
"#list td .name,"
"#list td .goup {"
" margin-left: 1.75em;"
" word-break: break-all;"
" overflow-wrap: break-word;"
" white-space: pre-wrap;"
"}"
"footer {"
" padding: 40px 20px;"
"}"
".markup {"
" max-width: 790px;"
" word-wrap: break-word;"
" font-size: 16px;"
" overflow: hidden;"
" line-height: 1.5 !important;"
"}"
".markup > :first-child {"
" margin-top: 0 !important;"
"}"
".markup > :last-child {"
" margin-bottom: 0 !important;"
"}"
".markup h1,"
".markup h2,"
".markup h3,"
".markup h4,"
".markup h5,"
".markup h6 {"
" font-weight: 600;"
" margin-top: 24px;"
" margin-bottom: 16px;"
" line-height: 1.25;"
"}"
".markup h1 tt,"
".markup h1 code,"
".markup h2 tt,"
".markup h2 code,"
".markup h3 tt,"
".markup h3 code,"
".markup h4 tt,"
".markup h4 code,"
".markup h5 tt,"
".markup h5 code,"
".markup h6 tt,"
".markup h6 code {"
" font-size: inherit;"
"}"
".markup h1 {"
" border-bottom: 1px solid var(--color-secondary);"
" padding-bottom: 0.3em;"
" font-size: 2em;"
"}"
".markup h2 {"
" border-bottom: 1px solid var(--color-secondary);"
" padding-bottom: 0.3em;"
" font-size: 1.5em;"
"}"
".markup h3 {"
" font-size: 1.25em;"
"}"
".markup h4 {"
" font-size: 1em;"
"}"
".markup h5 {"
" font-size: 0.875em;"
"}"
".markup h6 {"
" color: var(--color-text-light);"
" font-size: 0.85em;"
"}"
".markup p,"
".markup blockquote,"
".markup details,"
".markup ul,"
".markup ol,"
".markup dl,"
".markup table,"
".markup pre {"
" margin-top: 0;"
" margin-bottom: 16px;"
"}"
".markup hr {"
" background-color: var(--color-secondary);"
" border: 0;"
" height: 4px;"
" margin: 16px 0;"
" padding: 0;"
"}"
".markup ul,"
".markup ol {"
" padding-left: 2em;"
"}"
".markup ul ul,"
".markup ul ol,"
".markup ol ol,"
".markup ol ul {"
" margin-top: 0;"
" margin-bottom: 0;"
"}"
".markup ol ol,"
".markup ul ol {"
" list-style-type: lower-roman;"
"}"
".markup li > p {"
" margin-top: 16px;"
"}"
".markup li + li {"
" margin-top: 0.25em;"
"}"
".markup dl {"
" padding: 0;"
"}"
".markup dl dt {"
" font-size: 1em;"
" font-style: italic;"
" font-weight: 600;"
" margin-top: 16px;"
" padding: 0;"
"}"
".markup dl dd {"
" margin-bottom: 16px;"
" padding: 0 16px;"
"}"
".markup blockquote {"
" color: var(--color-text-light);"
" border-left: 4px solid var(--color-secondary);"
" margin-left: 0;"
" padding: 0 15px;"
"}"
".markup blockquote > :first-child {"
" margin-top: 0;"
"}"
".markup blockquote > :last-child {"
" margin-bottom: 0;"
"}"
".markup table {"
" width: max-content;"
" max-width: 100%;"
" display: block;"
" overflow: auto;"
"}"
".markup table th {"
" font-weight: 600;"
"}"
".markup table th,"
".markup table td {"
" border: 1px solid var(--color-secondary) !important;"
" padding: 6px 13px !important;"
"}"
".markup table tr {"
" border-top: 1px solid var(--color-secondary);"
"}"
".markup table tr:nth-child(2n) {"
" background-color: var(--color-secondary);"
"}"
".markup img,"
".markup video {"
" box-sizing: initial;"
" max-width: 100%;"
"}"
".markup img[align=\"right\"],"
".markup video[align=\"right\"] {"
" padding-left: 20px;"
"}"
".markup img[align=\"left\"],"
".markup video[align=\"left\"] {"
" padding-right: 28px;"
"}"
".markup code {"
" white-space: break-spaces;"
" background-color: var(--color-secondary);"
" border-radius: 4px;"
" margin: 0;"
" padding: 0.2em 0.4em;"
" font-size: 85%;"
"}"
".markup code br {"
" display: none;"
"}"
".markup pre {"
" background-color: var(--color-secondary);"
" border-radius: 4px;"
" padding: 16px;"
" font-size: 85%;"
" line-height: 1.45;"
" margin-bottom: 16px;"
" word-break: normal;"
" word-wrap: normal;"
"}"
".markup pre code {"
" white-space: pre-wrap;"
" word-break: break-all;"
" overflow-wrap: break-word;"
" background: 0 0;"
" line-height: inherit;"
" word-wrap: normal;"
" border: 0;"
" padding: 0;"
" margin: 0;"
" display: inline;"
" font-size: 100%;"
"}"
".markup pre code:before,"
".markup pre code:after {"
" content: normal;"
"}"
".markup .ui.list .list,"
".markup ol.ui.list ol,"
".markup ul.ui.list ul {"
" padding-left: 2em;"
"}" "}"
"</style>"
"\n" "\n"
" @media (max-width: 600px) {"
" td:nth-child(1) {"
" width: auto;"
" }"
" th:nth-child(2),"
" td:nth-child(2) {"
" display: none;"
" }"
" h1 a {"
" margin: 0;"
" }"
" #filter {"
" max-width: 100px;"
" }"
" }"
" @media (prefers-color-scheme: dark) {"
" * {"
" --color-secondary: #082437;"
" --color-text-light: rgb(139, 157, 169);"
" }"
" body {"
" background-color: #101010;"
" color: #dddddd;"
" }"
" header {"
" background-color: #151515;"
" }"
" #list tbody tr:hover {"
" background-color: #252525;"
" }"
" header h1 a,"
" #list th a {"
" color: #dddddd;"
" }"
" a {"
" color: #5796d1;"
" text-decoration: none;"
" }"
" a:hover,"
" h1 a:hover {"
" color: #62b2fd;"
" }"
" #list tr {"
" border-bottom: 1px dashed rgba(255, 255, 255, 0.12);"
" }"
" #filter {"
" background-color: #151515;"
" color: #ffffff;"
" border: 1px solid #212121;"
" }"
" .meta {"
" border-bottom: 1px solid #212121;"
" }"
" footer code, footer pre {"
" background-color: rgb(8, 36, 55);"
" }"
" }"
" </style>"
; ;
static const u_char t02_head2[] = "" static const u_char t02_head2[] = ""
"\n" "<title>"
"<title>Index of "
; ;
static const u_char t03_head3[] = "" static const u_char t03_head3[] = ""
"</title>" "</title>"
"\n"
"</head>" "</head>"
; ;
static const u_char t04_body1[] = "" static const u_char t04_body1[] = ""
"<body>" " <body onload=\"initFilter()\">"
"<h1>Index of " " <svg"
" version=\"1.1\""
" xmlns=\"http://www.w3.org/2000/svg\""
" xmlns:xlink=\"http://www.w3.org/1999/xlink\""
" height=\"0\""
" width=\"0\""
" style=\"position: absolute\""
" >"
" <defs>"
" <g id=\"folder\" fill-rule=\"nonzero\" fill=\"none\">"
" <path"
" d=\"M285.22 37.55h-142.6L110.9 0H31.7C14.25 0 0 16.9 0 37.55v75.1h316.92V75.1c0-20.65-14.26-37.55-31.7-37.55z\""
" fill=\"#FFA000\""
" />"
" <path"
" d=\"M285.22 36H31.7C14.25 36 0 50.28 0 67.74v158.7c0 17.47 14.26 31.75 31.7 31.75H285.2c17.44 0 31.7-14.3 31.7-31.75V67.75c0-17.47-14.26-31.75-31.7-31.75z\""
" fill=\"#FFCA28\""
" />"
" </g>"
" <g"
" id=\"folder-shortcut\""
" stroke=\"none\""
" stroke-width=\"1\""
" fill=\"none\""
" fill-rule=\"evenodd\""
" >"
" <g id=\"folder-shortcut-group\" fill-rule=\"nonzero\">"
" <g id=\"folder-shortcut-shape\">"
" <path"
" d=\"M285.224876,37.5486902 L142.612438,37.5486902 L110.920785,0 L31.6916529,0 C14.2612438,0 0,16.8969106 0,37.5486902 L0,112.646071 L316.916529,112.646071 L316.916529,75.0973805 C316.916529,54.4456008 302.655285,37.5486902 285.224876,37.5486902 Z\""
" id=\"Shape\""
" fill=\"#FFA000\""
" ></path>"
" <path"
" d=\"M285.224876,36 L31.6916529,36 C14.2612438,36 0,50.2838568 0,67.7419039 L0,226.451424 C0,243.909471 14.2612438,258.193328 31.6916529,258.193328 L285.224876,258.193328 C302.655285,258.193328 316.916529,243.909471 316.916529,226.451424 L316.916529,67.7419039 C316.916529,50.2838568 302.655285,36 285.224876,36 Z\""
" id=\"Shape\""
" fill=\"#FFCA28\""
" ></path>"
" </g>"
" <path"
" d=\"M126.154134,250.559184 C126.850974,251.883673 127.300549,253.006122 127.772602,254.106122 C128.469442,255.206122 128.919016,256.104082 129.638335,257.002041 C130.559962,258.326531 131.728855,259 133.100057,259 C134.493737,259 135.415364,258.55102 136.112204,257.67551 C136.809044,257.002041 137.258619,255.902041 137.258619,254.577551 C137.258619,253.904082 137.258619,252.804082 137.033832,251.457143 C136.786566,249.908163 136.561779,249.032653 136.561779,248.583673 C136.089726,242.814286 135.864939,237.920408 135.864939,233.273469 C135.864939,225.057143 136.786566,217.514286 138.180246,210.846939 C139.798713,204.202041 141.889234,198.634694 144.429328,193.763265 C147.216689,188.869388 150.678411,184.873469 154.836973,181.326531 C158.995535,177.779592 163.626149,174.883673 168.481552,172.661224 C173.336954,170.438776 179.113983,168.665306 185.587852,167.340816 C192.061722,166.218367 198.760378,165.342857 205.481514,164.669388 C212.18017,164.220408 219.598146,163.995918 228.162535,163.995918 L246.055591,163.995918 L246.055591,195.514286 C246.055591,197.736735 246.752431,199.510204 248.370899,201.059184 C250.214153,202.608163 252.079886,203.506122 254.372715,203.506122 C256.463236,203.506122 258.531277,202.608163 260.172223,201.059184 L326.102289,137.797959 C327.720757,136.24898 328.642384,134.47551 328.642384,132.253061 C328.642384,130.030612 327.720757,128.257143 326.102289,126.708163 L260.172223,63.4469388 C258.553756,61.8979592 256.463236,61 254.395194,61 C252.079886,61 250.236632,61.8979592 248.393377,63.4469388 C246.77491,64.9959184 246.07807,66.7693878 246.07807,68.9918367 L246.07807,100.510204 L228.162535,100.510204 C166.863084,100.510204 129.166282,117.167347 115.274437,150.459184 C110.666301,161.54898 108.350993,175.310204 108.350993,191.742857 C108.350993,205.279592 113.903236,223.912245 124.760454,247.438776 C125.00772,248.112245 125.457294,249.010204 126.154134,250.559184 Z\""
" id=\"Shape\""
" fill=\"#FFFFFF\""
" transform=\"translate(218.496689, 160.000000) scale(-1, 1) translate(-218.496689, -160.000000) \""
" ></path>"
" </g>"
" </g>"
" <g"
" id=\"file\""
" stroke=\"#000\""
" stroke-width=\"25\""
" fill=\"#FFF\""
" fill-rule=\"evenodd\""
" stroke-linecap=\"round\""
" stroke-linejoin=\"round\""
" >"
" <path"
" d=\"M13 24.12v274.76c0 6.16 5.87 11.12 13.17 11.12H239c7.3 0 13.17-4.96 13.17-11.12V136.15S132.6 13 128.37 13H26.17C18.87 13 13 17.96 13 24.12z\""
" />"
" <path d=\"M129.37 13L129 113.9c0 10.58 7.26 19.1 16.27 19.1H249L129.37 13z\" />"
" </g>"
" <g"
" id=\"file-shortcut\""
" stroke=\"none\""
" stroke-width=\"1\""
" fill=\"none\""
" fill-rule=\"evenodd\""
" >"
" <g id=\"file-shortcut-group\" transform=\"translate(13.000000, 13.000000)\">"
" <g"
" id=\"file-shortcut-shape\""
" stroke=\"#000000\""
" stroke-width=\"25\""
" fill=\"#FFFFFF\""
" stroke-linecap=\"round\""
" stroke-linejoin=\"round\""
" >"
" <path"
" d=\"M0,11.1214886 L0,285.878477 C0,292.039924 5.87498876,296.999983 13.1728373,296.999983 L225.997983,296.999983 C233.295974,296.999983 239.17082,292.039942 239.17082,285.878477 L239.17082,123.145388 C239.17082,123.145388 119.58541,2.84217094e-14 115.369423,2.84217094e-14 L13.1728576,2.84217094e-14 C5.87500907,-1.71479982e-05 0,4.96022995 0,11.1214886 Z\""
" id=\"rect1171\""
" ></path>"
" <path"
" d=\"M116.37005,0 L116,100.904964 C116,111.483663 123.258008,120 132.273377,120 L236,120 L116.37005,0 L116.37005,0 Z\""
" id=\"rect1794\""
" ></path>"
" </g>"
" <path"
" d=\"M47.803141,294.093878 C48.4999811,295.177551 48.9495553,296.095918 49.4216083,296.995918 C50.1184484,297.895918 50.5680227,298.630612 51.2873415,299.365306 C52.2089688,300.44898 53.3778619,301 54.7490634,301 C56.1427436,301 57.0643709,300.632653 57.761211,299.916327 C58.4580511,299.365306 58.9076254,298.465306 58.9076254,297.381633 C58.9076254,296.830612 58.9076254,295.930612 58.6828382,294.828571 C58.4355724,293.561224 58.2107852,292.844898 58.2107852,292.477551 C57.7387323,287.757143 57.5139451,283.753061 57.5139451,279.95102 C57.5139451,273.228571 58.4355724,267.057143 59.8292526,261.602041 C61.44772,256.165306 63.5382403,251.610204 66.0783349,247.62449 C68.8656954,243.620408 72.3274172,240.35102 76.4859792,237.44898 C80.6445412,234.546939 85.2751561,232.177551 90.1305582,230.359184 C94.9859603,228.540816 100.76299,227.089796 107.236859,226.006122 C113.710728,225.087755 120.409385,224.371429 127.13052,223.820408 C133.829177,223.453061 141.247152,223.269388 149.811542,223.269388 L167.704598,223.269388 L167.704598,249.057143 C167.704598,250.87551 168.401438,252.326531 170.019905,253.593878 C171.86316,254.861224 173.728893,255.595918 176.021722,255.595918 C178.112242,255.595918 180.180284,254.861224 181.82123,253.593878 L247.751296,201.834694 C249.369763,200.567347 250.291391,199.116327 250.291391,197.297959 C250.291391,195.479592 249.369763,194.028571 247.751296,192.761224 L181.82123,141.002041 C180.202763,139.734694 178.112242,139 176.044201,139 C173.728893,139 171.885639,139.734694 170.042384,141.002041 C168.423917,142.269388 167.727077,143.720408 167.727077,145.538776 L167.727077,171.326531 L149.811542,171.326531 C88.5120908,171.326531 50.8152886,184.955102 36.9234437,212.193878 C32.3153075,221.267347 30,232.526531 30,245.971429 C30,257.046939 35.5522422,272.291837 46.4094607,291.540816 C46.6567266,292.091837 47.1063009,292.826531 47.803141,294.093878 Z\""
" id=\"Shape-Copy\""
" fill=\"#000000\""
" fill-rule=\"nonzero\""
" transform=\"translate(140.145695, 220.000000) scale(-1, 1) translate(-140.145695, -220.000000) \""
" ></path>"
" </g>"
" </g>"
" </defs>"
" </svg>"
; ;
static const u_char t05_body2[] = "" static const u_char t05_body2[] = ""
"</h1>" " <header>"
"\n" ;
static const u_char t05_body3[] = ""
" </header>"
; ;
static const u_char t06_list1[] = "" static const u_char t06_list1[] = ""
"<table id=\"list\">" " <main>"
"<thead>" " <div class=\"meta\">"
"<tr>" " <div id=\"summary\">"
"<th colspan=\"2\"><a href=\"?C=N&amp;O=A\">File Name</a>&nbsp;<a href=\"?C=N&amp;O=D\">&nbsp;&darr;&nbsp;</a></th>" " <span class=\"meta-item\"><b>"
"<th><a href=\"?C=S&amp;O=A\">File Size</a>&nbsp;<a href=\"?C=S&amp;O=D\">&nbsp;&darr;&nbsp;</a></th>" ;
"<th><a href=\"?C=M&amp;O=A\">Date</a>&nbsp;<a href=\"?C=M&amp;O=D\">&nbsp;&darr;&nbsp;</a></th>" static const u_char t06_list2[] = ""
"</tr>" "</b> directories</span>"
"</thead>" "<span class=\"meta-item\"><b>"
;
static const u_char t06_list3[] = ""
"</b> files</span>"
" <span class=\"meta-item\""
" ><input type=\"text\" placeholder=\"filter\" id=\"filter\" onkeyup=\"filter()\""
" /></span>"
" </div>"
" </div>"
" <div class=\"listing\">"
" <table id=\"list\" aria-describedby=\"summary\">"
" <thead>"
" <tr>"
" <th>"
" <a href=\"?C=N&amp;O=A\">Size</a>&nbsp;<a href=\"?C=N&amp;O=D\""
" >&nbsp;&darr;&nbsp;</a"
" >"
" </th>"
" <th>"
" <a href=\"?C=S&amp;O=A\">Size</a>&nbsp;<a href=\"?C=S&amp;O=D\""
" >&nbsp;&darr;&nbsp;</a"
" >"
" </th>"
" <th>"
" <a href=\"?C=M&amp;O=A\">Modified</a>&nbsp;<a href=\"?C=M&amp;O=D\""
" >&nbsp;&darr;&nbsp;</a"
" >"
" </th>"
" </tr>"
" </thead>"
"\n" "\n"
"<tbody>" " <tbody>"
; ;
static const u_char t_parentdir_entry[] = "" static const u_char t_parentdir_entry[] = ""
"<tr>" " <tr>"
"<td colspan=\"2\" class=\"link\"><a href=\"../?C=N&amp;O=A\">Parent directory/</a></td>" " <td>"
"<td class=\"size\">-</td>" " <a href=\"../?C=N&amp;O=A\">"
"<td class=\"date\">-</td>" " <span class=\"goup\">Parent directory</span>"
"</tr>" " </a>"
" </td>"
" <td>&mdash;</td>"
" <td>&mdash;</td>"
" </tr>"
"\n" "\n"
; ;
static const u_char t07_list2[] = "" static const u_char t07_list2[] = ""
"</tbody>" " </tbody>"
"</table>" " </table>"
" </div>"
" </main>"
"\n"
; ;
static const u_char t08_foot1[] = "" static const u_char t08_foot[] = ""
"</body>" " <script>"
" var filterEl = document.getElementById(\"filter\");"
" filterEl.focus();"
" function initFilter() {"
" if (!filterEl.value) {"
" var filterParam = new URL(window.location.href).searchParams.get(\"filter\");"
" if (filterParam) {"
" filterEl.value = filterParam;"
" }"
" }"
" filter();"
" }"
" function filter() {"
" var q = filterEl.value.trim().toLowerCase();"
" var elems = document.querySelectorAll(\"tr.file\");"
" elems.forEach(function (el) {"
" if (!q) {"
" el.style.display = \"\";"
" return;"
" }"
" var nameEl = el.querySelector(\"td\");"
" var nameVal = nameEl.textContent.trim().toLowerCase();"
" if (nameVal.indexOf(q) !== -1) {"
" el.style.display = \"\";"
" } else {"
" el.style.display = \"none\";"
" }"
" });"
" }"
" function localizeDatetime(e, index, ar) {"
" if (e.textContent === undefined) {"
" return;"
" }"
" var d = new Date(e.getAttribute(\"datetime\"));"
" if (isNaN(d)) {"
" d = new Date(e.textContent);"
" if (isNaN(d)) {"
" return;"
" }"
" }"
" e.textContent = d.toLocaleString([], {"
" day: \"2-digit\","
" month: \"2-digit\","
" year: \"numeric\","
" hour: \"2-digit\","
" minute: \"2-digit\","
" second: \"2-digit\","
" });"
" }"
" var timeList = Array.prototype.slice.call(document.getElementsByTagName(\"time\"));"
" timeList.forEach(localizeDatetime);"
" </script>"
" </body>"
"</html>" "</html>"
; ;
#define NFI_TEMPLATE_SIZE (0 \ #define NFI_TEMPLATE_SIZE (0 \
@ -95,8 +626,11 @@ static const u_char t08_foot1[] = ""
+ nfi_sizeof_ssz(t03_head3) \ + nfi_sizeof_ssz(t03_head3) \
+ nfi_sizeof_ssz(t04_body1) \ + nfi_sizeof_ssz(t04_body1) \
+ nfi_sizeof_ssz(t05_body2) \ + nfi_sizeof_ssz(t05_body2) \
+ nfi_sizeof_ssz(t05_body3) \
+ nfi_sizeof_ssz(t06_list1) \ + nfi_sizeof_ssz(t06_list1) \
+ nfi_sizeof_ssz(t06_list2) \
+ nfi_sizeof_ssz(t06_list3) \
+ nfi_sizeof_ssz(t_parentdir_entry) \ + nfi_sizeof_ssz(t_parentdir_entry) \
+ nfi_sizeof_ssz(t07_list2) \ + nfi_sizeof_ssz(t07_list2) \
+ nfi_sizeof_ssz(t08_foot1) \ + nfi_sizeof_ssz(t08_foot) \
) )

File diff suppressed because it is too large Load diff