Skip to content

Commit

Permalink
more support for non-bang node ids
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinelliott committed Jul 3, 2024
1 parent d1dddd8 commit d31e29e
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 4 deletions.
6 changes: 6 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,12 @@ def save_nodes_to_file():
global chat
global nodes

old_nodes = nodes
nodes = {}
for id, node in old_nodes.items():
if id[0] == '!':
id = id[1:]
nodes['id'] = id
save_chat_to_file(chat, "json", f"{config['paths']['data']}/chat.json")
save_to_json_file(nodes, f"{config['paths']['data']}/nodes.json")
save_to_json_file(telemetry, f"{config['paths']['data']}/telemetry.json")
Expand Down
4 changes: 3 additions & 1 deletion models/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
class Node():
@staticmethod
def default_node(id):
if id == '!ffffffff':
if id[0] == '!':
id = id[1:]
if id == 'ffffffff':
return {
'id': id,
'neighborinfo': None,
Expand Down
2 changes: 0 additions & 2 deletions templates/static/map.html.j2
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,6 @@
var neighborLayers = [];
{% for id, node in nodes.items() %}
{% if node.position is defined and node.position %}
{% set id = id|replace('!', '') %}
nodes['{{ id }}'] = {
id: '{{ id }}',
shortname: '{{ node.shortname }}',
Expand Down Expand Up @@ -209,7 +208,6 @@
if (feature) {
var properties = feature.getProperties();
var node = properties.node;
console.log(node);
var address = await reverseGeocode(node.position[0], node.position[1]);
var display_name = [address.address.town, address.address.city, address.address.county, address.address.state, address.address.country].filter(Boolean).join(', ');
Expand Down
3 changes: 2 additions & 1 deletion templates/static/nodes.html.j2
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@
</td>
<td style="color: #{{ '777' if node.shortname == 'UNK' else '000' }}">
{% if id %}
<a href='node_{{ id }}.html'>{{ node.shortname }}</a>
{% set id = id|replace('!', '') %}
<a href='node_{{ id }}.html'>{{ node.shortname }}</a>
{% else %}
{{ node.shortname }}
{% endif %}
Expand Down

0 comments on commit d31e29e

Please sign in to comment.