Skip to content

Commit

Permalink
提交liblog开源版代码
Browse files Browse the repository at this point in the history
  • Loading branch information
livisky committed Jun 8, 2016
1 parent 9b19158 commit 9c5b37b
Show file tree
Hide file tree
Showing 3,278 changed files with 845,959 additions and 2 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
17 changes: 17 additions & 0 deletions .project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>liblog</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.aptana.ide.core.unifiedBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.aptana.projects.webnature</nature>
</natures>
</projectDescription>
5 changes: 5 additions & 0 deletions .thinkjsrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"createAt": "2016-02-29 15:35:54",
"mode": "module",
"es": true
}
25 changes: 23 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,23 @@
# liblog
build with thinkjs
##liblog开源博客系统(v1.0)
@(liblog)[thinkjs|nodejs|博客系统|liblog]
>liblog是一个基于thinkjs框架的nodejs的开源博客系统。
[toc]

##主要功能
###文章管理
文章的增、删、查、改,分类管理,标签管理
###添加markdown文章
上传markdown标准格式,自动解析为html文章
###邮件验证
注册用户邮件验证
###用户管理
用户的增、删、查、改及管理员管理
###防止csrf攻击
所有请求都有防csrf攻击
###评论管理
评论查看,删除,审核
###留言板
留言板
###系统设置
基本设置及邮件设置
207 changes: 207 additions & 0 deletions liblog.sql

Large diffs are not rendered by default.

120 changes: 120 additions & 0 deletions nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
server {
listen 80;
server_name example.com www.example.com;
root d:\study\Thinkjs\livi_blog/d:\study\Thinkjs\livi_blog\blog/www;
set $node_port 8360;

index index.js index.html index.htm;
if ( -f $request_filename/index.html ){
rewrite (.*) $1/index.html break;
}
if ( !-f $request_filename ){
rewrite (.*) /index.js;
}
location = /index.js {
proxy_http_version 1.1;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_set_header X-NginX-Proxy true;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_pass http://127.0.0.1:$node_port$request_uri;
proxy_redirect off;
}

location = /development.js {
deny all;
}

location = /testing.js {
deny all;
}

location = /production.js {
deny all;
}

location ~ /static/ {
etag on;
expires max;
}
}




## http/2 nginx conf

# server {
# listen 80;
# server_name example.com www.example.com;
# rewrite ^(.*) https://example.com$1 permanent;
# }
#
# server {
# listen 443 ssl http2 fastopen=3 reuseport;
# server_name www.thinkjs.org thinkjs.org;
# set $node_port 8360;
#
# root d:\study\Thinkjs\livi_blog/d:\study\Thinkjs\livi_blog\blog/www;
#
# keepalive_timeout 70;
#
# ssl_certificate /path/to/certificate;
# ssl_certificate_key /path/to/certificate.key;
# ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
# ssl_ciphers "ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA";
# ssl_prefer_server_ciphers on;

# # openssl dhparam -out dhparams.pem 2048
# ssl_dhparam /path/to/dhparams.pem;
#
# ssl_session_cache shared:SSL:10m;
# ssl_session_timeout 10m;
#
# ssl_session_ticket_key /path/to/tls_session_ticket.key;
# ssl_session_tickets on;
#
# ssl_stapling on;
# ssl_stapling_verify on;
# ssl_trusted_certificate /path/to/startssl_trust_chain.crt;
#
#
# add_header x-Content-Type-Options nosniff;
# add_header X-Frame-Options deny;
# add_header Strict-Transport-Security "max-age=16070400";
#
# index index.js index.html index.htm;
# if ( -f $request_filename/index.html ){
# rewrite (.*) $1/index.html break;
# }
# if ( !-f $request_filename ){
# rewrite (.*) /index.js;
# }
# location = /index.js {
# proxy_http_version 1.1;
# proxy_set_header X-Real-IP $remote_addr;
# proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# proxy_set_header Host $http_host;
# proxy_set_header X-NginX-Proxy true;
# proxy_set_header Upgrade $http_upgrade;
# proxy_set_header Connection "upgrade";
# proxy_pass http://127.0.0.1:$node_port$request_uri;
# proxy_redirect off;
# }
#
# location = /production.js {
# deny all;
# }
#
# location = /testing.js {
# deny all;
# }
#
# location ~ /static/ {
# etag on;
# expires max;
# }
#}

