Authored by 陈峰

rss格式解决问题

... ... @@ -18,14 +18,13 @@ const helpers = global.yoho.helpers;
const index = (req, res, next) => {
let gender = req.query.gender || '1,2,3',
items = [];
return rssModel.getRssArticle(gender).then((result) => {
if (!result) {
return next();
}
res.setHeader('Content-Type', 'text/xml; charset=utf-8');
var feed = new Feed({
id: 'yohobuy',
id: 'http://yohobuy.com',
title: '有货逛',
description: 'Yoho!Buy有货 | 年轻人潮流购物中心',
link: 'http://yohobuy.com',
... ... @@ -34,15 +33,15 @@ const index = (req, res, next) => {
updated: new Date(),
})
_.forEach(result, item => {
item.url = item.url.indexOf('http') > 0 ? item.url : 'http://'+item.url
feed.addItem({
title: item.title,
link: `${item.url}&ref=rss`,
description: item.intro,
author: [{
name: (item.author && item.author.name) || '',
url: (item.author && item.author.url) || ''
name: (item.author && item.author.name) || ' '
}],
date: new Date(moment(item.publishTime, "MM月DD日 HH:mm"))
date: new Date(item.publishTimeLong && parseFloat(item.publishTimeLong) || moment(item.publishTime, "MM月DD日 HH:mm"))
});
});
if (req.params[0] && req.params[0] === '/atom') {
... ...
... ... @@ -24,13 +24,13 @@ const getRssArticle = (gender) => {
switch (gender) {
case '1,3':
articlePromise = indexModel.getArticleList('1,3', 0, 0, '', 1, null, null, 100, false);
articlePromise = indexModel.getArticleList('1,3', 0, 0, '', 1, null, null, 3, false);
break;
case '2,3':
articlePromise = indexModel.getArticleList('2,3', 0, 0, '', 1, null, null, 100, false);
articlePromise = indexModel.getArticleList('2,3', 0, 0, '', 1, null, null, 3, false);
break;
default:
articlePromise = indexModel.getArticleList('1,2,3', 0, 0, '', 1, null, null, 100, false);
articlePromise = indexModel.getArticleList('1,2,3', 0, 0, '', 1, null, null, 3, false);
break;
}
return articlePromise.then((article) => {
... ...
... ... @@ -16,15 +16,15 @@ module.exports = {
siteUrl: '//m.yohobuy.com',
assetUrl: '//localhost:5001',
domains: {
api: 'http://api-test3.yohops.com:9999/',
service: 'http://service-test3.yohops.com:9999/',
liveApi: 'http://testapi.live.yohops.com:9999/',
singleApi: 'http://api-test3.yohops.com:9999/'
// api: 'http://api-test3.yohops.com:9999/',
// service: 'http://service-test3.yohops.com:9999/',
// liveApi: 'http://testapi.live.yohops.com:9999/',
// singleApi: 'http://api-test3.yohops.com:9999/'
// api: 'http://api.yoho.cn/',
// service: 'http://service.yoho.cn/',
// liveApi: 'http://api.live.yoho.cn/',
// singleApi: 'http://single.yoho.cn/'
api: 'http://api.yoho.cn/',
service: 'http://service.yoho.cn/',
liveApi: 'http://api.live.yoho.cn/',
singleApi: 'http://single.yoho.cn/'
},
subDomains: {
host: '.m.yohobuy.com',
... ...
... ... @@ -68,6 +68,7 @@ const formatArticle = (articleData, showTag, isApp, showAuthor, uid, reqQueryStr
title: articleData.title,
text: articleData.intro,
publishTime: articleData.publish_time,
publishTimeLong: articleData.publish_time_long,
pageView: articleData.views_num
};
... ...