This commit is contained in:
+1
-1
@@ -78,7 +78,7 @@ impl WikiGraph {
|
||||
);
|
||||
}
|
||||
|
||||
println!("");
|
||||
println!();
|
||||
|
||||
// Edges
|
||||
for (source, targets) in &self.edges {
|
||||
|
||||
+11
-14
@@ -106,10 +106,9 @@ async fn update_from_git(changelog_path: &Path, git_dir: &Path, wiki_root: &Path
|
||||
for line in stdout.lines() {
|
||||
if line.starts_with("---ENTRY---|") {
|
||||
// Push previous
|
||||
if let Some(entry) = current_entry.take() {
|
||||
if !entry.files.is_empty() && !existing_hashes.contains(&entry.hash) {
|
||||
new_entries.push(entry);
|
||||
}
|
||||
if let Some(entry) = current_entry.take()
|
||||
&& !entry.files.is_empty() && !existing_hashes.contains(&entry.hash) {
|
||||
new_entries.push(entry);
|
||||
}
|
||||
|
||||
// Parse new
|
||||
@@ -153,10 +152,10 @@ async fn update_from_git(changelog_path: &Path, git_dir: &Path, wiki_root: &Path
|
||||
}
|
||||
|
||||
// Push last
|
||||
if let Some(entry) = current_entry {
|
||||
if !entry.files.is_empty() && !existing_hashes.contains(&entry.hash) {
|
||||
new_entries.push(entry);
|
||||
}
|
||||
if let Some(entry) = current_entry
|
||||
&& !entry.files.is_empty()
|
||||
&& !existing_hashes.contains(&entry.hash) {
|
||||
new_entries.push(entry);
|
||||
}
|
||||
|
||||
if new_entries.is_empty() {
|
||||
@@ -180,12 +179,10 @@ async fn update_from_git(changelog_path: &Path, git_dir: &Path, wiki_root: &Path
|
||||
|
||||
pub async fn load_changelog(root_dir: &Path) -> Vec<ChangelogEntry> {
|
||||
let path = root_dir.join("_changelog.toml");
|
||||
if path.exists() {
|
||||
if let Ok(content) = fs::read_to_string(path).await {
|
||||
if let Ok(config) = toml::from_str::<ChangelogConfig>(&content) {
|
||||
return config.entries;
|
||||
}
|
||||
}
|
||||
if path.exists()
|
||||
&& let Ok(content) = fs::read_to_string(path).await
|
||||
&& if let Ok(config) = toml::from_str::<ChangelogConfig>(&content) {
|
||||
return config.entries;
|
||||
}
|
||||
Vec::new()
|
||||
}
|
||||
|
||||
+4
-4
@@ -59,7 +59,7 @@ async fn list_entries(root: &PathBuf) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn check_file_status(root: &PathBuf, filename: Option<String>) -> String {
|
||||
fn check_file_status(root: &Path, filename: Option<String>) -> String {
|
||||
match filename {
|
||||
Some(f) => {
|
||||
let path = root.join("images").join(&f);
|
||||
@@ -73,7 +73,7 @@ fn check_file_status(root: &PathBuf, filename: Option<String>) -> String {
|
||||
}
|
||||
}
|
||||
|
||||
async fn create_entry(root: &PathBuf, title: &str, category: Option<String>) -> Result<()> {
|
||||
async fn create_entry(root: &Path, title: &str, category: Option<String>) -> Result<()> {
|
||||
let slug: String = title
|
||||
.trim()
|
||||
.to_lowercase()
|
||||
@@ -139,7 +139,7 @@ content_file = "{}"
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn remove_entry(root: &PathBuf, name: &str) -> Result<()> {
|
||||
async fn remove_entry(root: &Path, name: &str) -> Result<()> {
|
||||
let toml_path = root.join(format!("{}.toml", name));
|
||||
|
||||
if !toml_path.exists() {
|
||||
@@ -176,7 +176,7 @@ async fn remove_entry(root: &PathBuf, name: &str) -> Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
async fn inspect_entry(root: &PathBuf, name: &str) -> Result<()> {
|
||||
async fn inspect_entry(root: &Path, name: &str) -> Result<()> {
|
||||
let toml_path = root.join(format!("{}.toml", name));
|
||||
if !toml_path.exists() {
|
||||
return Err(anyhow!("Entry '{}' not found", name));
|
||||
|
||||
+1
-1
@@ -114,7 +114,7 @@ async fn main() -> anyhow::Result<()> {
|
||||
.route("/changelog", get(render_changelog_handler))
|
||||
.nest_service(
|
||||
"/images",
|
||||
tower_http::services::ServeDir::new(&shared_state.docs_dir.join("images")),
|
||||
tower_http::services::ServeDir::new(shared_state.docs_dir.join("images")),
|
||||
)
|
||||
.nest_service(
|
||||
"/assets",
|
||||
|
||||
+2
-2
@@ -85,7 +85,7 @@ impl<'a> Iterator for Renderer<'a> {
|
||||
Event::Start(Tag::CodeBlock(kind)) => {
|
||||
let mut code_content = String::new();
|
||||
|
||||
while let Some(inner_event) = self.inner.next() {
|
||||
for inner_event in self.inner.by_ref() {
|
||||
match inner_event {
|
||||
Event::End(TagEnd::CodeBlock) => break,
|
||||
Event::Text(code) => code_content.push_str(&code),
|
||||
@@ -111,7 +111,7 @@ impl<'a> Iterator for Renderer<'a> {
|
||||
);
|
||||
Some(Event::Html(CowStr::Boxed(rendered_html.into_boxed_str())))
|
||||
}
|
||||
_ => return Some(event),
|
||||
_ => Some(event),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user