Changeset

3596:6e529f53b3c3

mod_http_muc_log: Allow specifying the default view
author Kim Alvefur <zash@zash.se>
date Mon, 13 May 2019 00:52:35 +0200
parents 3595:00a848ede42d
children 3597:da7ec4ed6ddf
files mod_http_muc_log/README.markdown mod_http_muc_log/mod_http_muc_log.lua
diffstat 2 files changed, 14 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/mod_http_muc_log/README.markdown	Mon May 13 11:13:19 2019 +0200
+++ b/mod_http_muc_log/README.markdown	Mon May 13 00:52:35 2019 +0200
@@ -50,6 +50,15 @@
 for rendering templates, with the pattern `"%b{}"` and HTML / XML
 escaping enabled.
 
+## Default view
+
+To link to the latest day instead of calendar from the room listing
+page:
+
+```lua
+http_muc_log_default_view = "latest"
+```
+
 ## Inline images
 
 Inline images can optionally be shown. This is disabled by default for
--- a/mod_http_muc_log/mod_http_muc_log.lua	Mon May 13 11:13:19 2019 +0200
+++ b/mod_http_muc_log/mod_http_muc_log.lua	Mon May 13 00:52:35 2019 +0200
@@ -96,11 +96,14 @@
 	return true;
 end
 
+-- Can be set to "latest"
+local default_view = module:get_option_string(module.name .. "_default_view", nil);
+
 module:hook("muc-disco#info", function (event)
 	local room = event.room;
 	if open_room(room) then
 		table.insert(event.form, { name = "muc#roominfo_logs", type="text-single" });
-		event.formdata["muc#roominfo_logs"] = get_absolute_link(jid_split(event.room.jid), nil);
+		event.formdata["muc#roominfo_logs"] = get_absolute_link(jid_split(event.room.jid), default_view);
 	end
 end);
 
@@ -371,7 +374,7 @@
 		if not (room.get_hidden or room.is_hidden)(room) then
 			room_list[i], i = {
 				jid = room.jid;
-				href = get_link(jid_split(room.jid), nil);
+				href = get_link(jid_split(room.jid), default_view);
 				name = room:get_name();
 				description = room:get_description();
 			}, i + 1;