diff --git a/mod_webpresence/README.txt b/mod_webpresence/README.txt index 47cc1e3..3d4cb3b 100644 --- a/mod_webpresence/README.txt +++ b/mod_webpresence/README.txt @@ -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/ diff --git a/mod_webpresence/src/mod_webpresence.erl b/mod_webpresence/src/mod_webpresence.erl index 238d2c9..d8c01b3 100644 --- a/mod_webpresence/src/mod_webpresence.erl +++ b/mod_webpresence/src/mod_webpresence.erl @@ -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, - iolist_to_binary(io_lib:format(<<"http://~s:~p/~s/">>, [Host, Port, Path]))), + 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}}. %%--------------------------------------------------------------------