Software /
code /
prosody-modules
Comparison
mod_http_index/mod_http_index.lua @ 3752:8992f84ca870
mod_http_index: Only show http apps that include a title by default
This lets http modules indicate whether they make sense to be
user-facing or not.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sun, 17 Nov 2019 16:33:28 +0100 |
parent | 3577:f169d9a513c6 |
child | 3756:ba4f45b8678f |
comparison
equal
deleted
inserted
replaced
3751:cb9517827d76 | 3752:8992f84ca870 |
---|---|
1 local url = require"socket.url"; | 1 local url = require"socket.url"; |
2 local render = require"util.interpolation".new("%b{}", require"util.stanza".xml_escape); | 2 local render = require"util.interpolation".new("%b{}", require"util.stanza".xml_escape); |
3 | 3 |
4 module:depends"http"; | 4 module:depends"http"; |
5 | |
6 local show_all = module:get_option_boolean(module.name .. "_show_all", true); | |
5 | 7 |
6 local base_template; | 8 local base_template; |
7 do | 9 do |
8 local template_file = module:get_option_string(module.name .. "_template", module.name .. ".html"); | 10 local template_file = module:get_option_string(module.name .. "_template", module.name .. ".html"); |
9 template_file = assert(module:load_resource(template_file)); | 11 template_file = assert(module:load_resource(template_file)); |
26 | 28 |
27 local function handler(event) | 29 local function handler(event) |
28 local host_items = module:get_host_items("http-provider"); | 30 local host_items = module:get_host_items("http-provider"); |
29 local http_apps = {} | 31 local http_apps = {} |
30 for _, item in ipairs(host_items) do | 32 for _, item in ipairs(host_items) do |
31 if module.name ~= item._provided_by then | 33 if module.name ~= item._provided_by and (show_all or item.title) then |
32 table.insert(http_apps, { | 34 table.insert(http_apps, { |
33 title = item.title or item.name; | 35 title = item.title or item.name; |
34 name = item.name; | 36 name = item.name; |
35 module = "mod_" .. item._provided_by; | 37 module = "mod_" .. item._provided_by; |
36 url = relative(canonical, module:http_url(item.name, item.default_path)); | 38 url = relative(canonical, module:http_url(item.name, item.default_path)); |