mirror of
https://github.com/processone/ejabberd
synced 2025-10-05 10:39:29 +02:00
Support to get module status from Elixir modules
This commit is contained in:
parent
17160e9379
commit
4ad4a3bf24
1 changed files with 41 additions and 6 deletions
|
@ -936,12 +936,7 @@ get_installed_module_el({ModAtom, Attrs}, Lang) ->
|
||||||
[]
|
[]
|
||||||
end,
|
end,
|
||||||
TitleEl = make_title_el(CommitDate, CommitMessage, CommitAuthorName),
|
TitleEl = make_title_el(CommitDate, CommitMessage, CommitAuthorName),
|
||||||
Status = case lists:member({mod_status, 0}, ModAtom:module_info(exports)) of
|
Status = get_module_status_el(ModAtom),
|
||||||
true ->
|
|
||||||
[?C(<<" ">>),
|
|
||||||
?C(ModAtom:mod_status())];
|
|
||||||
false -> []
|
|
||||||
end,
|
|
||||||
HomeTitleEl = make_home_title_el(Summary, Author),
|
HomeTitleEl = make_home_title_el(Summary, Author),
|
||||||
?XE(<<"tr">>,
|
?XE(<<"tr">>,
|
||||||
[?XE(<<"td">>, [?AXC(Home, [HomeTitleEl], Mod)]),
|
[?XE(<<"td">>, [?AXC(Home, [HomeTitleEl], Mod)]),
|
||||||
|
@ -954,6 +949,46 @@ get_installed_module_el({ModAtom, Attrs}, Lang) ->
|
||||||
++ Status)
|
++ Status)
|
||||||
| UpgradeEls]).
|
| UpgradeEls]).
|
||||||
|
|
||||||
|
get_module_status_el(ModAtom) ->
|
||||||
|
case {get_module_status(ModAtom),
|
||||||
|
get_module_status(elixir_module_name(ModAtom))} of
|
||||||
|
{Str, unknown} when is_list(Str) ->
|
||||||
|
[?C(<<" ">>), ?C(Str)];
|
||||||
|
{unknown, Str} when is_list(Str) ->
|
||||||
|
[?C(<<" ">>), ?C(Str)];
|
||||||
|
{unknown, unknown} ->
|
||||||
|
[]
|
||||||
|
end.
|
||||||
|
|
||||||
|
get_module_status(Module) ->
|
||||||
|
try Module:mod_status() of
|
||||||
|
Str when is_list(Str) ->
|
||||||
|
Str
|
||||||
|
catch
|
||||||
|
_:_ ->
|
||||||
|
unknown
|
||||||
|
end.
|
||||||
|
|
||||||
|
%% Converts mod_some_thing to Elixir.ModSomeThing
|
||||||
|
elixir_module_name(ModAtom) ->
|
||||||
|
list_to_atom("Elixir." ++ elixir_module_name("_" ++ atom_to_list(ModAtom), [])).
|
||||||
|
|
||||||
|
elixir_module_name([], Res) ->
|
||||||
|
lists:reverse(Res);
|
||||||
|
elixir_module_name([$_, Char | Remaining], Res) ->
|
||||||
|
[Upper] = uppercase([Char]),
|
||||||
|
elixir_module_name(Remaining, [Upper | Res]);
|
||||||
|
elixir_module_name([Char | Remaining], Res) ->
|
||||||
|
elixir_module_name(Remaining, [Char | Res]).
|
||||||
|
|
||||||
|
-ifdef(HAVE_URI_STRING).
|
||||||
|
uppercase(String) ->
|
||||||
|
string:uppercase(String). % OTP 20 or higher
|
||||||
|
-else.
|
||||||
|
uppercase(String) ->
|
||||||
|
string:to_upper(String). % OTP older than 20
|
||||||
|
-endif.
|
||||||
|
|
||||||
get_available_module_el({ModAtom, Attrs}) ->
|
get_available_module_el({ModAtom, Attrs}) ->
|
||||||
Installed = installed(),
|
Installed = installed(),
|
||||||
Mod = misc:atom_to_binary(ModAtom),
|
Mod = misc:atom_to_binary(ModAtom),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue