From ab9b587018e03484f67febcaf38f2c11413d1e25 Mon Sep 17 00:00:00 2001 From: jutty Date: Wed, 3 Jun 2026 14:35:50 -0300 Subject: [PATCH] Rename 'hidden' node option to 'listed' --- src/graph.rs | 2 +- src/graph/node.rs | 17 ++++++++++------- src/router/handlers/graph.rs | 2 +- templates/base.html | 4 ++-- templates/index.html | 2 +- templates/node.html | 2 +- templates/tree.html | 4 ++-- 7 files changed, 18 insertions(+), 15 deletions(-) diff --git a/src/graph.rs b/src/graph.rs index 67a32b5..0fd940c 100644 --- a/src/graph.rs +++ b/src/graph.rs @@ -665,7 +665,7 @@ mod tests { "title": "JSON", "links": [], "id": "JSON", - "hidden": false, + "listed": true, "connections": {} } }, diff --git a/src/graph/node.rs b/src/graph/node.rs index ff0c719..3472641 100644 --- a/src/graph/node.rs +++ b/src/graph/node.rs @@ -18,8 +18,8 @@ pub struct Node { pub links: Vec, #[serde(default)] pub redirect: String, - #[serde(default)] - pub hidden: bool, + #[serde(default = "mktrue")] + pub listed: bool, #[serde(default)] pub connections: HashMap, @@ -28,6 +28,9 @@ pub struct Node { pub stats: Stats, } +// See: https://github.com/serde-rs/serde/issues/368 +const fn mktrue() -> bool { true } + #[derive(Serialize, Deserialize, Clone, Default, Eq, PartialEq, Debug)] pub struct Stats { pub outgoing: u32, @@ -46,7 +49,7 @@ impl Node { connections: HashMap::default(), links: vec![], redirect: String::default(), - hidden: false, + listed: true, summary: String::default(), stats: Stats::default(), } @@ -78,8 +81,8 @@ impl std::fmt::Display for Node { meta_elements.push(format!("links:{links}")); } - if self.hidden { - meta_elements.push(String::from("hidden")); + if !self.listed { + meta_elements.push(String::from("unlisted")); } let meta = meta_elements.join(" "); @@ -143,7 +146,7 @@ mod tests { ) ); - node.hidden = true; + node.listed = false; assert_eq!( format!("{node}"), @@ -153,7 +156,7 @@ mod tests { text:15l summary:{} \ redirect:{redirect} \ links:{} \ - hidden\ + unlisted\ ]", summary.len(), node.links.len(), diff --git a/src/router/handlers/graph.rs b/src/router/handlers/graph.rs index bf0b112..0ebc539 100644 --- a/src/router/handlers/graph.rs +++ b/src/router/handlers/graph.rs @@ -93,7 +93,7 @@ mod tests { #[tokio::test] async fn docs_redirect() { - let response = wrap_node("docs").await; + let response = wrap_node("RedirectTest").await; assert_eq!(response.status(), StatusCode::PERMANENT_REDIRECT); } diff --git a/templates/base.html b/templates/base.html index 990f779..61043bd 100644 --- a/templates/base.html +++ b/templates/base.html @@ -52,8 +52,8 @@