Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
yohobuywap-node
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Plain Diff
Browse Files
Authored by
毕凯
7 years ago
Commit
492b58d8e77ab3efbbe510cdfdddbd1222966881
2 parents
09ee3f27
6a599385
Merge branch 'hotfix/rss' into 'feature/docker'
rss-link-err-fixed See merge request
!1326
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
9 additions
and
10 deletions
apps/guang/controllers/rss.js
apps/guang/models/rss.js
apps/guang/views/action/rss/index.hbs
apps/guang/controllers/rss.js
View file @
492b58d
...
...
@@ -33,10 +33,9 @@ const index = (req, res, next) => {
});
_
.
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
`
,
link
:
`
https
:
//m.yohobuy.com/guang/${item.id}.html?
ref=rss`,
description
:
item
.
intro
,
author
:
[{
name
:
(
item
.
author
&&
item
.
author
.
name
)
||
' '
...
...
@@ -60,7 +59,7 @@ const rss = (req, res, next, gmt) => {
return
next
();
}
_
.
forEach
(
result
,
item
=>
{
item
.
url
=
item
.
url
.
indexOf
(
'http'
)
>=
0
?
item
.
url
:
'http://'
+
item
.
url
;
item
.
url
=
`
https
:
//m.yohobuy.com/guang/${item.id}.html?ref=rss`
;
let
time
=
new
Date
(
item
.
publishTimeLong
&&
parseFloat
(
item
.
publishTimeLong
)
||
moment
(
item
.
publishTime
,
'MM月DD日 HH:mm'
));
let
format
=
gmt
?
'ddd, MM MMM YYYY hh:mm:ss +0800'
:
'YYYY-MM-DD hh:mm:ss +0800'
;
...
...
apps/guang/models/rss.js
View file @
492b58d
...
...
@@ -33,16 +33,16 @@ class RssModel extends global.yoho.BaseModel {
if
(
value
.
text
)
{
// 文字
result
+=
htmlProcess
.
removeHtml
(
htmlProcess
.
escapeToHtml
(
value
.
text
.
data
.
text
))
+
'<br/>'
;
}
else
if
(
value
.
singleImage
)
{
// 单张图
result
+=
`
<
img
src
=
"${helpers.image(value.singleImage.data[0].src, 640, 640)}"
/><
br
/>
`
;
result
+=
`
<
img
src
=
"
https:
${helpers.image(value.singleImage.data[0].src, 640, 640)}"
/><
br
/>
`
;
}
else
if
(
value
.
smallPic
&&
value
.
smallPic
.
data
)
{
// 多张小图
value
.
smallPic
.
data
.
forEach
((
small
)
=>
{
result
+=
`
<
img
src
=
"${helpers.image(small.src, 315, 420)}"
/>
`
;
result
+=
`
<
img
src
=
"
https:
${helpers.image(small.src, 315, 420)}"
/>
`
;
});
result
+=
'<br/>'
;
}
});
result
+=
`
<
a
href
=
"http
://guang.m.yohobuy.com/info/index?id=${id}
"
>
查看原文
<
/a>`
;
result
+=
`
<
a
href
=
"http
s://m.yohobuy.com/guang/${id}.html?ref=rss
"
>
查看原文
<
/a>`
;
return
result
;
}
});
...
...
apps/guang/views/action/rss/index.hbs
View file @
492b58d
<?xml version='1.0' encoding='utf-8'?>
<rss
version=
'2.0'
>
<channel>
<language>
zh-cn
</language>
<language>
zh-cn
</language>
<title>
<![CDATA[有货逛]]>
</title>
<link>
<![CDATA[http://yohobuy.com]]>
</link>
<description>
<![CDATA[Yoho!Buy有货 | 年轻人潮流购物中心]]>
</description>
...
...
@@ -17,13 +17,13 @@
{{#
items
}}
<item>
<title>
<
![CDATA[
{{
title
}}
]]>
</title>
<link>
<
![CDATA[
{{{
url
}}}
&
ref=rss
]]>
</link>
<link>
<
![CDATA[
{{{
url
}}}
]]>
</link>
<description>
<
![CDATA[
{{{
intro
}}}
]]>
</description>
<pubDate>
<
![CDATA[
{{
publishTime
}}
]]>
</pubDate>
<source>
<![CDATA[有货逛]]>
</source>
<author>
有货
</author>
</item>
{{/
items
}}
</channel>
</rss>
\ No newline at end of file
</rss>
...
...
Please
register
or
login
to post a comment