Software / code / prosody-modules
File
mod_adhoc_dataforms_demo/mod_adhoc_dataforms_demo.lua @ 6305:1c62edeb9147
mod_pastebin: Update Readme
diff --git a/mod_pastebin/README.md b/mod_pastebin/README.md
--- a/mod_pastebin/README.md
+++ b/mod_pastebin/README.md
@@ -37,12 +37,14 @@ For example:
Pastes will be available by default at
`http://<your-prosody>:5280/pastebin/` by default.
-In Prosody 0.9 and later this can be changed with [HTTP
-settings](https://prosody.im/doc/http).
+Ports and path can be changed with [HTTP
+settings](https://prosody.im/doc/http), for example like:
-In 0.8 and older this can be changed with `pastebin_ports` (see below),
-or you can forward another external URL from your web server to Prosody,
-use `pastebin_url` to set that URL.
+``` {.lua}
+ http_paths = {
+ pastebin = "/$host-paste";
+ }
+```
# Discovery
@@ -82,27 +84,16 @@ The line and character tresholds are adv
pastebin_line_threshold The maximum number of lines a message may have before it is sent to the pastebin. (default 4 lines)
pastebin_trigger A string of characters (e.g. "!paste ") which if detected at the start of a message, always sends the message to the pastebin, regardless of length. (default: not set)
pastebin_expire_after Number of hours after which to expire (remove) a paste, defaults to 24. Set to 0 to store pastes permanently on disk.
- pastebin_ports List of ports to run the HTTP server on, same format as mod_httpserver's http_ports[^1]
- pastebin_url Base URL to display for pastebin links, must end with / and redirect to Prosody's built-in HTTP server[^2]
# Compatibility
- ------ -------
- trunk Works
+ ------ ---------------------
+ trunk Works as of 25-06-13
+ 13 Works
0.12 Works
- 0.11 Works
- 0.10 Works
- 0.9 Works
- 0.8 Works
- ------ -------
+ ------ ---------------------
# Todo
- Maximum paste length
- Web interface to submit pastes?
-
-[^1]: As of Prosody 0.9, `pastebin_ports` is replaced by `http_ports`,
- see [Prosody HTTP server documentation](https://prosody.im/doc/http)
-
-[^2]: See also
- [http_external_url](https://prosody.im/doc/http#external_url)
| author | Menel <menel@snikket.de> |
|---|---|
| date | Fri, 13 Jun 2025 11:39:58 +0200 |
| parent | 4581:3e2e708fd18b |
line wrap: on
line source
local dataforms = require "util.dataforms"; local adhoc_util = require "util.adhoc"; local serialization = require "util.serialization"; local adhoc_new = module:require "adhoc".new; -- Dataform borrowed from Prosodys busted test for util.dataforms local form = dataforms.new({ title = "form-title", instructions = "form-instructions", { type = "hidden", name = "FORM_TYPE", value = "xmpp:prosody.im/spec/util.dataforms#1", }; { type = "fixed", label = "fixed-label", name = "fixed-field#1", value = "fixed-value", }, { type = "hidden", label = "hidden-label", name = "hidden-field", value = "hidden-value", }, { type = "text-single", label = "text-single-label", name = "text-single-field", value = "text-single-value", }, { type = "text-multi", label = "text-multi-label", name = "text-multi-field", value = "text\nmulti\nvalue", }, { type = "text-private", label = "text-private-label", name = "text-private-field", value = "text-private-value", }, { type = "boolean", label = "boolean-label", name = "boolean-field", value = true, }, { type = "fixed", label = "fixed-label", name = "fixed-field#2", value = "fixed-value", }, { type = "list-multi", label = "list-multi-label", name = "list-multi-field", value = { "list-multi-option-value#1", "list-multi-option-value#3", }, options = { { label = "list-multi-option-label#1", value = "list-multi-option-value#1", default = true, }, { label = "list-multi-option-label#2", value = "list-multi-option-value#2", default = false, }, { label = "list-multi-option-label#3", value = "list-multi-option-value#3", default = true, }, } }, { type = "jid-single", label = "jid-single-label", name = "jid-single-field", value = "jid@single/value", }, { type = "jid-multi", label = "jid-multi-label", name = "jid-multi-field", value = { "jid@multi/value#1", "jid@multi/value#2", }, }, { type = "list-single", label = "list-single-label", name = "list-single-field", value = "list-single-value", options = { "list-single-value", "list-single-value#2", "list-single-value#3", } }, }) local function handler(fields, err, data) -- luacheck: ignore 212/data return { status = "completed", info = "Data was:\n" .. serialization.serialize(err or fields), }; end module:provides("adhoc", adhoc_new("Dataforms Demo", "xmpp:zash.se/mod_adhoc_dataforms_demo#form", adhoc_util.new_simple_form(form, handler), "any")); local function multi_step_command(_, data, state) if data.action == "cancel" then return { status = "canceled" }; elseif data.action == "complete" then return { status = "completed", info = "State was:\n" .. serialization.serialize(state, { fatal = false }), }; end if state and data.action == "execute" then data.action = "next"; elseif not state and data.action == "next" then -- Prevent jumping directly to step 2 return { status = "canceled", error = "Invalid action" }; end state = state or { step = 1, forms = { } }; if data.action == "next" then state.step = state.step + 1; elseif data.action == "prev" then state.step = math.max(state.step - 1, 1); end local current_form = state.forms[state.step] if not current_form then current_form = { title = string.format("Step %d", state.step); instructions = state.step == 1 and "Here's a form." or "Here's another form."; }; local already_selected = {}; for _ = 1, math.random(1, 5) do local random repeat random = math.random(2, #form); until not already_selected[random] already_selected[random] = true; table.insert(current_form, form[random]); end state.forms[state.step] = dataforms.new(current_form); end local next_step = { status = "executing", form = current_form, default = "next", actions = { "next", "complete" }, }; if state.step > 1 then table.insert(next_step.actions, 1, "prev"); end return next_step, state; end local permission = "any"; if not module.send_iq then -- hacky attempt at detecting 0.11 or earlier permission = "user"; end module:depends("adhoc"); module:provides("adhoc", adhoc_new("Multi-step command demo", "xmpp:zash.se/mod_adhoc_dataforms_demo#multi", multi_step_command, permission));