poke/src/libpoketube/init/superinit.js

90 lines
2.2 KiB
JavaScript
Raw Normal View History

2022-11-16 11:26:47 +01:00
const {
fetcher,
core,
wiki,
musicInfo,
modules,
version,
initlog,
} = require("../libpoketube-initsys.js");
const {
IsJsonString,
convert,
getFirstLine,
capitalizeFirstLetter,
turntomins,
getRandomInt,
getRandomArbitrary,
} = require("../ptutils/libpt-coreutils.js");
const { api } = require("../init/pages-api.js");
2022-11-09 17:47:46 +01:00
function init(app, config, rendertemplate) {
initlog("Starting superinit");
2022-11-16 11:26:47 +01:00
2022-11-09 17:47:46 +01:00
initlog("[START] Load pages");
2022-11-16 11:26:47 +01:00
/* PokeTube Update daemon - checks for updates in poketube */
(async () => {
const url = `https://poketube.fun/api/version.json`;
let f = await modules
.fetch(url)
.then((res) => res.text())
.then((json) => JSON.parse(json));
2022-11-16 14:59:30 +01:00
if (f.vernum == api) {
2022-11-16 11:26:47 +01:00
console.log("[UPDATE DAEMON] PokeTube is up to date!");
}
2022-11-16 14:59:30 +01:00
if (f.vernum != api) {
2022-11-16 11:26:47 +01:00
console.warn(
"[UPDATE DAEMON] PokeTube is out of date! please re-clone the poketube repo :p "
);
}
})();
2022-11-13 11:06:29 +01:00
if (Math.random() < 0.5) {
2022-11-10 06:38:32 +01:00
initlog("https://poketube.fun/watch?v=lpiB2wMc49g");
}
2022-11-09 17:47:46 +01:00
try {
initlog("Loading video pages ");
require("../init/pages-video.js")(app, config, rendertemplate);
initlog("Loaded video pages ");
initlog("Loading redirects/old pages ");
require("../init/pages-redir.js")(app, config, rendertemplate);
2022-11-16 14:56:26 +01:00
initlog("Loaded redirects/old pages ");
2022-11-09 17:47:46 +01:00
initlog("Loading Download and channel pages");
require("../init/pages-channel-and-download.js")(
app,
config,
rendertemplate
);
initlog("Loaded Download and channel pages");
2022-11-13 11:06:29 +01:00
initlog("Loading api pages");
require("../init/pages-api.js")(app, config, rendertemplate);
2022-11-16 14:56:26 +01:00
initlog("Loaded api pages");
2022-11-13 11:06:29 +01:00
2022-11-09 17:47:46 +01:00
initlog("Loading static pages");
require("../init/pages-static.js")(app, config, rendertemplate);
2022-11-16 14:59:30 +01:00
initlog("Loaded static pages");
2022-11-09 17:47:46 +01:00
initlog("Loading main pages");
require("../init/pages-404-and-main.js")(app, config, rendertemplate);
2022-11-16 14:56:26 +01:00
initlog("Loaded main pages");
2022-11-09 17:47:46 +01:00
initlog("[OK] Load pages");
initlog("Loaded pages - initing poketube finnished :3");
2022-11-15 17:45:01 +01:00
} catch (err) {
initlog("[FAILED] Load pages \n" + err);
2022-11-09 17:47:46 +01:00
}
}
module.exports = {
sinit: init,
};