Authored by 陈峰

rss格式解决问题

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