diff options
author | Evgeniy Khramtsov <ekhramtsov@process-one.net> | 2017-10-09 21:46:38 +0300 |
---|---|---|
committer | Evgeniy Khramtsov <ekhramtsov@process-one.net> | 2017-10-09 21:46:38 +0300 |
commit | d22ee24e723df36d4895582db340395a5c92d97b (patch) | |
tree | fc159ba63b708030d49175026bad54e76c26a610 /src/mod_register_web.erl | |
parent | Resend presences and history if presence possesses <x/> MUC element (diff) |
Better handle mobile devices in CSS of mod_register_web
Thanks to Marek Foss. Fixes #2039
Diffstat (limited to 'src/mod_register_web.erl')
-rw-r--r-- | src/mod_register_web.erl | 41 |
1 files changed, 31 insertions, 10 deletions
diff --git a/src/mod_register_web.erl b/src/mod_register_web.erl index 16c2d802..b7bc2edc 100644 --- a/src/mod_register_web.erl +++ b/src/mod_register_web.erl @@ -156,10 +156,14 @@ process(_Path, _Request) -> %%%---------------------------------------------------------------------- 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">>, @@ -168,16 +172,30 @@ 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">>}, @@ -206,7 +224,8 @@ index_page(Lang) -> 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">>}, @@ -350,7 +369,8 @@ build_captcha_li_list2(Lang, IP) -> %%%---------------------------------------------------------------------- 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">>}, @@ -456,7 +476,8 @@ check_password(Username, Host, Password) -> %%%---------------------------------------------------------------------- form_del_get(Host, Lang) -> - HeadEls = [?XCT(<<"title">>, + HeadEls = [meta(), + ?XCT(<<"title">>, <<"Unregister a Jabber account">>), ?XA(<<"link">>, [{<<"href">>, <<"/register/register.css">>}, |