abridge update
Signed-off-by: Harald Hoyer <harald@hoyer.xyz>
This commit is contained in:
parent
03c1097fa3
commit
ee2611a5d7
|
@ -8,6 +8,9 @@ const util = require("util");
|
|||
const { exec } = require("child_process");
|
||||
const execPromise = util.promisify(exec);
|
||||
|
||||
if (!(fs.existsSync('config.toml'))) {
|
||||
throw new Error('ERROR: cannot find config.toml!');
|
||||
}
|
||||
const tomlString = String(fs.readFileSync('config.toml'));
|
||||
const data = TOML.parse(tomlString);
|
||||
const js_prestyle = data.extra.js_prestyle;
|
||||
|
@ -37,17 +40,23 @@ async function execWrapper(cmd) {
|
|||
console.log(stdout);
|
||||
}
|
||||
if (stderr) {
|
||||
console.log('Error: '+stderr);
|
||||
console.log('ERROR: '+stderr);
|
||||
}
|
||||
}
|
||||
|
||||
async function abridge() {
|
||||
if (offline === false) {
|
||||
if (typeof online_url !== 'undefined' && typeof online_indexformat !== 'undefined') {
|
||||
replace.sync({files: 'config.toml', from: /base_url.*=.*/g, to: "base_url = \""+online_url+"\""});
|
||||
replace.sync({files: 'config.toml', from: /index_format.*=.*/g, to: "index_format = \""+online_indexformat+"\""});
|
||||
}
|
||||
} else if (offline === true) {
|
||||
if (typeof online_url !== 'undefined' && typeof online_indexformat !== 'undefined') {
|
||||
replace.sync({files: 'config.toml', from: /base_url.*=.*/g, to: "base_url = \""+__dirname+"\/public\""});
|
||||
replace.sync({files: 'config.toml', from: /index_format.*=.*/g, to: "index_format = \"elasticlunr_javascript\""});
|
||||
} else {
|
||||
throw new Error('ERROR: offline = true requires that online_url and online_indexformat are set in config.toml, so that the base_url and index_format can be restored if offline is later set to false.');
|
||||
}
|
||||
}
|
||||
|
||||
console.log('Zola Build to generate files for minification:');
|
||||
|
@ -105,6 +114,7 @@ async function abridge() {
|
|||
}
|
||||
|
||||
if (pwa) {// Update pwa settings, file list, and hashes.
|
||||
if (typeof pwa_VER !== 'undefined' && typeof pwa_NORM_TTL !== 'undefined' && typeof pwa_LONG_TTL !== 'undefined' && typeof pwa_TTL_NORM !== 'undefined' && typeof pwa_TTL_LONG !== 'undefined' && typeof pwa_TTL_EXEMPT !== 'undefined') {
|
||||
// update from abridge theme.
|
||||
fs.copyFileSync(bpath+'static/sw.js', 'static/sw.js');
|
||||
fs.copyFileSync(bpath+'static/js/sw_load.js', 'static/js/sw_load.js');
|
||||
|
@ -124,7 +134,8 @@ async function abridge() {
|
|||
replace.sync({files: 'static/sw.js', from: /TTL_EXEMPT.*=.*/g, to: "TTL_EXEMPT = ["+pwa_TTL_EXEMPT+"];"});
|
||||
}
|
||||
|
||||
if (pwa_cache_all) {
|
||||
if (pwa_cache_all === true) {
|
||||
console.log('info: pwa_cache_all = true in config.toml, so caching the entire site.\n');
|
||||
// Generate array from the list of files, for the entire site.
|
||||
|
||||
var dir = 'public';
|
||||
|
@ -163,6 +174,9 @@ async function abridge() {
|
|||
to: cache,
|
||||
countMatches: true,
|
||||
});
|
||||
} else {
|
||||
throw new Error('ERROR: pwa requires that pwa_VER, pwa_NORM_TTL, pwa_LONG_TTL, pwa_TTL_NORM, pwa_TTL_LONG, pwa_TTL_EXEMPT are set in config.toml.');
|
||||
}
|
||||
}
|
||||
|
||||
if (bpath === '') {// abridge used directly
|
||||
|
|
Loading…
Reference in a new issue