-
-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move generate script language and year config to JSON (#867)
* Improve Ebook generation * Generalise generate chapters for multi-years * Make ebook generation dynamic * Code cleanup
- Loading branch information
1 parent
7b55230
commit 21201ff
Showing
13 changed files
with
170 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
const fs = require('fs-extra'); | ||
const { exec } = require("child_process"); | ||
|
||
const { find_config_files } = require('./shared'); | ||
|
||
const generate_ebook_pdfs = async () => { | ||
|
||
let configs = {}; | ||
let ebook_languages = {}; | ||
|
||
// Read all the config files | ||
for (const config_file of await find_config_files()) { | ||
const re = (process.platform != 'win32') | ||
? /config\/([0-9]*).json/ | ||
: /config\\([0-9]*).json/; | ||
const [path,year] = config_file.match(re); | ||
|
||
configs[year] = JSON.parse(await fs.readFile(`config/${year}.json`, 'utf8')); | ||
ebook_languages[year] = configs[year].settings[0].ebook_languages | ||
|
||
} | ||
|
||
//Generate all the configured ebook pdfs | ||
for(let year in ebook_languages) { | ||
console.log('Ebooks configured for',year, ':',ebook_languages[year]); | ||
ebook_languages[year].forEach((language) => { | ||
console.log('Generating ebook for',year,language); | ||
const command = `prince http://127.0.0.1:8080/${language}/${year}/ebook?print -o static/pdfs/web_almanac_${year}_${language}.pdf --pdf-profile='PDF/UA-1'`; | ||
exec (command, (err, stdout, stderr) => { | ||
if (err) { | ||
//some err occurred | ||
console.error(err) | ||
} else { | ||
// the *entire* stdout and stderr (buffered) | ||
console.log(`stdout: ${stdout}`); | ||
console.log(`stderr: ${stderr}`); | ||
} | ||
}); | ||
}); | ||
} | ||
}; | ||
|
||
(async () => { | ||
// Can uncomment this to get latest timestamps from origin:master | ||
// let { generate_last_updated } = require('./generate_last_updated'); | ||
// await generate_last_updated(); | ||
|
||
await generate_ebook_pdfs(); | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters