From 87351361f00504c71aa467e1247a0d6720e404d6 Mon Sep 17 00:00:00 2001 From: Minteck Date: Fri, 22 Jul 2022 12:04:14 +0200 Subject: New pages and stuff, with @CloudburstSys --- data/projects.json | 51 +++++++++++++++ index.js | 43 ++++++++++++- package-lock.json | 26 +++++++- package.json | 3 +- public/assets/.DS_Store | Bin 6148 -> 6148 bytes public/assets/about.css | 44 +++++++++++++ public/assets/custom.css | 6 +- public/assets/favicon.png | Bin 0 -> 7372 bytes public/assets/languages/csharp.svg | 1 + public/assets/languages/html.svg | 13 ++++ public/assets/languages/javascript.svg | 4 ++ public/assets/languages/kotlin.svg | 8 +++ public/assets/languages/php.svg | 96 ++++++++++++++++++++++++++++ public/assets/languages/python.svg | 113 +++++++++++++++++++++++++++++++++ public/assets/languages/typescript.svg | 6 ++ public/assets/plurality.css | 29 +++++++++ public/assets/projects.css | 45 +++++++++++++ views/about.ejs | 18 +++++- views/broken.ejs | 31 +++++++++ views/error.ejs | 64 +++++++++++++++++++ views/partials/header.ejs | 3 + views/plurality.ejs | 23 ++++++- views/projects.ejs | 16 +++-- views/servers.ejs | 2 + 24 files changed, 629 insertions(+), 16 deletions(-) create mode 100644 data/projects.json create mode 100644 public/assets/about.css create mode 100644 public/assets/favicon.png create mode 100644 public/assets/languages/csharp.svg create mode 100644 public/assets/languages/html.svg create mode 100644 public/assets/languages/javascript.svg create mode 100644 public/assets/languages/kotlin.svg create mode 100644 public/assets/languages/php.svg create mode 100644 public/assets/languages/python.svg create mode 100644 public/assets/languages/typescript.svg create mode 100644 public/assets/projects.css create mode 100644 views/broken.ejs create mode 100644 views/error.ejs diff --git a/data/projects.json b/data/projects.json new file mode 100644 index 0000000..c2b895d --- /dev/null +++ b/data/projects.json @@ -0,0 +1,51 @@ +[ + { + "id": "00001", + "name": "Test C# project", + "language": "csharp", + "description": "This is a description!", + "url": "https://example.com/" + }, + { + "id": "00002", + "name": "Test HTML project", + "language": "html", + "description": "This is a description!", + "url": "https://example.com/" + }, + { + "id": "00003", + "name": "Test JavaScript project", + "language": "javascript", + "description": "This is a description!", + "url": "https://example.com/" + }, + { + "id": "00004", + "name": "Test Kotlin project", + "language": "kotlin", + "description": "This is a description!", + "url": "https://example.com/" + }, + { + "id": "00005", + "name": "Test PHP project", + "language": "php", + "description": "This is a description!", + "url": "https://example.com/" + }, + { + "id": "00006", + "name": "Test Python project", + "language": "python", + "description": "This is a description!", + "url": "https://example.com/" + }, + { + "id": "00006", + "name": "Test TypeScript project", + "language": "typescript", + "description": "This is a description!", + "url": "https://example.com/" + } +] \ No newline at end of file diff --git a/index.js b/index.js index 73a35c3..bd66ffb 100644 --- a/index.js +++ b/index.js @@ -31,7 +31,23 @@ const fs = require('fs'); const app = express(); // Get version and build numbers -const version = (fs.existsSync("./.git/refs/heads/mane") ? fs.readFileSync("./.git/refs/heads/mane").toString().trim().substring(0, 8) : (fs.existsSync("../.git/refs/heads/mane") ? fs.readFileSync("../.git/refs/heads/mane").toString().trim().substring(0, 8) : (fs.existsSync("./version.txt") ? fs.readFileSync("./version.txt").toString().trim() : (fs.existsSync("../version.txt") ? fs.readFileSync("../version.txt").toString().trim().substring(0, 8) : "live")))); +const version = (fs.existsSync("./.git/refs/heads/mane") + ? + fs.readFileSync("./.git/refs/heads/mane").toString().trim().substring(0, 8) + : + (fs.existsSync("../.git/refs/heads/mane") + ? + fs.readFileSync("../.git/refs/heads/mane").toString().trim().substring(0, 8) + : + (fs.existsSync("./version.txt") + ? + fs.readFileSync("./version.txt").toString().trim().substring(0, 8) + : + (fs.existsSync("../version.txt") + ? + fs.readFileSync("../version.txt").toString().trim().substring(0, 8) + : + "live")))); const build = (fs.existsSync("./build.txt") ? fs.readFileSync("./build.txt").toString().trim() : (fs.existsSync("../build.txt") ? fs.readFileSync("../build.txt").toString().trim() : "dev")); // Restart manager @@ -53,6 +69,10 @@ app.get('/servers', (req, res) => { res.render("servers", { serverCache, version, build }); }); +app.get('/broken', (req, res) => { + res.render("broken", { serverCache, version, build }); +}); + app.get("/plurality", (req, res) => { res.render("plurality", { pluralCache, version, build }); }); @@ -62,12 +82,13 @@ app.get("/about", (req, res) => { }); app.get("/projects", (req, res) => { - res.render("projects", { version, build }); + res.render("projects", { projectCache, version, build }); }); // API let serverCache = {}; let pluralCache = {}; +let projectCache = JSON.parse(fs.readFileSync(__dirname + "/data/projects.json").toString()); app.get("/api/servers", (req, res) => { res.json(serverCache); @@ -77,6 +98,10 @@ app.get("/api/plural", (req, res) => { res.json(pluralCache); }); +app.get("/api/projects", (req, res) => { + res.json(projectCache); +}); + // Refresh handling const refresh = require('./refresh/servers'); const pkRefresh = require('./refresh/pluralkit'); @@ -84,6 +109,7 @@ setInterval(cacheReload, 300000); function cacheReload() { console.log("Running refresh..."); + projectCache = JSON.parse(fs.readFileSync(__dirname + "/data/projects.json").toString()); refresh().then(data => { console.log("Refresh halfway done!"); serverCache = data; @@ -104,4 +130,15 @@ const server = app.listen(8099, function () { console.log("Vapor Trail server listening at http://%s:%s", host, port) cacheReload(); -}) \ No newline at end of file +}) + +// Error handling +app.use((req, res) => { + res.status(404); + res.render("error", { code: '404', message: 'What are you even looking for?', version, build, process, req, UAParser: require('ua-parser-js') }); +}) + +app.use(function(err, req, res, next) { + res.status(500); + res.render("error", { err, code: '500', message: 'Things went pretty downhill.', version, build, process, req, UAParser: require('ua-parser-js') }); +}); \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 9655bca..bb782c8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -14,7 +14,8 @@ "ejs": "^3.1.8", "express": "^4.18.1", "multer": "^1.4.4", - "superagent": "^7.1.3" + "superagent": "^7.1.3", + "ua-parser-js": "^1.0.2" } }, "node_modules/accepts": { @@ -1118,6 +1119,24 @@ "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=" }, + "node_modules/ua-parser-js": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-1.0.2.tgz", + "integrity": "sha512-00y/AXhx0/SsnI51fTc0rLRmafiGOM4/O+ny10Ps7f+j/b8p/ZY11ytMgznXkOVo4GQ+KwQG5UQLkLGirsACRg==", + "funding": [ + { + "type": "opencollective", + "url": "https://opencollective.com/ua-parser-js" + }, + { + "type": "paypal", + "url": "https://paypal.me/faisalman" + } + ], + "engines": { + "node": "*" + } + }, "node_modules/unpipe": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", @@ -2019,6 +2038,11 @@ "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=" }, + "ua-parser-js": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/ua-parser-js/-/ua-parser-js-1.0.2.tgz", + "integrity": "sha512-00y/AXhx0/SsnI51fTc0rLRmafiGOM4/O+ny10Ps7f+j/b8p/ZY11ytMgznXkOVo4GQ+KwQG5UQLkLGirsACRg==" + }, "unpipe": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", diff --git a/package.json b/package.json index bc1968f..d94f580 100644 --- a/package.json +++ b/package.json @@ -18,6 +18,7 @@ "ejs": "^3.1.8", "express": "^4.18.1", "multer": "^1.4.4", - "superagent": "^7.1.3" + "superagent": "^7.1.3", + "ua-parser-js": "^1.0.2" } } diff --git a/public/assets/.DS_Store b/public/assets/.DS_Store index 593c8ec..eec69f5 100644 Binary files a/public/assets/.DS_Store and b/public/assets/.DS_Store differ diff --git a/public/assets/about.css b/public/assets/about.css new file mode 100644 index 0000000..ea26034 --- /dev/null +++ b/public/assets/about.css @@ -0,0 +1,44 @@ +/* + * MIT License + * + * Copyright (c) 2022- Equestria.dev Developers + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +.section { + display: block; + background-color: #353535; + border: 1px solid #353535; + border-radius: 10px; + padding: 10px; + margin-bottom: 10px; +} + +.section .section-title { + color: white !important; + text-decoration: none; + font-size: 1.17em; + font-weight: bold; +} + +.section .section-content { + margin-bottom: 0; +} \ No newline at end of file diff --git a/public/assets/custom.css b/public/assets/custom.css index 487bd25..64f9903 100644 --- a/public/assets/custom.css +++ b/public/assets/custom.css @@ -107,7 +107,7 @@ html, body { margin-top: 56px; } -.server, .plural-member { +.server, .plural-member, .project { border-style: solid; border-color: #303030; border-radius: 10px; @@ -116,13 +116,13 @@ html, body { margin: 5px; } -.server .name { +.server .name, .project .project-name { border-style: none none solid none; border-color: #303030; padding: 5px; } -.server p { +.server p, .project .project-description { margin-left: 5px; } diff --git a/public/assets/favicon.png b/public/assets/favicon.png new file mode 100644 index 0000000..b6b087b Binary files /dev/null and b/public/assets/favicon.png differ diff --git a/public/assets/languages/csharp.svg b/public/assets/languages/csharp.svg new file mode 100644 index 0000000..8e43620 --- /dev/null +++ b/public/assets/languages/csharp.svg @@ -0,0 +1 @@ +logo_Csharp \ No newline at end of file diff --git a/public/assets/languages/html.svg b/public/assets/languages/html.svg new file mode 100644 index 0000000..fbd31bf --- /dev/null +++ b/public/assets/languages/html.svg @@ -0,0 +1,13 @@ + + + + + + + diff --git a/public/assets/languages/javascript.svg b/public/assets/languages/javascript.svg new file mode 100644 index 0000000..9650ca7 --- /dev/null +++ b/public/assets/languages/javascript.svg @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/public/assets/languages/kotlin.svg b/public/assets/languages/kotlin.svg new file mode 100644 index 0000000..cd57db1 --- /dev/null +++ b/public/assets/languages/kotlin.svg @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/public/assets/languages/php.svg b/public/assets/languages/php.svg new file mode 100644 index 0000000..e4f137c --- /dev/null +++ b/public/assets/languages/php.svg @@ -0,0 +1,96 @@ + + + Official PHP Logo + + + + image/svg+xml + + Official PHP Logo + + + Colin Viebrock + + + + + + + + + + + + Copyright Colin Viebrock 1997 - All rights reserved. + + + 1997 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/public/assets/languages/python.svg b/public/assets/languages/python.svg new file mode 100644 index 0000000..366f52f --- /dev/null +++ b/public/assets/languages/python.svg @@ -0,0 +1,113 @@ + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + diff --git a/public/assets/languages/typescript.svg b/public/assets/languages/typescript.svg new file mode 100644 index 0000000..339da0b --- /dev/null +++ b/public/assets/languages/typescript.svg @@ -0,0 +1,6 @@ + + +TypeScript logo + + + diff --git a/public/assets/plurality.css b/public/assets/plurality.css index 3f522eb..a7210a4 100644 --- a/public/assets/plurality.css +++ b/public/assets/plurality.css @@ -78,4 +78,33 @@ text-align: center; margin-top: 5px; margin-bottom: 20px; +} + +@media (max-width: 600px) { + #cnp-intro { + grid-template-columns: 1fr !important; + text-align: center !important; + } + + #cnp-intro-outer { + padding-bottom: 10px !important; + margin-bottom: 10px !important; + border-bottom: 1px solid rgba(255, 255, 255, .25); + } + + #cnp-image { + display: block; + margin-left: auto; + margin-right: auto; + } + + #systems { + grid-template-columns: 1fr !important; + } + + #system-cloudburst { + padding-bottom: 10px; + margin-bottom: 10px; + border-bottom: 1px solid rgba(255, 255, 255, .25); + } } \ No newline at end of file diff --git a/public/assets/projects.css b/public/assets/projects.css new file mode 100644 index 0000000..e56b8eb --- /dev/null +++ b/public/assets/projects.css @@ -0,0 +1,45 @@ +/* + * MIT License + * + * Copyright (c) 2022- Equestria.dev Developers + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + * + */ + +.project { + display: block; + color: white !important; + text-decoration: none; + cursor: pointer; +} + +.project .project-language { + float: right; + width: 36px; + height: 36px; +} + +.project:hover { + opacity: .75; +} + +.project:active, .project:focus { + opacity: .5; +} \ No newline at end of file diff --git a/views/about.ejs b/views/about.ejs index 1dfb4b0..9dc7a60 100644 --- a/views/about.ejs +++ b/views/about.ejs @@ -25,7 +25,23 @@ <%- include("./partials/header.ejs", {title: "About Us"}) %> <%- include("./partials/footer.ejs") %> \ No newline at end of file diff --git a/views/broken.ejs b/views/broken.ejs new file mode 100644 index 0000000..84c0e62 --- /dev/null +++ b/views/broken.ejs @@ -0,0 +1,31 @@ + +<%- include("./partials/header.ejs", {title: "About Us"}) %> + + + +<%- include("./partials/footer.ejs") %> \ No newline at end of file diff --git a/views/error.ejs b/views/error.ejs new file mode 100644 index 0000000..cee0fd2 --- /dev/null +++ b/views/error.ejs @@ -0,0 +1,64 @@ + +<%- include("./partials/header.ejs", {title: "Error " + code}) %> + + + +<%- include("./partials/footer.ejs") %> \ No newline at end of file diff --git a/views/partials/header.ejs b/views/partials/header.ejs index 431be60..fee03d8 100644 --- a/views/partials/header.ejs +++ b/views/partials/header.ejs @@ -32,6 +32,9 @@ + + + <%= title %> - The Cuties diff --git a/views/plurality.ejs b/views/plurality.ejs index 412906e..ad57734 100644 --- a/views/plurality.ejs +++ b/views/plurality.ejs @@ -39,10 +39,27 @@ let frontersRaindrops = raindrops['fronters']['members'].map((i) => { return i['