# /usr/lib/ejabberd/priv/msgs
MSGSDIR = $(PRIVDIR)/msgs
+# /usr/lib/ejabberd/priv/css
+CSSDIR = $(PRIVDIR)/css
+
# /usr/lib/ejabberd/priv/sql
SQLDIR = $(PRIVDIR)/sql
DEPS_FILES_FILTERED=$(filter-out %/epam %/eimp deps/elixir/ebin/elixir.app,$(DEPS_FILES))
DEPS_DIRS=$(sort deps/ $(foreach DEP,$(DEPS),deps/$(DEP)/) $(dir $(DEPS_FILES)))
-MAIN_FILES=$(filter-out %/configure.beam,$(call FILES_WILDCARD,ebin/*.beam ebin/*.app priv/msgs/*.msg priv/lib/* include/*.hrl COPYING))
+MAIN_FILES=$(filter-out %/configure.beam,$(call FILES_WILDCARD,ebin/*.beam ebin/*.app priv/msgs/*.msg priv/css/*.css priv/lib/* include/*.hrl COPYING))
MAIN_DIRS=$(sort $(dir $(MAIN_FILES)) priv/bin priv/sql)
define DEP_VERSION_template
rm -fr $(SODIR)
rm -f $(MSGSDIR)/*.msgs
rm -fr $(MSGSDIR)
+ rm -f $(CSSDIR)/*.css
+ rm -fr $(CSSDIR)
rm -f $(SQLDIR)/*.sql
rm -fr $(SQLDIR)
rm -fr $(PRIVDIR)
atom_to_binary/1, binary_to_atom/1, tuple_to_binary/1,
l2i/1, i2l/1, i2l/2, expr_to_term/1, term_to_expr/1,
now_to_usec/1, usec_to_now/1, encode_pid/1, decode_pid/2,
- compile_exprs/2, join_atoms/2, try_read_file/1, have_eimp/0]).
+ compile_exprs/2, join_atoms/2, try_read_file/1, have_eimp/0,
+ css_dir/0]).
%% Deprecated functions
-export([decode_base64/1, encode_base64/1]).
have_eimp() -> false.
-endif.
+-spec css_dir() -> file:filename().
+css_dir() ->
+ case os:getenv("EJABBERD_CSS_PATH") of
+ false ->
+ case code:priv_dir(ejabberd) of
+ {error, _} -> filename:join(["priv", "css"]);
+ Path -> filename:join([Path, "css"])
+ end;
+ Path -> Path
+ end.
+
%%%===================================================================
%%% Internal functions
%%%===================================================================
%%%----------------------------------------------------------------------
serve_css() ->
- {200,
- [{<<"Content-Type">>, <<"text/css">>}, last_modified(),
- cache_control_public()],
- css()}.
+ case css() of
+ {ok, CSS} ->
+ {200,
+ [{<<"Content-Type">>, <<"text/css">>}, last_modified(),
+ cache_control_public()], CSS};
+ error ->
+ {404, [], "CSS not found"}
+ end.
last_modified() ->
{<<"Last-Modified">>,
cache_control_public() ->
{<<"Cache-Control">>, <<"public">>}.
+-spec css() -> {ok, binary()} | error.
css() ->
- <<"html,body {\nbackground: white;\nmargin: "
- "0;\npadding: 0;\nheight: 100%;\n}">>.
+ Dir = misc:css_dir(),
+ File = filename:join(Dir, "register.css"),
+ case file:read_file(File) of
+ {ok, Data} ->
+ {ok, Data};
+ {error, Why} ->
+ ?ERROR_MSG("failed to read ~s: ~s", [File, file:format_error(Why)]),
+ error
+ end.
+
+meta() ->
+ ?XA(<<"meta">>,
+ [{<<"name">>, <<"viewport">>},
+ {<<"content">>, <<"width=device-width, initial-scale=1">>}]).
%%%----------------------------------------------------------------------
%%% Index page
%%%----------------------------------------------------------------------
index_page(Lang) ->
- HeadEls = [?XCT(<<"title">>,
+ HeadEls = [meta(),
+ ?XCT(<<"title">>,
<<"Jabber Account Registration">>),
?XA(<<"link">>,
[{<<"href">>, <<"/register/register.css">>},
form_new_get(Host, Lang, IP) ->
CaptchaEls = build_captcha_li_list(Lang, IP),
- HeadEls = [?XCT(<<"title">>,
+ HeadEls = [meta(),
+ ?XCT(<<"title">>,
<<"Register a Jabber account">>),
?XA(<<"link">>,
[{<<"href">>, <<"/register/register.css">>},
%%%----------------------------------------------------------------------
form_changepass_get(Host, Lang) ->
- HeadEls = [?XCT(<<"title">>, <<"Change Password">>),
+ HeadEls = [meta(),
+ ?XCT(<<"title">>, <<"Change Password">>),
?XA(<<"link">>,
[{<<"href">>, <<"/register/register.css">>},
{<<"type">>, <<"text/css">>},
%%%----------------------------------------------------------------------
form_del_get(Host, Lang) ->
- HeadEls = [?XCT(<<"title">>,
+ HeadEls = [meta(),
+ ?XCT(<<"title">>,
<<"Unregister a Jabber account">>),
?XA(<<"link">>,
[{<<"href">>, <<"/register/register.css">>},