Merge structure changes from WIP

This commit is contained in:
Rampoina 2022-04-17 22:31:57 +02:00
commit 63d5c1e918
4 changed files with 2332 additions and 1404 deletions

3693
list.html

File diff suppressed because it is too large Load Diff

View File

@ -1,4 +1,7 @@
/* Theming taken from https://github.com/vector-im/riot-web/blob/cf5cf02529f95a094d88051c12fdb87a03d87335/src/skins/vector/css/themes/_base.scss */
table {
margin-left: 2em;
}
tbody {
margin-left: 2em;
}

View File

@ -9,25 +9,31 @@ def mxc2url(mxc):
mediaId = mxc.split('/')[3]
return "https://matrix.org/_matrix/media/v3/download/" + serverName + "/" + mediaId
def render(spaces, template):
def render(spaces, loops, template):
appTemplate = Template(filename=template)
print(appTemplate.render(s=spaces))
print(appTemplate.render(s=spaces,loops=loops))
def make_hierarchy(room, loops, depth=0):
def make_hierarchy(space, room, loops):
try:
print(' ' * depth + '- ' + room['name'])
if room['children_state'] and room['room_id'] not in loops:
for child in room['children_state']:
make_hierarchy(ROOMS[child['state_key']], loops, depth+1)
if 'children' in space:
space['children'].append(room)
else:
space['children'] = [room]
if 'children_state' in room:
for child in room['children_state']:
if ROOMS[child['state_key']]['room_id'] not in loops:
make_hierarchy(room,ROOMS[child['state_key']], loops)
except:
# missing or no name
print(' ' * depth + ' Skip ' + room['room_id'])
pass
if __name__ == '__main__':
with open('libregamingspaces.json') as f:
data = json.load(f)
# render(data, './spaces.html')
ROOMS = {room['room_id'] : room for room in data}
make_hierarchy(ROOMS['!IdUUdKALNzBLKEjvbP:matrix.org'], ['!JTpfWshTKZpZiUASvP:hacklab.fi'])
spaces={'name':"TOP"}
loops=['!JTpfWshTKZpZiUASvP:hacklab.fi']
make_hierarchy(spaces,ROOMS['!IdUUdKALNzBLKEjvbP:matrix.org'], loops)
#print(spaces)
render(spaces, loops, './spaces.html')

View File

@ -10,18 +10,19 @@
<link rel="stylesheet" href="main.css">
</head>
<body>
<%def name="render(space)">
<%def name="render(room)">
<table>
<tbody>
% for room in space:
<tr>
% if 'avatar_url' in room:
<td><img class="avatar roomAvatar" src=${mxc2url(room['avatar_url'])}></td>
% endif
% if 'room_type' in room and room['room_type'] == "m.space":
<td><div> Subspace: ${room['name']} </div></td>
% if 'children' in room:
<td><div>${room['name']} </div></td>
</tr>
<tr><td>${render(room['children_state'])}</td></tr>
% for subroom in room['children']:
<tr><td>${render(subroom)}</td></tr>
% endfor
% else:
% if 'room_id' in room:
@ -35,7 +36,6 @@
% endif
</tr>
% endif
% endfor
</tbody>
</table>
</%def>