释出修订版
This commit is contained in:
1 parent
6ec5e1404f
commit
d382ea563f
5 files changed
+29
-15
No files matched your search
@@ -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}...`);
|
||||
|
||||
@@ -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"
|
||||
}
|
||||
},
|
||||
|
||||
@@ -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<string>,
|
||||
|
||||
Reference in new issue
Block a user