diff -r 1ac4a59ac575 -r 1c8197075d04 mod_conversejs/mod_conversejs.lua --- a/mod_conversejs/mod_conversejs.lua Thu Mar 14 09:48:30 2024 +0000 +++ b/mod_conversejs/mod_conversejs.lua Sun Mar 17 15:05:29 2024 +0100 @@ -118,6 +118,11 @@ local add_tags = module:get_option_array("conversejs_tags", {}); +local service_name = module:get_option_string("name", "Prosody IM and Converse.js"); +local service_short_name = module:get_option_string("short_name", "Converse"); +local service_description = module:get_option_string("description", "Messaging Freedom") +local pwa_color = module:get_option_string("pwa_color", "#397491") + module:provides("http", { title = "Converse.js"; route = { @@ -126,7 +131,9 @@ event.response.headers.content_type = "text/html"; return render(html_template, { - service_name = module:get_option_string("name"); + service_name = service_name; + -- note that using a relative path won’t work as this URL doesn’t end in a / + manifest_url = module:http_url().."/manifest.json", header_scripts = { js_url }; header_style = { css_url }; header_tags = add_tags; @@ -143,6 +150,42 @@ event.response.headers.content_type = "application/javascript"; return js_template:format(json_encode(converse_options)); end; + ["GET /manifest.json"] = function (event) + -- See manifest.json in the root of Converse.js’s git repository + local data = { + short_name = service_short_name, + name = service_name, + description = service_description, + categories = {"social"}, + icons = module:get_option_array("manifest_icons", { + { + src = cdn_url..version.."/dist/images/logo/conversejs-filled-512.png", + sizes = "512x512", + }, + { + src = cdn_url..version.."/dist/images/logo/conversejs-filled-192.png", + sizes = "192x192", + }, + { + src = cdn_url..version.."/dist/images/logo/conversejs-filled-192.svg", + sizes = "192x192", + }, + { + src = cdn_url..version.."/dist/images/logo/conversejs-filled-512.svg", + sizes = "512x512", + }, + }), + start_url = module:http_url(), + background_color = pwa_color, + display = "standalone", + scope = module:http_url().."/", + theme_color = pwa_color, + } + return { + headers = { content_type = "application/schema+json" }, + body = json_encode(data), + } + end; ["GET /dist/*"] = serve_dist; } });