From d382ea563fa793edc17a7baeebe3acbead4ee337 Mon Sep 17 00:00:00 2001 From: ":NoBody:" Date: Sun, 14 Jun 2026 22:28:17 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8A=E5=87=BA=E4=BF=AE=E8=AE=A2=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- templates/computer_template/fonts.html | 4 ++-- templates/mobile_template/fonts.html | 4 ++-- tools/gp/cli/handlers.ts | 12 ++++-------- tools/gp/config.json | 6 +++--- tools/gp/main.ts | 18 ++++++++++++++++++ 5 files changed, 29 insertions(+), 15 deletions(-) diff --git a/templates/computer_template/fonts.html b/templates/computer_template/fonts.html index cd70614..82b85f4 100644 --- a/templates/computer_template/fonts.html +++ b/templates/computer_template/fonts.html @@ -47,7 +47,7 @@ font-display: swap; } - /* .zcool-qingke-huangyou-regular { + .zcool-qingke-huangyou-regular { font-family: "ZCOOL QingKe HuangYou", sans-serif; font-weight: 400; font-style: normal; @@ -92,5 +92,5 @@ font-family: "FangZhengFangSong", regular; font-weight: 400; font-style: normal; - } */ + } diff --git a/templates/mobile_template/fonts.html b/templates/mobile_template/fonts.html index cd70614..143c771 100644 --- a/templates/mobile_template/fonts.html +++ b/templates/mobile_template/fonts.html @@ -47,7 +47,7 @@ font-display: swap; } - /* .zcool-qingke-huangyou-regular { + .zcool-qingke-huangyou-regular { font-family: "ZCOOL QingKe HuangYou", sans-serif; font-weight: 400; font-style: normal; @@ -92,5 +92,5 @@ font-family: "FangZhengFangSong", regular; font-weight: 400; font-style: normal; - } */ + } diff --git a/tools/gp/cli/handlers.ts b/tools/gp/cli/handlers.ts index 7a2deae..c0a7669 100644 --- a/tools/gp/cli/handlers.ts +++ b/tools/gp/cli/handlers.ts @@ -3,9 +3,8 @@ import { OpenPGPSigner } from "../pdf_builder/utils.ts"; import { DocuBuilder } from "../pdf_builder/docu_builder.ts"; import { IndexBuilder } from "../pdf_builder/index_builder.ts"; //import TurndownService from "turndown"; - +import { cfg } from "../main.ts"; export async function generate_pdf() { - const cfg = JSON.parse(await Deno.readTextFile("config.json")); for (const config of cfg.settings) { const builder = new DocuBuilder(config); @@ -22,7 +21,6 @@ export async function generate_pdf() { } export async function generate_md() { - const cfg = JSON.parse(await Deno.readTextFile("config.json")); try { for (const config of cfg.settings) { const builder = new DocuBuilder(config); @@ -42,8 +40,6 @@ export async function generate_md() { } export async function generate_txt() { - const cfg = JSON.parse(await Deno.readTextFile("config.json")); - try { for (const config of cfg.settings) { const builder = new DocuBuilder(config); @@ -65,7 +61,7 @@ export async function generate_txt() { } export async function add_index_to_pdf(insert_index_after_page: number = 1) { - const config = JSON.parse(await Deno.readTextFile("config.json")); + const config = cfg; for (const cfg of config.settings) { console.log(`Adding index to PDF ${cfg.playwright.path}...`); @@ -104,7 +100,7 @@ export async function add_index_to_pdf(insert_index_after_page: number = 1) { } export async function use_qpdf() { - const config = JSON.parse(await Deno.readTextFile("config.json")); + const config = cfg; for (const cfg of config.settings) { if (cfg.pdf.use_qpdf?.enabled) { console.log(`Using qpdf to linearize PDF ${cfg.playwright.path}...`); @@ -148,7 +144,7 @@ export async function use_qpdf() { } export async function sign_pdf(passphrase?: string) { - const config = JSON.parse(await Deno.readTextFile("config.json")); + const config = cfg; for (const cfg of config.settings) { if (cfg.pdf.signing?.enabled) { console.log(`Signing PDF ${cfg.playwright.path}...`); diff --git a/tools/gp/config.json b/tools/gp/config.json index a6a4db7..03e1b4c 100644 --- a/tools/gp/config.json +++ b/tools/gp/config.json @@ -16,7 +16,7 @@ }, "signing": { "enabled": true, - "key_path": "./private_key.asc", + "key_path": "~/keys/中国马列毛主义统一战线_0x874AD0D3_SECRET.asc", "output_path": "./outputs/工农解放报RSF续刊第一期-适合手机阅读.pdf.sig" } }, @@ -53,7 +53,7 @@ }, "signing": { "enabled": true, - "key_path": "./private_key.asc", + "key_path": "~/keys/中国马列毛主义统一战线_0x874AD0D3_SECRET.asc", "output_path": "./outputs/工农解放报RSF续刊第一期-适合电脑阅读.pdf.sig" } }, @@ -91,7 +91,7 @@ }, "signing": { "enabled": true, - "key_path": "./private_key.asc", + "key_path": "~/keys/中国马列毛主义统一战线_0x874AD0D3_SECRET.asc", "output_path": "./outputs/工农解放报RSF续刊第一期-适合纸质打印.pdf.sig" } }, diff --git a/tools/gp/main.ts b/tools/gp/main.ts index 18321bc..f7589e0 100644 --- a/tools/gp/main.ts +++ b/tools/gp/main.ts @@ -7,6 +7,24 @@ export const cfg = await Deno.readTextFile("./config.json").then((text) => JSON.parse(text) ); +const homeDir = Deno.env.get("HOME") || Deno.env.get("USERPROFILE"); +for (const config of cfg.settings) { + if (config.journal.from_directory.startsWith("~/")) { + config.journal.from_directory = config.journal.from_directory.replace( + "~", + homeDir || "", + ); + } + if (config.pdf.signing.enabled) { + if (config.pdf.signing.key_path.startsWith("~/")) { + config.pdf.signing.key_path = config.pdf.signing.key_path.replace( + "~", + homeDir || "", + ); + } + } +} + if (import.meta.main) { await match_sub_command_to_function( args._ as Array,