Implement automatic titles
This commit is contained in:
parent
400eb02efc
commit
c6fccd2d7b
4 changed files with 31 additions and 37 deletions
|
|
@ -6,11 +6,11 @@ It works by ingesting a TOML file containing your node specification and serving
|
|||
|
||||
## Roadmap
|
||||
|
||||
- [ ] Automatic anchors
|
||||
- [x] Array syntax for lightweight connections
|
||||
- [x] Automatic IDs
|
||||
- [ ] Automatic titles
|
||||
- [ ] Automatic anchors
|
||||
- [ ] Mismatch between TOML ID and provided ID
|
||||
- [x] Automatic titles
|
||||
- [x] Mismatch between TOML ID and provided ID
|
||||
|
||||
## Motivation
|
||||
|
||||
|
|
|
|||
|
|
@ -28,15 +28,6 @@ fn modulate_nodes(old_nodes: HashMap<String, Node>) -> HashMap<String, Node> {
|
|||
let connections = node.connections.clone().unwrap_or_default();
|
||||
let mut new_edges = connections.clone();
|
||||
|
||||
for link in node.links.iter() {
|
||||
new_edges.push(Edge {
|
||||
from: key.to_string(),
|
||||
to: link.to_string(),
|
||||
anchor: String::new(),
|
||||
detached: !old_nodes.contains_key(link),
|
||||
})
|
||||
}
|
||||
|
||||
for (i, edge) in connections.iter().enumerate() {
|
||||
|
||||
let mut new_edge = edge.clone();
|
||||
|
|
@ -54,8 +45,26 @@ fn modulate_nodes(old_nodes: HashMap<String, Node>) -> HashMap<String, Node> {
|
|||
new_edges[i] = new_edge;
|
||||
}
|
||||
|
||||
// Create connections for each link
|
||||
for link in node.links.iter() {
|
||||
new_edges.push(Edge {
|
||||
from: key.to_string(),
|
||||
to: link.to_string(),
|
||||
anchor: String::new(),
|
||||
detached: !old_nodes.contains_key(link),
|
||||
})
|
||||
}
|
||||
|
||||
// Populate empty titles with IDs
|
||||
let new_title = if node.title.is_empty() {
|
||||
key.clone()
|
||||
} else {
|
||||
node.title.clone()
|
||||
};
|
||||
|
||||
let new_node = Node {
|
||||
id: key.clone(),
|
||||
title: new_title,
|
||||
connections: Some(new_edges),
|
||||
..node.clone()
|
||||
};
|
||||
|
|
|
|||
25
src/types.rs
25
src/types.rs
|
|
@ -3,34 +3,29 @@ use std::collections::HashMap;
|
|||
|
||||
#[derive(Serialize, Deserialize, Clone, Default, Debug)]
|
||||
pub struct Graph {
|
||||
pub messages: Vec<String>,
|
||||
pub root_node: String,
|
||||
pub nodes: HashMap<String, Node>,
|
||||
#[serde(skip)]
|
||||
pub incoming: HashMap<String, Vec<Edge>>,
|
||||
pub root_node: String,
|
||||
#[serde(default)] pub messages: Vec<String>,
|
||||
#[serde(skip)] pub incoming: HashMap<String, Vec<Edge>>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Clone, Default, Debug)]
|
||||
pub struct Node {
|
||||
pub title: String,
|
||||
pub body: String,
|
||||
#[serde(default)] pub title: String,
|
||||
#[serde(default)] pub links: Vec<String>,
|
||||
#[serde(default)] pub id: String,
|
||||
|
||||
#[serde(skip_serializing_if = "Option::is_none")]
|
||||
pub connections: Option<Vec<Edge>>,
|
||||
#[serde(default)]
|
||||
pub links: Vec<String>,
|
||||
#[serde(default)]
|
||||
pub id: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Clone, Default, PartialEq, Deserialize, Debug)]
|
||||
pub struct Edge {
|
||||
pub to: String,
|
||||
#[serde(default)]
|
||||
pub anchor: String,
|
||||
#[serde(default)]
|
||||
pub from: String,
|
||||
#[serde(default)]
|
||||
pub detached: bool,
|
||||
#[serde(default)] pub anchor: String,
|
||||
#[serde(default)] pub from: String,
|
||||
#[serde(default)] pub detached: bool,
|
||||
}
|
||||
|
||||
impl Graph {
|
||||
|
|
|
|||
|
|
@ -1,8 +1,6 @@
|
|||
messages = []
|
||||
root_node = "Interface"
|
||||
|
||||
[nodes.Interface]
|
||||
title = "Interface"
|
||||
body = """
|
||||
An interface is a point of contact between the inside and the outside of something. Contrast with intraface.
|
||||
"""
|
||||
|
|
@ -10,7 +8,6 @@ An interface is a point of contact between the inside and the outside of somethi
|
|||
links = ["Intraface"]
|
||||
|
||||
[nodes.Intraface]
|
||||
title = "Intraface"
|
||||
body = """
|
||||
The intraface is the reflexive process of communicating, creating, thinking, that does not or cannot get shared with others. Contrast with interface.
|
||||
"""
|
||||
|
|
@ -18,13 +15,11 @@ The intraface is the reflexive process of communicating, creating, thinking, tha
|
|||
links = ["Thinking", "Interface"]
|
||||
|
||||
[nodes.Thinking]
|
||||
title = "Thinking"
|
||||
body = """
|
||||
Thinking is a process by which some beings create and manipulate mental constructs.
|
||||
"""
|
||||
|
||||
[nodes.Paradigm]
|
||||
title = "Paradigm"
|
||||
body = """
|
||||
A paradigm is a cohesive set of beliefs, methods and principles that serve both as justification for a given position and as guidance for how to pursue its praxis.
|
||||
"""
|
||||
|
|
@ -32,7 +27,6 @@ A paradigm is a cohesive set of beliefs, methods and principles that serve both
|
|||
links = [ "Principle", "Belief", "Method", "Position", "Praxis" ]
|
||||
|
||||
[nodes.Principle]
|
||||
title = "Principle"
|
||||
body = """
|
||||
A principle is a belief that implies commitment and necessity.
|
||||
|
||||
|
|
@ -50,7 +44,6 @@ anchor = "identifying"
|
|||
to = "Identity"
|
||||
|
||||
[nodes.Religion]
|
||||
title = "Religion"
|
||||
body = """
|
||||
A religion is a paradigm that involves unfalsifiable beliefs, particularly those in the domain of morality.
|
||||
|
||||
|
|
@ -79,7 +72,6 @@ links = [
|
|||
]
|
||||
|
||||
[nodes.Identity]
|
||||
title = "Identity"
|
||||
body = """
|
||||
Identity is how individuals construe their sameness and otherness from each other and from nothingness.
|
||||
"""
|
||||
|
|
@ -91,7 +83,6 @@ anchor = "nothingness"
|
|||
to = "Emptiness"
|
||||
|
||||
[nodes.Emptiness]
|
||||
title = "Emptiness"
|
||||
body = """
|
||||
Emptiness is the vacuous base in which entities exist.
|
||||
"""
|
||||
|
|
@ -99,7 +90,6 @@ Emptiness is the vacuous base in which entities exist.
|
|||
links = [ "Entity" ]
|
||||
|
||||
[nodes.Entity]
|
||||
title = "Entity"
|
||||
body = """
|
||||
An entity is anything except for actual emptiness. It does not have to be sentient, or physical. It can be an idea, a concept, a memory. The concept of emptiness is an entity, but emptiness itself is not.
|
||||
"""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue