Skip to content

Commit

Permalink
update to v1.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
jackhutu committed Apr 30, 2016
1 parent b12b009 commit c7528be
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 21 deletions.
6 changes: 6 additions & 0 deletions History.md
@@ -1,3 +1,9 @@
1.3.1 / 2016-04-30
==================
* 修复七牛没配置时首页图片API错误
* 更新依赖包


1.3.0 / 2016-04-10
==================

Expand Down
17 changes: 16 additions & 1 deletion README.md
Expand Up @@ -37,7 +37,7 @@ redis 2.8+
bucket:"bucket" //七牛空间名称
},
```

* 七牛不配置也可以运行, 但如果使用[后台管理功能 https://github.com/jackhutu/jackblog-admin](https://github.com/jackhutu/jackblog-admin), 必须配置七牛.

## 开发
```
Expand All @@ -47,6 +47,21 @@ $ npm install
$ gulp serve
```

## [windows 用户注意事项](#windows)
经亲测windows上开发没有任何问题, 测试环境如下:
- windows 7 64位
- mongodb 3.2.6
- [redis 2.8.24](https://github.com/MSOpenTech/redis/releases)
- Python 2.7
- Microsoft Visual Studio C++ 2013

1, node-gyp
一定要全局安装好node-gyp, ```npm i -g node-gyp```
这个库依赖python 2.7, vs2013. c++编译环境一定要配置好, 不然很多包都装不了.

2, redis
redis for windows 只支持64位的操作系统

## 线上布署
```
$ pm2 start process.json
Expand Down
20 changes: 10 additions & 10 deletions package.json
@@ -1,6 +1,6 @@
{
"name": "jackblog-api-express",
"version": "1.3.0",
"version": "1.3.1",
"description": "Jackblog API Express版",
"main": "server/app.js",
"scripts": {
Expand All @@ -23,9 +23,9 @@
},
"homepage": "https://github.com/jackhutu/jackblog-api-express#readme",
"dependencies": {
"bluebird": "^3.3.4",
"bluebird": "^3.3.5",
"body-parser": "^1.15.0",
"bunyan": "^1.8.0",
"bunyan": "^1.8.1",
"ccap": "^0.6.4",
"composable-middleware": "^0.3.0",
"compression": "^1.6.1",
Expand All @@ -37,20 +37,20 @@
"express-jwt": "^3.3.0",
"express-session": "^1.13.0",
"ioredis": "^1.15.1",
"jsonwebtoken": "^5.7.0",
"lodash": "^4.9.0",
"jsonwebtoken": "^6.2.0",
"lodash": "^4.11.1",
"markdown-it": "^6.0.1",
"method-override": "^2.3.5",
"moment": "^2.12.0",
"mongoose": "^4.4.12",
"moment": "^2.13.0",
"mongoose": "^4.4.14",
"multer": "^1.1.0",
"passport": "^0.3.2",
"passport-github": "^1.1.0",
"passport-local": "^1.0.0",
"passport-qq": "0.0.3",
"passport-weibo": "^0.1.2",
"pm2": "^1.1.1",
"qiniu": "^6.1.9"
"pm2": "^1.1.3",
"qiniu": "^6.1.10"
},
"devDependencies": {
"gulp": "^3.9.1",
Expand All @@ -61,7 +61,7 @@
"gulp-nodemon": "^2.0.6",
"gulp-sequence": "^0.4.5",
"gulp-util": "^3.0.7",
"should": "^8.3.0",
"should": "^8.3.1",
"sinon": "^1.17.3",
"supertest": "^1.2.0"
}
Expand Down
11 changes: 7 additions & 4 deletions server/api/article/article.controller.js
Expand Up @@ -262,11 +262,14 @@ exports.getIndexImage = function (req,res,next) {
redis.llen('indexImages').then(function (imagesCount) {
if(imagesCount < 1){
res.status(200).json({success:true,img:config.defaultIndexImage});
return qiniuHelper.list('blog/index','',30).then(function(result){
return Promise.map(result.items,function (item) {
return redis.lpush('indexImages',config.qiniu.domain + item.key + '-600x1500q80');
if(config.qiniu.app_key !== '' && config.qiniu.app_secret !== ''){
return qiniuHelper.list('blog/index','',30).then(function(result){
return Promise.map(result.items,function (item) {
return redis.lpush('indexImages',config.qiniu.domain + item.key + '-600x1500q80');
});
});
});
}
return;
}else{
return redis.lrange('indexImages', 0, 30).then(function (images) {
var index = _.random(images.length - 1);
Expand Down
8 changes: 4 additions & 4 deletions server/config/env/index.js
Expand Up @@ -30,10 +30,10 @@ var all = {
userRoles: ['user', 'admin'],
//七牛配置
qiniu:{
app_key:"app_key",
app_secret:"app_secret",
domain:"domain", //七牛配置域名
bucket:"bucket" //七牛空间名称
app_key:'',
app_secret:'',
domain:'', //七牛配置域名
bucket:'' //七牛空间名称
},
//默认首页图片.
defaultIndexImage:"http://upload.jackhu.top/blog/index/8x7hVJvpE3Z6ruwgtd2G.jpg",
Expand Down
3 changes: 1 addition & 2 deletions server/config/express.js
Expand Up @@ -7,11 +7,10 @@ var cors = require('cors');
var methodOverride = require('method-override');
var cookieParser = require('cookie-parser');
var path = require('path');
var config = require('./env');
var passport = require('passport');
var session = require('express-session');
var RedisStore = require('connect-redis')(session);
var mongoose = require('mongoose');
var config = require('./env');

module.exports = function(app) {
app.enable('trust proxy');
Expand Down
3 changes: 3 additions & 0 deletions test/api/article.test.js
Expand Up @@ -8,6 +8,9 @@ var User = mongoose.model('User');
var Article = mongoose.model('Article');
var Logs = mongoose.model('Logs');
var Promise = require('bluebird');
var config = require('../../server/config/env');
config.qiniu.app_key = 'test';
config.qiniu.app_secret = 'test';
var qiniuHelper = require('../../server/util/qiniu');
var sinon = require('sinon');
var authHelper = require('../middlewares/authHelper');
Expand Down

0 comments on commit c7528be

Please sign in to comment.