Authored by 周少峰

Merge branch 'gray'

... ... @@ -37,19 +37,19 @@ const getStaticUrls = (currentStatics) => {
};
// 关键词页面
const keywordsPage = () => {
return redis.getAsync('golobal:yoho:seo:keywords:allIds').then(function(res) {
let page = [];
const keywordsPage = (page) => {
return redis.getAsync(`global:yoho:seo:keywords:allIds:page:${page}`).then(function(res) {
let pages = [];
_.forEach(JSON.parse(res), val => {
page.push({
pages.push({
url: `https://www.yohobuy.com/chanpin/${val}.html`,
changefreq: 'daily',
priority: 0.5
});
});
return page;
return pages;
}).catch(()=>{
return {};
});
... ... @@ -74,10 +74,16 @@ const getArticleUrls = () => {
};
// www 地图数据
const wwwXmlData = () => {// eslint-disable-line
return Promise.all([keywordsPage(), getStaticUrls(_.get(staticUrls, 'www')), getArticleUrls()]).then(result => {
return _.concat(result[1], result[0], result[2]);
});
const wwwXmlData = (page) => {// eslint-disable-line
if (page > 1) {
return keywordsPage(page);
} else {
return Promise.all([keywordsPage(page),
getStaticUrls(_.get(staticUrls, 'www')),
getArticleUrls()]).then(result => {
return _.concat(result[1], result[0], result[2]);
});
}
};
// list 地图数据
... ... @@ -133,7 +139,9 @@ const siteMap = (req, res, next) => {
return;
}
eval(subdomain + 'XmlData')().then(urls => {// eslint-disable-line
let page = req.params[0] || 1;
eval(subdomain + 'XmlData')(page).then(urls => {// eslint-disable-line
sm.createSitemap({
hostname: `https://${subdomain}.yohobuy.com`,
xmlNs: ' ',
... ...
... ... @@ -30,6 +30,6 @@ router.post('/common/getNewArrival', channelController.getNewArrival);
router.get('/guide', channelController.getIndexGuide);
// www站点地图
router.get('/sitemap.xml', sitemap.siteMap);
router.get(/\/sitemap(\d*)\.xml/, sitemap.siteMap);
module.exports = router;
... ...
... ... @@ -160,7 +160,7 @@ const getLikeAsync = (skn, limit) => {
// 根据small_sort从redis获取分类下的关键词
const getRecommendKeywords = (smallSort) => {
return redis.all([['get', `golobal:yoho:seo:keywords:sortId:${smallSort}`]]).then(res => {
return redis.all([['get', `global:yoho:seo:keywords:sortId:${smallSort}:page:1`]]).then(res => {
return res[0];
});
};
... ...
... ... @@ -415,7 +415,7 @@ exports.getSearchKeywordDataById = (id, params, channel) => {
return co(function * () {
let redisData = yield redis.all([
['get', `golobal:yoho:seo:keywords:id:${id}`]
['get', `global:yoho:seo:keywords:id:${id}`]
]);
if (!redisData[0]) {
... ...
... ... @@ -78,6 +78,54 @@ module.exports = [
target: (req, match, p1) => `/product/search/keyword/${p1}`
},
// TODO
// {
// type: TYPE.redirect,
// origin: /^\/so\/(.*)\.html(.*)/,
// target: (req, match, p1) => {
// let urls = {
// '4175746F426F74E6898BE69CBAE9858DE4BBB6E794B7': 57517,
// E6BBA1E58DB0E4BABAE5AD97E68B96: 11877,
// E6BDAEE6ACBEE5A4AAE79CBCE9959C: 43319,
// E6B3A2E782B9E995BFE8A296E8A1ACE8A1A3: 5709,
// E688B7E5A496E58C85E9858D: 27481,
// E993B6E98791E889B2: 12279,
// E697B6E5B09AE68ABDE7BBB3E79FADE8A3A4: 84593,
// '4C554E414C494D49544544E99288E7BB87E5A5B3': 36255,
// '4B4F594F': 10297,
// E99288E7BB87E8A5BFE8A385: 72093,
// E8838CE5BF83E995BFE8A399: 81419,
// E9929FE8A1A8E5A5B3: 71361,
// '424142414D41E79AAEE5B8A6': 47883,
// E5BEBDE7ABA0E58DABE8A1A3: 75023,
// E9BB91E799BDE6A0BC: 20095,
// E7949CE7BE8EE7BAAFE889B2E79FADE8A3A4: 10309,
// E58DB0E88AB1E995BFE6ACBEE7BEBDE7BB92E69C8D: 62085,
// E68B89E993BEE5BC80E8A59F: 43223,
// E7BBBFE889B2E7AE80E7BAA6E4BC91E997B2E8A3A4: 7781,
// E79CBCE5BDB1E5A5B3: 39279,
// E7BAAFE889B2E6A392E79083E5B8BD: 2021,
// E5A191E69699E590B8E7AEA1E69DAF: 1956427,
// E59BB4E5859C20E794B7: 71493,
// E59BB4E5859C20E5A5B3: 65257,
// E68BBCE889B2E6898BE993BE: 48821,
// '5452494E49544573747564696FE8A1ACE8A1AB': 53871,
// E799BDE889B2E9A490E585B7: 36291,
// E8939DE889B2E79CBCE9959C: 6287,
// E7AB96E69DA1E7BAB9E8BF9EE8A1A3E8A399: 40513,
// E7899BE4BB94E8939DE794B7E5A3ABE995BFE8A3A4: 2297,
// E58DB0E88AB1E4BC91E997B2E5A4B9E5858B: 26725,
// E8BF90E58AA8E8939DE78999E880B3E69CBA: 46837,
// E7BAAFE889B2E6B299E6BBA9E8A3A4: 8709,
// E7BAAFE889B2E8B4B4E6A087: 28027
// };
//
// return urls[p1] ?
// helpers.urlFormat(`/chanpin/${urls[p1]}.html`, null, 'www') :
// helpers.urlFormat('/', null, 'www');
// }
// },
// 推荐词id列表页
{
type: TYPE.rewrite,
... ...
... ... @@ -59,6 +59,8 @@ module.exports = () => {
}
} else if (proRegNew.test(url)) {
data.mobileRefer = url.replace(proRegNew, `//${domain}/product/pro_$1_1/1.html$2`);
} else {
data.mobileRefer = `//${domain}${req.originalUrl}`;
}
if (!_.isEmpty(req.query) && !qsReg.test(data.mobileRefer)) {
... ...
... ... @@ -23,7 +23,7 @@ try {
}
return client.multi.call(client, args).execAsync().timeout(timeout).catch(()=>{
logger.err('redis exe time out');
logger.error('redis exe time out');
return false;
});
};
... ...
... ... @@ -11,6 +11,11 @@
<meta name="apple-mobile-web-app-status-bar-style" content="black" />
<meta content="telephone=no" name="format-detection" />
<meta content="email=no" name="format-detection" />
<meta name="applicable-device"content="pc">
{{#if mobileRefer}}
<link rel="alternate" media="only screen and(max-width: 640px)" href="{{mobileRefer}}">
<meta name="mobile-agent" content="format=html5;url={{mobileRefer}}">
{{/if}}
{{#dnsPrefetch.hosts}}
<link rel="dns-prefetch" href="{{this}}">
{{/dnsPrefetch.hosts}}
... ...