Authored by 刘传洋

guang page

... ... @@ -17,7 +17,6 @@ const querystring = require('querystring');
* 首页文章列表 类型列表
*/
exports.index = (req, res, next) => {
let channel = req.yoho.channel;
let page = req.query.page || 1;
let pageSize = req.query.pageSize || 20;
... ... @@ -37,7 +36,7 @@ exports.index = (req, res, next) => {
guangModel.getRecoArticles(gender, 1, 10),
headerModel.requestHeaderData(channel)
]).then(ret => {
res.render('index', {
res.render('guang/index', {
guang: {
slider: ret[0],
msgTypes: ret[1],
... ... @@ -88,7 +87,7 @@ exports.tags = (req, res, next) => {
headerModel.requestHeaderData(channel)
]).then(ret => {
res.render('tag', {
res.render('guang/tag', {
title: query + (res.locals.title || ''),
guang: {
slider: ret[0],
... ... @@ -138,7 +137,7 @@ exports.editor = (req, res, next) => {
guangModel.getRecoArticles(gender, 1, 10),
headerModel.requestHeaderData(channel)
]).then(ret => {
res.render('editor', {
res.render('guang/editor', {
title: ret[0].name + (res.locals.title || ''),
guang: {
editor: ret[0],
... ... @@ -183,7 +182,7 @@ exports.detail = (req, res, next) => {
if (pjax) {
guangModel.getArticleComments(id, page, pageSize).then(ret => {
res.render('detail-comment', {
res.render('guang/detail-comment', {
layout: false,
comment: ret
}, function(err, html) {
... ... @@ -236,7 +235,7 @@ exports.detail = (req, res, next) => {
Promise.all(promises).then(ret => {
res.render('detail', Object.assign({
res.render('guang/detail', Object.assign({
module: 'guang',
page: 'detail',
headerData: ret[0].headerData,
... ... @@ -351,7 +350,7 @@ exports.comment = (req, res) => {
return guangModel.getArticleComments(id, 1, 20);
}).then(commentInfo => {
res.render('detail-comment', {
res.render('guang/detail-comment', {
comment: commentInfo,
layout: false
}, (err, content) => {
... ...
... ... @@ -6,12 +6,8 @@
'use strict';
let // fs = require('fs'),
_ = require('lodash'),
exphbs = require('express-handlebars').create(),
Handlebars = exphbs.handlebars;/* ,
Pagination = require('../common/pagination');
*/
let _ = require('lodash');
let Handlebars = require('handlebars');
let ALL_TYPES = {
stand: 'p-page-n',
... ... @@ -21,8 +17,10 @@ let ALL_TYPES = {
ellipsis: 'p-pe-n'
};
Handlebars.registerHelper('pager', function() {
exports.pager = function() {
let options = arguments[arguments.length - 1];
let baseUrl = (arguments.length > 1 ? arguments[0] : null) || options.hash.baseUrl || '',
page = (options.hash.page || 1) * 1,
showNum = (options.hash.showNum || 7) * 1,
... ... @@ -203,6 +201,4 @@ Handlebars.registerHelper('pager', function() {
}
ret += '</div>';
return new Handlebars.SafeString(ret);
});
exports = exphbs.handlebars;
};
... ...
... ... @@ -27,11 +27,11 @@
defaultLayout: 'layout',
layoutsDir: doraemon,
partialsDir: [`${partials}/partial`, `${doraemon}/partial`],
helpers: global.yoho.helpers
helpers: Object.assign(require('./helpers/pager'), global.yoho.helpers)
}));
require('./helpers/json');
require('./helpers/page');
// require('./helpers/json');
// require('./helpers/page');
// router
app.use(require('./router'));
... ...
<div class="con"></div>
<div class="guide-box" spm-name="homepage_guide" style="top: 255.5px;">
<a class="close" href="javascript:void(0)">x</a>
<ul class="clear">
{{#list}}
<li class="{{channel}}" >
<dl>
<dt class="tag-img-warpper">
<a href="{{url}}" target="_self">
<img spm-name="homepage_guide_manimg" alt="YOHO!BOYS" src="{{image src 180 168}}"></a>
</dt>
<dd class="block-cn">{{sort_name}}</dd>
<dd class="block-en"> <b>{{sort_name_en}}</b>
</dd>
<dd class="block-line">
</dd>
<dd class="goods-num"> <b>{{num}}+ Items.</b>
</dd>
<dd>
<a class="go" href="{{url}}">
Enter
<span class="ifont">&gt;</span>
</a>
</dd>
</dl>
</li>
{{/list}}
</ul>
</div>
... ... @@ -37,6 +37,7 @@
"connect-memcached": "^0.2.0",
"cookie-parser": "^1.4.3",
"express": "^4.13.1",
"handlebars": "^4.0.5",
"express-handlebars": "^3.0.0",
"influxdb-winston": "^1.0.1",
"lodash": "^4.13.1",
... ...