Merge pull request #50 from weiss/host-in-baseurl

mod_webpresence: Support @HOST@ in 'baseurl' value
This commit is contained in:
badlop 2014-11-12 12:24:25 +01:00
commit b8120ee64e
2 changed files with 5 additions and 3 deletions

View File

@ -82,6 +82,7 @@ baseurl:
This informational option is used only when sending a message to the user
and when building the JavaScript code.
It is the base part of the URL of the webpresence HTTP content.
You can use the keyword @HOST@.
If the option is not specified, it takes as default value: http://host:port/path/

View File

@ -93,15 +93,16 @@ init([Host, Opts]) ->
Access = gen_mod:get_opt(access, Opts, fun(O) -> O end, local),
Port = gen_mod:get_opt(port, Opts, fun(O) -> O end, 5280),
Path = gen_mod:get_opt(path, Opts, fun(O) -> O end, <<"presence">>),
BaseURL = gen_mod:get_opt(baseurl, Opts, fun(O) -> O end,
BaseURL1 = gen_mod:get_opt(baseurl, Opts, fun(O) -> O end,
iolist_to_binary(io_lib:format(<<"http://~s:~p/~s/">>, [Host, Port, Path]))),
BaseURL2 = ejabberd_regexp:greplace(BaseURL1, <<"@HOST@">>, Host),
ejabberd_router:register_route(MyHost),
ejabberd_hooks:add(remove_user, Host, ?MODULE, remove_user, 50),
ejabberd_hooks:add(webadmin_menu_host, Host, ?MODULE, web_menu_host, 50),
ejabberd_hooks:add(webadmin_page_host, Host, ?MODULE, web_page_host, 50),
{ok, #state{host = MyHost,
server_host = Host,
base_url = BaseURL,
base_url = BaseURL2,
access = Access}}.
%%--------------------------------------------------------------------