Mercurial > prosody-modules
changeset 3212:69b6910f3bfc
mod_adhoc_test -> mod_adhoc_dataforms_demo
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Fri, 03 Aug 2018 19:40:24 +0200 |
parents | 2969ed764fe8 |
children | 85c8a8c33028 |
files | mod_adhoc_dataforms_demo/README.markdown mod_adhoc_dataforms_demo/mod_adhoc_dataforms_demo.lua mod_adhoc_test/README.markdown mod_adhoc_test/mod_adhoc_test.lua |
diffstat | 4 files changed, 145 insertions(+), 145 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mod_adhoc_dataforms_demo/README.markdown Fri Aug 03 19:40:24 2018 +0200 @@ -0,0 +1,24 @@ +# Introduction + +This module adds an [Ad-Hoc command][xep0050] with a demo [data +form][xep0004] that includes all kinds of fields. It's meant to help +debug both Prosodys +[`util.dataforms`][doc:developers:util:dataforms] library and +clients, eg seeing how various field types are rendered. + +# Configuration + +Simply add it to [`modules_enabled`][doc:modules_enabled] like any +other module. + +``` {.lua} +modules_enabled = { + -- All your other modules etc + "adhoc_dataforms_demo"; +} +``` + +# Usage + +In your Ad-Hoc capable client, look for **Dataforms Demo**, and execute +it. You should see a form with various kinds of fields.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mod_adhoc_dataforms_demo/mod_adhoc_dataforms_demo.lua Fri Aug 03 19:40:24 2018 +0200 @@ -0,0 +1,121 @@ +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"; + value = "Fixed field"; + }, + { + type = "boolean", + label = "boolean-label", + name = "boolean-field", + value = true, + }, + { + type = "fixed", + label = "fixed-label", + name = "fixed-field", + value = "fixed-value", + }, + { + type = "hidden", + label = "hidden-label", + name = "hidden-field", + value = "hidden-value", + }, + { + type = "jid-multi", + label = "jid-multi-label", + name = "jid-multi-field", + value = { + "jid@multi/value#1", + "jid@multi/value#2", + }, + }, + { + type = "jid-single", + label = "jid-single-label", + name = "jid-single-field", + value = "jid@single/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 = "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", + } + }, + { + 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 = "text-single", + label = "text-single-label", + name = "text-single-field", + value = "text-single-value", + }, +}) + +local function handler(fields, err, 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_test", + adhoc_util.new_simple_form(form, handler)));
--- a/mod_adhoc_test/README.markdown Fri Aug 03 19:30:15 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,24 +0,0 @@ -# Introduction - -This module adds an [Ad-Hoc command][xep0050] with a demo [data -form][xep0004] that includes all kinds of fields. It's meant to help -debug both Prosodys -[`util.dataforms`][doc:developers:util:dataforms] library and -clients, eg seeing how various field types are rendered. - -# Configuration - -Simply add it to [`modules_enabled`][doc:modules_enabled] like any -other module. - -``` {.lua} -modules_enabled = { - -- All your other modules etc - "adhoc_test"; -} -``` - -# Usage - -In your Ad-Hoc capable client, look for **Dataforms Demo**, and execute -it. You should see a form with various kinds of fields.
--- a/mod_adhoc_test/mod_adhoc_test.lua Fri Aug 03 19:30:15 2018 +0200 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,121 +0,0 @@ -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"; - value = "Fixed field"; - }, - { - type = "boolean", - label = "boolean-label", - name = "boolean-field", - value = true, - }, - { - type = "fixed", - label = "fixed-label", - name = "fixed-field", - value = "fixed-value", - }, - { - type = "hidden", - label = "hidden-label", - name = "hidden-field", - value = "hidden-value", - }, - { - type = "jid-multi", - label = "jid-multi-label", - name = "jid-multi-field", - value = { - "jid@multi/value#1", - "jid@multi/value#2", - }, - }, - { - type = "jid-single", - label = "jid-single-label", - name = "jid-single-field", - value = "jid@single/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 = "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", - } - }, - { - 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 = "text-single", - label = "text-single-label", - name = "text-single-field", - value = "text-single-value", - }, -}) - -local function handler(fields, err, 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_test", - adhoc_util.new_simple_form(form, handler)));