diff --git a/api/rss.js b/api/rss.js new file mode 100644 index 0000000..ea77dcd --- /dev/null +++ b/api/rss.js @@ -0,0 +1,44 @@ +const { Feed } = require("feed"); + +const { Style } = require("../models/Style"); + +async function getRss(req, res) { + const feed = new Feed({ + title: "StyleBase", + description: "Website styles from various authors", + id: "https://stylebase.cc", + link: "https://stylebase.cc", + favicon: "https://stylebase.cc/favicon.ico", + author: { + name: "StyleBase", + link: "https://stylebase.cc", + email: "feedback@stylebase.cc" + } + }); + + const styles = await Style.find({}).lean(); + styles.forEach(style => { + let content = []; + content.push(`${style.customName || style.name} by ${style.owner}.`); + content.push(`Install UserCSS`); + content.push(`Repository`); + content = content.join("
"); + + feed.addItem({ + title: style.customName || style.name, + id: style._id, + link: `https://stylebase.cc/${style.owner}/${style.name}`, + description: style.description, + content, + author: [{ name: style.owner }], + date: style._id.getTimestamp(), + image: style.customPreview || style.preview + }); + }); + + res.type("application/xml").send(feed.rss2()); +} + +module.exports = { + getRss +}; diff --git a/package.json b/package.json index b6210c7..6416ed2 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "express": "^4.17.1", "express-rate-limit": "^5.1.3", "express-session": "^1.17.1", + "feed": "^4.2.1", "helmet": "^4.2.0", "mongoose": "^5.10.15", "mongoose-paginate-v2": "^1.3.11", diff --git a/routes.js b/routes.js index b3d95bc..052ee72 100644 --- a/routes.js +++ b/routes.js @@ -2,6 +2,8 @@ const express = require("express"); const path = require("path"); const passport = require("passport"); +const { getRss } = require("./api/rss"); + const router = express.Router(); const clientIndex = path.join(__dirname, "public/index.html"); const maintenance = path.join(__dirname, "maintenance.html"); @@ -14,6 +16,9 @@ router.get("/logout", (req, res) => { }); router.get("/github/callback", passport.authenticate("github"), (req, res) => res.redirect("/")); +// RSS +router.get("/rss", getRss); + // Client serving router.get("*", (req, res) => res.sendFile(clientIndex, (error) => { if (error && error.code === "ENOENT") return res.status(503).sendFile(maintenance); diff --git a/src/src/components/AppFooter.vue b/src/src/components/AppFooter.vue index ce6bd2b..6f20a6d 100644 --- a/src/src/components/AppFooter.vue +++ b/src/src/components/AppFooter.vue @@ -1,9 +1,20 @@ @@ -22,12 +33,22 @@ footer { .container { padding-top: 0.25rem; padding-bottom: 0.25rem; - text-align: right; } - button, - a:not(:last-child) { - margin-right: 1rem; + .link-list { + display: flex; + flex-wrap: wrap; + justify-content: flex-end; + gap: 0.75rem 1rem; + margin: 0; + list-style-type: none; + + @include media-size-mobile { + flex-flow: column nowrap; + padding-top: 0.5rem; + padding-bottom: 0.5rem; + font-size: 16px; + } } }