diff --git a/mod_muc_log_http/README.txt b/mod_muc_log_http/README.txt index 69d30f4..b97d556 100644 --- a/mod_muc_log_http/README.txt +++ b/mod_muc_log_http/README.txt @@ -2,9 +2,9 @@ mod_muc_log_http - Serve MUC logs on the web - Homepage: http://ejabberd.jabber.ru/mod_muc_log_http + Homepage: http://ejabberd.im/mod_muc_log_http Author: Badlop - Requirement: ejabberd SVN r1561, or ejabbed 2.1.0 when released + Requirement: ejabberd git master DESCRIPTION @@ -19,34 +19,20 @@ of mod_http_fileserver, customized for log serving. CONFIGURATION ============= -If you want to compile this module with Erlang/OTP R11B-3 or older, -edit Emakefile and remove this: - {d, 'SSL39'}, - -Sample ejabberd.cfg options. The directory to serve is already defined +Sample ejabberd.yml options. The directory to serve is already defined on mod_muc_log. -{listen, - ... - {5280, ejabberd_http, [http_poll, web_admin, - {request_handlers, [ - {["pub", "muclogs"], mod_muc_log_http} - ] - } - ] - } - ... -]}. +listen: + - + port: 5280 + module: ejabberd_http + request_handlers: + "/pub/muclogs": mod_muc_log_http -{modules, - [ - ... - {mod_muc_log, [ - {outdir, "/var/www/ejabberdlogs"} - ]}, - {mod_muc_log_http, []}, - ... -]}. +modules: + mod_muc_log: + outdir: "/tmp/muclogs" + mod_muc_log_http: {} USAGE diff --git a/mod_muc_log_http/src/mod_muc_log_http.erl b/mod_muc_log_http/src/mod_muc_log_http.erl index 50f0b17..9c4f8d7 100644 --- a/mod_muc_log_http/src/mod_muc_log_http.erl +++ b/mod_muc_log_http/src/mod_muc_log_http.erl @@ -26,12 +26,6 @@ -define(PROCNAME, mod_muc_log_http). --ifdef(SSL39). --define(STRING2LOWER, string). --else. --define(STRING2LOWER, httpd_util). --endif. - % TODO: % - If chatroom is password protected, ask password % - If chatroom is only for members, ask for username and password @@ -47,10 +41,11 @@ process(LocalPath, Request) -> serve(LocalPath, Request). -serve(LocalPath, #request{host = Host} = Request) -> +serve(LocalPathBin, #request{host = Host} = Request) -> Proc = gen_mod:get_module_proc(Host, ?PROCNAME), Proc ! {get_docroot, self()}, receive DocRoot -> ok end, + LocalPath = [binary_to_list(LPB) || LPB <- LocalPathBin], FileName = filename:join(filename:split(DocRoot) ++ LocalPath), case file:read_file(FileName) of {ok, FileContents} -> @@ -213,7 +208,7 @@ show_dir_listing(DirName, LocalPath) -> %%%---------------------------------------------------------------------- content_type(Filename) -> - case ?STRING2LOWER:to_lower(filename:extension(Filename)) of + case string:to_lower(filename:extension(Filename)) of ".jpg" -> "image/jpeg"; ".jpeg" -> "image/jpeg"; ".gif" -> "image/gif"; @@ -246,8 +241,9 @@ loop(DocRoot) -> %%%---------------------------------------------------------------------- start(Host, _Opts) -> - DocRoot = gen_mod:get_module_opt(Host, mod_muc_log, outdir, "www/muc"), + DocRootBin = gen_mod:get_module_opt(Host, mod_muc_log, outdir, fun(A) -> A end, <<"www/muc">>), Proc = gen_mod:get_module_proc(Host, ?PROCNAME), + DocRoot = binary_to_list(DocRootBin), catch register(Proc, spawn(?MODULE, loop, [DocRoot])), ok.