Software / code / prosody-modules
Comparison
mod_http_muc_log/mod_http_muc_log.lua @ 3578:ea63dc0cc824
mod_http_muc_log: Sort room listing by jid for stable order
It was silly that the list would be shuffled every time you reloaded the
page.
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Sun, 05 May 2019 11:01:17 +0200 |
| parent | 3560:0ebb7112c102 |
| child | 3582:444e2306c99a |
comparison
equal
deleted
inserted
replaced
| 3577:f169d9a513c6 | 3578:ea63dc0cc824 |
|---|---|
| 333 local request, response = event.request, event.response; | 333 local request, response = event.request, event.response; |
| 334 local room_list, i = {}, 1; | 334 local room_list, i = {}, 1; |
| 335 for room in each_room() do | 335 for room in each_room() do |
| 336 if not (room.get_hidden or room.is_hidden)(room) then | 336 if not (room.get_hidden or room.is_hidden)(room) then |
| 337 room_list[i], i = { | 337 room_list[i], i = { |
| 338 jid = room.jid; | |
| 338 href = get_link(jid_split(room.jid), nil); | 339 href = get_link(jid_split(room.jid), nil); |
| 339 name = room:get_name(); | 340 name = room:get_name(); |
| 340 description = room:get_description(); | 341 description = room:get_description(); |
| 341 }, i + 1; | 342 }, i + 1; |
| 342 end | 343 end |
| 343 end | 344 end |
| 345 | |
| 346 table.sort(room_list, function (a, b) | |
| 347 return a.jid < b.jid; | |
| 348 end); | |
| 344 | 349 |
| 345 response.headers.content_type = "text/html; charset=utf-8"; | 350 response.headers.content_type = "text/html; charset=utf-8"; |
| 346 return render(template, { | 351 return render(template, { |
| 347 title = module:get_option_string("name", "Prosody Chatrooms"); | 352 title = module:get_option_string("name", "Prosody Chatrooms"); |
| 348 jid = module.host; | 353 jid = module.host; |