Pass full node struct to node handler
This commit is contained in:
parent
df61b2c779
commit
77d08036c6
2 changed files with 19 additions and 18 deletions
|
|
@ -9,15 +9,11 @@ pub async fn node(Path(id): Path<String>) -> Response<Body> {
|
|||
let node: &Node = graph.nodes.get(&id).unwrap_or(&empty_node);
|
||||
|
||||
let mut context = tera::Context::new();
|
||||
context.insert("id", &id);
|
||||
context.insert("title", &node.title);
|
||||
context.insert("connections", &node.connections.clone());
|
||||
context.insert("node", &node);
|
||||
context.insert("text", &content::parse(&node.text));
|
||||
context.insert("incoming", &graph.incoming.get(&id));
|
||||
context.insert("config", &graph.meta.config.parse_text());
|
||||
|
||||
let out_text = content::parse(&node.text);
|
||||
context.insert("text", &out_text);
|
||||
|
||||
let not_found = *node == empty_node;
|
||||
let template_name = "node.html".to_string();
|
||||
|
||||
|
|
|
|||
|
|
@ -1,30 +1,35 @@
|
|||
{% extends "base.html" %}
|
||||
|
||||
{% block title %}{{ title }}{% endblock title %}
|
||||
{% block title %}{{ node.title }}{% endblock title %}
|
||||
|
||||
{%- block body %}
|
||||
<section>
|
||||
<h1>{{ title }}</h1>
|
||||
<code style="display: inline;">ID: {{ id }}</code>
|
||||
<div class="header-row">
|
||||
<h1 class="node-title">{{ node.title }}</h1>
|
||||
<div class="labels">
|
||||
<span class="label id-label">ID: {{ node.id }}</span>
|
||||
{% if node.hidden %}<span class="label hidden-label">Hidden</span>{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
{{ text | safe }}
|
||||
</section>
|
||||
{% if connections or incoming %}
|
||||
{% if node.connections or incoming %}
|
||||
<aside>
|
||||
<hr>
|
||||
<h2>Connections</h2>
|
||||
{% if connections %}
|
||||
{% if node.connections %}
|
||||
<ul>
|
||||
{% for connection in connections | filter(attribute="detached", value=false) %}
|
||||
{% for connection in node.connections | filter(attribute="detached", value=false) %}
|
||||
<li>
|
||||
<strong>{{id}}</strong>
|
||||
🡪
|
||||
<strong>{{node.id}}</strong>
|
||||
»
|
||||
<a href="/node/{{connection.to}}">{{connection.to}}</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
{% for connection in connections | filter(attribute="detached", value=true) %}
|
||||
{% for connection in node.connections | filter(attribute="detached", value=true) %}
|
||||
<li>
|
||||
<strong>{{id}}</strong>
|
||||
🡪
|
||||
<strong>{{node.id}}</strong>
|
||||
»
|
||||
<span style="filter: opacity(70%);">{{connection.to}}</span>
|
||||
</li>
|
||||
{% endfor %}
|
||||
|
|
@ -38,7 +43,7 @@
|
|||
{% for connection in incoming %}
|
||||
<li>
|
||||
<strong>{{connection.to}}</strong>
|
||||
🡨
|
||||
«
|
||||
<a href="/node/{{connection.from}}">{{connection.from}}</a>
|
||||
</li>
|
||||
{% endfor %}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue