Software / code / prosody
Comparison
util/dataforms.lua @ 6777:5de6b93d0190
util.*: Remove use of module() function, make all module functions local and return them in a table at the end
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Sat, 21 Feb 2015 10:36:37 +0100 |
| parent | 6672:d6a60e74f773 |
| child | 6829:22522443982f |
comparison
equal
deleted
inserted
replaced
| 6774:3965662ae091 | 6777:5de6b93d0190 |
|---|---|
| 11 local tostring, type, next = tostring, type, next; | 11 local tostring, type, next = tostring, type, next; |
| 12 local t_concat = table.concat; | 12 local t_concat = table.concat; |
| 13 local st = require "util.stanza"; | 13 local st = require "util.stanza"; |
| 14 local jid_prep = require "util.jid".prep; | 14 local jid_prep = require "util.jid".prep; |
| 15 | 15 |
| 16 module "dataforms" | 16 local _ENV = nil; |
| 17 | 17 |
| 18 local xmlns_forms = 'jabber:x:data'; | 18 local xmlns_forms = 'jabber:x:data'; |
| 19 | 19 |
| 20 local form_t = {}; | 20 local form_t = {}; |
| 21 local form_mt = { __index = form_t }; | 21 local form_mt = { __index = form_t }; |
| 22 | 22 |
| 23 function new(layout) | 23 local function new(layout) |
| 24 return setmetatable(layout, form_mt); | 24 return setmetatable(layout, form_mt); |
| 25 end | 25 end |
| 26 | 26 |
| 27 function form_t.form(layout, data, formtype) | 27 function form_t.form(layout, data, formtype) |
| 28 local form = st.stanza("x", { xmlns = xmlns_forms, type = formtype or "form" }); | 28 local form = st.stanza("x", { xmlns = xmlns_forms, type = formtype or "form" }); |
| 236 field_readers["hidden"] = | 236 field_readers["hidden"] = |
| 237 function (field_tag) | 237 function (field_tag) |
| 238 return field_tag:get_child_text("value"); | 238 return field_tag:get_child_text("value"); |
| 239 end | 239 end |
| 240 | 240 |
| 241 return _M; | 241 return { |
| 242 new = new; | |
| 243 }; | |
| 242 | 244 |
| 243 | 245 |
| 244 --[=[ | 246 --[=[ |
| 245 | 247 |
| 246 Layout: | 248 Layout: |