diff --git a/.gitignore b/.gitignore index 4b19e9e..17398b6 100644 --- a/.gitignore +++ b/.gitignore @@ -132,4 +132,5 @@ dist # Violet's Purgatory static/cached -cached \ No newline at end of file +cached +config \ No newline at end of file diff --git a/assets/defaults/config.json b/assets/defaults/config.json new file mode 100644 index 0000000..c004e68 --- /dev/null +++ b/assets/defaults/config.json @@ -0,0 +1,3 @@ +{ + "dailyVideoURL": "" +} \ No newline at end of file diff --git a/config.json b/constants.json similarity index 100% rename from config.json rename to constants.json diff --git a/index.js b/index.js index 969c2d3..045b9df 100644 --- a/index.js +++ b/index.js @@ -9,16 +9,26 @@ var app = express() const PORT = process.env.PORT || 8080 const staticpath = path.join(__dirname, 'static') +const cachePath = path.join(__dirname, 'cached') +const assetPath = path.join(__dirname, "assets") +const configPath = path.join(__dirname, 'config') -var config = JSON.parse(fs.readFileSync(path.join(__dirname, 'config.json'))) +const configFile = path.join(configPath, "config.json") + +if (!fs.existsSync(configPath)) { + fs.mkdirSync(configPath) +} + +if (!fs.existsSync(configFile)) { + fs.writeFileSync(configFile, fs.readFileSync(path.join(assetPath, "defaults/config.json"))) +} + +var constants = JSON.parse(fs.readFileSync(path.join(__dirname, 'constants.json'))) app.listen(PORT, () => { console.log("Violet's Purgatory is now listening on port: " + PORT) }) -var cachePath = path.join(__dirname, 'cached') -var assetPath = path.join(__dirname, "assets") - app.use("/fonts", express.static(path.join(assetPath, "fonts"))) app.use("/cached", express.static(cachePath)) app.use("/imgs", express.static(path.join(assetPath, "Images"))) diff --git a/overcomplicatedStatuses.js b/overcomplicatedStatuses.js index cc47964..5142ef1 100644 --- a/overcomplicatedStatuses.js +++ b/overcomplicatedStatuses.js @@ -1,9 +1,9 @@ const path = require("path"), fs = require("fs") -var config = JSON.parse(fs.readFileSync(path.join(__dirname, 'config.json'))) +var constants = JSON.parse(fs.readFileSync(path.join(__dirname, 'constants.json'))) -var activityImages = config.activityImages +var activityImages = constants.activityImages function get_img_url(activity, size = "large_image") { if ("assets" in activity) { diff --git a/pageUpdater.js b/pageUpdater.js index 860e52c..b44ea5c 100644 --- a/pageUpdater.js +++ b/pageUpdater.js @@ -3,13 +3,14 @@ const path = require('path'), WebSocket = require('ws'), minify = require('minify-html'), activityToHTML = require("./overcomplicatedStatuses.js") + // weatherGenerator = require("./weatherGenerator") -var config = JSON.parse(fs.readFileSync(path.join(__dirname, 'config.json'))) +var constants = JSON.parse(fs.readFileSync(path.join(__dirname, 'constants.json'))) -var highlightedWords = config.highlightedWords -var quotes = config.quotes -var titles = config.titles +var highlightedWords = constants.highlightedWords +var quotes = constants.quotes +var titles = constants.titles var globalSpins = 0 @@ -43,6 +44,7 @@ function timeFormatter(seconds) { } function converter(html, query) { + var config = JSON.parse(fs.readFileSync(path.join(__dirname, 'config/config.json'))) reloads += 1 var startTime = Date.now() while (html.includes("{PATH_")) { @@ -60,14 +62,14 @@ function converter(html, query) { var statusText = "" if (lanyardData) { - var statusData = config.discStatuses[lanyardData.discord_status] + var statusData = constants.discStatuses[lanyardData.discord_status] var username = lanyardData.discord_user.username if (lanyardData.activities[0] && lanyardData.activities[0].type == 4) { var statusText = `

${lanyardData.activities[0].state}

` } } else { - var statusData = config.discStatuses.offline + var statusData = constants.discStatuses.offline var username = "bingus_violet" } @@ -97,7 +99,14 @@ function converter(html, query) { "TOPBAR": `

Socials

`, "DISCORD_USER": username, "CUSTOM_STATUS": statusText, - "LATEST_YOUTUBE": "filler", + "SELECTED_VIDEO": () => { + if (config.dailyVideoURL) { + return `


Random video!

I would call it random daily video but its not at all daily...

+
+ ` + } + return `` + }, "SPINCOUNT": globalSpins, "UPTIME": timeFormatter((Date.now() - uptime) / 1000), "RELOAD_COUNT": reloads, @@ -206,7 +215,7 @@ updateCommits() var lastLanyardUpdate = Date.now() var lastPong = 0 -var activityImages = config.activityImages +var activityImages = constants.activityImages var cachedImages = {} function get_img_url(activity, size = "large_image") { diff --git a/static/socials/index.html b/static/socials/index.html index 3538906..53d5bc5 100644 --- a/static/socials/index.html +++ b/static/socials/index.html @@ -47,7 +47,7 @@

Coding

- Forgejo: https://git.violets-purgatory.dev/bingus_violet/ + Forgejo: bingus_violet (git.violets-purgatory.dev) Codeberg: bingus_violet Docker: bingusviolet Github: violets-puragtory @@ -62,11 +62,11 @@

-
+
{ACTIVITIES}
- {LASTEST_YOUTUBE} + {SELECTED_VIDEO}
diff --git a/static/subpage.css b/static/subpage.css index ab32dc8..79d1340 100644 --- a/static/subpage.css +++ b/static/subpage.css @@ -30,4 +30,9 @@ body { transform: none; opacity: 1; } +} + +video { + width: 95%; + max-height: 90vh; } \ No newline at end of file