Change old config to constants, add real conffig file, add daily video URLs.
This commit is contained in:
parent
710d7c237f
commit
8e703ecd3f
8 changed files with 46 additions and 18 deletions
3
.gitignore
vendored
3
.gitignore
vendored
|
@ -132,4 +132,5 @@ dist
|
|||
|
||||
# Violet's Purgatory
|
||||
static/cached
|
||||
cached
|
||||
cached
|
||||
config
|
3
assets/defaults/config.json
Normal file
3
assets/defaults/config.json
Normal file
|
@ -0,0 +1,3 @@
|
|||
{
|
||||
"dailyVideoURL": ""
|
||||
}
|
18
index.js
18
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")))
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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") {
|
||||
|
|
|
@ -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>
|
||||
|
||||
|
|
|
@ -30,4 +30,9 @@ body {
|
|||
transform: none;
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
|
||||
video {
|
||||
width: 95%;
|
||||
max-height: 90vh;
|
||||
}
|
Loading…
Reference in a new issue