31 changes: 31 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"name": "thinkjs-application",
"description": "application created by thinkjs",
"version": "1.0.0",
"scripts": {
"start": "node www/development.js",
"compile": "babel --presets es2015-loose,stage-1 --plugins transform-runtime src/ --out-dir app/ --retain-lines",
"watch-compile": "node -e \"console.log('<npm run watch-compile> no longer need, use <npm start> command direct.');console.log();\"",
"watch": "npm run watch-compile"
},
"dependencies": {
"babel-runtime": "6.x.x",
"geetest": "^1.0.1",
"jquery": "^2.2.2",
"marked": "^0.3.5",
"nodemailer": "^0.7.1",
"pm2": "^1.1.2",
"think-debug-toolbar": "^1.0.12",
"think-ip-filter": "^1.0.3",
"thinkjs": "2.1.x"
},
"devDependencies": {
"babel-cli": "6.x.x",
"babel-preset-es2015-loose": "6.x.x",
"babel-preset-stage-1": "6.x.x",
"babel-plugin-transform-runtime": "6.x.x",
"babel-core": "6.x.x"
},
"repository": "",
"license": "MIT"
}
7 changes: 7 additions & 0 deletions src/admin/config/config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict';
/**
* config
*/
export default {
//key: value
};
22 changes: 22 additions & 0 deletions src/admin/controller/article.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
'use strict';
/**
* rest controller
* @type {Class}
*/
export default class extends think.controller.rest {
/**
* init
* @param {Object} http []
* @return {} []
*/
init(http){
super.init(http);
this._method='method';
}
/**
* before magic method
* @return {Promise} []
*/
async __before(){
}
}
27 changes: 27 additions & 0 deletions src/admin/controller/base.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
'use strict';

export default class extends think.controller.base {
/**
* some base method in here
*/
async __before() {
await this.getConfig();
//判断登陆
let userinfo=await this.session("userInfo");
if(think.isEmpty(userinfo)){
return this.redirect("/login/redirect");
}else{
this.assign('userinfo',userinfo);
}
//判断登陆

// csrf 防止模拟提交
let csrf=await this.session("__CSRF__");
this.assign("csrf",csrf);

}
async getConfig() {
let sysdata=await this.model('system').where({id:1}).find();
this.assign('_web',sysdata);
}
}
50 changes: 50 additions & 0 deletions src/admin/controller/comment.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
'use strict';

import Base from './base.js';

export default class extends Base {
/**
* index action
* @return {Promise} []
*/
async indexAction(){

// 分页
let commentList=await this.model("comment").page(this.get("page"), this.get("pagesize")).select();
let result = await this.model("comment").page(this.get('page'),this.get('pagesize')).countSelect();
let Page=think.adapter("template", "page");
let page = new Page(this.http);
let pageData=page.pagination(result);
this.assign("commentList",commentList);
this.assign('pageData',pageData);
// 分页
// 初始化分页
let pagesize=await this.config("pagesize");
if(!this.get("page")){
return this.redirect("/admin/comment/index?page=1&pagesize="+pagesize);
}
// 初始化分页
this.assign("title","评论管理");
return this.display();
}


//删除或批量删除接口
async delsomeAction(){
let arr=await this.post('delarr[]');
let rs=this.model("comment").where({id: ["IN", arr]}).delete();
if(rs){
//操作成功
return this.success();
}
}

//举报列表
async tiplistAction(){

let tiplist=await this.model('comment').where({tipoff:1}).select();
this.assign('tiplist',tiplist);
this.assign('title','评论举报列表')
return this.display();
}
}
Loading

0 comments on commit 9c5b37b

Please sign in to comment.