diff --git a/config.json b/config.json index d5b46f1..59aa117 100644 --- a/config.json +++ b/config.json @@ -75,6 +75,8 @@ "Github": "gray", "Steam": "lightgray", "Univerter": "rgb(200, 175, 255)", - "Ko-fi": "rgb(255, 150, 150)" + "Ko-fi": "rgb(255, 150, 150)", + "Revolt": "rgb(255, 50, 50)", + "Discord": "rgb(150, 150, 255)" } } \ No newline at end of file diff --git a/index.js b/index.js index 2361b03..5f38520 100644 --- a/index.js +++ b/index.js @@ -11,7 +11,6 @@ const PORT = process.env.PORT || 8080 const staticpath = path.join(__dirname, 'static') var mostRecentVideo = undefined -var lanyardData = undefined var config = JSON.parse(fs.readFileSync(path.join(__dirname, 'config.json'))) @@ -39,38 +38,17 @@ app.listen(PORT, () => { console.log("Violet's Purgatory is now listening on port: " + PORT) }) -if (!fs.existsSync(path.join(staticpath, 'cached'))) { - fs.mkdirSync(path.join(staticpath, 'cached')) -} +var cachePath = path.join(staticpath, 'cached') +var imgPath = path.join(staticpath, 'imgs') -var randomQuotes = config.quotes - -var commitCount = "300+" - -function timeFormatter(seconds) { - seconds = Math.ceil(seconds) - var minutes = Math.floor(seconds / 60) - - if (seconds % 60 < 10) { - return `${minutes}:0${seconds % 60}` - } else { - return `${minutes}:${seconds % 60}` +if (!fs.existsSync(cachePath)) { + fs.mkdirSync(cachePath) +} else { + var files = fs.readdirSync(cachePath) + for (let index = 0; index < files.length; index++) { + const file = files[index]; + fs.rmSync(path.join(cachePath, file)) } - -} - -function gameTimeFormatter(seconds) { - seconds = Math.ceil(seconds) - var minutes = Math.ceil(seconds / 60) - var hours = Math.floor(minutes / 60) - if (seconds <= 60) { - return 'about ' + seconds + ' seconds' - } else if (minutes < 60) { - return `${minutes} Minutes` - } - - return `${hours} hours and ${minutes % 60} minutes` - } app.use(pageUpdater.middleWare) \ No newline at end of file diff --git a/overcomplicatedStatuses.js b/overcomplicatedStatuses.js new file mode 100644 index 0000000..b9a57d1 --- /dev/null +++ b/overcomplicatedStatuses.js @@ -0,0 +1,195 @@ +const path = require("path") + +function get_img_url(activity, size = "large_image") { + + if ("assets" in activity) { + var image = activity.assets[size] + + if (image) { + if (image.includes("https/")) { + return decodeURIComponent('https://' + image.substr(image.indexOf('https/') + 6, image.length)) + } else if (image.includes("spotify")) { + return decodeURIComponent('https://i.scdn.co/image/' + image.substr(image.indexOf('spotify:') + 8, image.length)) + } else { + return decodeURIComponent(`https://cdn.discordapp.com/app-assets/${activity.application_id}/${image}.png`) + } + } + } + + if (!image) { + if (activity.name in activityImages) { + return decodeURIComponent(activityImages[activity.name]) + } else { + return null + } + } +} + + +function timeFormatter(seconds) { + seconds = Math.ceil(seconds) + var minutes = Math.floor(seconds / 60) + + if (seconds % 60 < 10) { + return `${minutes}:0${seconds % 60}` + } else { + return `${minutes}:${seconds % 60}` + } + +} + +function gameTimeFormatter(seconds) { + seconds = Math.ceil(seconds) + var minutes = Math.ceil(seconds / 60) + var hours = Math.floor(minutes / 60) + if (seconds <= 60) { + return 'about ' + seconds + ' seconds' + } else if (minutes < 60) { + return `${minutes} Minutes` + } + + return `${hours} hours and ${minutes % 60} minutes` + +} + +module.exports = { + activitiesToHTML: (lanyardData, cachedImages) => { + var debounce = false + var addedHTML = "" + + if (lanyardData && lanyardData.activities.length > 0) { + for (let index = 0; index < lanyardData.activities.length; index++) { + const activity = lanyardData.activities[index]; + + var found = false + for (let index = 0; index < lanyardData.activities.length; index++) { + const act = lanyardData.activities[index] + if (act.name == activity.name) { + if (Object.keys(act).length > Object.keys(activity).length) { + found = true + } + } + } + if (found) { + continue + } + + if (!debounce && activity.type != 4) { + addedHTML += `


What I'm up to:

` + debounce = true + } + + + function get_img(activity, size = "large_image") { + if (cachedImages[get_img_url(activity, size)]) { + var fn = cachedImages[get_img_url(activity, size)] + var fp = path.join(__dirname, 'static/cached', fn) + } else { + return 'imgs/notFound.png' + } + + return '/cached/' + fn + } + + function songStats() { + var html = `` + + if (activity.assets && activity.assets.large_text != activity.details) { + html += ` +
Album: ${activity.assets.large_text || " "} +
Artist: ${activity.state || " "} + ` + } else { + html += `
Artist: ${activity.state || " "}` + } + + return html + } + if (activity.type == 2) { + var timeLeft = Math.round((activity.timestamps.end - Date.now()) / 1000) + var currentPercent = (Date.now() - activity.timestamps.start) / (activity.timestamps.end - activity.timestamps.start) * 100 + addedHTML += ` +
+ +

+ Listening to ${activity.name} +
Song: ${activity.details || " "} + ${songStats()} +
+ + ${timeFormatter((activity.timestamps.end - activity.timestamps.start) / 1000)} +

+
+ + ` + } else if (activity.type == 0) { + var time = activity.created_at + if (activity.timestamps) { + time = activity.timestamps.start + } + if (!activity.assets) { + activity.assets = { "large_text": " ", "small_text": " " } + } + + function smch() { + if (get_img_url(activity, "small_image")) { + return `` + } + return "" + } + + + addedHTML += ` +
+ + ${smch()} +

+ Playing ${activity.name} +
${(activity.details || activity.assets.large_text || " ")} +
${(activity.state || activity.assets.small_text || " ")} +
${gameTimeFormatter((Date.now() - time) / 1000)} +

+
+ ` + } else if (activity.type != 4) { + var time = activity.created_at + if (activity.timestamps) { + time = activity.timestamps.start + } + if (!activity.assets) { + activity.assets = { "large_text": " ", "small_text": " " } + } + + addedHTML += ` +
+ +

+ ${activity.name} +
${(activity.details || activity.assets.large_text || " ")} +
${(activity.state || activity.assets.small_text || " ")} +
${gameTimeFormatter((Date.now() - time) / 1000)} +

+
+ ` + } + } + } + return addedHTML + "
" + } +} \ No newline at end of file diff --git a/pageUpdater.js b/pageUpdater.js index 3ec5451..2f91687 100644 --- a/pageUpdater.js +++ b/pageUpdater.js @@ -1,7 +1,8 @@ const path = require('path'), fs = require('fs'), WebSocket = require('ws'), - minify = require('minify-html') + minify = require('minify-html'), + activityToHTML = require("./overcomplicatedStatuses.js") var config = JSON.parse(fs.readFileSync(path.join(__dirname, 'config.json'))) @@ -16,30 +17,6 @@ var lanyardData = undefined var uptime = Date.now() function converter(html) { - if (lanyardData) { - var statusData = config.discStatuses[lanyardData.discord_status] - } else { - var statusData = config.discStatuses.offline - } - var replacers = { - "COMMIT_COUNT": commitCount, - "RANDOM_QUOTE": quotes[Math.floor(Math.random() * quotes.length)], - "QUOTE_COUNT": quotes.length, - "RANDOM_TITLE": titles[Math.floor(Math.random() * titles.length)], - "DISCORD_STATUS": - `${statusData.text}` + - ``, - "UPTIME": uptime, - "TOPBAR": `

Socials

` - } - - var rpTable = Object.keys(replacers) - - for (let index = 0; index < rpTable.length; index++) { - const text = rpTable[index]; - html = html.replaceAll(`{${text}}`, replacers[text]) - } - while (html.includes("{PATH_")) { var pagePath = html.substring(html.indexOf("{PATH_")) pagePath = pagePath.substring(6, pagePath.indexOf('}')) @@ -52,6 +29,42 @@ function converter(html) { html = html.replace(stringIndex, pageHTML) } + var statusText = "" + + if (lanyardData) { + var statusData = config.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 username = "bingus_violet" + } + + var replacers = { + "COMMIT_COUNT": commitCount, + "RANDOM_QUOTE": quotes[Math.floor(Math.random() * quotes.length)], + "QUOTE_COUNT": quotes.length, + "RANDOM_TITLE": titles[Math.floor(Math.random() * titles.length)], + "DISCORD_STATUS": + `${statusData.text}` + + ``, + "UPTIME": uptime, + "TOPBAR": `

Socials

`, + "DISCORD_USER": username, + "CUSTOM_STATUS": statusText, + "ACTIVITIES": activityToHTML.activitiesToHTML(lanyardData, cachedImages) + } + + var rpTable = Object.keys(replacers) + + for (let index = 0; index < rpTable.length; index++) { + const text = rpTable[index]; + html = html.replaceAll(`{${text}}`, replacers[text]) + } + var bodyHTML = html.substring(html.indexOf("") + 6, html.lastIndexOf("")) var highTable = Object.keys(highlightedWords) for (let index = 0; index < highTable.length; index++) { @@ -73,6 +86,14 @@ module.exports = { var filePath = (req.baseUrl + req.path).trim() + if (filePath.includes("cached") || filePath.includes("imgs")) { + filePath = path.join(__dirname, 'static', filePath) + console.log(filePath) + res.send(fs.readFileSync(filePath)) + + return + } + if (filePath.includes(".")) { } else { diff --git a/static/imgs/notFound.png b/static/imgs/notFound.png new file mode 100644 index 0000000..a750080 Binary files /dev/null and b/static/imgs/notFound.png differ diff --git a/static/index.html b/static/index.html index a4bba37..7002f55 100644 --- a/static/index.html +++ b/static/index.html @@ -25,7 +25,7 @@

{RANDOM_QUOTE}

-

Violet

+

{Violet}

@@ -34,23 +34,19 @@

{DISCORD_STATUS}

- Donate (Ko-fi) -
-

Hi! I'm Violet, a 15 year old web and game developer.
I aspire to make fast and Javascript free websites! I'm currently learning the Godot Engine, and have been becoming quite fluent in NodeJS.

+
+
+

Hi! I'm Violet, a 15 year old web and game developer.
I aspire to make fast and Javascript free websites! I'm currently learning the Godot Engine, but most of my time recently has been spent learning NodeJS.

Beta site Blog Clipdump + {CUSTOM_STATUS}
+ {ACTIVITIES} -
-

Main Projects

- Univerter - {Steam}RPC - -
- -

Socials

+
+

Socials

{PATH_SOCIALS}
diff --git a/static/root.css b/static/root.css index c17de76..a1bf430 100644 --- a/static/root.css +++ b/static/root.css @@ -11,8 +11,8 @@ } #card { - background-color: rgb(75, 25, 100); - padding: 15px; + background-color: rgb(25, 5, 80); + padding: 15px 5px; border: 2px white solid; margin: 20px auto; width: 95%; @@ -43,6 +43,90 @@ border-radius: 50%; } +.activity { + border-width: 3px; + border-radius: 10px; + overflow: hidden; + margin: auto; + padding: 0; + display: flex; + position: relative; + z-index: 3; +} + +.activity>p { + width: 100%; + overflow-wrap: break-word; + padding: 5px; + justify-content: center; +} + +.activity>img { + width: 128px; + aspect-ratio: 1/1; + object-fit: cover; +} + +.activity>.smallimg { + width: 64px; + height: 64px; + position: absolute; + bottom: 0px; + left: 72px; + border-radius: 50px; + background: black; + padding: 5px; + /* border: 2px gray solid; */ + transform: scale(0.9); +} + +.activity>.smallimg:hover { + transform: scale(1); +} + +img:not(.project-inner > div > img) { + width: 100%; + max-width: 135px; + transition: all 2s cubic-bezier(0.075, 0.82, 0.165, 1); +} + +@media screen and (min-width: 750px) { + .activity-container { + display: grid; + grid-template-columns: 1fr 1fr; + grid-gap: 10px; + } + + .activity { + margin: auto; + width: 100%; + align-content: center; + /* border: 2px white solid; */ + } +} + +.lengthBar { + background-color: rgb(50, 40, 60); + display: inline-block; + width: 80%; + height: 10px; + padding: 0; + overflow: hidden; + border-radius: 5px; + margin-right: 1.9%; +} + +.lengthBar>span { + margin: 0; + padding: 0; + width: 100%; + background-color: rgb(200, 200, 230); + height: 20px; + display: block; + position: relative; +} + + @keyframes mainText { 0% { transform: translateY(calc(50vh - 6rem)) scale(1.5); diff --git a/static/socials/index.html b/static/socials/index.html index 39cb3d9..aca6bdb 100644 --- a/static/socials/index.html +++ b/static/socials/index.html @@ -23,44 +23,41 @@

Socials

+

Here's most of the sites you can find me on- if you needed that for some reason?

Chat

- Matrix: @bingus_violet:​catgirl.cloud + Matrix: @bingus_violet:​catgirl.cloud +

Discord: {DISCORD_USER}

+

Revolt: Bingus{Violet}#5573

+
+

Please note I am extremely unhinged and gay on Fedi, I don't use Github, and I barely understand Docker.

diff --git a/static/style.css b/static/style.css index 94631c4..de88965 100644 --- a/static/style.css +++ b/static/style.css @@ -40,7 +40,7 @@ transform: scale(1.05); } -#topbar > * { +#topbar>* { display: inline-block; font-size: 1.5rem; } @@ -83,7 +83,7 @@ h3 { grid-template-columns: 1fr 1fr; grid-gap: 10px; } - + .grid-child { margin: auto; align-content: center; @@ -91,8 +91,6 @@ h3 { } } - - .chip { position: relative; z-index: 3; @@ -129,8 +127,12 @@ h3 { } hr { - border: 2px gray solid; - margin: 20px; + color: white; + border: white solid; + opacity: 0.25; + border-width: 2px; + margin: 15px 10%; + /* background-color: none; */ } p {