mirror of
https://github.com/Lumither/nocturne.git
synced 2026-10-17 18:36:21 +00:00
Compare commits
2
Commits
6a6af722c3
...
15a88074e9
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
15a88074e9 | ||
|
|
5bf6d24733 |
No files matched your search
@@ -20,6 +20,7 @@ tracing-appender = "0.2.3"
|
|||||||
dirs = "6.0.0"
|
dirs = "6.0.0"
|
||||||
thiserror = "2.0.11"
|
thiserror = "2.0.11"
|
||||||
tokio = { version = "1.42.0", features = ["rt", "rt-multi-thread", "macros", "sync"] }
|
tokio = { version = "1.42.0", features = ["rt", "rt-multi-thread", "macros", "sync"] }
|
||||||
|
regex = "1.11.1"
|
||||||
dotenv = "0.15.0"
|
dotenv = "0.15.0"
|
||||||
uuid = { version = "1.13.2", features = ["v4"] }
|
uuid = { version = "1.13.2", features = ["v4"] }
|
||||||
futures = "0.3.31"
|
futures = "0.3.31"
|
||||||
|
|||||||
File renamed without changes.
@@ -1,3 +1,4 @@
|
|||||||
|
use std::sync::LazyLock;
|
||||||
use std::{collections::HashMap, fs::remove_dir_all, path::PathBuf};
|
use std::{collections::HashMap, fs::remove_dir_all, path::PathBuf};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
@@ -10,6 +11,7 @@ use crate::{
|
|||||||
use markdown::MdFile;
|
use markdown::MdFile;
|
||||||
|
|
||||||
use git2::{Delta, Repository};
|
use git2::{Delta, Repository};
|
||||||
|
use regex::Regex;
|
||||||
use tracing::{error, warn};
|
use tracing::{error, warn};
|
||||||
use uuid::Uuid;
|
use uuid::Uuid;
|
||||||
|
|
||||||
@@ -64,14 +66,17 @@ pub async fn fetch_deltas(
|
|||||||
|
|
||||||
// process deleted deltas before merging commit to prevent "file not found" os error
|
// process deleted deltas before merging commit to prevent "file not found" os error
|
||||||
for delta in commit_deltas.into_iter() {
|
for delta in commit_deltas.into_iter() {
|
||||||
// todo: limit scanning scope to post only OR extract merging logic to external component
|
let relative_file_path = delta
|
||||||
|
.new_path
|
||||||
|
.clone()
|
||||||
|
.expect("cannot parse modified post `new_path`");
|
||||||
|
|
||||||
|
if !should_delta_tracked(&relative_file_path) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
if delta.status == Delta::Deleted {
|
if delta.status == Delta::Deleted {
|
||||||
let file_path = &git_work_dir.join(
|
let file_path = &git_work_dir.join(relative_file_path);
|
||||||
delta
|
|
||||||
.new_path
|
|
||||||
.expect("cannot parse modified post `new_path`"),
|
|
||||||
);
|
|
||||||
if let Some(id) = extract_post_id(&MdFile::from_file(file_path)?) {
|
if let Some(id) = extract_post_id(&MdFile::from_file(file_path)?) {
|
||||||
changes.push(Change::Delete(Delete {
|
changes.push(Change::Delete(Delete {
|
||||||
uuid: id,
|
uuid: id,
|
||||||
@@ -169,3 +174,10 @@ fn merge_changes(changes: Vec<Change>) -> Vec<Change> {
|
|||||||
|
|
||||||
merged
|
merged
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static TRACKED_DELTA_RULE: LazyLock<Regex> =
|
||||||
|
LazyLock::new(|| Regex::new(r"posts/\d{4}/[a-zA-Z0-9-]+/index\.md").unwrap());
|
||||||
|
|
||||||
|
fn should_delta_tracked(path: &PathBuf) -> bool {
|
||||||
|
TRACKED_DELTA_RULE.is_match(path.to_str().unwrap())
|
||||||
|
}
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
pub mod check_update;
|
pub mod check_update;
|
||||||
mod consistency_guard;
|
pub mod consistency_guard;
|
||||||
mod rag;
|
pub mod rag;
|
||||||
@@ -10,13 +10,14 @@ from utils.lang import eprint, wprint
|
|||||||
|
|
||||||
POST_TEMPLATE = '''
|
POST_TEMPLATE = '''
|
||||||
---
|
---
|
||||||
|
uuid: {{ uuid }}
|
||||||
title: {{ title }}
|
title: {{ title }}
|
||||||
subtitle: {{ subtitle }}
|
subtitle: {{ subtitle }}
|
||||||
published_date: {{ published_date }}
|
status: {{ status }}
|
||||||
last_updated: {{ last_update }}
|
date: {{ date }}
|
||||||
|
update: {{ update }}
|
||||||
category: {{ category }}
|
category: {{ category }}
|
||||||
tags: {{ tags }}
|
tags: {{ tags }}
|
||||||
uuid: {{ uuid }}
|
|
||||||
---
|
---
|
||||||
|
|
||||||
WIP
|
WIP
|
||||||
@@ -38,9 +39,9 @@ def get_subtitle():
|
|||||||
return input("subtitle > ")
|
return input("subtitle > ")
|
||||||
|
|
||||||
|
|
||||||
def get_published_date():
|
def get_date():
|
||||||
while True:
|
while True:
|
||||||
d = input("published_date (YYYY-MM-DD) > ")
|
d = input("date (YYYY-MM-DD) > ")
|
||||||
if d == "":
|
if d == "":
|
||||||
wprint("using today's date")
|
wprint("using today's date")
|
||||||
return dt.today().strftime("%Y-%m-%d")
|
return dt.today().strftime("%Y-%m-%d")
|
||||||
@@ -78,8 +79,8 @@ class BlogPost(Template):
|
|||||||
index_md = POST_TEMPLATE.format(
|
index_md = POST_TEMPLATE.format(
|
||||||
title=get_title(),
|
title=get_title(),
|
||||||
subtitle=get_subtitle(),
|
subtitle=get_subtitle(),
|
||||||
published_date=get_published_date(),
|
date=get_date(),
|
||||||
last_update=dt.today().strftime("%Y-%m-%d"),
|
update=dt.today().strftime("%Y-%m-%d"),
|
||||||
tags=get_tags(),
|
tags=get_tags(),
|
||||||
category=get_category(),
|
category=get_category(),
|
||||||
uuid=uuid.uuid4()
|
uuid=uuid.uuid4()
|
||||||
|
|||||||
Reference in new issue
Block a user