refreshing pages & look and feel a bit
hopefully the new :folder: and :page: icons help you navigate the hobby corners better
This commit is contained in:
parent
7720c9df0b
commit
d968da10a0
24 changed files with 453 additions and 204 deletions
|
@ -160,7 +160,13 @@ async fn sandbox(State(state): State<Arc<Server>>) -> Response {
|
|||
|
||||
async fn branch(RawQuery(named_id): RawQuery, State(state): State<Arc<Server>>) -> Html<String> {
|
||||
if let Some(named_id) = named_id {
|
||||
if let Some(&branch_id) = state.treehouse.branches_by_named_id.get(&named_id) {
|
||||
let branch_id = state
|
||||
.treehouse
|
||||
.branches_by_named_id
|
||||
.get(&named_id)
|
||||
.copied()
|
||||
.or_else(|| state.treehouse.branch_redirects.get(&named_id).copied());
|
||||
if let Some(branch_id) = branch_id {
|
||||
let branch = state.treehouse.tree.branch(branch_id);
|
||||
if let Source::Tree { input, tree_path } = state.treehouse.source(branch.file_id) {
|
||||
let file_path = state.target_dir.join(format!("{tree_path}.html"));
|
||||
|
|
|
@ -43,6 +43,8 @@ pub struct Treehouse {
|
|||
pub branches_by_named_id: HashMap<String, SemaBranchId>,
|
||||
pub roots: HashMap<String, SemaRoots>,
|
||||
|
||||
pub branch_redirects: HashMap<String, SemaBranchId>,
|
||||
|
||||
missingno_generator: ulid::Generator,
|
||||
}
|
||||
|
||||
|
@ -56,6 +58,8 @@ impl Treehouse {
|
|||
branches_by_named_id: HashMap::new(),
|
||||
roots: HashMap::new(),
|
||||
|
||||
branch_redirects: HashMap::new(),
|
||||
|
||||
missingno_generator: ulid::Generator::new(),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -166,6 +166,8 @@ impl SemaBranch {
|
|||
attributes.id
|
||||
);
|
||||
|
||||
let redirect_here = attributes.redirect_here.clone();
|
||||
|
||||
let branch = Self {
|
||||
file_id,
|
||||
indent_level: branch.indent_level,
|
||||
|
@ -210,6 +212,38 @@ impl SemaBranch {
|
|||
)
|
||||
}
|
||||
|
||||
for source_branch_named_id in redirect_here {
|
||||
if let Some(old_branch_id) = treehouse
|
||||
.branch_redirects
|
||||
.insert(source_branch_named_id.clone(), new_branch_id)
|
||||
{
|
||||
let new_branch = treehouse.tree.branch(new_branch_id);
|
||||
let old_branch = treehouse.tree.branch(old_branch_id);
|
||||
|
||||
treehouse.diagnostics.push(
|
||||
Diagnostic::warning()
|
||||
.with_code("sema")
|
||||
.with_message(format!(
|
||||
"two branches serve as redirect targets for `{source_branch_named_id}`"
|
||||
))
|
||||
.with_labels(vec![
|
||||
Label {
|
||||
style: LabelStyle::Primary,
|
||||
file_id,
|
||||
range: new_branch.kind_span.clone(),
|
||||
message: String::new(),
|
||||
},
|
||||
Label {
|
||||
style: LabelStyle::Primary,
|
||||
file_id: old_branch.file_id,
|
||||
range: old_branch.kind_span.clone(),
|
||||
message: String::new(),
|
||||
},
|
||||
]),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
new_branch_id
|
||||
}
|
||||
|
||||
|
|
|
@ -61,6 +61,12 @@ pub struct Attributes {
|
|||
#[serde(default)]
|
||||
pub id: String,
|
||||
|
||||
/// Redirect old and deleted listed in the list to this branch.
|
||||
///
|
||||
/// This can be used to keep links permanent even in case the structure of the treehouse changes.
|
||||
#[serde(default)]
|
||||
pub redirect_here: Vec<String>,
|
||||
|
||||
/// Controls how the block should be presented.
|
||||
#[serde(default)]
|
||||
pub content: Content,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue