fixed rss feed for ie7

This commit is contained in:
scoliono 2020-09-10 20:24:57 -07:00
parent b50c6ea4a2
commit bc2a56383d
3 changed files with 40 additions and 33 deletions

View File

@ -34,6 +34,7 @@
}
-->
</style>
<link rel='alternate' type='application/rss+xml' title='HowFeed RSS Feed' href='/rss.xml'>
</head>
<body style="width: 640px;">
<table width="640" cellspacing="0" cellpadding="0" border="0">

View File

@ -1,32 +0,0 @@
import RSS from 'rss';
import Article from '../models/article.js';
export async function get(req, res)
{
let feed = new RSS();
let articles = await Article.find().populate({
path: 'author',
select: 'realname avatar'
}).populate({
path: 'category'
});
for (let article of articles) {
feed.item({
title: article.title,
description: article.html,
url: `http://howfeed.biz/a/${article.slug}`,
categories: [ article.category.name ],
author: article.author.realname,
date: article.created_at,
enclosure: {
url: `http://howfeed.biz/a/${article.image}`
}
});
}
res.writeHead(200, {
'Content-Type': 'application/rss+xml'
});
res.end(feed.xml());
}

View File

@ -13,6 +13,7 @@ import fs from 'fs';
import cors from 'cors';
import helmet from 'helmet';
import useragent from 'useragent';
import RSS from 'rss';
import path from 'path';
import crypto from 'crypto';
import Article from './models/article.js';
@ -391,7 +392,44 @@ mainRouter
}));
}
}
);
)
.get('/rss.xml', async function (req, res) {
let year = new Date().getFullYear();
let feed = new RSS({
title: 'HowFeed.biz Articles',
feed_url: 'http://howfeed.biz/rss.xml',
site_url: 'http://howfeed.biz/',
image_url: 'http://howfeed.biz/logo.png',
language: 'en',
webMaster: 'webmaster@howfeed.biz',
copyright: `${year} FemboyFinancial Holdings Co., Ltd. (USA LLC)`
});
let articles = await Article.find().populate({
path: 'author',
select: 'realname avatar'
}).populate({
path: 'category'
});
for (let article of articles) {
feed.item({
title: article.title,
description: article.html,
url: `http://howfeed.biz/a/${article.slug}`,
categories: [ article.category.name ],
author: article.author.realname,
date: article.created_at,
enclosure: {
url: `http://howfeed.biz/a/${article.image}`
}
});
}
res.writeHead(200, {
'Content-Type': 'application/rss+xml'
});
res.end(feed.xml());
});
app.use(helmet())
.use(cors())