25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-24 16:23:40 +01:00

ext_mod: Support in WebAdmin when a module spec lacks some information

This commit is contained in:
Badlop 2024-02-06 11:52:54 +01:00
parent a33be2d67a
commit 2979fb4a9b

View File

@ -823,7 +823,7 @@ write_commit_json(Url, RepDir) ->
end. end.
find_commit_json(Attrs) -> find_commit_json(Attrs) ->
{_, FromPath} = lists:keyfind(path, 1, Attrs), FromPath = get_module_path(Attrs),
case {find_commit_json_path(FromPath), case {find_commit_json_path(FromPath),
find_commit_json_path(filename:join(FromPath, ".."))} find_commit_json_path(filename:join(FromPath, ".."))}
of of
@ -946,7 +946,7 @@ get_page(Node, Query, Lang) ->
Title ++ Result ++ Contents. Title ++ Result ++ Contents.
get_module_home(Module, Attrs) -> get_module_home(Module, Attrs) ->
case element(2, lists:keyfind(home, 1, Attrs)) of case get_module_information(home, Attrs) of
"https://github.com/processone/ejabberd-contrib/tree/master/" = P1 -> "https://github.com/processone/ejabberd-contrib/tree/master/" = P1 ->
P1 ++ atom_to_list(Module); P1 ++ atom_to_list(Module);
Other -> Other ->
@ -954,17 +954,26 @@ get_module_home(Module, Attrs) ->
end. end.
get_module_summary(Attrs) -> get_module_summary(Attrs) ->
element(2, lists:keyfind(summary, 1, Attrs)). get_module_information(summary, Attrs).
get_module_author(Attrs) -> get_module_author(Attrs) ->
element(2, lists:keyfind(author, 1, Attrs)). get_module_information(author, Attrs).
get_module_path(Attrs) ->
get_module_information(path, Attrs).
get_module_information(Attribute, Attrs) ->
case lists:keyfind(Attribute, 1, Attrs) of
false -> "";
{_, Value} -> Value
end.
get_installed_module_el({ModAtom, Attrs}, Lang) -> get_installed_module_el({ModAtom, Attrs}, Lang) ->
Mod = misc:atom_to_binary(ModAtom), Mod = misc:atom_to_binary(ModAtom),
Home = list_to_binary(get_module_home(ModAtom, Attrs)), Home = list_to_binary(get_module_home(ModAtom, Attrs)),
Summary = list_to_binary(get_module_summary(Attrs)), Summary = list_to_binary(get_module_summary(Attrs)),
Author = list_to_binary(get_module_author(Attrs)), Author = list_to_binary(get_module_author(Attrs)),
{_, FromPath} = lists:keyfind(path, 1, Attrs), FromPath = get_module_path(Attrs),
FromFile = case find_commit_json_path(FromPath) of FromFile = case find_commit_json_path(FromPath) of
{ok, FF} -> FF; {ok, FF} -> FF;
{error, _} -> "dummypath" {error, _} -> "dummypath"