From 9f80ec4fb6e6eba6e6fba11b8b47debceb04aa0d Mon Sep 17 00:00:00 2001 From: Badlop Date: Wed, 7 Jan 2009 00:55:02 +0000 Subject: [PATCH] * src/web/ejabberd_web_admin.erl: WebAdmin serves Guide and links to related sections; the path to guide.html can be configured with option doc_path (EJAB-837) * src/web/ejabberd_web_admin.hrl: Likewise * src/mod_shared_roster.erl: Likewise * doc/guide.tex: Likewise * doc/guide.html: Likewise SVN Revision: 1777 --- ChangeLog | 10 +++++++ doc/guide.html | 12 +++++++- doc/guide.tex | 12 ++++++++ src/mod_shared_roster.erl | 4 +-- src/web/ejabberd_web_admin.erl | 51 +++++++++++++++++++++++++++------- src/web/ejabberd_web_admin.hrl | 14 ++++++++++ 6 files changed, 90 insertions(+), 13 deletions(-) diff --git a/ChangeLog b/ChangeLog index 67c4f575e..0192aa7e0 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2009-01-07 Badlop + + * src/web/ejabberd_web_admin.erl: WebAdmin serves Guide and links + to related sections; the path to guide.html can be configured with + option doc_path (EJAB-837) + * src/web/ejabberd_web_admin.hrl: Likewise + * src/mod_shared_roster.erl: Likewise + * doc/guide.tex: Likewise + * doc/guide.html: Likewise + 2009-01-06 Badlop * src/msgs/ru.po: Fix typo (thanks to Dominges) diff --git a/doc/guide.html b/doc/guide.html index 6d143c335..b7466955e 100644 --- a/doc/guide.html +++ b/doc/guide.html @@ -3072,7 +3072,17 @@ web browser to https://192.168.1.1:5280/admin/: tls, {certfile, "/usr/local/etc/server.pem"}]}, ... ]}. -

+

Certain pages in the ejabberd Web Admin contain a link to a related +section in the ejabberd Installation and Operation Guide. +In order to view such links, a copy in HTML format of the Guide must +be installed in the system. +The file is searched by default in +"/share/doc/ejabberd/guide.html". +The directory of the documentation can be specified in +ejabberd.cfg with the option doc_path. +For example: +

{doc_path, "/usr/local/share/doc/ejabberd/"}.
+

4.3  Ad-hoc Commands

If you enable mod_configure and mod_adhoc, you can perform several administrative tasks in ejabberd with a Jabber client. diff --git a/doc/guide.tex b/doc/guide.tex index afc63a3ff..c3fb6db07 100644 --- a/doc/guide.tex +++ b/doc/guide.tex @@ -3943,6 +3943,18 @@ Examples: \end{verbatim} \end{itemize} +Certain pages in the ejabberd Web Admin contain a link to a related +section in the ejabberd Installation and Operation Guide. +In order to view such links, a copy in HTML format of the Guide must +be installed in the system. +The file is searched by default in +\term{"/share/doc/ejabberd/guide.html"}. +The directory of the documentation can be specified in +\term{ejabberd.cfg} with the option \term{doc\_path}. +For example: +\begin{verbatim} +{doc_path, "/usr/local/share/doc/ejabberd/"}. +\end{verbatim} \makesection{adhoccommands}{Ad-hoc Commands} diff --git a/src/mod_shared_roster.erl b/src/mod_shared_roster.erl index d62124d1e..0fd13d4c5 100644 --- a/src/mod_shared_roster.erl +++ b/src/mod_shared_roster.erl @@ -723,7 +723,7 @@ list_shared_roster_groups(Host, Query, Lang) -> ] )] )]), - [?XC("h1", ?T("Shared Roster Groups"))] ++ + ?H1GL(?T("Shared Roster Groups"), "modsharedroster", "mod_shared_roster") ++ case Res of ok -> [?CT("Submitted"), ?P]; error -> [?CT("Bad format"), ?P]; @@ -822,7 +822,7 @@ shared_roster_group(Host, Group, Query, Lang) -> ] )] )]), - [?XC("h1", ?T("Shared Roster Groups"))] ++ + ?H1GL(?T("Shared Roster Groups"), "modsharedroster", "mod_shared_roster") ++ [?XC("h2", ?T("Group ") ++ Group)] ++ case Res of ok -> [?CT("Submitted"), ?P]; diff --git a/src/web/ejabberd_web_admin.erl b/src/web/ejabberd_web_admin.erl index b25882d9a..81211a50f 100644 --- a/src/web/ejabberd_web_admin.erl +++ b/src/web/ejabberd_web_admin.erl @@ -40,6 +40,30 @@ -include("ejabberd_web_admin.hrl"). +process(["doc", LocalFile], _Request) -> + DocPath = case ejabberd_config:get_global_option(doc_path) of + P when is_list(P) -> P; + _ -> "/share/doc/ejabberd/" + end, + %% Code based in mod_http_fileserver + FileName = filename:join(DocPath, LocalFile), + case file:read_file(FileName) of + {ok, FileContents} -> + ?DEBUG("Delivering content.", []), + {200, + [{"Server", "ejabberd"}], + FileContents}; + {error, Error} -> + ?DEBUG("Delivering error: ~p", [Error]), + Help = " " ++ FileName ++ " - Try to specify the path to ejabberd guide.html " + "with the option doc_path. Check the ejabberd Guide for more information", + case Error of + eacces -> {403, [], "Forbidden"++Help}; + enoent -> {404, [], "Not found"++Help}; + _Else -> {404, [], atom_to_list(Error)++Help} + end + end; + process(["server", SHost | RPath], #request{auth = Auth} = Request) -> Host = jlib:nameprep(SHost), case lists:member(Host, ?MYHOSTS) of @@ -509,8 +533,13 @@ h3 { padding-top: 5px; } -*.alignright { +div.guidelink { text-align: right; + padding-right: 1em; +} + +*.alignright { + font-size: 10pt; } ". @@ -556,8 +585,8 @@ process_admin(global, lang = Lang}) -> Base = get_base_path(global, cluster), MenuItems2 = make_menu_items(global, cluster, Base, Lang), - make_xhtml([?XCT("h1", "Administration"), - ?XE("ul", + make_xhtml(?H1GL(?T("Administration"), "toc", "Contents") ++ + [?XE("ul", [?LI([?ACT("/admin/acls/", "Access Control Lists"), ?C(" "), ?ACT("/admin/acls-raw/", "(Raw)")]), ?LI([?ACT("/admin/access/", "Access Rules"), ?C(" "), @@ -631,7 +660,7 @@ process_admin(Host, "~p.", [lists:keysort( 2, ets:select(acl, [{{acl, {'$1', Host}, '$2'}, [], [{{acl, '$1', '$2'}}]}]))])), - make_xhtml([?XCT("h1", "Access Control Lists")] ++ + make_xhtml(?H1GL(?T("Access Control Lists"), "ACLDefinition", "ACL Definition") ++ case Res of ok -> [?CT("Submitted"), ?P]; error -> [?CT("Bad format"), ?P]; @@ -674,7 +703,7 @@ process_admin(Host, ACLs = lists:keysort( 2, ets:select(acl, [{{acl, {'$1', Host}, '$2'}, [], [{{acl, '$1', '$2'}}]}])), - make_xhtml([?XCT("h1", "Access Control Lists")] ++ + make_xhtml(?H1GL(?T("Access Control Lists"), "ACLDefinition", "ACL Definition") ++ case Res of ok -> [?CT("Submitted"), ?P]; error -> [?CT("Bad format"), ?P]; @@ -742,7 +771,7 @@ process_admin(Host, [{{config, {access, '$1', Host}, '$2'}, [], [{{access, '$1', '$2'}}]}])])), - make_xhtml([?XCT("h1", "Access Rules")] ++ + make_xhtml(?H1GL(?T("Access Rules"), "AccessRights", "Access Rights") ++ case Res of ok -> [?CT("Submitted"), ?P]; error -> [?CT("Bad format"), ?P]; @@ -780,7 +809,7 @@ process_admin(Host, [{{config, {access, '$1', Host}, '$2'}, [], [{{access, '$1', '$2'}}]}]), - make_xhtml([?XCT("h1", "Access Rules")] ++ + make_xhtml(?H1GL(?T("Access Rules"), "AccessRights", "Access Rights") ++ case Res of ok -> [?CT("Submitted"), ?P]; error -> [?CT("Bad format"), ?P]; @@ -837,7 +866,7 @@ process_admin(global, #request{path = ["vhosts"], lang = Lang}) -> Res = list_vhosts(Lang), - make_xhtml([?XCT("h1", "ejabberd virtual hosts")] ++ Res, global, Lang); + make_xhtml(?H1GL(?T("ejabberd virtual hosts"), "virtualhost", "Virtual Hosting") ++ Res, global, Lang); process_admin(Host, #request{path = ["users"], @@ -1786,7 +1815,8 @@ get_node(global, Node, ["ports"], Query, Lang) -> end, NewPorts = lists:sort( rpc:call(Node, ejabberd_config, get_local_option, [listen])), - [?XC("h1", ?T("Listened Ports at ") ++ atom_to_list(Node))] ++ + H1String = ?T("Listened Ports at ") ++ atom_to_list(Node), + ?H1GL(H1String, "listened", "Listening Ports") ++ case Res of ok -> [?CT("Submitted"), ?P]; error -> [?CT("Bad format"), ?P]; @@ -1809,7 +1839,8 @@ get_node(Host, Node, ["modules"], Query, Lang) when is_list(Host) -> end, NewModules = lists:sort( rpc:call(Node, gen_mod, loaded_modules_with_opts, [Host])), - [?XC("h1", ?T("Modules at ") ++ atom_to_list(Node))] ++ + H1String = ?T("Modules at ") ++ atom_to_list(Node), + ?H1GL(H1String, "modoverview", "Modules Overview") ++ case Res of ok -> [?CT("Submitted"), ?P]; error -> [?CT("Bad format"), ?P]; diff --git a/src/web/ejabberd_web_admin.hrl b/src/web/ejabberd_web_admin.hrl index ddceaa1ee..015886dba 100644 --- a/src/web/ejabberd_web_admin.hrl +++ b/src/web/ejabberd_web_admin.hrl @@ -50,3 +50,17 @@ {"size", Size}])). -define(INPUTST(Type, Name, Value, Size), ?INPUT(Type, Name, ?T(Value), Size)). -define(ACLINPUT(Text), ?XE("td", [?INPUT("text", "value" ++ ID, Text)])). + +%% Guide Link +-define(GL(Ref, Title), + ?XAE("div", + [{"class", "guidelink"}], + [?XAE("a", + [{"href", "/admin/doc/guide.html#"++ Ref}, + {"target", "_blank"}], + [?C("[Guide: " ++ Title ++ "]")]) + ])). + + +%% h1 with a Guide Link +-define(H1GL(Name, Ref, Title), [?XC("h1", Name), ?GL(Ref, Title)]).