A better mod_dirlisting for lighttpd

The default module is cool and fast, but i lacks some features like it doesn’t show the modes of the files, and not all tags are associated with class names which limits our usage in using an external css. So i made an attempt to add these to the default module.

as lighttpd runs based on a config file, you have to code the config file every-time or you can write a custom script with cmdline-args(for config) to do that for you, here’s mine

[link: https://gist.github.com/9b3e0a7daecdc0206305 ]

It starts a port scan from 9009 and searches for the available one to bind lighttpd, adds all known mimetypes(from python module) to the config, copies external css for mod_dirlisting. and of-course document root is current directory.

At first i tried to implement the features as mod_cgi – python using jinja which is obviously the easy way but unfortunately the mod_cgi – python is deadly slow, it decreased the speed from 360 requests / sec to 7 requests / sec. here’s my index.jinja2 and dir-generator.py.cgi

[link: https://gist.github.com/38d382872086e6bf154f]

For adding class names to the tags, we have to edit mod_dirlisting.c, system stat call will provide the modes of file.

[link: https://gist.github.com/bab0ae824bd526f17f0e]

If you want to test it on your computer, here’s my mod_dirlisting.c, and its git diff(just in case)

[mod_dirlisting.c: https://gist.github.com/f5fcf309c62beaae841b]

[git diff src/mod_dirlisting.c: https://gist.github.com/553cfd249bffef44369c]

[style.css: https://gist.github.com/6609af61d4fa2f1682fc] (most of it is from bootstrap.css)

screenshots:

Screenshot_2015-11-15-09-55-20

Screenshot from 2015-11-15 09:41:22 Screenshot from 2015-11-15 09:54:20