Mercurial > prosody-modules
annotate mod_http_index/mod_http_index.lua @ 6258:06fbbd45ba75
mod_cloud_notify: Readme: fix links and labels that were removed in the last commit
diff --git a/mod_cloud_notify/README.md b/mod_cloud_notify/README.md
--- a/mod_cloud_notify/README.md
+++ b/mod_cloud_notify/README.md
@@ -1,3 +1,9 @@
+----
+-labels:
+-- 'Stage-Beta'
+-summary: 'XEP-0357: Cloud push notifications'
+----
+
# Introduction
This module enables support for sending "push notifications" to clients
@@ -32,15 +38,15 @@ notification to your device. When your d
it will display it or wake up the app so it can connect to XMPP and
receive any pending messages.
-This protocol is described for developers in \[XEP-0357: Push
-Notifications\].
+This protocol is described for developers in [XEP-0357: Push
+Notifications].
-For this module to work reliably, you must have \[mod_smacks\],
-\[mod_mam\] and \[mod_carbons\] also enabled on your server.
+For this module to work reliably, you must have [mod_smacks],
+[mod_mam] and [mod_carbons] also enabled on your server.
Some clients, notably Siskin and Snikket iOS need some additional
extensions that are not currently defined in a standard XEP. To support
-these clients, see \[mod_cloud_notify_extensions\].
+these clients, see [mod_cloud_notify_extensions].
# Configuration
@@ -58,18 +64,18 @@ these clients, see \[mod_cloud_notify_ex
# Internal design notes
App servers are notified about offline messages, messages stored by
-\[mod_mam\] or messages waiting in the smacks queue. The business rules
+[mod_mam] or messages waiting in the smacks queue. The business rules
outlined
[here](//mail.jabber.org/pipermail/standards/2016-February/030925.html)
are all honored[^2].
-To cooperate with \[mod_smacks\] this module consumes some events:
+To cooperate with [mod_smacks] this module consumes some events:
`smacks-ack-delayed`, `smacks-hibernation-start` and
`smacks-hibernation-end`. These events allow this module to send out
notifications for messages received while the session is hibernated by
-\[mod_smacks\] or even when smacks acknowledgements for messages are
+[mod_smacks] or even when smacks acknowledgements for messages are
delayed by a certain amount of seconds configurable with the
-\[mod_smacks\] setting `smacks_max_ack_delay`.
+[mod_smacks] setting `smacks_max_ack_delay`.
The `smacks_max_ack_delay` setting allows to send out notifications to
clients which aren't already in smacks hibernation state (because the
| author | Menel <menel@snikket.de> |
|---|---|
| date | Fri, 13 Jun 2025 10:44:37 +0200 |
| parents | a1aa56ebe73f |
| children |
| rev | line source |
|---|---|
|
1573
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
1 local url = require"socket.url"; |
|
1825
1b5c817cb642
mod_http_index: Update to use util.interpolation (makes it depend on 0.10+)
Kim Alvefur <zash@zash.se>
parents:
1573
diff
changeset
|
2 local render = require"util.interpolation".new("%b{}", require"util.stanza".xml_escape); |
|
1573
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
3 |
|
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
4 module:depends"http"; |
|
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
5 |
|
3756
ba4f45b8678f
mod_http_index: Hide http apps that haven't set a title by default
Kim Alvefur <zash@zash.se>
parents:
3752
diff
changeset
|
6 local show_all = module:get_option_boolean(module.name .. "_show_all", false); |
|
3752
8992f84ca870
mod_http_index: Only show http apps that include a title by default
Kim Alvefur <zash@zash.se>
parents:
3577
diff
changeset
|
7 |
|
1827
9376e870f0e1
mod_http_index: Move template out into a file and make it configurable
Kim Alvefur <zash@zash.se>
parents:
1826
diff
changeset
|
8 local base_template; |
|
9376e870f0e1
mod_http_index: Move template out into a file and make it configurable
Kim Alvefur <zash@zash.se>
parents:
1826
diff
changeset
|
9 do |
|
5968
a1aa56ebe73f
mod_http_index: Fix loading template
Kim Alvefur <zash@zash.se>
parents:
5967
diff
changeset
|
10 local template_file = module:get_option_path(module.name .. "_template", "html/" .. module.name .. ".html"); |
|
5967
28b386fc7a05
mod_http_index: Add metadata to enable installation with plugin installer
Kim Alvefur <zash@zash.se>
parents:
3756
diff
changeset
|
11 template_file = assert(io.open(template_file)); |
|
1827
9376e870f0e1
mod_http_index: Move template out into a file and make it configurable
Kim Alvefur <zash@zash.se>
parents:
1826
diff
changeset
|
12 base_template = template_file:read("*a"); |
|
9376e870f0e1
mod_http_index: Move template out into a file and make it configurable
Kim Alvefur <zash@zash.se>
parents:
1826
diff
changeset
|
13 template_file:close(); |
|
9376e870f0e1
mod_http_index: Move template out into a file and make it configurable
Kim Alvefur <zash@zash.se>
parents:
1826
diff
changeset
|
14 end |
|
1573
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
15 |
|
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
16 local canonical = module:http_url(nil, "/"); |
|
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
17 |
|
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
18 local function relative(base, link) |
|
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
19 base = url.parse(base); |
|
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
20 link = url.parse(link); |
|
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
21 for k,v in pairs(base) do |
|
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
22 if link[k] == v then |
|
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
23 link[k] = nil; |
|
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
24 end |
|
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
25 end |
|
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
26 return url.build(link); |
|
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
27 end |
|
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
28 |
|
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
29 local function handler(event) |
|
1825
1b5c817cb642
mod_http_index: Update to use util.interpolation (makes it depend on 0.10+)
Kim Alvefur <zash@zash.se>
parents:
1573
diff
changeset
|
30 local host_items = module:get_host_items("http-provider"); |
|
1b5c817cb642
mod_http_index: Update to use util.interpolation (makes it depend on 0.10+)
Kim Alvefur <zash@zash.se>
parents:
1573
diff
changeset
|
31 local http_apps = {} |
|
1b5c817cb642
mod_http_index: Update to use util.interpolation (makes it depend on 0.10+)
Kim Alvefur <zash@zash.se>
parents:
1573
diff
changeset
|
32 for _, item in ipairs(host_items) do |
|
3752
8992f84ca870
mod_http_index: Only show http apps that include a title by default
Kim Alvefur <zash@zash.se>
parents:
3577
diff
changeset
|
33 if module.name ~= item._provided_by and (show_all or item.title) then |
|
1825
1b5c817cb642
mod_http_index: Update to use util.interpolation (makes it depend on 0.10+)
Kim Alvefur <zash@zash.se>
parents:
1573
diff
changeset
|
34 table.insert(http_apps, { |
|
3336
4af114684e0a
mod_http_index: Allow listed modules to include a friendlier name
Kim Alvefur <zash@zash.se>
parents:
2927
diff
changeset
|
35 title = item.title or item.name; |
|
1573
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
36 name = item.name; |
|
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
37 module = "mod_" .. item._provided_by; |
|
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
38 url = relative(canonical, module:http_url(item.name, item.default_path)); |
|
1825
1b5c817cb642
mod_http_index: Update to use util.interpolation (makes it depend on 0.10+)
Kim Alvefur <zash@zash.se>
parents:
1573
diff
changeset
|
39 }); |
|
1573
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
40 end |
|
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
41 end |
|
2927
7953b7dde6e7
mod_http_index: Sort list of HTTP applications by name
Kim Alvefur <zash@zash.se>
parents:
1827
diff
changeset
|
42 table.sort(http_apps, function (a, b) return a.name < b.name; end); |
|
1573
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
43 event.response.headers.content_type = "text/html"; |
|
1825
1b5c817cb642
mod_http_index: Update to use util.interpolation (makes it depend on 0.10+)
Kim Alvefur <zash@zash.se>
parents:
1573
diff
changeset
|
44 return render(base_template, { |
|
3577
f169d9a513c6
mod_http_index: Improve page title
Kim Alvefur <zash@zash.se>
parents:
3336
diff
changeset
|
45 title = "Prosody IM - HTTP Services"; |
|
1825
1b5c817cb642
mod_http_index: Update to use util.interpolation (makes it depend on 0.10+)
Kim Alvefur <zash@zash.se>
parents:
1573
diff
changeset
|
46 items = http_apps; |
|
1b5c817cb642
mod_http_index: Update to use util.interpolation (makes it depend on 0.10+)
Kim Alvefur <zash@zash.se>
parents:
1573
diff
changeset
|
47 prosody_version = prosody.version; |
|
1b5c817cb642
mod_http_index: Update to use util.interpolation (makes it depend on 0.10+)
Kim Alvefur <zash@zash.se>
parents:
1573
diff
changeset
|
48 mod_name = module.name; |
|
1b5c817cb642
mod_http_index: Update to use util.interpolation (makes it depend on 0.10+)
Kim Alvefur <zash@zash.se>
parents:
1573
diff
changeset
|
49 canonical = canonical; |
|
1b5c817cb642
mod_http_index: Update to use util.interpolation (makes it depend on 0.10+)
Kim Alvefur <zash@zash.se>
parents:
1573
diff
changeset
|
50 }); |
|
1573
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
51 end |
|
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
52 |
|
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
53 module:provides("http", { |
|
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
54 route = { |
|
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
55 ["GET /"] = handler; |
|
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
56 }; |
|
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
57 default_path = "/"; |
|
0d8cc6971cdb
mod_http_index: Generates an index of local HTTP apps
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
58 }); |
