Mercurial > prosody-modules
comparison mod_register_apps/mod_register_apps.lua @ 4113:c85af57e82e0
mod_register_apps: Add site_apps_show and site_apps_hide options (thanks meaz)
| author | Matthew Wild <mwild1@gmail.com> |
|---|---|
| date | Sat, 12 Sep 2020 10:42:37 +0100 |
| parents | ae2699f1cba9 |
| children | 4656a64e59be |
comparison
equal
deleted
inserted
replaced
| 4112:d0366474aace | 4113:c85af57e82e0 |
|---|---|
| 98 }; | 98 }; |
| 99 }; | 99 }; |
| 100 }; | 100 }; |
| 101 }); | 101 }); |
| 102 | 102 |
| 103 local show_apps = module:get_option_set("site_apps_show"); | |
| 104 local hide_apps = module:get_option_set("site_apps_hide"); | |
| 105 | |
| 103 local base_url = module.http_url and module:http_url(); | 106 local base_url = module.http_url and module:http_url(); |
| 104 local function relurl(s) | 107 local function relurl(s) |
| 105 if s:match("^%w+://") then | 108 if s:match("^%w+://") then |
| 106 return s; | 109 return s; |
| 107 end | 110 end |
| 116 end | 119 end |
| 117 end | 120 end |
| 118 | 121 |
| 119 for _, app_info in ipairs(app_config) do | 122 for _, app_info in ipairs(app_config) do |
| 120 local app_id = app_info.id or app_info.name:gsub("%W+", "-"):lower(); | 123 local app_id = app_info.id or app_info.name:gsub("%W+", "-"):lower(); |
| 121 app_info.id = app_id; | 124 if (not show_apps or show_apps:contains(app_id)) |
| 122 app_info.image = relurl(app_info.image); | 125 and not hide_apps:contains(app_id) then |
| 123 site_apps[app_id] = app_info; | 126 app_info.id = app_id; |
| 124 app_info._source = module.name; | 127 app_info.image = relurl(app_info.image); |
| 125 table.insert(site_apps, app_info); | 128 site_apps[app_id] = app_info; |
| 129 app_info._source = module.name; | |
| 130 table.insert(site_apps, app_info); | |
| 131 end | |
| 126 end | 132 end |
| 127 | 133 |
| 128 local mime_map = { | 134 local mime_map = { |
| 129 png = "image/png"; | 135 png = "image/png"; |
| 130 svg = "image/svg+xml"; | 136 svg = "image/svg+xml"; |
