Changeset

6264:29a646bad096

mod_invites_register_web: Allow pointing other HTML templates Follows how some other modules allow overriding templates.
author Kim Alvefur <zash@zash.se>
date Thu, 22 May 2025 23:40:23 +0200
parents 6260:b3489b046782
children 6265:22b5b744fc78
files mod_invites_register_web/README.md mod_invites_register_web/mod_invites_register_web.lua
diffstat 2 files changed, 18 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/mod_invites_register_web/README.md	Fri May 16 13:45:22 2025 +0200
+++ b/mod_invites_register_web/README.md	Thu May 22 23:40:23 2025 +0200
@@ -34,8 +34,18 @@
 validates invite tokens. It also supports guiding the user through client
 download and configuration via mod_register_apps.
 
-There is no specific configuration for this module (though it uses the
-optional `site_name` to override the displayed site name.
+The optional `site_name` setting can be used to override the displayed site name.
+
+```lua
+site_name = "My Chat Service"
+```
+
+HTML templates can be overridden by using `invites_register_template_path`, see the `html/` directory in the sources for the files needed.
+
+```lua
+invites_register_template_path = "/path/to/templates/html"
+```
+
 
 You may also set `webchat_url` to the URL of a web chat that will be linked
 to after successful registration. If not specified but mod_conversejs is loaded
--- a/mod_invites_register_web/mod_invites_register_web.lua	Fri May 16 13:45:22 2025 +0200
+++ b/mod_invites_register_web/mod_invites_register_web.lua	Thu May 22 23:40:23 2025 +0200
@@ -34,8 +34,9 @@
 local invites = module:depends("invites");
 local invites_page = module:depends("invites_page");
 
+local template_path = module:get_option_path("invites_register_template_path", "html");
 function serve_register_page(event)
-	local register_page_template = assert(module:load_resource("html/register.html")):read("*a");
+	local register_page_template = assert(module:load_resource(template_path .. "/register.html")):read("*a");
 
 	local query_params = event.request.url.query and http_formdecode(event.request.url.query);
 
@@ -71,8 +72,8 @@
 	local user, password, token = form_data["user"], form_data["password"], form_data["token"];
 	local app_id = form_data["app_id"];
 
-	local register_page_template = assert(module:load_resource("html/register.html")):read("*a");
-	local error_template = assert(module:load_resource("html/register_error.html")):read("*a");
+	local register_page_template = assert(module:load_resource(template_path .. "/register.html")):read("*a");
+	local error_template = assert(module:load_resource(template_path .. "/register_error.html")):read("*a");
 
 	local invite = invites.get(token);
 	if not invite then
@@ -201,9 +202,9 @@
 				};
 			end
 			-- If recognised app, we serve a page that includes setup instructions
-			success_template = assert(module:load_resource("html/register_success_setup.html")):read("*a");
+			success_template = assert(module:load_resource(template_path .. "/register_success_setup.html")):read("*a");
 		else
-			success_template = assert(module:load_resource("html/register_success.html")):read("*a");
+			success_template = assert(module:load_resource(template_path .. "/register_success.html")):read("*a");
 		end
 
 		-- Due to the credentials being served here, ensure that