Toggle navigation
Toggle navigation
This project
Loading...
Sign in
OPENTECH
/
yoho-node-ci
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
2
Merge Requests
0
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
周少峰
8 years ago
Commit
3a0f321ea5893ee7ed024cbccf81f22be3f99744
1 parent
f275dcd0
tdk add
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
137 additions
and
1 deletions
apps/web/actions/seo.js
apps/web/index.js
apps/web/routers.js
apps/web/views/action/seo_tdk.hbs
apps/web/views/partials/common/menu.hbs
config/config.js
lib/redis.js
package.json
apps/web/actions/seo.js
0 → 100644
View file @
3a0f321
'use strict'
;
const
Router
=
require
(
'koa-router'
);
const
_
=
require
(
'lodash'
);
let
r
=
new
Router
();
const
tdk
=
{
// tdk 列表
index
:
async
(
ctx
,
next
)
=>
{
await
ctx
.
render
(
'action/seo_tdk'
,
{
title
:
'TDK管理'
});
},
// 添加tdk
add
:
async
(
ctx
,
next
)
=>
{
let
result
=
{
code
:
500
,
message
:
'非法参数'
},
typeList
=
[
'skn'
,
'article'
,
'shop'
,
'url'
];
// skn, article, shop, url
let
type
=
ctx
.
request
.
body
.
type
,
val
=
ctx
.
request
.
body
.
val
,
title
=
ctx
.
request
.
body
.
title
||
''
,
keywords
=
ctx
.
request
.
body
.
keywords
,
description
=
ctx
.
request
.
body
.
description
;
// type 不合法, 返回错误
if
(
!
_
.
find
(
typeList
,
type
))
{
ctx
.
response
.
body
=
result
;
}
ctx
.
redis
.
multi
([
[
"lpush"
,
`
tdk
:
$
{
type
}:
links
`
,
val
],
[
"hmset"
,
`
tdk
:
$
{
type
}:
$
{
val
}
`
,
"title"
,
title
,
"keywords"
,
keywords
,
"description"
,
description
]
]).
execAsync
().
then
(
function
(
res
)
{
Object
.
assign
(
result
,
{
code
:
200
,
message
:
'success'
})
});
ctx
.
response
.
body
=
result
;
}
};
r
.
get
(
'/'
,
tdk
.
index
);
r
.
get
(
'/tdk'
,
tdk
.
index
);
r
.
get
(
'/tdk/add'
,
tdk
.
add
);
module
.
exports
=
r
;
...
...
apps/web/index.js
View file @
3a0f321
...
...
@@ -12,6 +12,7 @@ const helpers = require('../../lib/helpers');
const
routers
=
require
(
'./routers'
);
const
collectData
=
require
(
'./actions/collect_data'
);
const
checkcode
=
require
(
'./actions/checkcode'
);
const
redis
=
require
(
'../../lib/redis'
);
const
app
=
new
Koa
();
...
...
@@ -38,6 +39,8 @@ checkcode.check();
collectData
.
collect
();
app
.
use
(
async
(
ctx
,
next
)
=>
{
ctx
.
redis
=
redis
.
client
;
ctx
.
locals
=
{
title
:
'Yoho Node.js 持续集成平台'
};
...
...
apps/web/routers.js
View file @
3a0f321
...
...
@@ -19,6 +19,7 @@ const deploy = require('./actions/deploy');
const
api
=
require
(
'./actions/api'
);
const
abuseProtection
=
require
(
'./actions/abuse_protection'
);
const
crawler
=
require
(
'./actions/crawler'
);
const
seo
=
require
(
'./actions/seo'
);
const
checkcode
=
require
(
'./actions/checkcode'
).
router
;
const
noAuth
=
new
Router
();
const
base
=
new
Router
();
...
...
@@ -60,6 +61,7 @@ module.exports = function(app) {
base
.
use
(
'/crawler_black'
,
black
.
routes
(),
black
.
allowedMethods
());
base
.
use
(
'/abuse_protection'
,
abuseProtection
.
routes
(),
degrade
.
allowedMethods
());
base
.
use
(
'/seo'
,
seo
.
routes
(),
seo
.
allowedMethods
());
base
.
use
(
''
,
index
.
routes
(),
index
.
allowedMethods
());
...
...
apps/web/views/action/seo_tdk.hbs
0 → 100644
View file @
3a0f321
<div
class=
"pageheader"
>
<div
class=
"media"
>
<div
class=
"pageicon pull-left"
>
<i
class=
"fa fa-th-list"
></i>
</div>
<div
class=
"media-body"
>
<ul
class=
"breadcrumb"
>
<li><a
href=
""
><i
class=
"glyphicon glyphicon-home"
></i></a></li>
<li><a
href=
""
>
Hotfix
</a></li>
<li>
{{
type
}}
</li>
</ul>
<h4>
{{
title
}}
</h4>
</div>
</div>
<!-- media -->
</div>
<!-- pageheader -->
<div
class=
"contentpanel"
>
<div
class=
"panel panel-primary-head"
>
<div
class=
"panel-heading"
>
<div
class=
"pull-right"
>
<a
id=
"new-page"
href=
"/hotfix/new/
{{
type
}}
"
class=
"btn btn-success btn-rounded"
><i
class=
"glyphicon glyphicon-plus"
></i>
新增Hotfix
</a>
</div>
<h4
class=
"panel-title"
>
{{
type
}}
hotfix
</h4>
<p>
</p>
</div>
<!-- panel-heading -->
<table
id=
"table-hotfixs"
class=
"table table-striped table-bordered responsive"
>
<thead
class=
""
>
<tr>
<th>
ID
</th>
<th>
类型
</th>
<th>
标题
</th>
<th>
关键词
</th>
<th>
描述
</th>
<th>
操作
</th>
</tr>
</thead>
<tbody>
{{#
each
hotfixs
}}
<tr>
<td>
{{
id
}}
</td>
<td>
{{
type
}}
</td>
<td>
{{
title
}}
</td>
<td>
{{
keywords
}}
</td>
<td>
{{
description
}}
</td>
<td>
{{
operate
}}
</td>
</tr>
{{/
each
}}
</tbody>
</table>
</div>
<!-- panel -->
</div>
\ No newline at end of file
...
...
apps/web/views/partials/common/menu.hbs
View file @
3a0f321
...
...
@@ -66,6 +66,7 @@
<li><a
href=
"/check/list"
>
代码检查
</a></li>
</ul>
</li>
<li><a
href=
"/seo/tdk"
><i
class=
"fa fa-list"
></i>
<span>
TDK管理
</span></a></li>
{{/if}}
</ul>
...
...
config/config.js
View file @
3a0f321
...
...
@@ -11,6 +11,13 @@ const defaults = {
influxdb
:
{
host
:
'influxdblog.web.yohoops.org'
,
port
:
4444
},
redis
:
{
connect
:
{
host
:
'127.0.0.1'
,
port
:
'6379'
,
//password: ''
}
}
};
...
...
lib/redis.js
0 → 100644
View file @
3a0f321
const
redis
=
require
(
'redis'
);
const
bluebird
=
require
(
'bluebird'
);
const
config
=
require
(
'../config/config'
);
const
client
=
redis
.
createClient
(
config
.
redis
.
connect
);
bluebird
.
promisifyAll
(
redis
.
RedisClient
.
prototype
);
bluebird
.
promisifyAll
(
redis
.
Multi
.
prototype
);
module
.
exports
=
{
client
}
\ No newline at end of file
...
...
package.json
View file @
3a0f321
...
...
@@ -25,7 +25,7 @@
"author"
:
"jiangfeng <jeff.jiang@yoho.cn>"
,
"license"
:
"ISC"
,
"dependencies"
:
{
"bluebird"
:
"^3.
4.1
"
,
"bluebird"
:
"^3.
5.0
"
,
"co"
:
"^4.6.0"
,
"co-body"
:
"^4.2.0"
,
"formidable"
:
"^1.0.17"
,
...
...
@@ -57,11 +57,15 @@
"qcloudapi-sdk"
:
"^0.1.5"
,
"qn"
:
"^1.3.0"
,
"qs"
:
"^6.2.0"
,
"redis"
:
"^2.7.1"
,
"request-promise"
:
"^4.1.1"
,
"shelljs"
:
"^0.7.0"
,
"socket.io"
:
"^1.4.6"
,
"ssh2"
:
"^0.5.4"
,
"tar"
:
"^2.2.1"
,
"utility"
:
"^1.8.0"
},
"devDependencies"
:
{
"nodemon"
:
"^1.11.0"
}
}
...
...
Please
register
or
login
to post a comment