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>");
|
||||
}
|
||||
|
||||
enum SectionInfo {
|
||||
enum TabInfo {
|
||||
Lines(Vec<String>),
|
||||
Game(IndexMap<Box<str>, Box<str>>),
|
||||
Description,
|
||||
Comment(Vec<Comment>),
|
||||
}
|
||||
|
||||
struct Section {
|
||||
struct Tab {
|
||||
title: Box<str>,
|
||||
info: SectionInfo,
|
||||
info: TabInfo,
|
||||
}
|
||||
|
||||
let mut sections = Vec::new();
|
||||
@ -668,9 +668,9 @@ fn handle_relative_connection(
|
||||
.map(|parent| parent.with_extension("mlc"));
|
||||
|
||||
if let Some(config_map) = config_map {
|
||||
sections.push(Section {
|
||||
sections.push(Tab {
|
||||
title: "Game".into(),
|
||||
info: SectionInfo::Game(config_map),
|
||||
info: TabInfo::Game(config_map),
|
||||
});
|
||||
} 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 !current_title.is_empty() {
|
||||
sections.push(Section {
|
||||
sections.push(Tab {
|
||||
title: current_title,
|
||||
info: SectionInfo::Lines(current_lines),
|
||||
info: TabInfo::Lines(current_lines),
|
||||
})
|
||||
}
|
||||
current_title = title.into();
|
||||
@ -700,22 +700,22 @@ fn handle_relative_connection(
|
||||
current_lines.push(line);
|
||||
}
|
||||
|
||||
sections.push(Section {
|
||||
sections.push(Tab {
|
||||
title: current_title,
|
||||
info: SectionInfo::Lines(current_lines),
|
||||
info: TabInfo::Lines(current_lines),
|
||||
})
|
||||
}
|
||||
|
||||
if file_paths.pki.is_some() {
|
||||
sections.push(Section {
|
||||
sections.push(Tab {
|
||||
title: "Description".into(),
|
||||
info: SectionInfo::Description,
|
||||
info: TabInfo::Description,
|
||||
});
|
||||
}
|
||||
|
||||
sections.push(Section {
|
||||
sections.push(Tab {
|
||||
title: "Comments".into(),
|
||||
info: SectionInfo::Comment(comments),
|
||||
info: TabInfo::Comment(comments),
|
||||
});
|
||||
|
||||
let count = sections.len();
|
||||
@ -789,7 +789,7 @@ fn handle_relative_connection(
|
||||
}
|
||||
|
||||
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 _ = write!(
|
||||
stream,
|
||||
@ -798,11 +798,11 @@ fn handle_relative_connection(
|
||||
}
|
||||
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 _ = write!(stream, r#"<div class="tab-content" id="content-{index}">"#);
|
||||
match info {
|
||||
SectionInfo::Lines(lines) => {
|
||||
TabInfo::Lines(lines) => {
|
||||
convert_extended(
|
||||
lines,
|
||||
&mut stream,
|
||||
@ -812,7 +812,7 @@ fn handle_relative_connection(
|
||||
.with_use_textboxes(true),
|
||||
);
|
||||
}
|
||||
SectionInfo::Game(config_map) => {
|
||||
TabInfo::Game(config_map) => {
|
||||
if render_novel(
|
||||
config_map,
|
||||
file_paths.pk,
|
||||
@ -829,7 +829,7 @@ fn handle_relative_connection(
|
||||
return;
|
||||
}
|
||||
}
|
||||
SectionInfo::Description => {
|
||||
TabInfo::Description => {
|
||||
let Ok(pki_file) = File::open(file_paths.pki.unwrap()) else {
|
||||
unreachable!();
|
||||
};
|
||||
@ -848,7 +848,7 @@ fn handle_relative_connection(
|
||||
let lines = BufReader::new(pki_file).lines();
|
||||
convert_subheader(lines.map(Result::unwrap_or_default), &mut stream, 1);
|
||||
}
|
||||
SectionInfo::Comment(comments) => {
|
||||
TabInfo::Comment(comments) => {
|
||||
let html = html! {
|
||||
h1 { "Comments" }
|
||||
form method="POST" {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user