fix translate

This commit is contained in:
2026-01-18 17:34:30 +09:00
parent 97bcd13a8d
commit cbcb01ab4e
2 changed files with 27 additions and 21 deletions

View File

@@ -1,18 +1,16 @@
{ {
"cid": "bafyreielgn743kg5xotfj5x53edl25vkbbd2d6v7s3tydyyjsvczcluyme", "cid": "bafyreigwaeqfluw7btvnmxfogd77gtk4efwomvjsvq2yxmmxr2665zwwbi",
"uri": "at://did:plc:vzsvtbtbnwn22xjqhcu3vd6y/ai.syui.log.post/3mchqlshygs2s", "uri": "at://did:plc:vzsvtbtbnwn22xjqhcu3vd6y/ai.syui.log.post/3mchqlshygs2s",
"value": { "value": {
"$type": "ai.syui.log.post", "$type": "ai.syui.log.post",
"cid": "bafyreidymanu2xk4ftmvfdna3j7ixyijc37s6h3aytstuqgzatgjl4tp7e", "content": "## ailogとは\n\natprotoと連携するサイトジェネレータ。\n\n## ailogの使い方\n\n```sh\n$ git clone https://git.syui.ai/ai/log\n$ cd log\n$ cat public/config.json\n{\n \"title\": \"syui.ai\",\n \"handle\": \"syui.syui.ai\",\n \"collection\": \"ai.syui.log.post\",\n \"network\": \"syu.is\",\n \"color\": \"#0066cc\",\n \"siteUrl\": \"https://syui.ai\"\n}\n---\n$ npm run dev\n```\n\n## ailogのコンセプト\n\n1. at-browserを基本にする\n2. atproto oauthでログインする\n3. ログインしたアカウントで記事をポストする",
"content": "## ailogとは\n\natprotoと連携するサイトジェネレータ。\n\n## ailogの使い方\n\n```sh\n$ git clone https://git.syui.ai/ai/log\n$ cd log\n$ cat public/config.json\n{\n \"title\": \"syui.ai\",\n \"handle\": \"syui.syui.ai\",\n \"collection\": \"ai.syui.log.post\",\n \"network\": \"syu.is\",\n \"color\": \"#0066cc\",\n \"siteUrl\": \"https://syui.ai\"\n}\n---\n$ npm run dev\n```\n\n## ailogのコンセプト\n\n1. at-browserを基本にする\n2. atproto oauthでログインする\n3. ログインしたアカウントで記事をポストする\n\n## ailogの追加機能\n\n1. atproto recordからjsonをdownloadすると表示速度が上がる(ただし更新はlocalから)\n2. コメントはurlの言及を検索して表示\n\n```sh\n$ npm run fetch\n$ npm run generate\n```", "createdAt": "2026-01-18T08:31:52.715Z",
"createdAt": "2026-01-15T13:59:52.367Z",
"title": "ailogを作り直した", "title": "ailogを作り直した",
"translations": { "translations": {
"en": { "en": {
"content": "## What is ailog?\n\nA site generator that integrates with the atproto framework.\n\n## How to Use ailog\n\n```sh\n$ git clone https://git.syui.ai/ai/log\n$ cd log\n$ cat public/config.json\n{\n \"title\": \"syui.ai\",\n \"handle\": \"syui.syui.ai\",\n \"collection\": \"ai.syui.log.post\",\n \"network\": \"syu.is\",\n \"color\": \"#0066cc\",\n \"siteUrl\": \"https://syui.ai\"\n}\n---\n$ npm run dev\n```\n\n## ailog's Concept\n\n1. Based on at-browser as its foundation\n2. Authentication via atproto oAuth\n3. Post articles using the logged-in account\n\n## Additional Features of ailog\n\n1. Downloading JSON from atproto record improves display speed (though updates still come from local storage)\n2. Comments are displayed by searching for URL mentions\n\n```sh\n$ npm run fetch\n$ npm run generate\n```", "content": "## About ailog\n\nA site generator that integrates with atproto.\n\n## How to Use ailog\n\n```sh\n$ git clone https://git.syui.ai/ai/log\n$ cd log\n$ cat public/config.json\n{\n \"title\": \"syui.ai\",\n \"handle\": \"syui.syui.ai\",\n \"collection\": \"ai.syui.log.post\",\n \"network\": \"syu.is\",\n \"color\": \"#0066cc\",\n \"siteUrl\": \"https://syui.ai\"\n}\n---\n$ npm run dev\n```\n\n## ailog's Concept\n\n1. Based on at-browser architecture\n2. Uses atproto oAuth for login\n3. Allows posting articles through the logged-in account",
"title": "recreated ailog" "title": "recreated ailog"
} }
}, }
"uri": "at://did:plc:vzsvtbtbnwn22xjqhcu3vd6y/ai.syui.log.post/3mchqlshygs2s"
} }
} }

View File

@@ -170,18 +170,27 @@ async fn translate_file(input: &Path, from: &str, to: &str) -> Result<()> {
Ok(()) Ok(())
} }
async fn translate_folder(dir: &Path, from: &str, to: &str) -> Result<()> { fn collect_json_files(dir: &Path, files: &mut Vec<std::path::PathBuf>) -> Result<()> {
let mut files: Vec<_> = fs::read_dir(dir)? for entry in fs::read_dir(dir)? {
.filter_map(|e| e.ok()) let entry = entry?;
.filter(|e| { let path = entry.path();
e.path() if path.is_dir() {
.extension() collect_json_files(&path, files)?;
.map(|ext| ext == "json") } else if path.extension().map(|e| e == "json").unwrap_or(false) {
.unwrap_or(false) // Skip non-post files (describe.json, self.json, index.json)
}) let filename = path.file_name().and_then(|n| n.to_str()).unwrap_or("");
.collect(); if filename != "describe.json" && filename != "self.json" && filename != "index.json" {
files.push(path);
}
}
}
Ok(())
}
files.sort_by_key(|e| e.path()); async fn translate_folder(dir: &Path, from: &str, to: &str) -> Result<()> {
let mut files = Vec::new();
collect_json_files(dir, &mut files)?;
files.sort();
println!("Translating {} files ({} -> {})", files.len(), from, to); println!("Translating {} files ({} -> {})", files.len(), from, to);
@@ -189,9 +198,8 @@ async fn translate_folder(dir: &Path, from: &str, to: &str) -> Result<()> {
let mut skipped = 0; let mut skipped = 0;
let mut failed = 0; let mut failed = 0;
for entry in files { for path in &files {
let path = entry.path(); match translate_file(path, from, to).await {
match translate_file(&path, from, to).await {
Ok(_) => { Ok(_) => {
// Check if it was actually translated or skipped // Check if it was actually translated or skipped
let content = fs::read_to_string(&path)?; let content = fs::read_to_string(&path)?;