Skip to content

Commit

Permalink
v1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
luoyjx committed Oct 28, 2016
1 parent 5cabe1d commit efb8e79
Show file tree
Hide file tree
Showing 77 changed files with 3,725 additions and 7,267 deletions.
7 changes: 5 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
.idea
.svn
node_modules
config.js
assets.json
logs
*.log
Expand All @@ -10,4 +9,8 @@ pids
*.pid
*.seed
lib-cov
coverage
coverage
public/**/*.debug.css
public/**/*.min.css
public/**/*.debug.js
public/**/*.min.js
47 changes: 0 additions & 47 deletions Makefile

This file was deleted.

37 changes: 18 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,32 +26,31 @@ gaoqi-blog
# 安装运行

* 安装上面所需的3个环境
* 安装前置
* linux
* `make preinstall`
* `npm run prebuild`
* windows
* `npm run prebuild`
* `make install` 把依赖安装上
* 如果`config.js`中debug 未设置为true,则需要`make build`(Windows 可使用`npm run build`来构建),压缩合并一下js、css文件
* 使用`node app.js`运行,推荐`pm2`管理应用进程,安装后使用`make start`
* `make restart`重新编译重启,`make reboot`直接重启
* 浏览`http://localhost:3001`

# 测试
* 安装依赖 `npm install`
* js、css压缩合并 `npm run build`
* 开发环境启动 `npm run dev`
* 生产环境启动 `npm start`
* 生产环境重启 `npm restart`
* 生产环境快速重启 `make reboot`
* 访问 `http://localhost:3001`

# test

* `npm test`
* `make test`

# 覆盖
# coverage

* `npm run test-cov`
* `make test-cov`

# 版本日志
# changelog

## 1.0.1 / 2016-10-25
* 重构config files
* 更新readme
* 移除`Makefile`,全部使用`npm scripts`代替

## 0.0.11 / 2016-8-13
* 界面改版
## 1.0.0 / 2016-10-21
* 界面重构

## 0.0.10 / 2016-7-16
* 升级依赖
Expand Down
6 changes: 1 addition & 5 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,6 @@


var config = require('./config');
if (!config.debug && config.oneapm_key !== 'your oneapm key') {
require('oneapm');
}

var path = require('path');
var Loader = require('loader');
var LoaderConnect = require('loader-connect')
Expand Down Expand Up @@ -39,7 +35,7 @@ var app = express();
// 静态文件目录
var staticDir = path.join(__dirname, 'public');
var assets = {};
if (config.mini_assets) {
if (process.env.NODE_ENV === 'production') {
try {
assets = require('./assets.json');
} catch (e) {
Expand Down
22 changes: 0 additions & 22 deletions bin/pre_install.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,31 +5,9 @@

var fs = require("fs");
var util = require("util");
var cp = require("../util/cp");

var configFileName = "config.js";
var configDefaultFileName = "config.default.js";
var uploadDirPath = "public/upload";

console.log(util.format("checking \x1b[36m %s \x1b[0m file.", configFileName));

//配置文件configFileName不存在的情况下,根据配置文件模板configDefaultFileName复制一份新的
fs.access(configFileName, fs.F_OK, function(err) {

if (err) {

cp(configDefaultFileName, configFileName, function(err) {
if (err) {
console.log(err);
} else {
console.log(util.format("successfully creat file \x1b[36m %s \x1b[0m .", configFileName));
}
});
} else {
console.log(util.format("file \x1b[36m %s \x1b[0m exists.", configFileName));
}
});

console.log(util.format("checking \x1b[36m %s \x1b[0m directory.", uploadDirPath));
fs.access(uploadDirPath, fs.F_OK, function(err) {
if (err) {
Expand Down
9 changes: 4 additions & 5 deletions common/cutter.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,12 @@ exports.shorter = function (content, length) {
var t = 0;
for (var i = 0; i < length; i++) {
if (cache.substr(i, 1).match("[\u4e00-\u9fa5]")) {
if (t + 2 > length) break;
t = t + 2;//汉字
} else {
if (t + 1 > length) break;
t = t + 1;//英文
}
if (t > length) {
break;
}
}
var result = cache.substring(0, t);
if (len > length) {
Expand All @@ -37,5 +36,5 @@ exports.shorter = function (content, length) {
* @param {String} content 需要被清除的内容
*/
exports.clearHtml = function (content) {

};
return content;
};
2 changes: 1 addition & 1 deletion common/tools.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ exports.bhash = function (str) {

};

exports.bcompare = function (str, hash, callback) {
exports.bcompare = function (str, hash) {
return new Promise(function (resolve, reject) {
bcrypt.compare(str, hash, function(err, result) {
if (err) return reject(err);
Expand Down
122 changes: 0 additions & 122 deletions config.default.js

This file was deleted.

11 changes: 11 additions & 0 deletions config/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/**
* config index
* @authors yanjixiong
* @date 2016-10-25 09:23:33
*/

var env = process.env.NODE_ENV === 'production' ? 'production' : 'development';

console.log('load %s config', env);

module.exports = require('./env/' + env);
2 changes: 1 addition & 1 deletion controllers/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ exports.create = function(req, res, next) {
})
.then(function(userFind) {
userFind.score += 5;
userFind.topic_count += 1;
userFind.post_count += 1;
userFind.save();
req.session.user = userFind;
//发送at消息
Expand Down
2 changes: 2 additions & 0 deletions controllers/reply.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ exports.add = function (req, res, next) {
at.sendMessageToMentionUsers(newContent, post_id, req.session.user._id, reply._id, userFind.login_name, _post.title);
_post.reply_count += 1;
_post.update_at = new Date();
_post.last_reply_at = new Date();
_post.last_reply = req.session.user._id;
_post.save();
return Promise.resolve(reply);
})
Expand Down
2 changes: 1 addition & 1 deletion controllers/sign.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ exports.signup = function (req, res, next) {
return tools.bhash(pass);
})
.then(function(passhash) {
var avatarUrl = User.makeGravatar();
var avatarUrl = User.makeGravatar(email);
User
.newAndSave(loginname, loginname, passhash, email, avatarUrl, false)
.then(function() {
Expand Down
Loading

0 comments on commit efb8e79

Please sign in to comment.