[PATCH] Add autoindex_css_file option

Clément Bœsch ubitux at gmail.com
Fri Mar 4 03:57:44 MSK 2011


On Wed, Feb 23, 2011 at 10:20:23AM +0100, Clément Bœsch wrote:
> On Mon, Feb 21, 2011 at 02:00:04PM +0300, Maxim Dounin wrote:
> > Hello!
> > 
> > On Mon, Feb 21, 2011 at 01:20:27AM +0100, Clément Bœsch wrote:
> > 
> > > On Mon, Feb 21, 2011 at 03:08:18AM +0300, Maxim Dounin wrote:
> > > > Hello!
> > > > 
> > > > On Sun, Feb 20, 2011 at 09:47:37PM +0100, Clément Bœsch wrote:
> > > > 
> > > > [...]
> > > > 
> > > > >  static u_char title[] =
> > > > > -"<html>" CRLF
> > > > > +"<!DOCTYPE html>" CRLF
> > > > >  "<head><title>Index of "
> > > > >  ;
> > > > 
> > > > The result isn't html at all.
> > > > 
> > > 
> > > Well it's HTML5…
> > 
> > No it isn't.  You dropped html element.
> > 
> 
> My bad, it didn't look mandatory for the w3c validator: "<!doctype
> html><head><title></title></head></html>" seems to be the minimum, but
> I'll definitely update the patch.
> 
> > Please note that there is also other issues with you patches, you 
> > may want spend some more time on them before posting again.
> > 
> 
> Could you be a bit more explicit? What are the issues?
> 
> Regards,
> 

It seems those patches don't get much attention, but I guess it's normal.
Anyway, I re-attached the third patch fixing the HTML issue. If you plan
to apply those patches and need me to fix something else, just ask me.

Regards,

-- 
Clément B.
-------------- next part --------------
From 974145d80b9cd295e51b9dfef67e9eafcfb4534c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Cl=C3=A9ment=20B=C5=93sch?= <ubitux at gmail.com>
Date: Sun, 20 Feb 2011 21:27:44 +0100
Subject: [PATCH 3/3] Use valid HTML.

---
 src/http/modules/ngx_http_autoindex_module.c |   23 ++++++++++-------------
 1 files changed, 10 insertions(+), 13 deletions(-)

diff --git a/src/http/modules/ngx_http_autoindex_module.c b/src/http/modules/ngx_http_autoindex_module.c
index 8d43028..25c6861 100644
--- a/src/http/modules/ngx_http_autoindex_module.c
+++ b/src/http/modules/ngx_http_autoindex_module.c
@@ -122,22 +122,19 @@ ngx_module_t  ngx_http_autoindex_module = {
     NGX_MODULE_V1_PADDING
 };
 
+#define HTML_HEAD "<!DOCTYPE html>" CRLF "<html>" CRLF "<head>"
 
-static u_char title[] =
-"<html>" CRLF
-"<head><title>Index of "
-;
+static u_char title[] = HTML_HEAD "<title>Index of ";
 
-static u_char title_pre_css[] =
-"<html>" CRLF
-"<head><link rel=\"stylesheet\" type=\"text/css\" href=\""
+static u_char title_pre_css[] = HTML_HEAD \
+"<link rel=\"stylesheet\" type=\"text/css\" href=\""
 ;
 
 static u_char title_post_css[] = "\" /><title>Index of ";
 
 static u_char header[] =
 "</title></head>" CRLF
-"<body bgcolor=\"white\">" CRLF
+"<body>" CRLF
 "<h1>Index of "
 ;
 
@@ -384,8 +381,8 @@ ngx_http_autoindex_handler(ngx_http_request_t *r)
         + sizeof(header) - 1
         + r->uri.len
         + sizeof("</h1>") - 1
-        + sizeof("<hr><pre><a href=\"../\">../</a>" CRLF) - 1
-        + sizeof("</pre><hr>") - 1
+        + sizeof("<hr/><pre><a href=\"../\">../</a>" CRLF) - 1
+        + sizeof("</pre><hr/>") - 1
         + sizeof(tail) - 1;
 
     entry = entries.elts;
@@ -428,8 +425,8 @@ ngx_http_autoindex_handler(ngx_http_request_t *r)
     b->last = ngx_cpymem(b->last, r->uri.data, r->uri.len);
     b->last = ngx_cpymem(b->last, "</h1>", sizeof("</h1>") - 1);
 
-    b->last = ngx_cpymem(b->last, "<hr><pre><a href=\"../\">../</a>" CRLF,
-                         sizeof("<hr><pre><a href=\"../\">../</a>" CRLF) - 1);
+    b->last = ngx_cpymem(b->last, "<hr/><pre><a href=\"../\">../</a>" CRLF,
+                         sizeof("<hr/><pre><a href=\"../\">../</a>" CRLF) - 1);
 
     tp = ngx_timeofday();
 
@@ -563,7 +560,7 @@ ngx_http_autoindex_handler(ngx_http_request_t *r)
 
     /* TODO: free temporary pool */
 
-    b->last = ngx_cpymem(b->last, "</pre><hr>", sizeof("</pre><hr>") - 1);
+    b->last = ngx_cpymem(b->last, "</pre><hr/>", sizeof("</pre><hr/>") - 1);
 
     b->last = ngx_cpymem(b->last, tail, sizeof(tail) - 1);
 
-- 
1.7.4.1

-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 490 bytes
Desc: not available
URL: <http://nginx.org/pipermail/nginx-devel/attachments/20110304/717ec450/attachment.pgp>


More information about the nginx-devel mailing list