diff options
author | Evgeniy Khramtsov <ekhramtsov@process-one.net> | 2018-06-29 11:34:53 +0300 |
---|---|---|
committer | Evgeniy Khramtsov <ekhramtsov@process-one.net> | 2018-06-29 11:34:53 +0300 |
commit | dff940b89ec05181b706893385b3605b28f5e546 (patch) | |
tree | ef4fba227ee8f710ded7123c6e947a7ba40b3088 /src/mod_muc_log.erl | |
parent | Improve URLs validation (diff) |
Support both filenames and URLs in 'cssfile' option of mod_muc_log
If filename is provided, its content is inserted into the HTML page.
If URL is provided, it's used as a value of 'href' HTML attribute.
Diffstat (limited to '')
-rw-r--r-- | src/mod_muc_log.erl | 18 |
1 files changed, 11 insertions, 7 deletions
diff --git a/src/mod_muc_log.erl b/src/mod_muc_log.erl index 2e47a19da..7f5ca1b71 100644 --- a/src/mod_muc_log.erl +++ b/src/mod_muc_log.erl @@ -599,20 +599,20 @@ put_header(F, Room, Date, CSSFile, Lang, Hour_offset, fw(F, <<"<br/><a class=\"ts\">GMT~s</a><br/>">>, [Time_offset_str]). -put_header_css(F, false) -> +put_header_css(F, {file, Path}) -> fw(F, <<"<style type=\"text/css\">">>), fw(F, <<"<!--">>), - case misc:read_css("muc.css") of + case file:read_file(Path) of {ok, Data} -> fw(F, Data); {error, _} -> ok end, fw(F, <<"//-->">>), fw(F, <<"</style>">>); -put_header_css(F, CSSFile) -> +put_header_css(F, {url, URL}) -> fw(F, <<"<link rel=\"stylesheet\" type=\"text/css\" " "href=\"~s\" media=\"all\">">>, - [CSSFile]). + [URL]). put_header_script(F) -> fw(F, <<"<script type=\"text/javascript\">">>), @@ -931,8 +931,12 @@ has_no_permanent_store_hint(Packet) -> mod_opt_type(access_log) -> fun acl:access_rules_validator/1; mod_opt_type(cssfile) -> - fun(false) -> false; - (File) -> misc:try_read_file(File) + fun(S) -> + case str:to_lower(S) of + <<"http:/", _/binary>> -> {url, misc:try_url(S)}; + <<"https:/", _/binary>> -> {url, misc:try_url(S)}; + _ -> {file, misc:try_read_file(S)} + end end; mod_opt_type(dirname) -> fun (room_jid) -> room_jid; @@ -969,7 +973,7 @@ mod_opt_type(top_link) -> mod_options(_) -> [{access_log, muc_admin}, - {cssfile, false}, + {cssfile, filename:join(misc:css_dir(), "muc.css")}, {dirname, room_jid}, {dirtype, subdirs}, {file_format, html}, |