aboutsummaryrefslogtreecommitdiff
path: root/src/web/ejabberd_web.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/web/ejabberd_web.erl')
-rw-r--r--src/web/ejabberd_web.erl85
1 files changed, 55 insertions, 30 deletions
diff --git a/src/web/ejabberd_web.erl b/src/web/ejabberd_web.erl
index e75f61d09..8c7ccaf69 100644
--- a/src/web/ejabberd_web.erl
+++ b/src/web/ejabberd_web.erl
@@ -2,6 +2,7 @@
%%% File : ejabberd_web.erl
%%% Author : Alexey Shchepin <alexey@process-one.net>
%%% Purpose :
+%%% Purpose :
%%% Created : 28 Feb 2004 by Alexey Shchepin <alexey@process-one.net>
%%%
%%%
@@ -25,56 +26,80 @@
%%%----------------------------------------------------------------------
-module(ejabberd_web).
+
-author('alexey@process-one.net').
%% External exports
--export([make_xhtml/1, make_xhtml/2,
- error/1]).
+-export([make_xhtml/1, make_xhtml/2, error/1]).
-include("ejabberd.hrl").
+
-include("jlib.hrl").
--include("ejabberd_http.hrl").
+-include("ejabberd_http.hrl").
%% XXX bard: there are variants of make_xhtml in ejabberd_http and
%% ejabberd_web_admin. It might be a good idea to centralize it here
%% and also create an ejabberd_web.hrl file holding the macros, so
%% that third parties can use ejabberd_web as an "utility" library.
-make_xhtml(Els) ->
- make_xhtml([], Els).
+make_xhtml(Els) -> make_xhtml([], Els).
make_xhtml(HeadEls, Els) ->
- {xmlelement, "html", [{"xmlns", "http://www.w3.org/1999/xhtml"},
- {"xml:lang", "en"},
- {"lang", "en"}],
- [{xmlelement, "head", [],
- [{xmlelement, "meta", [{"http-equiv", "Content-Type"},
- {"content", "text/html; charset=utf-8"}], []}
- | HeadEls]},
- {xmlelement, "body", [], Els}
- ]}.
-
-
--define(X(Name), {xmlelement, Name, [], []}).
--define(XA(Name, Attrs), {xmlelement, Name, Attrs, []}).
--define(XE(Name, Els), {xmlelement, Name, [], Els}).
--define(XAE(Name, Attrs, Els), {xmlelement, Name, Attrs, Els}).
+ #xmlel{name = <<"html">>,
+ attrs =
+ [{<<"xmlns">>, <<"http://www.w3.org/1999/xhtml">>},
+ {<<"xml:lang">>, <<"en">>}, {<<"lang">>, <<"en">>}],
+ children =
+ [#xmlel{name = <<"head">>, attrs = [],
+ children =
+ [#xmlel{name = <<"meta">>,
+ attrs =
+ [{<<"http-equiv">>, <<"Content-Type">>},
+ {<<"content">>,
+ <<"text/html; charset=utf-8">>}],
+ children = []}
+ | HeadEls]},
+ #xmlel{name = <<"body">>, attrs = [], children = Els}]}.
+
+-define(X(Name),
+ #xmlel{name = Name, attrs = [], children = []}).
+
+-define(XA(Name, Attrs),
+ #xmlel{name = Name, attrs = Attrs, children = []}).
+
+-define(XE(Name, Els),
+ #xmlel{name = Name, attrs = [], children = Els}).
+
+-define(XAE(Name, Attrs, Els),
+ #xmlel{name = Name, attrs = Attrs, children = Els}).
+
-define(C(Text), {xmlcdata, Text}).
+
-define(XC(Name, Text), ?XE(Name, [?C(Text)])).
--define(XAC(Name, Attrs, Text), ?XAE(Name, Attrs, [?C(Text)])).
--define(LI(Els), ?XE("li", Els)).
--define(A(URL, Els), ?XAE("a", [{"href", URL}], Els)).
+-define(XAC(Name, Attrs, Text),
+ ?XAE(Name, Attrs, [?C(Text)])).
+
+-define(LI(Els), ?XE(<<"li">>, Els)).
+
+-define(A(URL, Els),
+ ?XAE(<<"a">>, [{<<"href">>, URL}], Els)).
+
-define(AC(URL, Text), ?A(URL, [?C(Text)])).
--define(P, ?X("p")).
--define(BR, ?X("br")).
+
+-define(P, ?X(<<"p">>)).
+
+-define(BR, ?X(<<"br">>)).
+
-define(INPUT(Type, Name, Value),
- ?XA("input", [{"type", Type},
- {"name", Name},
- {"value", Value}])).
+ ?XA(<<"input">>,
+ [{<<"type">>, Type}, {<<"name">>, Name},
+ {<<"value">>, Value}])).
error(not_found) ->
- {404, [], make_xhtml([?XC("h1", "404 Not Found")])};
+ {404, [],
+ make_xhtml([?XC(<<"h1">>, <<"404 Not Found">>)])};
error(not_allowed) ->
- {401, [], make_xhtml([?XC("h1", "401 Unauthorized")])}.
+ {401, [],
+ make_xhtml([?XC(<<"h1">>, <<"401 Unauthorized">>)])}.