".to_owned()
+ }
+ } else {
+ panic!(
+ "Attempt to render a paragraph tag while open state is unknown"
+ )
+ }
+ }
+}
+
+impl Display for Paragraph {
+ fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+ if let Some(open) = self.open {
+ if open {
+ write!(f, "Open Paragraph")
+ } else {
+ write!(f, "Closed Paragraph")
+ }
+ } else {
+ write!(f, "Unitialized Paragraph (Unknown open state)")
+ }
+ }
+}
diff --git a/src/syntax/content/parser/token/preformat.rs b/src/syntax/content/parser/token/preformat.rs
new file mode 100644
index 0000000..195636d
--- /dev/null
+++ b/src/syntax/content/parser/token/preformat.rs
@@ -0,0 +1,38 @@
+use crate::{
+ syntax::content::{Parseable, Lexeme},
+};
+
+#[derive(Debug)]
+pub struct PreFormat {
+ open: Option,
+}
+
+impl PreFormat {
+ pub fn new(open: bool) -> PreFormat {
+ PreFormat { open: Some(open) }
+ }
+}
+
+impl Parseable for PreFormat {
+ fn probe(lexeme: &Lexeme) -> bool {
+ lexeme.match_first_char('`') && lexeme.next == "\n"
+ }
+
+ fn lex(_lexeme: &Lexeme) -> PreFormat {
+ PreFormat { open: None }
+ }
+
+ fn render(&self) -> String {
+ if let Some(o) = self.open {
+ if o {
+ "
".to_owned()
+ } else {
+ "
".to_owned()
+ }
+ } else {
+ panic!(
+ "Attempt to render a preformat tag while open state is unknown"
+ )
+ }
+ }
+}
diff --git a/src/syntax/content/parser/token/span.rs b/src/syntax/content/parser/token/span.rs
new file mode 100644
index 0000000..b312a28
--- /dev/null
+++ b/src/syntax/content/parser/token/span.rs
@@ -0,0 +1,50 @@
+use std::fmt::Display;
+use crate::syntax::content::{Parseable, parser::lexeme::Lexeme};
+
+#[derive(Debug)]
+pub struct Span {
+ open: Option,
+}
+
+impl Span {
+ pub fn new(open: bool) -> Span {
+ Span { open: Some(open) }
+ }
+}
+
+impl Parseable for Span {
+ fn probe(_lexeme: &Lexeme) -> bool {
+ // there is no lexeme for span
+ false
+ }
+
+ fn lex(_lexeme: &Lexeme) -> Span {
+ Span { open: None }
+ }
+
+ fn render(&self) -> String {
+ if let Some(open) = self.open {
+ if open {
+ "".to_owned()
+ } else {
+ "".to_owned()
+ }
+ } else {
+ panic!("Attempt to render a span tag while open state is unknown")
+ }
+ }
+}
+
+impl Display for Span {
+ fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
+ if let Some(open) = self.open {
+ if open {
+ write!(f, "Open Span")
+ } else {
+ write!(f, "Closed Span")
+ }
+ } else {
+ write!(f, "Span (Unknown open state)")
+ }
+ }
+}
diff --git a/src/syntax/serial.rs b/src/syntax/serial.rs
new file mode 100644
index 0000000..7ed2a87
--- /dev/null
+++ b/src/syntax/serial.rs
@@ -0,0 +1,224 @@
+use std::collections::HashMap;
+
+use crate::{
+ syntax::command::Arguments,
+ types::{Edge, Graph, Node},
+};
+
+pub fn populate_graph() -> Graph {
+ let args = Arguments::new().parse();
+ let toml_source = match std::fs::read_to_string(args.graph_path) {
+ Ok(s) => s,
+ Err(e) => format!("Error: {e}"),
+ };
+ let graph = deserialize_graph(&Format::TOML, &toml_source);
+
+ let nodes = modulate_nodes(&graph.nodes);
+
+ Graph {
+ nodes: nodes.clone(),
+ incoming: make_incoming(&nodes),
+ lowercase_keymap: map_lowercase_keys(&nodes),
+ ..graph
+ }
+}
+
+fn map_lowercase_keys(
+ source_map: &HashMap,
+) -> HashMap {
+ let mut out_map: HashMap = HashMap::new();
+ let keys = source_map.keys();
+ for key in keys {
+ out_map.insert(key.clone().to_lowercase(), key.clone());
+ }
+ out_map
+}
+
+fn modulate_nodes(old_nodes: &HashMap) -> HashMap {
+ let mut nodes: HashMap = HashMap::new();
+
+ for (key, node) in old_nodes {
+ let connections = node.connections.clone().unwrap_or_default();
+ let mut new_edges = connections.clone();
+
+ for (i, edge) in connections.iter().enumerate() {
+ let mut new_edge = edge.clone();
+
+ // Populate empty "from" IDs in edges with node's ID
+ if edge.from.is_empty() {
+ new_edge.from.clone_from(key);
+ }
+
+ // Flag detached edges
+ if !old_nodes.contains_key(&edge.to) {
+ new_edge.detached = true;
+ }
+
+ if let Some(e) = new_edges.get_mut(i) {
+ *e = new_edge;
+ }
+ }
+
+ // Create connections for each link
+ for link in &node.links {
+ new_edges.push(Edge {
+ from: key.clone(),
+ to: link.clone(),
+ 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()
+ };
+
+ nodes.insert(key.clone(), new_node);
+ }
+
+ nodes
+}
+
+// Construct a HashMap with incoming connections (reversed edges)
+fn make_incoming(nodes: &HashMap) -> HashMap> {
+ let mut incoming: HashMap> = HashMap::new();
+
+ for node in nodes.clone().into_values() {
+ let empty_vec: Vec = vec![];
+ for edge in &node.connections.clone().unwrap_or_default() {
+ let mut edges =
+ incoming.get(&edge.to.clone()).unwrap_or(&empty_vec).clone();
+ edges.extend_from_slice(std::slice::from_ref(edge));
+ incoming.insert(edge.to.clone(), edges.clone());
+ }
+ }
+
+ incoming
+}
+
+pub enum Format {
+ TOML,
+ JSON,
+}
+
+pub fn serialize_graph(out_format: &Format, graph: &Graph) -> String {
+ match *out_format {
+ Format::TOML => match toml::to_string(graph) {
+ Ok(s) => s,
+ Err(e) => e.to_string(),
+ },
+ Format::JSON => match serde_json::to_string(graph) {
+ Ok(s) => s,
+ Err(e) => e.to_string(),
+ },
+ }
+}
+
+pub fn deserialize_graph(in_format: &Format, serial: &str) -> Graph {
+ match *in_format {
+ Format::TOML => match toml::from_str(serial) {
+ Ok(g) => g,
+ Err(error) => Graph::new(Some(&error.to_string())),
+ },
+ Format::JSON => match serde_json::from_str(serial) {
+ Ok(g) => g,
+ Err(error) => Graph::new(Some(&error.to_string())),
+ },
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use super::*;
+
+ #[test]
+ fn good_json() {
+ let json = r#"
+ {
+ "nodes": {
+ "JSON": {
+ "text": "",
+ "title": "JSON",
+ "links": [],
+ "id": "JSON",
+ "hidden": false,
+ "connections": []
+ }
+ },
+ "root_node": "JSON"
+ }
+ "#;
+
+ let graph = deserialize_graph(&Format::JSON, json);
+ assert!(graph.meta.messages.is_empty());
+ }
+
+ #[test]
+ fn bad_json() {
+ let graph = deserialize_graph(&Format::JSON, ":::");
+ let message = graph.meta.messages.first().unwrap();
+ assert!(message.contains("expected value at line 1 column 1"));
+ }
+
+ #[test]
+ fn detached_node() {
+ let node = Node {
+ id: String::from("SomeNode"),
+ text: String::new(),
+ title: String::new(),
+ links: vec![String::new()],
+ hidden: false,
+ connections: Some(vec![Edge {
+ anchor: String::from("SomeAnchor"),
+ from: String::new(),
+ to: String::new(),
+ detached: false,
+ }]),
+ };
+
+ let mut map: HashMap = HashMap::new();
+ map.insert(String::from("SomeNode"), node);
+
+ let modulated_map = modulate_nodes(&map);
+ let modulated_node = modulated_map.get("SomeNode").unwrap().clone();
+ let modulated_connections = modulated_node.connections.unwrap();
+ let modulated_connection = modulated_connections.first().unwrap();
+ assert!(modulated_connection.anchor == "SomeAnchor");
+ assert!(modulated_connection.detached);
+ }
+}
+
+#[cfg(test)]
+mod serial_tests {
+ use super::*;
+
+ #[test]
+ fn bad_graph_path() {
+ println!("T");
+ let original_working_directory = std::env::current_dir().unwrap();
+
+ assert!(
+ std::env::set_current_dir(std::path::Path::new(
+ "tests/mocks/no_graph"
+ ))
+ .is_ok()
+ );
+
+ let graph = populate_graph();
+ let message = graph.meta.messages.first().unwrap();
+ assert!(message.contains("TOML parse error"));
+ assert!(message.contains("No such file or directory"));
+
+ assert!(std::env::set_current_dir(original_working_directory).is_ok());
+ }
+}
diff --git a/src/types.rs b/src/types.rs
index 4bbcfee..00d78e6 100644
--- a/src/types.rs
+++ b/src/types.rs
@@ -2,14 +2,18 @@ use std::collections::HashMap;
use serde::{Serialize, Deserialize};
+use crate::syntax::content;
+
#[derive(Serialize, Deserialize, Clone, Default, PartialEq, Eq, Debug)]
pub struct Graph {
pub nodes: HashMap,
pub root_node: String,
- #[serde(default)]
- pub messages: Vec,
- #[serde(skip)]
+ #[serde(skip_deserializing)]
pub incoming: HashMap>,
+ #[serde(skip_deserializing)]
+ pub lowercase_keymap: HashMap,
+ #[serde(default)]
+ pub meta: Meta,
}
#[derive(Serialize, Deserialize, Clone, Default, PartialEq, Eq, Debug)]
@@ -21,6 +25,8 @@ pub struct Node {
pub links: Vec,
#[serde(default)]
pub id: String,
+ #[serde(default)]
+ pub hidden: bool,
#[serde(skip_serializing_if = "Option::is_none")]
pub connections: Option>,
@@ -37,19 +43,118 @@ pub struct Edge {
pub detached: bool,
}
+#[derive(Serialize, Deserialize, Clone, Default, PartialEq, Eq, Debug)]
+pub struct Meta {
+ pub config: Config,
+ #[serde(default = "mkversion")]
+ pub version: (u8, u8, u8),
+ #[serde(default)]
+ pub messages: Vec,
+}
+
+// See: https://github.com/serde-rs/serde/issues/368
+fn mkversion() -> (u8, u8, u8) {
+ (0, 0, 0)
+}
+
+#[expect(clippy::struct_excessive_bools)]
+#[derive(Serialize, Deserialize, Clone, Default, PartialEq, Eq, Debug)]
+pub struct Config {
+ #[serde(default)]
+ pub site_title: String,
+ #[serde(default)]
+ pub site_description: String,
+ #[serde(default = "mktrue")]
+ pub footer: bool,
+ #[serde(default = "mktrue")]
+ pub footer_credits: bool,
+ #[serde(default = "mktrue")]
+ pub footer_date: bool,
+ #[serde(default)]
+ pub footer_text: String,
+ #[serde(default = "mktrue")]
+ pub about: bool,
+ #[serde(default)]
+ pub about_text: String,
+ #[serde(default = "mktrue")]
+ pub tree: bool,
+ #[serde(default = "mktrue")]
+ pub raw: bool,
+ #[serde(default = "mktrue")]
+ pub raw_toml: bool,
+ #[serde(default = "mktrue")]
+ pub raw_json: bool,
+ #[serde(default = "mktrue")]
+ pub index_search: bool,
+ #[serde(default = "mktrue")]
+ pub index_node_list: bool,
+ #[serde(default = "mk8")]
+ pub index_node_count: u16,
+ #[serde(default = "mktrue")]
+ pub index_root_node: bool,
+ #[serde(default = "mkfalse")]
+ pub tree_node_text: bool,
+ #[serde(default = "mkfalse")]
+ pub ascii_dom_ids: bool,
+ #[serde(default)]
+ pub content_language: String,
+}
+
+// See: https://github.com/serde-rs/serde/issues/368
+fn mktrue() -> bool {
+ true
+}
+fn mkfalse() -> bool {
+ false
+}
+fn mk8() -> u16 {
+ 8
+}
+
impl Graph {
- pub fn new(message: Option) -> Graph {
- Self {
+ pub fn new(message: Option<&str>) -> Graph {
+ Graph {
nodes: HashMap::new(),
root_node: "VoidNode".to_string(),
incoming: HashMap::new(),
- messages: vec![
- message
- .unwrap_or("This graph is empty or in error".to_string()),
- ],
+ lowercase_keymap: HashMap::new(),
+ meta: Meta {
+ config: Config {
+ site_title: String::new(),
+ site_description: String::new(),
+ footer: true,
+ footer_credits: true,
+ footer_date: true,
+ footer_text: String::new(),
+ about: true,
+ about_text: String::new(),
+ tree: true,
+ raw: true,
+ raw_toml: true,
+ raw_json: true,
+ index_search: true,
+ index_node_list: true,
+ index_node_count: 8,
+ index_root_node: true,
+ tree_node_text: false,
+ ascii_dom_ids: false,
+ content_language: String::new(),
+ },
+ version: (0, 1, 0),
+ messages: message.map_or(vec![], |m| vec![m.to_string()]),
+ },
}
}
+ pub fn find_node(&self, query: &str) -> Option {
+ self.nodes.get(query).cloned().or_else(|| {
+ self.lowercase_keymap
+ .get(query)
+ .and_then(|lower_key| self.nodes.get(lower_key))
+ .cloned()
+ })
+ }
+
pub fn get_root(&self) -> Option {
self.nodes.get(&self.root_node).cloned()
}
@@ -57,7 +162,7 @@ impl Graph {
impl Node {
pub fn new(message: Option) -> Node {
- Self {
+ Node {
id: "VoidNode".to_string(),
title: "Pure Void".to_string(),
text: match message {
@@ -66,6 +171,111 @@ impl Node {
},
connections: None,
links: vec![],
+ hidden: false,
}
}
}
+
+impl Config {
+ #[must_use]
+ pub fn parse_text(self) -> Config {
+ let footer_text = if self.footer_text.is_empty() {
+ self.footer_text
+ } else {
+ content::parse(&self.footer_text)
+ };
+
+ let about_text = if self.about_text.is_empty() {
+ self.about_text
+ } else {
+ content::parse(&self.about_text)
+ };
+
+ Config {
+ footer_text,
+ about_text,
+ ..self
+ }
+ }
+}
+
+#[cfg(test)]
+mod tests {
+ use crate::syntax::serial::populate_graph;
+
+ use super::*;
+
+ #[test]
+ fn empty_graph() {
+ let graph = Graph::new(Some("ISryQFd9peG6eYz9CFRQFWeD1GnPo0oj"));
+ assert!(graph.nodes.is_empty());
+ assert!(graph.incoming.is_empty());
+ assert_eq!(
+ graph.meta.messages.first().unwrap(),
+ "ISryQFd9peG6eYz9CFRQFWeD1GnPo0oj"
+ );
+ }
+
+ #[test]
+ fn empty_node_message() {
+ let node = Node::new(None);
+ assert_eq!(node.text, "Node is empty, missing or wasn't found.");
+ }
+
+ #[test]
+ fn empty_footer_text() {
+ let default_graph = populate_graph();
+
+ let config = Config {
+ footer_text: String::new(),
+ ..default_graph.meta.config
+ };
+
+ let parsed_config = config.parse_text();
+
+ println!("{:?}", parsed_config.footer_text);
+ assert!(parsed_config.footer_text.is_empty());
+ }
+
+ #[test]
+ fn config_footer_text() {
+ let payload = "0kqBrdS8NPrU4xVxh2xW0hUzAw926JCQ";
+ let default_graph = populate_graph();
+
+ let config = Config {
+ footer_text: format!("`{payload}`"),
+ ..default_graph.meta.config
+ };
+
+ let parsed_config = config.parse_text();
+
+ assert!(
+ parsed_config
+ .footer_text
+ .matches(format!("{payload}").as_str())
+ .count()
+ == 1
+ );
+ }
+
+ #[test]
+ fn config_about_text() {
+ let payload = "ZqPFl84JlzSS0QUo61RwTUPONIE78Lmw";
+ let default_graph = populate_graph();
+
+ let config = Config {
+ about_text: format!("`{payload}`"),
+ ..default_graph.meta.config
+ };
+
+ let parsed_config = config.parse_text();
+
+ assert!(
+ parsed_config
+ .about_text
+ .matches(format!("{payload}").as_str())
+ .count()
+ == 1
+ );
+ }
+}
diff --git a/static/graph.toml b/static/graph.toml
index ac70b0b..f66957c 100644
--- a/static/graph.toml
+++ b/static/graph.toml
@@ -1,97 +1,401 @@
-root_node = "Interface"
+root_node = "Documentation"
-[nodes.Interface]
+[nodes.Documentation]
text = """
-An interface is a point of contact between the inside and the outside of something. Contrast with intraface.
+## Installation
+
+For now, if you want to try en, you must build it yourself.
+
+In an environment with a |Rust toolchain|https://rustup.rs/ and Git installed, run:
+
+`
+git clone https://codeberg.org/jutty/en
+cd en
+cargo build --release
+`
+
+The en binary will be in `target/release/en`.
+
+You can start it and point it to an address, port and graph:
+
+`
+en --host localhost --port 3003 --graph ./graph.toml
+`
+
+See |CLI| for defaults and details on the CLI options.
+
+
+## Graph Syntax
+
+The graph is a TOML file. You can create nodes by adding text such as:
+
+`
+[nodes.Computer]
+text = "A computer is a machine capable of executing arbitrary instructions."
+`
+
+If you need longer text, it's more convenient to use triple quotes:
+
+`
+[nodes.Computer]
+text = \"""
+A computer is a machine capable of executing arbitrary instructions.
+\"""
+`
+
+Some special syntax is allowed inside the node text. See |Syntax| for supported features.
+
+## Connections
+
+Nodes can have connections between each other.
+
+To add a simple connection without any associated properties, you can simply add links:
+
+`
+[nodes.Quark]
+text = "A subatomic particle that forms hadrons."
+
+links = [ "Particle", "Hadron" ]
+`
+
+This will create two outgoing connections from Quark: to Particle and to Hadron. It will also list Quark as an incoming connection in these nodes' pages.
+
+If you want to add properties to the connection, you can use the connection syntax:
+
+`
+[[nodes.Quark.connections]]
+to = "Particle physics"
+anchor = "particle"
+`
+
+This will create a connection from Quark to "Particle physics", and the first occurrence of the word "particle" in the text of Quark gets anchored to this connection.
"""
-links = ["Intraface"]
-
-[nodes.Intraface]
+[nodes.CLI]
+title = "CLI Options"
text = """
-The intraface is the reflexive process of communicating, creating, thinking, that does not or cannot get shared with others. Contrast with interface.
+You can set the hostname, port and graph file path using CLI options:
+
+For the hostname, use `-h` or `--hostname`:
+
+`
+en -h localhost
+en --hostname 10.120.0.5
+`
+
+If unspecified, the default is `0.0.0.0`.
+
+For the port, use `-p` or `--port`:
+
+`
+en -p 3003
+en --port 3000
+`
+
+If unspecified, the default is to use a random available port assigned by the operating system.
+
+For the graph path, use `-g` or `--graph`:
+
+`
+en -g graph.toml
+en --g ./static/my-graph.toml
+`
+
+If unspecified, the default is `./static/graph.toml`.
+
+You can combine these options as you wish:
+
+`
+en -h localhost -p 3000
+en -p 3003 --host localhost --graph ./graph.toml
+en --g ./graph.toml -p 1312
+`
+
+If an option is specified more than once, the last use will override any previous ones.
+
"""
-links = ["Thinking", "Interface"]
+[nodes.Syntax]
+text= """
+
+## Anchors
+
+Anchors follow the following syntax:
+
+`
+anchor|destination
+`
+
+For example:
+
+`
+docs|/node/Documentation
+`
+
+If the left side contains spaces, you need a leading `|` character:
+
+`
+|en docs|https://en.jutty.dev/node/Documentation
+`
+
+If you have a trailing character that you don't want to be considered as part of the destination, you can separate it with a third `|`:
+
+`
+This gem|PreciousStone|, though green, was not an emerald.
+`
+
+To make a plain address clickable, wrap it in two `|` characters:
+
+`
+|https://en.jutty.dev|
+`
+
+### Node anchors
+
+We saw above an example like `docs|/node/Documentation`, but there is a shorter syntax for node anchors.
+
+If the address doesn't contain any `/` or `:` characters, it will be interpreted as a node ID:
+
+`
+particles|ParticlePhysics
+`
+
+This allows you to specify what to display as the anchor text, but just the ID wrapped inside two `|` characters also works:
+
+`
+|Documentation|
+`
+
+Because en can resolve IDs case insensitively (with priority to case-sensitive matches), you can also write the above anchor as `|documentation|`.
+
+In summary, all of the anchors below are valid and lead to the same page:
+
+`
+|en Syntax|https://en.jutty.dev/node/Syntax|
+|en Syntax|https://en.jutty.dev/node/Syntax
+Syntax|https://en.jutty.dev/node/Syntax
+
+Syntax|/node/syntax
+
+|syntax|Syntax
+Syntax|syntax
+Syntax|syntax|
+
+|Syntax|
+|syntax|
+`
+
+While flexible, this can sometimes be ambiguous. See |AnchorSyntax| for some caveats regarding anchors.
-[nodes.Thinking]
-text = """
-Thinking is a process by which some beings create and manipulate mental constructs.
"""
-[nodes.Paradigm]
+[nodes.AnchorSyntax]
+title = "Anchor Syntax"
text = """
-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.
+Anchor syntax can be very concise, but some situations lead to ambiguity.
+
+In short, following these two rules should keep you out of trouble:
+
+- Avoid special characters in your node IDs
+- When needed, use full three-pipe `|text|destination|` syntax to fix ambiguity
+
+## Punctuation in destinations
+
+Consider this example:
+
+`
+|gem|PreciousStone
+|PreciousStone|,
+`
+
+Both seem to point to the node with ID `PreciousStone`, as they _seem_ to. But if we didn't treat punctuation differently, we'd have:
+
+`
+|a|b
+|a|b
+`
+
+For this reason, punctuation is treated differently. It won't be considered as a possible destination, so you can write the previous example and have it behave as expected.
+
+This also means you can't have punctuation symbols as node IDs or as their first character.
+
+These are the punctuation symbols that are treated specially:
+
+`
+, . : ; ? ! ( ) ' "
+
+`
+
+You can also force this using a third pipe:
+
+`
+|PreciousStone||,
+`
+
+This unambiguously tells en that your destination is a node ID.
+
+## URL detection
+
+en must differentiate node anchors from outgoing URLs:
+
+`
+|sample|Example|
+|sample|https://example.com|
+
+|Example|
+|https://example.com|
+`
+
+It does this by looking at the destination and checking if it contains a `:` or `/`, so also avoid these in your node IDs.
+
"""
-links = [ "Principle", "Belief", "Method", "Position", "Praxis" ]
-
-[nodes.Principle]
+[nodes.en]
text = """
-A principle is a belief that implies commitment and necessity.
+en is a tool to write non-linear, connected pieces of text and have their references mapped out as a graph of connected information.
-Principles change, but to change one's principles too constantly defeats its purpose.
+It works by ingesting a TOML file containing your node specification and serving it as a website that allows nodes to be browsed, searched and listed in relation to each other or as a shallow tree of nodes.
-A principle is usually informed by experience or formed by cultural context, namely religion.
+## Motivation
+
+en was created out of the desire to write complex, long-form descriptions of a personal worldview without being constrained or getting stuck trying to mimic the linearity of a typical philosophy book.
+
+It's described as a "writing instrument" because it's not so much about the presentation or even the web format. While that's the medium for this particular implementation, you can notice en serves its raw data in both TOML and JSON. It's first and foremost about mapping out and structuring written thoughts.
+
+Because en is defined in simple configuration files, you can add new pages easily from a few lines and start connecting them. Instead of having to create a dedicated file or resource for each new entry you find deserving of observation, with its own beginning and end, its own "I'm empty, fill me to completion" demeanor, you can stay in the flow of your sprawling thoughts. This is meant to fit the specific wiring of minds whose thoughts spread and fork quickly and often, whether to great depth or across wide expanses.
-As other beliefs, simply identifying with a principle does not mean one follows it, which can introduce a sense of dissonance and/or guilt.
"""
-links = [ "Dissonance", "Guilt", "Belief", "Religion", ]
+links = [ "Graph" ]
-[[nodes.Principle.connections]]
-anchor = "identifying"
-to = "Identity"
+[[nodes.en.connections]]
+to = "TOML"
+anchor = "TOML"
-[nodes.Religion]
+[nodes.Graph]
text = """
-A religion is a paradigm that involves unfalsifiable beliefs, particularly those in the domain of morality.
+A graph is a data structure composed of connected (and disconnected) nodes.
-A reductive critique of religion dismisses it based on its dogmatic adherence to certain beliefs usually rooted in tradition.
+A familiar example is that of a social network. Each account can be thought of as a node and the "follow" and "follower" relationships can be thought of as edges (connections). A node may have many or few connections, and the nodes it is connected to are meaningful to understand how it fits into the whole.
-As a counterpoint, consider that the fact religion carries false beliefs does not imply all of the beliefs that religion carries are false, which is an assertion that holds for any other entity. The beliefs that compose the episteme of a religion may include both falsifiable and unfalsifiable beliefs. In this sense, it does not differ from any other paradigm.
-
-Religion does not subsist solely because of its hard truths, but because it caters to various other basic human necessities: community, identity, knowledge regarding how to conduct one's life. This gives religion enormous presence in society and allows it to act as a strong political force against societal changes that contradict its positions.
-
-One poignant fact about religion is that its dogmas tend to create exclusion, segregating those who can or want to adhere to them from those who can't or don't want to. This not only means religion will create divisions, it also means that the people excluded from it will be left with less means to fulfill the previously mentioned basic human necessities that religion addresses.
+en uses this concept to create a writing tool, allowing you to map out complex thoughts as a web of connected texts.
"""
-links = [
- "Paradigm",
- "Principle",
- "Truth",
- "Tradition",
- "Morality",
- "Episteme",
- "Necessity",
- "Knowledge",
- "Community",
- "Identity",
- "Dogma",
- "Reductionism",
-]
-
-[nodes.Identity]
+[nodes.TOML]
text = """
-Identity is how individuals construe their sameness and otherness from each other and from nothingness.
+TOML is a configuration format that can be easily read and understood by humans and machines alike.
+
+To learn more about TOML, you can visit its website at |https://toml.io|.
+
+To see the TOML declaration that translates into the rendered graph you are reading right now, visit the "TOML Graph" link on the top navigation bar.
"""
-links = ["Principle"]
-
-[[nodes.Identity.connections]]
-anchor = "nothingness"
-to = "Emptiness"
-
-[nodes.Emptiness]
+[nodes.Acknowledgments]
text = """
-Emptiness is the vacuous base in which entities exist.
+en is only possible thanks to a number of projects and people:
+
+- |The Rust Programing Language|https://rust-lang.org/
+- Tokio|https://tokio.rs/
+- Axum|https://github.com/tokio-rs/axum
+- Tera|https://keats.github.io/tera/
+- Serde|https://serde.rs/ and the |toml crate|https://github.com/toml-rs/toml
+- Bacon|https://dystroy.org/bacon/config/
"""
-links = [ "Entity" ]
-
-[nodes.Entity]
+[nodes.Test]
+hidden = true
text = """
-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.
+
+This node is just for testing syntax rendering, but I appreciate your curiosity.
+
+`
+|en purple|https://purple.en/n/purple
+cyan|https://cyan.en/n/cyan
+
+|en Giraffe|/node/Giraffe
+|Gorilla|/node/Gorilla
+Crow|/node/Crow
+
+|Circle|Circle
+Circle|Circle
+|Circle|
+`
+
+|en purple|https://purple.en/n/purple
+cyan|https://cyan.en/n/cyan
+
+|en Giraffe|/node/Giraffe
+Crow|/node/Crow
+
+Circle|Circle
+|Circle|
+
+These `|anchors|` are inside `|backticks|Backtick` and should `|not render|https://test.com` as backticks but as `|raw text|` instead. This `|syntax is|` now `being demonstrated|https://test.com` here.
+
+Well |have I ever found such a long anchor in my entire life|Nowhere|, have I?
+
+This failed to parse due to a misunderstanding about what `parts.push(peaker.next().unwrap_or_else(|| unreachable!() ));` really meant.
+
+This greedy anchor is |at the end of a line|Somewhere
+This greedy anchor is |at the end of a line|Somewhere|
+This greedy anchor is |at the end of a line with a period|Somewhere|.
+This inline code is `at the end of a line`
+This inline code is `at the end of a line with a period`.
+
+---
+
+For trailing characters you don't want as part of destination, add a third `|`:
+
+`
+This gem|PreciousStone|, though green, was not an emerald.
+`
+
+Which renders as:
+
+This gem|PreciousStone|, though green, was not an emerald.
+
+Supported for punctuation only.
+
+### Node anchors
+
+We saw example `docs|/node/Documentation`, but shorter syntax exists.
+
+## Green
+## Green
+## Green
+## Purple
+## Purple
+## Purple
+## Cyan
+### Cyan
+#### Cyan
+### Cyan
+## Cyan
+## Épistème
+## Épistème
+## Epistème
+## Epistēmē
+### Epistēmē
+#### Epistēmē
+#### Epistēmē
+
+|en Syntax|https://en.jutty.dev/node/Syntax|
+|en Syntax|https://en.jutty.dev/node/Syntax
+Syntax|https://en.jutty.dev/node/Syntax
+
+Syntax|/node/syntax
+
+|syntax|Syntax
+Syntax|syntax
+Syntax|syntax|
+
+|Syntax|
+|syntax|
"""
-links = [ "Emptiness" ]
+[meta.config]
+content_language = "en"
+footer_credits = false
+footer_text = """
+made by jutty|https://jutty.dev • acknowledgments|Acknowledgments • |source code|https://codeberg.org/jutty/en
+"""
diff --git a/static/style.css b/static/style.css
index 55babcf..97a5840 100644
--- a/static/style.css
+++ b/static/style.css
@@ -1,21 +1,91 @@
-* {
- line-height: 1.6em;
-}
-
html {
- height: 100%;
+ height: 100%;
+ font-family: sans-serif;
+ line-height: 1.5;
}
body {
- height: 100%;
- display: grid;
- grid-template-rows: auto 1fr auto;
+ height: 100%;
+ display: grid;
+ grid-template-rows: auto 1fr auto;
+}
+
+pre {
+ max-width: 90vw;
+ overflow: auto;
+ box-sizing: border-box;
+ padding: 10px;
+ margin: 10px;
+
+}
+
+code {
+ padding: 3px 6px;
+ border-radius: 6px;
+ margin-right: 2px;
+}
+
+pre, code {
+ background-color: #e0e0e0;
+ border: solid 1px #d0d0d0;
+}
+
+a {
+ color: #0d6161;
+ text-decoration: underline dotted #138e8e;
+ text-decoration-thickness: 1.5px;
+}
+
+a:visited {
+ text-decoration-color: #aaa;
+}
+
+div.header-row {
+ display: flex;
+ justify-content: space-between;
+ align-items: center;
+}
+
+div.labels {
+ margin-right: 10px;
+ display: flex;
+ align-items: center;
+}
+
+span.label {
+ padding: 3px 6px;
+ border-radius: 6px;
+ margin: 5px;
+}
+
+span.id-label {
+ background-color: #e0e0e0;
+ border: solid 1px #d0d0d0;
+}
+
+span.hidden-label {
+ background-color: #888;
+ color: #eee;
+ border: solid 1px #d0d0d0;
+}
+
+h1.node-title {
+ display: inline;
+ margin: 10px 0;
}
footer div {
- margin: 20px 0;
- text-align: center;
- font-size: 0.8em;
+ margin: 20px 0;
+ text-align: center;
+ font-size: 0.8em;
+}
+
+footer p {
+ margin: 0;
+}
+
+nav li {
+ margin-right: 10px;
}
@media (prefers-color-scheme: dark) {
@@ -23,4 +93,35 @@ footer div {
background-color: #222222;
color: #f1e9e5;
}
+
+ pre, code {
+ background-color: #333333;
+ border: solid 1px #434343;
+ }
+
+ a {
+ color: #1bc8c8;
+ text-decoration-color: #159b9b;
+ }
+
+ span.id-label {
+ background-color: #444;
+ border-color: #666;
+ }
+
+ span.hidden-label {
+ background-color: #000;
+ border-color: #555;
+ color: #969696;
+ }
+}
+
+@media (max-width: 600px) {
+ nav li {
+ margin-right: 3px;
+ }
+
+ div.header-row {
+ display: block;
+ }
}
diff --git a/templates/about.html b/templates/about.html
index 9c7d15a..25a1397 100644
--- a/templates/about.html
+++ b/templates/about.html
@@ -5,16 +5,21 @@
{%- block body %}
+{% endif %}
diff --git a/templates/error.html b/templates/error.html
index 971cbfe..4bf2617 100644
--- a/templates/error.html
+++ b/templates/error.html
@@ -11,7 +11,7 @@
fallen
out of the circle
you are welcome to climb
- back onto the tree
+ back onto the {% if config.tree %}tree{% else %}tree{% endif %}
diff --git a/templates/index.html b/templates/index.html
index 76b32c3..20cfd34 100644
--- a/templates/index.html
+++ b/templates/index.html
@@ -3,34 +3,56 @@
{% block title %}Index{% endblock title %}
{%- block body %}
-