Mercurial > prosody-modules
annotate mod_discodot/mod_discodot.tl @ 5627:3a5cf8d80089
mod_http_oauth2: Tweak method of centering the UI
The percentage here was relative to the viewport width, which on some
very wide screens may put the UI slightly outside of the view, requiring
scrolling to see.
By using a unit relative to the height of the viewport, this is avoided
and should work better. But no guarantees, it's still possible to resize
the browser or adjust font sizes so that the UI goes out of view.
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 31 Jul 2023 07:28:09 +0200 |
parents | 253df0798996 |
children |
rev | line source |
---|---|
4577
253df0798996
mod_discodot: Print a graph of service discovery
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
1 local cm = require"core.configmanager"; |
253df0798996
mod_discodot: Print a graph of service discovery
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
2 |
253df0798996
mod_discodot: Print a graph of service discovery
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
3 local function format_host(host:string, conf:{string:any}) : string |
253df0798996
mod_discodot: Print a graph of service discovery
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
4 if host == "*" then |
253df0798996
mod_discodot: Print a graph of service discovery
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
5 return "Global"; |
253df0798996
mod_discodot: Print a graph of service discovery
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
6 end |
253df0798996
mod_discodot: Print a graph of service discovery
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
7 local component_module = conf["component_module"]; |
253df0798996
mod_discodot: Print a graph of service discovery
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
8 if component_module is string then |
253df0798996
mod_discodot: Print a graph of service discovery
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
9 if component_module == "component" then |
253df0798996
mod_discodot: Print a graph of service discovery
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
10 return string.format("Component %q", host); |
253df0798996
mod_discodot: Print a graph of service discovery
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
11 else |
253df0798996
mod_discodot: Print a graph of service discovery
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
12 return string.format("Component %q %q", host, component_module); |
253df0798996
mod_discodot: Print a graph of service discovery
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
13 end |
253df0798996
mod_discodot: Print a graph of service discovery
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
14 else |
253df0798996
mod_discodot: Print a graph of service discovery
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
15 return string.format("VirtualHost %q", host); |
253df0798996
mod_discodot: Print a graph of service discovery
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
16 end |
253df0798996
mod_discodot: Print a graph of service discovery
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
17 end |
253df0798996
mod_discodot: Print a graph of service discovery
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
18 |
253df0798996
mod_discodot: Print a graph of service discovery
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
19 function module.command(arg : { string }) : integer |
253df0798996
mod_discodot: Print a graph of service discovery
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
20 |
253df0798996
mod_discodot: Print a graph of service discovery
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
21 local config : { string : { string : any } } = cm.getconfig(); |
253df0798996
mod_discodot: Print a graph of service discovery
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
22 |
253df0798996
mod_discodot: Print a graph of service discovery
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
23 print"digraph \"prosody\" {" |
253df0798996
mod_discodot: Print a graph of service discovery
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
24 for host, conf in pairs(config) do |
253df0798996
mod_discodot: Print a graph of service discovery
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
25 print(string.format("%q [label=%q]", host, format_host(host, conf))); |
253df0798996
mod_discodot: Print a graph of service discovery
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
26 local parent = host:match("%.(.*)"); |
253df0798996
mod_discodot: Print a graph of service discovery
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
27 if parent and rawget(config, parent) then |
253df0798996
mod_discodot: Print a graph of service discovery
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
28 print(string.format("%q -> %q", parent, host)); |
253df0798996
mod_discodot: Print a graph of service discovery
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
29 end |
253df0798996
mod_discodot: Print a graph of service discovery
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
30 local disco_items = conf["disco_items"] |
253df0798996
mod_discodot: Print a graph of service discovery
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
31 if disco_items is { { string, string } } then |
253df0798996
mod_discodot: Print a graph of service discovery
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
32 for _, pair in ipairs(disco_items) do |
253df0798996
mod_discodot: Print a graph of service discovery
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
33 print(string.format("%q -> %q", host, pair[1])); |
253df0798996
mod_discodot: Print a graph of service discovery
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
34 end |
253df0798996
mod_discodot: Print a graph of service discovery
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
35 end |
253df0798996
mod_discodot: Print a graph of service discovery
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
36 |
253df0798996
mod_discodot: Print a graph of service discovery
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
37 end |
253df0798996
mod_discodot: Print a graph of service discovery
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
38 |
253df0798996
mod_discodot: Print a graph of service discovery
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
39 print"}" |
253df0798996
mod_discodot: Print a graph of service discovery
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
40 |
253df0798996
mod_discodot: Print a graph of service discovery
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
41 return 0 |
253df0798996
mod_discodot: Print a graph of service discovery
Kim Alvefur <zash@zash.se>
parents:
diff
changeset
|
42 end |