Renamed tab related structs from section to tab
This commit is contained in:
parent
81134d2007
commit
f1d38b8cf1
38
src/main.rs
38
src/main.rs
@ -644,16 +644,16 @@ fn handle_relative_connection(
|
|||||||
let _ = writeln!(stream, "<h1>{title}</h1>");
|
let _ = writeln!(stream, "<h1>{title}</h1>");
|
||||||
}
|
}
|
||||||
|
|
||||||
enum SectionInfo {
|
enum TabInfo {
|
||||||
Lines(Vec<String>),
|
Lines(Vec<String>),
|
||||||
Game(IndexMap<Box<str>, Box<str>>),
|
Game(IndexMap<Box<str>, Box<str>>),
|
||||||
Description,
|
Description,
|
||||||
Comment(Vec<Comment>),
|
Comment(Vec<Comment>),
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Section {
|
struct Tab {
|
||||||
title: Box<str>,
|
title: Box<str>,
|
||||||
info: SectionInfo,
|
info: TabInfo,
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut sections = Vec::new();
|
let mut sections = Vec::new();
|
||||||
@ -668,9 +668,9 @@ fn handle_relative_connection(
|
|||||||
.map(|parent| parent.with_extension("mlc"));
|
.map(|parent| parent.with_extension("mlc"));
|
||||||
|
|
||||||
if let Some(config_map) = config_map {
|
if let Some(config_map) = config_map {
|
||||||
sections.push(Section {
|
sections.push(Tab {
|
||||||
title: "Game".into(),
|
title: "Game".into(),
|
||||||
info: SectionInfo::Game(config_map),
|
info: TabInfo::Game(config_map),
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
let Ok(pk_file) = File::open(file_paths.pk) else {
|
let Ok(pk_file) = File::open(file_paths.pk) else {
|
||||||
@ -686,9 +686,9 @@ fn handle_relative_connection(
|
|||||||
};
|
};
|
||||||
if let Some(title) = line.strip_prefix("# ") {
|
if let Some(title) = line.strip_prefix("# ") {
|
||||||
if !current_title.is_empty() {
|
if !current_title.is_empty() {
|
||||||
sections.push(Section {
|
sections.push(Tab {
|
||||||
title: current_title,
|
title: current_title,
|
||||||
info: SectionInfo::Lines(current_lines),
|
info: TabInfo::Lines(current_lines),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
current_title = title.into();
|
current_title = title.into();
|
||||||
@ -700,22 +700,22 @@ fn handle_relative_connection(
|
|||||||
current_lines.push(line);
|
current_lines.push(line);
|
||||||
}
|
}
|
||||||
|
|
||||||
sections.push(Section {
|
sections.push(Tab {
|
||||||
title: current_title,
|
title: current_title,
|
||||||
info: SectionInfo::Lines(current_lines),
|
info: TabInfo::Lines(current_lines),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
if file_paths.pki.is_some() {
|
if file_paths.pki.is_some() {
|
||||||
sections.push(Section {
|
sections.push(Tab {
|
||||||
title: "Description".into(),
|
title: "Description".into(),
|
||||||
info: SectionInfo::Description,
|
info: TabInfo::Description,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
sections.push(Section {
|
sections.push(Tab {
|
||||||
title: "Comments".into(),
|
title: "Comments".into(),
|
||||||
info: SectionInfo::Comment(comments),
|
info: TabInfo::Comment(comments),
|
||||||
});
|
});
|
||||||
|
|
||||||
let count = sections.len();
|
let count = sections.len();
|
||||||
@ -789,7 +789,7 @@ fn handle_relative_connection(
|
|||||||
}
|
}
|
||||||
|
|
||||||
let _ = write!(stream, r#"<div class="tab-nav">"#);
|
let _ = write!(stream, r#"<div class="tab-nav">"#);
|
||||||
for (i, Section { title, .. }) in sections.iter().enumerate() {
|
for (i, Tab { title, .. }) in sections.iter().enumerate() {
|
||||||
let index = i + 1;
|
let index = i + 1;
|
||||||
let _ = write!(
|
let _ = write!(
|
||||||
stream,
|
stream,
|
||||||
@ -798,11 +798,11 @@ fn handle_relative_connection(
|
|||||||
}
|
}
|
||||||
let _ = write!(stream, "</div>");
|
let _ = write!(stream, "</div>");
|
||||||
|
|
||||||
for (i, Section { info, .. }) in sections.into_iter().enumerate() {
|
for (i, Tab { info, .. }) in sections.into_iter().enumerate() {
|
||||||
let index = i + 1;
|
let index = i + 1;
|
||||||
let _ = write!(stream, r#"<div class="tab-content" id="content-{index}">"#);
|
let _ = write!(stream, r#"<div class="tab-content" id="content-{index}">"#);
|
||||||
match info {
|
match info {
|
||||||
SectionInfo::Lines(lines) => {
|
TabInfo::Lines(lines) => {
|
||||||
convert_extended(
|
convert_extended(
|
||||||
lines,
|
lines,
|
||||||
&mut stream,
|
&mut stream,
|
||||||
@ -812,7 +812,7 @@ fn handle_relative_connection(
|
|||||||
.with_use_textboxes(true),
|
.with_use_textboxes(true),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
SectionInfo::Game(config_map) => {
|
TabInfo::Game(config_map) => {
|
||||||
if render_novel(
|
if render_novel(
|
||||||
config_map,
|
config_map,
|
||||||
file_paths.pk,
|
file_paths.pk,
|
||||||
@ -829,7 +829,7 @@ fn handle_relative_connection(
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SectionInfo::Description => {
|
TabInfo::Description => {
|
||||||
let Ok(pki_file) = File::open(file_paths.pki.unwrap()) else {
|
let Ok(pki_file) = File::open(file_paths.pki.unwrap()) else {
|
||||||
unreachable!();
|
unreachable!();
|
||||||
};
|
};
|
||||||
@ -848,7 +848,7 @@ fn handle_relative_connection(
|
|||||||
let lines = BufReader::new(pki_file).lines();
|
let lines = BufReader::new(pki_file).lines();
|
||||||
convert_subheader(lines.map(Result::unwrap_or_default), &mut stream, 1);
|
convert_subheader(lines.map(Result::unwrap_or_default), &mut stream, 1);
|
||||||
}
|
}
|
||||||
SectionInfo::Comment(comments) => {
|
TabInfo::Comment(comments) => {
|
||||||
let html = html! {
|
let html = html! {
|
||||||
h1 { "Comments" }
|
h1 { "Comments" }
|
||||||
form method="POST" {
|
form method="POST" {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user