# HG changeset patch # User Matthew Wild # Date 1599482022 -3600 # Node ID 88a469b285f5bbd55725f9f2fb969892f0935615 # Parent 50644402c6f5726120bcc1be7d9fa30ba286b6c3 mod_http_libjs: New module to serve common CSS/Javascript libraries diff -r 50644402c6f5 -r 88a469b285f5 mod_http_libjs/README.markdown --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mod_http_libjs/README.markdown Mon Sep 07 13:33:42 2020 +0100 @@ -0,0 +1,24 @@ +--- +labels: +- 'Stage-Stable' +summary: 'Serve common Javascript libraries' +... + +Introduction +============ + +This module serves common static CSS and Javascript libraries from the +filesystem, allowing other HTTP modules to easily reference them. + +The default configuration works out of the box with Debian (and derivatives) +`libjs-*` packages, such as libjs-jquery and libjs-bootstrap. + +You can override the filesystem location using the `libjs_path` configuration +option. The default is `/usr/share/javascript`. + +Compatibility +============= + + ----- ------- + 0.11 Works + ----- ------- diff -r 50644402c6f5 -r 88a469b285f5 mod_http_libjs/mod_http_libjs.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mod_http_libjs/mod_http_libjs.lua Mon Sep 07 13:33:42 2020 +0100 @@ -0,0 +1,13 @@ +local mime_map = module:shared("/*/http_files/mime").types or { + css = "text/css", + js = "application/javascript", +}; + +local libjs_path = module:get_option_string("libjs_path", "/usr/share/javascript"); + +module:provides("http", { + default_path = "/share"; + route = { + ["GET /*"] = require "net.http.files".serve({ path = libjs_path, mime_map = mime_map }); + } + });