Software /
code /
prosody-modules
Annotate
mod_invites_page/mod_invites_page.lua @ 4094:dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
author | Matthew Wild <mwild1@gmail.com> |
---|---|
date | Fri, 11 Sep 2020 13:52:32 +0100 |
child | 4107:798f284717e7 |
rev | line source |
---|---|
4094
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
1 local st = require "util.stanza"; |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
2 local url_escape = require "util.http".urlencode; |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
3 |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
4 module:depends("http"); |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
5 local base_url = module.http_url and module:http_url(); |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
6 |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
7 local render_html_template = require"util.interpolation".new("%b{}", st.xml_escape, { |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
8 urlescape = url_escape; |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
9 lower = string.lower; |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
10 classname = function (s) return (s:gsub("%W+", "-")); end; |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
11 relurl = function (s) |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
12 if s:match("^%w+://") then |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
13 return s; |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
14 end |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
15 return base_url.."/"..s; |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
16 end; |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
17 }); |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
18 local render_url = require "util.interpolation".new("%b{}", url_escape, { |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
19 urlescape = url_escape; |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
20 noscheme = function (url) |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
21 return (url:gsub("^[^:]+:", "")); |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
22 end; |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
23 }); |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
24 |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
25 module:depends("register_apps"); |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
26 module:depends("invites_register_web"); |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
27 |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
28 local site_name = module:get_option_string("site_name", module.host); |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
29 local site_apps = module:shared("register_apps/apps"); |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
30 |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
31 local http_files; |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
32 |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
33 if prosody.shutdown then |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
34 module:depends("http"); |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
35 http_files = module:depends("http_files"); |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
36 end |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
37 local invites = module:depends("invites"); |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
38 |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
39 -- Point at eg https://github.com/ge0rg/easy-xmpp-invitation |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
40 -- This URL must always be absolute, as it is shared standalone |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
41 local invite_url_template = module:get_option_string("invites_page", base_url and (base_url.."?{invite.token}") or nil); |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
42 -- This URL is relative to the invite page, or can be absolute |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
43 local register_url_template = module:get_option_string("invites_registration_page", "register?t={invite.token}&c={app.id}"); |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
44 |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
45 local function add_landing_url(invite) |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
46 if not invite_url_template then return; end |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
47 -- TODO: we don't currently have a landing page for subscription-only invites, |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
48 -- so the user will only receive a URI. The client should be able to handle this |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
49 -- by automatically falling back to a client-specific landing page, per XEP-0401. |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
50 if not invite.allow_registration then return; end |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
51 invite.landing_page = render_url(invite_url_template, { host = module.host, invite = invite }); |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
52 end |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
53 |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
54 module:hook("invite-created", add_landing_url); |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
55 |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
56 local function render_app_urls(apps, invite_vars) |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
57 local rendered_apps = {}; |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
58 for _, unrendered_app in ipairs(apps) do |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
59 local app = setmetatable({}, { __index = unrendered_app }); |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
60 local template_vars = { app = app, invite = invite_vars, base_url = base_url }; |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
61 if app.magic_link_format then |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
62 -- Magic link generally links directly to third-party |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
63 app.proceed_url = render_url(app.magic_link_format or app.link or "#", template_vars); |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
64 elseif app.supports_preauth_uri then |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
65 -- Proceed to a page that guides the user to download, and then |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
66 -- click the URI button |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
67 app.proceed_url = render_url("{base_url!}/setup/{app.id}?{invite.token}", template_vars); |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
68 else |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
69 -- Manual means proceed to web registration, but include app id |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
70 -- so it can show post-registration instructions |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
71 app.proceed_url = render_url(register_url_template, template_vars); |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
72 end |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
73 table.insert(rendered_apps, app); |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
74 end |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
75 return rendered_apps; |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
76 end |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
77 |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
78 function serve_invite_page(event) |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
79 local invite_page_template = assert(module:load_resource("html/invite.html")):read("*a"); |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
80 local invalid_invite_page_template = assert(module:load_resource("html/invite_invalid.html")):read("*a"); |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
81 |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
82 local invite = invites.get(event.request.url.query); |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
83 if not invite then |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
84 return render_html_template(invalid_invite_page_template, { |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
85 site_name = site_name; |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
86 static = base_url.."/static"; |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
87 }); |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
88 end |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
89 |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
90 local template_vars = { |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
91 site_name = site_name; |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
92 token = invite.token; |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
93 uri = invite.uri; |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
94 type = invite.type; |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
95 jid = invite.jid; |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
96 inviter = invite.inviter; |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
97 static = base_url.."/static"; |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
98 }; |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
99 template_vars.apps = render_app_urls(site_apps, template_vars); |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
100 |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
101 local invite_page = render_html_template(invite_page_template, template_vars); |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
102 return invite_page; |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
103 end |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
104 |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
105 function serve_setup_page(event, app_id) |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
106 local invite_page_template = assert(module:load_resource("html/client.html")):read("*a"); |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
107 local invalid_invite_page_template = assert(module:load_resource("html/invite_invalid.html")):read("*a"); |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
108 |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
109 local invite = invites.get(event.request.url.query); |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
110 if not invite then |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
111 return render_html_template(invalid_invite_page_template, { |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
112 site_name = site_name; |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
113 static = base_url.."/static"; |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
114 }); |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
115 end |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
116 |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
117 local template_vars = { |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
118 site_name = site_name; |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
119 apps = site_apps; |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
120 token = invite.token; |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
121 uri = invite.uri; |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
122 type = invite.type; |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
123 jid = invite.jid; |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
124 static = base_url.."/static"; |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
125 }; |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
126 template_vars.app = render_app_urls({ site_apps[app_id] }, template_vars)[1]; |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
127 |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
128 local invite_page = render_html_template(invite_page_template, template_vars); |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
129 return invite_page; |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
130 end |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
131 |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
132 local mime_map = { |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
133 png = "image/png"; |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
134 svg = "image/svg+xml"; |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
135 js = "application/javascript"; |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
136 }; |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
137 |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
138 module:provides("http", { |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
139 route = { |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
140 ["GET"] = serve_invite_page; |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
141 ["GET /setup/*"] = serve_setup_page; |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
142 ["GET /static/*"] = http_files and http_files.serve({ path = module:get_directory().."/static", mime_map = mime_map }); |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
143 }; |
dd00a2b9927c
mod_invites_page: New module to generate landing page for invites
Matthew Wild <mwild1@gmail.com>
parents:
diff
changeset
|
144 }); |