Mercurial > prosody-modules
annotate mod_adhoc_dataforms_demo/mod_adhoc_dataforms_demo.lua @ 3245:1d57f485efef
mod_profile: Use type property over content identifiguesstimation
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 20 Aug 2018 21:20:53 +0200 |
parents | 85c8a8c33028 |
children | 78d4e631bc5f |
rev | line source |
---|---|
3211
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
1 local dataforms = require "util.dataforms"; |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
2 local adhoc_util = require "util.adhoc"; |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
3 local serialization = require "util.serialization"; |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
4 |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
5 local adhoc_new = module:require "adhoc".new; |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
6 |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
7 -- Dataform borrowed from Prosodys busted test for util.dataforms |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
8 local form = dataforms.new({ |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
9 title = "form-title", |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
10 instructions = "form-instructions", |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
11 { |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
12 type = "hidden", |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
13 name = "FORM_TYPE", |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
14 value = "xmpp:prosody.im/spec/util.dataforms#1", |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
15 }; |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
16 { |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
17 type = "fixed"; |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
18 value = "Fixed field"; |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
19 }, |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
20 { |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
21 type = "boolean", |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
22 label = "boolean-label", |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
23 name = "boolean-field", |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
24 value = true, |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
25 }, |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
26 { |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
27 type = "fixed", |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
28 label = "fixed-label", |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
29 name = "fixed-field", |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
30 value = "fixed-value", |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
31 }, |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
32 { |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
33 type = "hidden", |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
34 label = "hidden-label", |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
35 name = "hidden-field", |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
36 value = "hidden-value", |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
37 }, |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
38 { |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
39 type = "jid-multi", |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
40 label = "jid-multi-label", |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
41 name = "jid-multi-field", |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
42 value = { |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
43 "jid@multi/value#1", |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
44 "jid@multi/value#2", |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
45 }, |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
46 }, |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
47 { |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
48 type = "jid-single", |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
49 label = "jid-single-label", |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
50 name = "jid-single-field", |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
51 value = "jid@single/value", |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
52 }, |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
53 { |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
54 type = "list-multi", |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
55 label = "list-multi-label", |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
56 name = "list-multi-field", |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
57 value = { |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
58 "list-multi-option-value#1", |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
59 "list-multi-option-value#3", |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
60 }, |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
61 options = { |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
62 { |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
63 label = "list-multi-option-label#1", |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
64 value = "list-multi-option-value#1", |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
65 default = true, |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
66 }, |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
67 { |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
68 label = "list-multi-option-label#2", |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
69 value = "list-multi-option-value#2", |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
70 default = false, |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
71 }, |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
72 { |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
73 label = "list-multi-option-label#3", |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
74 value = "list-multi-option-value#3", |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
75 default = true, |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
76 }, |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
77 } |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
78 }, |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
79 { |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
80 type = "list-single", |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
81 label = "list-single-label", |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
82 name = "list-single-field", |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
83 value = "list-single-value", |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
84 options = { |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
85 "list-single-value", |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
86 "list-single-value#2", |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
87 "list-single-value#3", |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
88 } |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
89 }, |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
90 { |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
91 type = "text-multi", |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
92 label = "text-multi-label", |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
93 name = "text-multi-field", |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
94 value = "text\nmulti\nvalue", |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
95 }, |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
96 { |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
97 type = "text-private", |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
98 label = "text-private-label", |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
99 name = "text-private-field", |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
100 value = "text-private-value", |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
101 }, |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
102 { |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
103 type = "text-single", |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
104 label = "text-single-label", |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
105 name = "text-single-field", |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
106 value = "text-single-value", |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
107 }, |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
108 }) |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
109 |
3213
85c8a8c33028
mod_adhoc_dataforms_demo: Silence warning about unused argument [luacheck]
Kim Alvefur <zash@zash.se>
parents:
3212
diff
changeset
|
110 local function handler(fields, err, data) -- luacheck: ignore 212/data |
3211
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
111 return { |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
112 status = "completed", |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
113 info = "Data was:\n" |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
114 .. serialization.serialize(err or fields), |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
115 }; |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
116 end |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
117 |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
118 module:provides("adhoc", |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
119 adhoc_new("Dataforms Demo", |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
120 "xmpp:zash.se/mod_adhoc_test", |
2969ed764fe8
mod_adhoc_test: A module to test dataforms generation and rendering
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
121 adhoc_util.new_simple_form(form, handler))); |