Software /
code /
prosody-modules
Changeset
3703:7244ff1d62a8
mod_http_muc_log: Expose xml:lang from each message/body #a11y
Individual messages may be in a different language than the main
language of the room.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Wed, 09 Oct 2019 21:35:13 +0200 |
parents | 3702:caf27826c7b2 |
children | 3704:c6563625f60e |
files | mod_http_muc_log/http_muc_log.html mod_http_muc_log/mod_http_muc_log.lua |
diffstat | 2 files changed, 6 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/mod_http_muc_log/http_muc_log.html Wed Oct 09 21:36:23 2019 +0200 +++ b/mod_http_muc_log/http_muc_log.html Wed Oct 09 21:35:13 2019 +0200 @@ -91,7 +91,7 @@ </div> <ol class="chat-logs">{lines# -<li class="{item.st_name} {item.st_type?}" id="{item.key}"> +<li {item.lang&lang="{item.lang}"} class="{item.st_name} {item.st_type?}" id="{item.key}"> <a class="time" href="#{item.key}"><time id="{item.time}" datetime="{item.datetime}">{item.time}</time></a> <b class="nick">{item.nick}</b> <em class="verb">{item.verb?}</em>
--- a/mod_http_muc_log/mod_http_muc_log.lua Wed Oct 09 21:36:23 2019 +0200 +++ b/mod_http_muc_log/mod_http_muc_log.lua Wed Oct 09 21:35:13 2019 +0200 @@ -294,9 +294,11 @@ local first, last; for key, item, when in iter do - local body = item:get_child_text("body"); + local body_tag = item:get_child("body"); + local body = body_tag and body_tag:get_text(); local subject = item:get_child_text("subject"); local verb = nil; + local lang = body_tag and body_tag.attr["xml:lang"] or item.attr["xml:lang"]; if subject then verb, body = "set the topic to", subject; elseif body and body:sub(1,4) == "/me " then @@ -304,6 +306,7 @@ elseif item.name == "presence" then -- TODO Distinguish between join and presence update verb = item.attr.type == "unavailable" and "has left" or "has joined"; + lang = "en"; end local oob = use_oob and item:get_child("x", "jabber:x:oob"); if body or verb or oob then @@ -313,6 +316,7 @@ time = datetime.time(when); verb = verb; body = body; + lang = lang; nick = select(3, jid_split(item.attr.from)); st_name = item.name; st_type = item.attr.type;