Skip to content
This repository has been archived by the owner on Oct 1, 2021. It is now read-only.

Commit

Permalink
Merge branch 'feature/rss' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
VChet committed Nov 27, 2020
2 parents 03b6abe + 4b1da26 commit 369af8b
Show file tree
Hide file tree
Showing 4 changed files with 78 additions and 7 deletions.
44 changes: 44 additions & 0 deletions api/rss.js
Original file line number Diff line number Diff line change
@@ -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(`<a href='${style.usercss}'>Install UserCSS</a>`);
content.push(`<a href='${style.url}'>Repository</a>`);
content = content.join("<br />");

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
};
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
5 changes: 5 additions & 0 deletions routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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);
Expand Down
35 changes: 28 additions & 7 deletions src/src/components/AppFooter.vue
Original file line number Diff line number Diff line change
@@ -1,9 +1,20 @@
<template>
<footer>
<div class="container">
<a href="mailto:feedback@stylebase.cc" rel="noopener">Contact Us</a>
<button class="link" type="button" @click="$emit('open-nav-link', 'showPrivacyModal')">Privacy Policy</button>
<a href="https://github.com/VChet/StyleBase" rel="noopener" target="_blank">Code on GitHub</a>
<ul class="link-list">
<li>
<a href="/rss">RSS Feed</a>
</li>
<li>
<a href="mailto:feedback@stylebase.cc" rel="noopener">Contact Us</a>
</li>
<li>
<button class="link" type="button" @click="$emit('open-nav-link', 'showPrivacyModal')">Privacy Policy</button>
</li>
<li>
<a href="https://github.com/VChet/StyleBase" rel="noopener" target="_blank">Code on GitHub</a>
</li>
</ul>
</div>
</footer>
</template>
Expand All @@ -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;
}
}
}
</style>

0 comments on commit 369af8b

Please sign in to comment.