Rename 'hidden' node option to 'listed'

This commit is contained in:
Juno Takano 2026-06-03 14:35:50 -03:00
commit ab9b587018
7 changed files with 18 additions and 15 deletions

View file

@ -665,7 +665,7 @@ mod tests {
"title": "JSON", "title": "JSON",
"links": [], "links": [],
"id": "JSON", "id": "JSON",
"hidden": false, "listed": true,
"connections": {} "connections": {}
} }
}, },

View file

@ -18,8 +18,8 @@ pub struct Node {
pub links: Vec<String>, pub links: Vec<String>,
#[serde(default)] #[serde(default)]
pub redirect: String, pub redirect: String,
#[serde(default)] #[serde(default = "mktrue")]
pub hidden: bool, pub listed: bool,
#[serde(default)] #[serde(default)]
pub connections: HashMap<String, Edge>, pub connections: HashMap<String, Edge>,
@ -28,6 +28,9 @@ pub struct Node {
pub stats: Stats, 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)] #[derive(Serialize, Deserialize, Clone, Default, Eq, PartialEq, Debug)]
pub struct Stats { pub struct Stats {
pub outgoing: u32, pub outgoing: u32,
@ -46,7 +49,7 @@ impl Node {
connections: HashMap::default(), connections: HashMap::default(),
links: vec![], links: vec![],
redirect: String::default(), redirect: String::default(),
hidden: false, listed: true,
summary: String::default(), summary: String::default(),
stats: Stats::default(), stats: Stats::default(),
} }
@ -78,8 +81,8 @@ impl std::fmt::Display for Node {
meta_elements.push(format!("links:{links}")); meta_elements.push(format!("links:{links}"));
} }
if self.hidden { if !self.listed {
meta_elements.push(String::from("hidden")); meta_elements.push(String::from("unlisted"));
} }
let meta = meta_elements.join(" "); let meta = meta_elements.join(" ");
@ -143,7 +146,7 @@ mod tests {
) )
); );
node.hidden = true; node.listed = false;
assert_eq!( assert_eq!(
format!("{node}"), format!("{node}"),
@ -153,7 +156,7 @@ mod tests {
text:15l summary:{} \ text:15l summary:{} \
redirect:{redirect} \ redirect:{redirect} \
links:{} \ links:{} \
hidden\ unlisted\
]", ]",
summary.len(), summary.len(),
node.links.len(), node.links.len(),

View file

@ -93,7 +93,7 @@ mod tests {
#[tokio::test] #[tokio::test]
async fn docs_redirect() { async fn docs_redirect() {
let response = wrap_node("docs").await; let response = wrap_node("RedirectTest").await;
assert_eq!(response.status(), StatusCode::PERMANENT_REDIRECT); assert_eq!(response.status(), StatusCode::PERMANENT_REDIRECT);
} }

View file

@ -52,8 +52,8 @@
<select class="node-selector" name="node"> <select class="node-selector" name="node">
<option value="">Nodes</option> <option value="">Nodes</option>
{% for _, node in graph.nodes %} {% for _, node in graph.nodes %}
{% if node.hidden or node.redirect %}{% continue %}{% endif %} {% if not node.listed or node.redirect %}{% continue %}{% endif %}
{% if not node.hidden and not node.redirect %} {% if node.listed and not node.redirect %}
<option value="{{node.id}}">{{node.title}}</option> <option value="{{node.id}}">{{node.title}}</option>
{% endif %} {% endif %}
{% endfor %} {% endfor %}

View file

@ -37,7 +37,7 @@
{% if loop.index > graph.meta.config.index_node_count %} {% if loop.index > graph.meta.config.index_node_count %}
{% break %} {% break %}
{% endif %} {% endif %}
{% if node.id != graph.root_node and not node.hidden and not node.redirect %} {% if node.id != graph.root_node and node.listed and not node.redirect %}
<li><a href="/node/{{node.id}}">{{node.title}}</a></li> <li><a href="/node/{{node.id}}">{{node.title}}</a></li>
{% endif %} {% endif %}
{% endfor %} {% endfor %}

View file

@ -8,7 +8,7 @@
<h1 class="node-title">{{ node.title }}</h1> <h1 class="node-title">{{ node.title }}</h1>
<div class="labels"> <div class="labels">
{% if node.title != node.id %}<span class="label id-label">ID: {{ node.id }}</span>{% endif %} {% if node.title != node.id %}<span class="label id-label">ID: {{ node.id }}</span>{% endif %}
{% if node.hidden %}<span class="label hidden-label">Hidden</span>{% endif %} {% if not node.listed %}<span class="label unlisted-label">Unlisted</span>{% endif %}
{% if node.id == graph.root_node %}<span class="label root-label">Root</span>{% endif %} {% if node.id == graph.root_node %}<span class="label root-label">Root</span>{% endif %}
</div> </div>
</div> </div>

View file

@ -6,7 +6,7 @@
{% if graph.nodes or root_node %} {% if graph.nodes or root_node %}
<h1>Tree</h1> <h1>Tree</h1>
<ul> <ul>
{% if root_node and not root_node.hidden %} {% if root_node and root_node.listed %}
<li> <li>
<a href="/node/{{root_node.id}}">{{root_node.title}}</a> <a href="/node/{{root_node.id}}">{{root_node.title}}</a>
<span class="label root-label">Root</span> <span class="label root-label">Root</span>
@ -34,7 +34,7 @@
{% endif %} {% endif %}
{% if graph.nodes %} {% if graph.nodes %}
{% for id, node in graph.nodes %} {% for id, node in graph.nodes %}
{% if node.hidden or (root_node and node.id == root_node.id ) %}{% continue %}{% endif %} {% if not node.listed or (root_node and node.id == root_node.id ) %}{% continue %}{% endif %}
<li> <li>
<a href="/node/{{node.id}}">{{node.title}}</a> <a href="/node/{{node.id}}">{{node.title}}</a>
{% if node.connections or graph.meta.config.tree_node_summary %} {% if node.connections or graph.meta.config.tree_node_summary %}