changeset 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 d0366474aace
children 4656a64e59be
files mod_register_apps/README.markdown mod_register_apps/mod_register_apps.lua
diffstat 2 files changed, 29 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/mod_register_apps/README.markdown	Sat Sep 12 10:28:28 2020 +0100
+++ b/mod_register_apps/README.markdown	Sat Sep 12 10:42:37 2020 +0100
@@ -16,7 +16,24 @@
 
 # Configuration
 
-There is one configuration option, `site_apps`, which contains the list
+| Field                | Description                                                              |
+|----------------------|--------------------------------------------------------------------------|
+| site_apps            | A list of apps and their metadata                                        |
+| site_apps_show       | A list of app ids to only show                                           |
+| site_apps_hide       | A list of app ids to never show                                          |
+
+An "app id" is the lower case app name, with any spaces replaced by `-`. E.g. "My Chat" would be `"my-chat"`.
+
+The module comes with a preconfigured `site_apps` containing popular clients. Patches are welcome to
+add/update this list as needed!
+
+If you want to limit to just displaying a subset of the apps on your server, use the `site_apps_show`
+option, e.g. `site_apps_show = { "conversations", "siskin-im" }`. To never show specific apps, you
+can use `site_apps_hide`, e.g. `site_apps_hide = { "pidgin" }`.
+
+# App metadata format
+
+The configuration option `site_apps` contains the list
 of apps and their metadata.
 
 ``` {.lua}
--- a/mod_register_apps/mod_register_apps.lua	Sat Sep 12 10:28:28 2020 +0100
+++ b/mod_register_apps/mod_register_apps.lua	Sat Sep 12 10:42:37 2020 +0100
@@ -100,6 +100,9 @@
 	};
 });
 
+local show_apps = module:get_option_set("site_apps_show");
+local hide_apps = module:get_option_set("site_apps_hide");
+
 local base_url = module.http_url and module:http_url();
 local function relurl(s)
 	if s:match("^%w+://") then
@@ -118,11 +121,14 @@
 
 for _, app_info in ipairs(app_config) do
 	local app_id = app_info.id or app_info.name:gsub("%W+", "-"):lower();
-	app_info.id = app_id;
-	app_info.image = relurl(app_info.image);
-	site_apps[app_id] = app_info;
-	app_info._source = module.name;
-	table.insert(site_apps, app_info);
+	if (not show_apps or show_apps:contains(app_id))
+	and not hide_apps:contains(app_id) then
+		app_info.id = app_id;
+		app_info.image = relurl(app_info.image);
+		site_apps[app_id] = app_info;
+		app_info._source = module.name;
+		table.insert(site_apps, app_info);
+	end
 end
 
 local mime_map = {