Software /
code /
prosody-modules
Comparison
mod_rest/jsonmap.lib.lua @ 3856:8bdb1729529b
mod_rest: Make XHTML-IM mapping more convenient
Avoid burdening web developers with XML namespace attribute
Might be a bit fragile
Note that the <body> element must be included
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Sat, 25 Jan 2020 00:46:09 +0100 |
parent | 3855:0e1e900577c4 |
child | 3859:da3a0f055526 |
comparison
equal
deleted
inserted
replaced
3855:0e1e900577c4 | 3856:8bdb1729529b |
---|---|
23 -- XEP-0045 MUC | 23 -- XEP-0045 MUC |
24 -- TODO history, password, ??? | 24 -- TODO history, password, ??? |
25 join = {"bool_tag", "http://jabber.org/protocol/muc", "x"}, | 25 join = {"bool_tag", "http://jabber.org/protocol/muc", "x"}, |
26 | 26 |
27 -- XEP-0071 | 27 -- XEP-0071 |
28 -- FIXME xmlns is awkward | |
29 html = { | 28 html = { |
30 "func", "http://jabber.org/protocol/xhtml-im", "html", | 29 "func", "http://jabber.org/protocol/xhtml-im", "html", |
31 function (s) --> json string | 30 function (s) --> json string |
32 return tostring(s:get_child("body", "http://www.w3.org/1999/xhtml")); | 31 return (tostring(s:get_child("body", "http://www.w3.org/1999/xhtml")):gsub(" xmlns='[^']*'","", 1)); |
33 end; | 32 end; |
34 function (s) --> xml | 33 function (s) --> xml |
35 if type(s) == "string" then | 34 if type(s) == "string" then |
36 return xml.parse([[<html xmlns='http://jabber.org/protocol/xhtml-im'>]]..s..[[</html>]]); | 35 return assert(xml.parse([[<x:html xmlns:x='http://jabber.org/protocol/xhtml-im' xmlns='http://www.w3.org/1999/xhtml'>]]..s..[[</x:html>]])); |
37 end | 36 end |
38 end; | 37 end; |
39 }; | 38 }; |
40 | 39 |
41 -- XEP-0199: XMPP Ping | 40 -- XEP-0199: XMPP Ping |