Skip to content

Commit 9cdee7d

Browse files
authored
Merge pull request #154 from mayeaux/rss-feeds
Rss feeds
2 parents bbfe9dc + cc244ac commit 9cdee7d

File tree

5 files changed

+328
-271
lines changed

5 files changed

+328
-271
lines changed

Dockerfile

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ RUN apk add --no-cache ffmpeg
44
RUN apk add --no-cache git
55
RUN apk add --no-cache tar
66

7-
87
COPY package*.json /app/
98

109
WORKDIR /app/

controllers/frontend/mediaBrowsing.js

+29-2
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const uploadFilters = require('../../lib/mediaBrowsing/helpers');
1313
const getSensitivityFilter = uploadFilters.getSensitivityFilter;
1414
const categories = require('../../config/categories');
1515
const logCaching = process.env.LOG_CACHING;
16+
const RSS = require('rss');
1617

1718
// todo: get out of controller
1819
let viewStats;
@@ -35,10 +36,36 @@ const pageLimit = 42;
3536

3637
exports.recentRssFeed = async(req, res) => {
3738
const uploads = await getFromCache.getRecentUploads(20, 0, 'all', 'sensitive', 'all', '');
39+
const feed = new RSS({
40+
title: process.env.INSTANCE_BRAND_NAME,
41+
description: process.env.META_DESCRIPTION,
42+
feed_url: `${process.env.DOMAIN_NAME_AND_TLD}/media/recent/rss`,
43+
site_url: process.env.DOMAIN_NAME_AND_TLD,
44+
image_url: process.env.META_IMAGE,
45+
copyright: `2020 ${process.env.INSTANCE_DOMAIN_NAME}`,
46+
language: 'en',
47+
pubDate: new Date(),
48+
ttl: '60'
49+
});
3850

39-
console.log(uploads);
51+
uploads.map(item => {
52+
const { title, category } = item;
53+
const categories = [category];
54+
const author = item.uploader.channelName;
55+
const url = `${process.env.DOMAIN_NAME_AND_TLD}/user/${author}/${item.uniqueTag}`;
56+
57+
feed.item({
58+
title,
59+
url, // link to the item
60+
guid: item._id, // optional - defaults to url
61+
categories, // optional - array of item categories
62+
author, // optional - defaults to feed author property
63+
date: item.createdAt // any format that js Date can parse.
64+
});
65+
});
4066

41-
res.send(uploads);
67+
const xml = feed.xml({indent: true});
68+
res.send(xml);
4269

4370
// TOOD: incorporate rss feed here and send it as response
4471
};

0 commit comments

Comments
 (0)