# HG changeset patch # User Kim Alvefur # Date 1747950023 -7200 # Node ID 29a646bad0966e6cd8b3e324772d327a67cf1d2d # Parent b3489b0467821d9098ed33e42f6ec3ba4d2ee4e2 mod_invites_register_web: Allow pointing other HTML templates Follows how some other modules allow overriding templates. diff -r b3489b046782 -r 29a646bad096 mod_invites_register_web/README.md --- 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 diff -r b3489b046782 -r 29a646bad096 mod_invites_register_web/mod_invites_register_web.lua --- 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