Skip to content

Commit

Permalink
Merge pull request #154 from mayeaux/rss-feeds
Browse files Browse the repository at this point in the history
Rss feeds
  • Loading branch information
mayeaux authored Feb 1, 2020
2 parents bbfe9dc + cc244ac commit 9cdee7d
Show file tree
Hide file tree
Showing 5 changed files with 328 additions and 271 deletions.
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ RUN apk add --no-cache ffmpeg
RUN apk add --no-cache git
RUN apk add --no-cache tar


COPY package*.json /app/

WORKDIR /app/
Expand Down
31 changes: 29 additions & 2 deletions controllers/frontend/mediaBrowsing.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const uploadFilters = require('../../lib/mediaBrowsing/helpers');
const getSensitivityFilter = uploadFilters.getSensitivityFilter;
const categories = require('../../config/categories');
const logCaching = process.env.LOG_CACHING;
const RSS = require('rss');

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

exports.recentRssFeed = async(req, res) => {
const uploads = await getFromCache.getRecentUploads(20, 0, 'all', 'sensitive', 'all', '');
const feed = new RSS({
title: process.env.INSTANCE_BRAND_NAME,
description: process.env.META_DESCRIPTION,
feed_url: `${process.env.DOMAIN_NAME_AND_TLD}/media/recent/rss`,
site_url: process.env.DOMAIN_NAME_AND_TLD,
image_url: process.env.META_IMAGE,
copyright: `2020 ${process.env.INSTANCE_DOMAIN_NAME}`,
language: 'en',
pubDate: new Date(),
ttl: '60'
});

console.log(uploads);
uploads.map(item => {
const { title, category } = item;
const categories = [category];
const author = item.uploader.channelName;
const url = `${process.env.DOMAIN_NAME_AND_TLD}/user/${author}/${item.uniqueTag}`;

feed.item({
title,
url, // link to the item
guid: item._id, // optional - defaults to url
categories, // optional - array of item categories
author, // optional - defaults to feed author property
date: item.createdAt // any format that js Date can parse.
});
});

res.send(uploads);
const xml = feed.xml({indent: true});
res.send(xml);

// TOOD: incorporate rss feed here and send it as response
};
Expand Down
Loading

0 comments on commit 9cdee7d

Please sign in to comment.