Mercurial > prosody-modules
annotate mod_muc_lang/mod_muc_lang.lua @ 5627:3a5cf8d80089
mod_http_oauth2: Tweak method of centering the UI
The percentage here was relative to the viewport width, which on some
very wide screens may put the UI slightly outside of the view, requiring
scrolling to see.
By using a unit relative to the height of the viewport, this is avoided
and should work better. But no guarantees, it's still possible to resize
the browser or adjust font sizes so that the UI goes out of view.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 31 Jul 2023 07:28:09 +0200 |
parents | ef5d52ca31bb |
children |
rev | line source |
---|---|
3546
ef5d52ca31bb
mod_muc_lang: Abort on Prosody 0.11 which supports this natively (thanks Ge0rG)
Kim Alvefur <zash@zash.se>
parents:
3076
diff
changeset
|
1 assert(module:depends"muc".rooms, "This module is not required with Prosody >= 0.11"); |
3069
e1db146984a0
mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
2 |
e1db146984a0
mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
3 module:hook("muc-config-form", function(event) |
e1db146984a0
mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
4 local room, form = event.room, event.form; |
e1db146984a0
mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
5 table.insert(form, { |
e1db146984a0
mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
6 name = "muc#roomconfig_lang", |
e1db146984a0
mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
7 type = "text-single", |
e1db146984a0
mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
8 label = "Natural Language for Room Discussions", |
e1db146984a0
mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
9 value = room._data.language, |
e1db146984a0
mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
10 }); |
e1db146984a0
mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
11 end); |
e1db146984a0
mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
12 |
e1db146984a0
mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
13 module:hook("muc-config-submitted", function(event) |
e1db146984a0
mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
14 local room, fields, changed = event.room, event.fields, event.changed; |
e1db146984a0
mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
15 local new = fields["muc#roomconfig_lang"]; |
e1db146984a0
mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
16 if new ~= room._data.language then |
3073
ef8fe8bec5b1
mod_muc_lang: Fix to use correct data field
Kim Alvefur <zash@zash.se>
parents:
3069
diff
changeset
|
17 room._data.language = new; |
3069
e1db146984a0
mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
18 if type(changed) == "table" then |
e1db146984a0
mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
19 changed["muc#roomconfig_lang"] = true; |
e1db146984a0
mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
20 else |
e1db146984a0
mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
21 event.changed = true; |
e1db146984a0
mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
22 end |
e1db146984a0
mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
23 end |
e1db146984a0
mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
24 end); |
e1db146984a0
mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
25 |
e1db146984a0
mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
26 module:hook("muc-disco#info", function (event) |
e1db146984a0
mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
27 local room, form, formdata = event.room, event.form, event.formdata; |
e1db146984a0
mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
28 |
e1db146984a0
mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
29 table.insert(form, { |
3074
57396a32fc05
mod_muc_lang: Fix to use correct field name in disco#info
Kim Alvefur <zash@zash.se>
parents:
3073
diff
changeset
|
30 name = "muc#roominfo_lang", |
3069
e1db146984a0
mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
31 value = room._data.language, |
e1db146984a0
mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
32 }); |
e1db146984a0
mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
33 formdata["muc#roominfo_lang"] = room._data.language; |
e1db146984a0
mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
34 end); |
e1db146984a0
mod_muc_lang: Advertises the room language
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
35 |