Change old config to constants, add real conffig file, add daily video URLs.

This commit is contained in:
bingus_violet 2024-05-20 10:20:19 -05:00
parent 710d7c237f
commit 8e703ecd3f
8 changed files with 46 additions and 18 deletions

1
.gitignore vendored
View file

@ -133,3 +133,4 @@ dist
# Violet's Purgatory
static/cached
cached
config

View file

@ -0,0 +1,3 @@
{
"dailyVideoURL": ""
}

View file

@ -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")))

View file

@ -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) {

View file

@ -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 = `<hr><p>${lanyardData.activities[0].state}</p>`
}
} else {
var statusData = config.discStatuses.offline
var statusData = constants.discStatuses.offline
var username = "bingus_violet"
}
@ -97,7 +99,14 @@ function converter(html, query) {
"TOPBAR": `<div id="topbar"><h3><a href="/socials">Socials</a></h3></div>`,
"DISCORD_USER": username,
"CUSTOM_STATUS": statusText,
"LATEST_YOUTUBE": "filler",
"SELECTED_VIDEO": () => {
if (config.dailyVideoURL) {
return `<h2><hr>Random video!</h2><p>I would call it random <em>daily</em> video but its not at all daily...</p>
<br>
<video controls src="${config.dailyVideoURL}"></video>`
}
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") {

View file

@ -47,7 +47,7 @@
<div class="grid-child">
<div>
<h3>Coding</h3>
<a class="chip" href="https://git.violets-purgatory.dev/bingus_violet/">Forgejo: https://git.violets-purgatory.dev/bingus_violet/</a>
<a class="chip" href="https://git.violets-purgatory.dev/bingus_violet/">Forgejo: bingus_violet (git.violets-purgatory.dev)</a>
<a class="chip" href="https://codeberg.org/Bingus_violet">Codeberg: bingus_violet</a>
<a class="chip" href="https://hub.docker.com/u/bingusviolet">Docker: bingusviolet</a>
<a class="chip" href="https://github.com/violets-puragtory">Github: violets-puragtory</a>
@ -62,11 +62,11 @@
</div>
<br>
</main>
<div id="activityHTML">
<div id="activityHtml">
{ACTIVITIES}
</div>
{LASTEST_YOUTUBE}
{SELECTED_VIDEO}
</div>
</body>

View file

@ -31,3 +31,8 @@ body {
opacity: 1;
}
}
video {
width: 95%;
max-height: 90vh;
}