Update mod_muc_log_http to work with ejabberd git master
This commit is contained in:
parent
edb67df064
commit
2b7bbd9535
|
@ -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
|
||||
|
|
|
@ -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.
|
||||
|
||||
|
|
Loading…
Reference in New Issue