mirror of
https://github.com/NohamR/pdfy.git
synced 2026-10-11 02:39:58 +00:00
Typo
This commit is contained in:
@@ -10,7 +10,7 @@ const READABILITY_PATH = path.join(EXTENSION_DIR, 'data/inject/Readability.js')
|
|||||||
export function checkExtension () {
|
export function checkExtension () {
|
||||||
if (!fs.existsSync(MANIFEST_PATH)) {
|
if (!fs.existsSync(MANIFEST_PATH)) {
|
||||||
logger.error(
|
logger.error(
|
||||||
`Extension not found at: ${EXTENSION_DIR}\n` +
|
`Extension not found at: "${EXTENSION_DIR}"\n` +
|
||||||
'Please extract the extension first:\n' +
|
'Please extract the extension first:\n' +
|
||||||
' mkdir -p extension/reader-view\n' +
|
' mkdir -p extension/reader-view\n' +
|
||||||
' unzip extension/Reader-View-Chrome-Web-Store.zip -d extension/reader-view'
|
' unzip extension/Reader-View-Chrome-Web-Store.zip -d extension/reader-view'
|
||||||
@@ -19,7 +19,7 @@ export function checkExtension () {
|
|||||||
}
|
}
|
||||||
if (!fs.existsSync(READABILITY_PATH)) {
|
if (!fs.existsSync(READABILITY_PATH)) {
|
||||||
logger.error(
|
logger.error(
|
||||||
`Readability.js not found at: ${READABILITY_PATH}\n` +
|
`Readability.js not found at: "${READABILITY_PATH}"\n` +
|
||||||
'The extension may be incomplete. Please re-extract it.'
|
'The extension may be incomplete. Please re-extract it.'
|
||||||
)
|
)
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
@@ -35,7 +35,7 @@ export function getExtensionDir () {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export async function launchBrowser () {
|
export async function launchBrowser () {
|
||||||
logger.debug(`Launching browser with extension: ${EXTENSION_DIR}`)
|
logger.debug(`Launching browser with extension: "${EXTENSION_DIR}"`)
|
||||||
const browser = await puppeteer.launch({
|
const browser = await puppeteer.launch({
|
||||||
headless: true,
|
headless: true,
|
||||||
ignoreDefaultArgs: [
|
ignoreDefaultArgs: [
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ export function loadPreferences (prefsPath) {
|
|||||||
try {
|
try {
|
||||||
return JSON.parse(fs.readFileSync(prefsPath, 'utf-8'))
|
return JSON.parse(fs.readFileSync(prefsPath, 'utf-8'))
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.warn(`Warning: could not parse preferences file: ${prefsPath}`)
|
logger.warn(`Warning: could not parse preferences file: "${prefsPath}"`)
|
||||||
return {}
|
return {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ async function main () {
|
|||||||
customCss = readCustomCss(path.resolve(opts.css))
|
customCss = readCustomCss(path.resolve(opts.css))
|
||||||
if (customCss !== null) {
|
if (customCss !== null) {
|
||||||
preferences['user-css'] = customCss
|
preferences['user-css'] = customCss
|
||||||
logger.info(`Custom CSS loaded: ${path.resolve(opts.css)}`)
|
logger.info(`Custom CSS loaded: "${path.resolve(opts.css)}"`)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,7 +72,7 @@ async function main () {
|
|||||||
try {
|
try {
|
||||||
const extId = await discoverExtensionId(browser)
|
const extId = await discoverExtensionId(browser)
|
||||||
|
|
||||||
logger.info(`Fetching article: ${url}`)
|
logger.info(`Fetching article: "${url}"`)
|
||||||
const articlePage = await browser.newPage()
|
const articlePage = await browser.newPage()
|
||||||
await articlePage.goto(url, { waitUntil: 'networkidle0', timeout: 30000 })
|
await articlePage.goto(url, { waitUntil: 'networkidle0', timeout: 30000 })
|
||||||
let article = await extractArticle(articlePage, getReadabilityPath())
|
let article = await extractArticle(articlePage, getReadabilityPath())
|
||||||
@@ -86,11 +86,11 @@ async function main () {
|
|||||||
const resolvedPath = path.resolve(htmlPath)
|
const resolvedPath = path.resolve(htmlPath)
|
||||||
|
|
||||||
if (!fs.existsSync(resolvedPath)) {
|
if (!fs.existsSync(resolvedPath)) {
|
||||||
logger.error(`File not found: ${resolvedPath}`)
|
logger.error(`File not found: "${resolvedPath}"`)
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.info(`Loading article from local file: ${resolvedPath}`)
|
logger.info(`Loading article from local file: "${resolvedPath}"`)
|
||||||
await articlePage.goto(`file://${resolvedPath}`, { waitUntil: 'networkidle0', timeout: 30000 })
|
await articlePage.goto(`file://${resolvedPath}`, { waitUntil: 'networkidle0', timeout: 30000 })
|
||||||
article = await extractArticle(articlePage, getReadabilityPath())
|
article = await extractArticle(articlePage, getReadabilityPath())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ export function enhanceHtml (html, customCss) {
|
|||||||
|
|
||||||
export async function generatePdf (page, html, outputPath) {
|
export async function generatePdf (page, html, outputPath) {
|
||||||
await page.setContent(html, { waitUntil: 'networkidle0' })
|
await page.setContent(html, { waitUntil: 'networkidle0' })
|
||||||
logger.info(`Generating PDF: ${outputPath}`)
|
logger.info(`Generating PDF: "${outputPath}"`)
|
||||||
await page.pdf({
|
await page.pdf({
|
||||||
path: outputPath,
|
path: outputPath,
|
||||||
format: 'A4',
|
format: 'A4',
|
||||||
@@ -55,5 +55,5 @@ export async function generatePdf (page, html, outputPath) {
|
|||||||
right: '0mm'
|
right: '0mm'
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
logger.info(`PDF saved: ${outputPath}`)
|
logger.info(`PDF saved: "${outputPath}"`)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ export async function extractArticle (page, readabilityPath) {
|
|||||||
throw new Error('Failed to extract article content with Readability')
|
throw new Error('Failed to extract article content with Readability')
|
||||||
}
|
}
|
||||||
logger.info(
|
logger.info(
|
||||||
`Extracted article: ${article.title} (${article.length} chars, reading ${article.readingTimeMinsFast}-${article.readingTimeMinsSlow} min` +
|
`Extracted article: '${article.title}' (${article.length} chars, reading ${article.readingTimeMinsFast}-${article.readingTimeMinsSlow} min` +
|
||||||
(article.published_time ? `, ${article.published_time}` : '') +
|
(article.published_time ? `, ${article.published_time}` : '') +
|
||||||
')'
|
')'
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user