Rename 'hidden' node option to 'listed'
This commit is contained in:
parent
0d48291d5f
commit
ab9b587018
7 changed files with 18 additions and 15 deletions
|
|
@ -665,7 +665,7 @@ mod tests {
|
|||
"title": "JSON",
|
||||
"links": [],
|
||||
"id": "JSON",
|
||||
"hidden": false,
|
||||
"listed": true,
|
||||
"connections": {}
|
||||
}
|
||||
},
|
||||
|
|
|
|||
|
|
@ -18,8 +18,8 @@ pub struct Node {
|
|||
pub links: Vec<String>,
|
||||
#[serde(default)]
|
||||
pub redirect: String,
|
||||
#[serde(default)]
|
||||
pub hidden: bool,
|
||||
#[serde(default = "mktrue")]
|
||||
pub listed: bool,
|
||||
|
||||
#[serde(default)]
|
||||
pub connections: HashMap<String, Edge>,
|
||||
|
|
@ -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(),
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue