Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yohobuy-node
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
1
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
yyq
7 years ago
Commit
6d1dabf5f6961cd5ac49f74f8f1581cea1f01a34
1 parent
f429a9b6
guang seo
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
32 additions
and
23 deletions
apps/guang/controllers/index.js
apps/guang/models/guang-service.js
apps/guang/models/url-helper.js
apps/guang/router.js
apps/guang/views/action/guang/detail.hbs
apps/guang/views/action/guang/tag.hbs
doraemon/views/partial/product/good.hbs
apps/guang/controllers/index.js
View file @
6d1dabf
...
...
@@ -12,7 +12,6 @@ const guangModel = require('../models/guang-service');
const
headerModel
=
require
(
'../../../doraemon/models/header'
);
const
ghelper
=
require
(
'../models/guang-helper'
);
const
urlHelper
=
require
(
'../models/url-helper'
);
const
querystring
=
require
(
'querystring'
);
const
tdk
=
require
(
'../../../utils/getTDK'
);
/**
...
...
@@ -80,9 +79,8 @@ exports.index = (req, res, next) => {
* 指定标签的文章列表
*/
exports
.
tags
=
(
req
,
res
,
next
)
=>
{
let
query
=
req
.
query
.
query
=
(
req
.
query
.
query
||
''
).
replace
(
/<|>/ig
,
''
);
let
page
=
req
.
query
.
page
||
1
;
let
query
=
req
.
query
.
query
=
(
req
.
query
.
query
||
req
.
params
.
query
||
''
).
replace
(
/<|>/ig
,
''
);
let
page
=
req
.
query
.
page
||
req
.
params
.
page
||
1
;
let
pageSize
=
req
.
query
.
pageSize
||
20
;
let
type
=
req
.
query
.
type
||
0
;
...
...
@@ -122,7 +120,7 @@ exports.tags = (req, res, next) => {
tag
:
query
,
guangIndexPage
:
true
,
baseUrl
:
`
?
$
{
querystring
.
stringify
(
req
.
query
)}
`
,
baseUrl
:
urlHelper
.
tagsUrl
(
query
)
,
pageSize
:
pageSize
,
type
:
type
,
pathNav
:
pathNav
,
...
...
@@ -249,7 +247,7 @@ exports.detail = (req, res, next) => {
let
promises
=
[
headerModel
.
requestHeaderData
(
channel
),
reqCtx
.
getArticleContent
(
id
),
reqCtx
.
getArticleContent
(
id
,
info
.
title
),
reqCtx
.
getHotTags
(
1
,
20
,
channel
,
isHotDegrade
),
reqCtx
.
getArticleComments
(
udid
,
uid
,
id
,
page
,
pageSize
),
reqCtx
.
getArticleBaseInfo
(
id
,
uid
,
udid
),
...
...
apps/guang/models/guang-service.js
View file @
6d1dabf
...
...
@@ -79,15 +79,12 @@ module.exports = class extends global.yoho.BaseModel {
}
_formatTag
(
tagData
)
{
let
name
=
tagData
.
name
,
param
=
{
query
:
name
};
let
name
=
tagData
.
name
;
return
{
tag
:
name
,
name
:
name
,
url
:
helpers
.
urlFormat
(
'/guang/tags/index'
,
param
)
url
:
encodeURI
(
helpers
.
urlFormat
(
`
/
guang
/
tags
/
$
{
name
}
/`, null
)
)
};
}
...
...
@@ -424,13 +421,11 @@ module.exports = class extends global.yoho.BaseModel {
}).
then
(
res
=>
{
return
_
.
map
((
res
&&
res
.
data
)
||
[],
it
=>
{
let
param
=
{
query
:
it
.
tag_name
};
let
name
=
it
.
tag_name
;
return
{
tagName
:
it
.
tag_name
,
url
:
helpers
.
urlFormat
(
'/guang/tags/index'
,
param
)
url
:
encodeURI
(
helpers
.
urlFormat
(
`
/
guang
/
tags
/
$
{
name
}
/`, null
)
)
};
});
});
...
...
@@ -827,7 +822,7 @@ module.exports = class extends global.yoho.BaseModel {
/**
* 获取文章内容详情
*/
getArticleContent
(
aid
)
{
getArticleContent
(
aid
,
title
)
{
let
that
=
this
;
let
content
=
[],
...
...
@@ -859,6 +854,8 @@ module.exports = class extends global.yoho.BaseModel {
let
gpromises
=
[],
ggpromises
=
[];
if
(
res
&&
res
.
code
===
200
&&
res
.
data
)
{
let
altNum
=
0
;
_
.
forEach
(
res
.
data
,
(
it
)
=>
{
_
.
forEach
(
it
,
(
val
,
key
)
=>
{
...
...
@@ -875,6 +872,12 @@ module.exports = class extends global.yoho.BaseModel {
let
other
=
_
.
isFunction
(
that
.
_articleContentFormat
()[
key
])
?
that
.
_articleContentFormat
()[
key
](
val
.
data
)
:
''
;
// 前五张图片添加alt
if
(
altNum
<
6
&&
(
other
.
pic
||
other
.
smallPic
))
{
other
.
alt
=
title
;
altNum
+=
other
.
pic
?
1
:
other
.
smallPic
.
length
;
}
content
.
push
(
other
);
}
});
...
...
apps/guang/models/url-helper.js
View file @
6d1dabf
...
...
@@ -13,3 +13,7 @@ module.exports.editorUrl = function(channel, authorId) {
module
.
exports
.
listUrl
=
function
(
channel
,
type
)
{
return
helpers
.
urlFormat
(
`
/
guang
/
$
{
channel
}
-
t$
{
type
}
/`, null
)
;
};
module
.
exports
.
tagsUrl
=
function
(
query
,
page
)
{
return
encodeURI
(
page
?
`
/
guang
/
tags
/
$
{
query
}
-
p$
{
page
}
/` : `/g
uang
/
tags
/
$
{
query
}
/`
)
;
};
...
...
apps/guang/router.js
View file @
6d1dabf
...
...
@@ -16,6 +16,8 @@ router.get(['/', '/index/index'], guangController.index);
router
.
get
([
'/detail/:id'
,
'/info/index'
],
guangController
.
detail
);
// guang/info/index
router
.
get
(
/^
\/([\d]
+
)(
.*
)
/
,
guangController
.
detail
);
router
.
get
(
'/tags/index'
,
guangController
.
tags
);
router
.
get
(
'/tags/:query-p:page'
,
guangController
.
tags
);
// tags 伪静态路由
router
.
get
(
'/tags/:query'
,
guangController
.
tags
);
// tags 伪静态路由
router
.
get
(
'/Index/editor'
,
guangController
.
editor
);
// ajax
...
...
apps/guang/views/action/guang/detail.hbs
View file @
6d1dabf
...
...
@@ -18,7 +18,9 @@
<div
class=
"article-status clearfix"
>
<span
class=
"article-time"
>
{{
time
}}
</span>
<span
class=
"article-click"
>
点击:
<em>
{{
click
}}
</em></span>
<a
href=
"#comment-info"
id=
"article-comment"
class=
"article-comment"
><em
class=
"comment-num"
rel=
"nofollow"
>
{{
commentNum
}}
</em>
条评论
</a>
<a
href=
"#comment-info"
id=
"article-comment"
class=
"article-comment"
rel=
"nofollow"
>
<em
class=
"comment-num"
>
{{
commentNum
}}
</em>
条评论
</a>
</div>
</div>
{{/
header
}}
...
...
@@ -32,7 +34,7 @@
{{/
video
}}
{{#
pic
}}
<div
class=
"article-pic block"
>
<img
class=
"lazy"
data-original=
"
{{
image2
.
}}
"
>
<img
class=
"lazy"
data-original=
"
{{
image2
.
}}
"
{{#if
..
/
alt
}}
alt=
"
{{
..
/
alt
}}
"
{{/if}}
>
</div>
{{/
pic
}}
{{#
text
}}
...
...
@@ -43,7 +45,7 @@
{{#if
smallPic
}}
<div
class=
"article-small-pic block clearfix"
>
{{#
smallPic
}}
<img
class=
"lazy"
data-original=
"
{{
image2
.
}}
"
>
<img
class=
"lazy"
data-original=
"
{{
image2
.
}}
"
{{#if
..
/
alt
}}
alt=
"
{{
..
/
alt
}}
"
{{/if}}
>
{{/
smallPic
}}
</div>
{{/if}}
...
...
apps/guang/views/action/guang/tag.hbs
View file @
6d1dabf
...
...
@@ -12,7 +12,7 @@
{{/
msgs
}}
</div>
{{
gpager
baseUrl
totalRecords
=
total
page
=
page
type
=
"ellipsis"
theme
=
"msg-pager"
}}
{{
spager
baseUrl
totalRecords
=
total
page
=
page
pageVar
=
"p"
type
=
"ellipsis"
theme
=
"msg-pager"
}}
</div>
<div
class=
"right-side"
>
{{>
right-side
}}
...
...
doraemon/views/partial/product/good.hbs
View file @
6d1dabf
...
...
@@ -31,8 +31,8 @@
{{/
tags
}}
</div>
<div
class=
"good-detail-img"
>
<a
class=
"good-thumb"
href=
"
{{
url
}}
"
{{#
productTitle
}}
title=
"
{{
.
}}
"
{{/
productTitle
}}{{#if
noFollow
}}
rel=
"nofollow"
{{/if}}
target=
"_blank"
>
<img
class=
"lazy"
data-original=
"
{{
image2
thumb
w
=
280
h
=
382
}}
"
{{#
productTitle
}}
alt=
"
{{
.
}}
"
{{/
productTitle
}}
>
<a
class=
"good-thumb"
href=
"
{{
url
}}
"
title=
"
{{#if
productTitle
}}{{
productTitle
}}{{^}}{{
product_name
}}{{/if}}
"
{{#if
noFollow
}}
rel=
"nofollow"
{{/if}}
target=
"_blank"
>
<img
class=
"lazy"
data-original=
"
{{
image2
thumb
w
=
280
h
=
382
}}
"
alt=
"
{{#if
productTitle
}}{{
productTitle
}}{{^}}{{
product_name
}}{{/if}}
"
>
</a>
{{#
is_few
}}
<p
class=
"few-tag"
>
即将售罄
</p>
...
...
@@ -43,7 +43,7 @@
{{/
is_solded
}}
</div>
<div
class=
"good-detail-text
{{#
for_stu
}}
stu-good-detail
{{/
for_stu
}}
"
>
<a
href=
"
{{
url
}}
"
target=
"_blank"
{{#
productTitle
}}
title=
"
{{
.
}}
"
{{/
productTitle
}}{{#
if
noFollow
}}
rel=
"nofollow"
{{/if}}
>
{{{
product_name
}}}
</a>
<a
href=
"
{{
url
}}
"
target=
"_blank"
{{#if
noFollow
}}
rel=
"nofollow"
{{/if}}
>
{{{
product_name
}}}
</a>
<p
class=
"brand"
>
{{#if
brand_name
}}
<a
href=
"
{{
brandUrl
}}
"
{{#if
@root
.
pageNoFollow
}}
rel=
"nofollow"
{{/if}}
>
{{
brand_name
}}
</a>
...
...
Please
register
or
login
to post a comment