├── public ├── image │ ├── header-log.jpg │ └── blog-header-log.jpg ├── fonts │ ├── glyphicons-halflings-regular.eot │ ├── glyphicons-halflings-regular.ttf │ ├── glyphicons-halflings-regular.woff │ ├── glyphicons-halflings-regular.woff2 │ └── glyphicons-halflings-regular.svg ├── js │ ├── admin.js │ ├── index.js │ └── bootstrap.min.js └── css │ ├── admin.css │ └── main.css ├── schemas ├── categories.js ├── users.js └── contents.js ├── models ├── User.js ├── Content.js └── Category.js ├── views ├── admin │ ├── index.html │ ├── page.html │ ├── success.html │ ├── category_add.html │ ├── error.html │ ├── cate_edit.html │ ├── category_index.html │ ├── user_admin.html │ ├── content_index.html │ ├── content_add.html │ ├── content_edit.html │ └── layout.html └── main │ ├── index.html │ ├── content_view.html │ └── layout.html ├── package.json ├── LICENSE ├── routers ├── main.js ├── api.js └── admin.js └── app.js /public/image/header-log.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/moaiqin/Nodejs-blog/HEAD/public/image/header-log.jpg -------------------------------------------------------------------------------- /public/image/blog-header-log.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/moaiqin/Nodejs-blog/HEAD/public/image/blog-header-log.jpg -------------------------------------------------------------------------------- /public/fonts/glyphicons-halflings-regular.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/moaiqin/Nodejs-blog/HEAD/public/fonts/glyphicons-halflings-regular.eot -------------------------------------------------------------------------------- /public/fonts/glyphicons-halflings-regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/moaiqin/Nodejs-blog/HEAD/public/fonts/glyphicons-halflings-regular.ttf -------------------------------------------------------------------------------- /public/fonts/glyphicons-halflings-regular.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/moaiqin/Nodejs-blog/HEAD/public/fonts/glyphicons-halflings-regular.woff -------------------------------------------------------------------------------- /public/fonts/glyphicons-halflings-regular.woff2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/moaiqin/Nodejs-blog/HEAD/public/fonts/glyphicons-halflings-regular.woff2 -------------------------------------------------------------------------------- /schemas/categories.js: -------------------------------------------------------------------------------- 1 | var mongoose = require('mongoose'); 2 | //分类的表结构 3 | module.exports = new mongoose.Schema({ 4 | //分类名称 5 | name:String 6 | }); -------------------------------------------------------------------------------- /models/User.js: -------------------------------------------------------------------------------- 1 | var mongoose = require('mongoose'); 2 | 3 | var userSchema = require('../schemas/users'); 4 | 5 | module.exports = mongoose.model('User',userSchema); -------------------------------------------------------------------------------- /models/Content.js: -------------------------------------------------------------------------------- 1 | var mongoose = require('mongoose'); 2 | var contentSchema = require('../schemas/contents'); 3 | 4 | module.exports = mongoose.model('Content',contentSchema); -------------------------------------------------------------------------------- /models/Category.js: -------------------------------------------------------------------------------- 1 | var mongoose = require('mongoose'); 2 | var categorySchema = require('../schemas/categories'); 3 | 4 | module.exports = mongoose.model('Category',categorySchema); -------------------------------------------------------------------------------- /public/js/admin.js: -------------------------------------------------------------------------------- 1 | function cateDelete(id){ 2 | var deleBool = window.confirm('确定删除吗?'); 3 | if(deleBool){ 4 | window.location.href = '/admin/category/delete?_id='+id; 5 | } 6 | } -------------------------------------------------------------------------------- /public/css/admin.css: -------------------------------------------------------------------------------- 1 | .admin-in-block{ 2 | background: #eee; 3 | } 4 | .header-admin{ 5 | margin-bottom: 0px; 6 | background-color: #ccc; 7 | } 8 | .breadcrumb{ 9 | margin-bottom: 0; 10 | } -------------------------------------------------------------------------------- /views/admin/index.html: -------------------------------------------------------------------------------- 1 | {% extends 'layout.html' %} 2 | 3 | {% block main %} 4 |
5 |

hello,{{userInfo.username}}

6 |

欢迎进入后台管理系统

7 |
8 | {% endblock %} -------------------------------------------------------------------------------- /schemas/users.js: -------------------------------------------------------------------------------- 1 | var mongoose = require('mongoose'); 2 | 3 | module.exports = new mongoose.Schema({ 4 | //用户名 5 | username: String, 6 | //密码 7 | password: String, 8 | //是否是管理员 9 | isAdmin: { 10 | type:Boolean, 11 | default:false 12 | } 13 | }); -------------------------------------------------------------------------------- /views/admin/page.html: -------------------------------------------------------------------------------- 1 | 2 | 9 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "blog", 3 | "version": "1.0.0", 4 | "description": "node to dev blog", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [ 10 | "node", 11 | "js" 12 | ], 13 | "author": "moge", 14 | "license": "ISC", 15 | "dependencies": { 16 | "body-parser": "^1.17.2", 17 | "cookies": "^0.7.0", 18 | "express": "^4.15.3", 19 | "markdown": "^0.5.0", 20 | "mongoose": "^4.11.0", 21 | "swig": "^1.4.2" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /views/admin/success.html: -------------------------------------------------------------------------------- 1 | {% extends 'layout.html' %} 2 | {% block main %} 3 | 8 |
9 |
10 |
11 |

成功提示:

12 |
13 |
14 |

{{message}}

15 |
16 | 19 |
20 |
21 | 22 | {% endblock %} -------------------------------------------------------------------------------- /views/admin/category_add.html: -------------------------------------------------------------------------------- 1 | {% extends 'layout.html' %} 2 | {% block main %} 3 | 8 |

分类添加

9 |
10 |
11 |
12 | 13 | 14 |
15 | 16 |
17 |
18 | 19 | {% endblock %} -------------------------------------------------------------------------------- /views/admin/error.html: -------------------------------------------------------------------------------- 1 | {% extends 'layout.html' %} 2 | {% block main %} 3 | 8 |
9 |
10 |
11 |

错误提示:

12 |
13 |
14 |

{{error}}

15 |
16 | 23 |
24 |
25 | 26 | {% endblock %} -------------------------------------------------------------------------------- /views/admin/cate_edit.html: -------------------------------------------------------------------------------- 1 | {% extends 'layout.html'%} 2 | {% block main %} 3 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 19 | 22 | 25 | 26 | 27 |
ID类名编辑
17 | {{cate._id.toString()}} 18 | 20 | 21 | 23 | 24 |
28 | {% endblock%} -------------------------------------------------------------------------------- /views/admin/category_index.html: -------------------------------------------------------------------------------- 1 | {% extends 'layout.html' %} 2 | {% block main %} 3 | 7 |

分类列表

8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 | {% for cate in cates%} 16 | 17 | 18 | 19 | 24 | 25 | {% endfor %} 26 |
ID类名操作
{{cate._id.toString()}}{{cate.name}} 20 | 删除 21 | | 22 | 编辑 23 |
27 | {% include 'page.html' %} 28 |
29 | {% endblock %} -------------------------------------------------------------------------------- /views/admin/user_admin.html: -------------------------------------------------------------------------------- 1 | {% extends 'layout.html' %} 2 | {% block main %} 3 | 7 |

用户列表

8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | {% for user in users %} 18 | 19 | 20 | 21 | 22 | 29 | 30 | {% endfor %} 31 |
ID用户名密码是否是管理员
{{user._id.toString()}}{{user.username}}{{user.password}} 23 | {% if user.isAdmin %} 24 | 是 25 | {% else %} 26 | 否 27 | {% endif %} 28 |
32 | {% include 'page.html' %} 33 |
34 | {% endblock %} -------------------------------------------------------------------------------- /schemas/contents.js: -------------------------------------------------------------------------------- 1 | var mongoose = require('mongoose'); 2 | module.exports = new mongoose.Schema({ 3 | //关联,如果没有populate(category)那么categoty就是id,有的话categrory就是另一个表{ddd} 4 | category:{ 5 | type:mongoose.Schema.Types.ObjectId, 6 | ref:'Category' 7 | }, 8 | 9 | //标题 10 | title:{ 11 | type:String, 12 | default:'' 13 | }, 14 | 15 | //user 16 | user:{ 17 | type:mongoose.Schema.Types.ObjectId, 18 | ref:'User' 19 | }, 20 | 21 | 22 | //时间 23 | date:{ 24 | type:Date, 25 | default:new Date() 26 | }, 27 | 28 | //浏览数 29 | views:{ 30 | type:Number, 31 | default:0 32 | }, 33 | 34 | //简介 35 | description:{ 36 | type:String, 37 | default:'' 38 | }, 39 | 40 | //内容 41 | content:{ 42 | type:String, 43 | default:'' 44 | }, 45 | //评论 46 | comment:{ 47 | type:Array, 48 | default:[] 49 | } 50 | }); -------------------------------------------------------------------------------- /views/admin/content_index.html: -------------------------------------------------------------------------------- 1 | {% extends 'layout.html' %} 2 | 3 | {% block main %} 4 | 8 |

内容列表

9 |
10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | {% for content in contents %} 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 33 | 34 | {% endfor %} 35 |
ID分类标题作者时间浏览量操作
{{content._id.toString()}}{{content.category.name.toString()}}{{content.title}}{{content.user.username}}{{content.date|date('Y年m月d日 H:i:s',-8*60)}}{{content.views}} 29 | 编辑| 30 | 删除| 31 | 查看| 32 |
36 |
37 | {% include 'page.html' %} 38 | {% endblock %} -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2017 moaiqin 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /views/main/index.html: -------------------------------------------------------------------------------- 1 | {% extends 'layout.html' %} 2 | 3 | {% block main %} 4 | {% for content in contents %} 5 |
6 |

{{ content.title }}

7 |
8 | 作者:{{content.user.username}} 9 | 时间:{{content.date|date('Y-m-d H:i:s', -8*60)}} 10 | 阅读:{{content.views}} 11 | 评论:{{content.comment.length}} 12 |
13 |

{{content.description}}

14 |
15 | 阅读全文 16 |
17 |
18 | {% endfor %} 19 | 38 | {% endblock %} -------------------------------------------------------------------------------- /views/admin/content_add.html: -------------------------------------------------------------------------------- 1 | {% extends 'layout.html' %} 2 | 3 | 4 | {% block main %} 5 | 10 |
添加文章
11 |
12 |
13 |
14 | 15 | {% if cates %} 16 | 21 | {% else %} 22 | 添加分类 23 | {% endif %} 24 |
25 |
26 | 27 | 28 |
29 |
30 | 31 | 32 |
33 |
34 | 35 | 36 |
37 | 38 |
39 |
40 | {% endblock %} -------------------------------------------------------------------------------- /routers/main.js: -------------------------------------------------------------------------------- 1 | var express = require('express'); 2 | var Category = require('../models/Category'); 3 | var Content = require('../models/Content'); 4 | 5 | var router = express.Router(); 6 | var data ={}; 7 | router.use(function(req,res,next){ 8 | data.userInfo = req.userInfo; 9 | Category.find().then(function(cates){ 10 | data.cates = cates; 11 | next(); 12 | }) 13 | }) 14 | 15 | router.get('/', function(req, res, next) { 16 | data.limit = 4, 17 | data.category = req.query.category || '', 18 | data.page = Number(req.query.page) || 1, 19 | data.totalPage = 0, 20 | data.skip = 0, 21 | data.contents = [] 22 | var where = {}; 23 | 24 | if(data.category){ 25 | where.category = data.category; 26 | } 27 | 28 | Content.where(where).count().then(function(rowsNum){ 29 | data.totalPage = Math.ceil(rowsNum/data.limit); 30 | data.page = Math.min(data.page,data.totalPage); 31 | data.page = Math.max(1,data.page); 32 | data.skip = (data.page - 1)*data.limit; 33 | return Content.where(where).find().sort({_id:-1}).limit(data.limit).skip(data.skip).populate(['category','user']) 34 | }).then(function(contents){ 35 | data.contents = contents; 36 | res.render('main/index',data); 37 | }) 38 | 39 | }) 40 | 41 | router.get('/view',function(req,res,next){ 42 | var id = req.query.content; 43 | Content.findOne({ 44 | _id:id 45 | }).populate('user').then(function(contentInfo){ 46 | data.content = contentInfo; 47 | contentInfo.views++; 48 | contentInfo.save(); 49 | res.render('main/content_view',data); 50 | }); 51 | }) 52 | 53 | module.exports = router; -------------------------------------------------------------------------------- /views/admin/content_edit.html: -------------------------------------------------------------------------------- 1 | {% extends 'layout.html'%} 2 | {% block main %} 3 | 8 |
内容编辑
9 |
10 |
11 |
12 | 13 | {% if cates %} 14 | 23 | {% else %} 24 | 添加分类 25 | {% endif %} 26 |
27 |
28 | 29 | 30 |
31 |
32 | 33 | 34 |
35 |
36 | 37 | 38 |
39 | 40 |
41 |
42 | {% endblock%} -------------------------------------------------------------------------------- /views/main/content_view.html: -------------------------------------------------------------------------------- 1 | {% extends 'layout.html' %} 2 | {% block main %} 3 |
4 |

{{ content.title }}

5 |
6 | 作者:{{content.user.username}} 7 | 时间:{{content.date|date('Y-m-d H:i:s', -8*60)}} 8 | 阅读:{{content.views}} 9 | 评论:{{content.comment.length}} 10 |
11 |

{{content.content}}

12 |
13 |
14 |
15 |

评论

16 | 一共有{{content.comment.length}}条评论 17 |
18 |
19 |
20 | 21 | 22 |
23 | 24 |
25 |
26 |
27 | {% if !userInfo._id%} 28 |
29 | 你还没登陆,请先登录 30 |
31 | {% endif %} 32 | {% if content.comment.length == 0 %} 33 |
34 | 还没有留言 35 |
36 | {% endif %} 37 | 48 | 58 |
59 | {% endblock %} 60 | -------------------------------------------------------------------------------- /views/admin/layout.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Document 6 | {% block css %} 7 | 8 | 9 | {% endblock %} 10 | 11 | 12 | 13 | 14 | 15 | 60 | {% block main %} 61 | 62 | -------------------------------------------------------------------------------- /app.js: -------------------------------------------------------------------------------- 1 | 2 | //加载express模块 3 | var express = require('express'); 4 | //加载body-parse接受前台发过来的数据 5 | var bodyParser = require('body-parser'); 6 | //加载cookies 7 | var cookies = require('cookies'); 8 | //加载模板 9 | var swig = require('swig'); 10 | 11 | var User = require('./models/User'); 12 | //创建app应用 =>nodejs http.createServer(); 13 | var app = express(); 14 | 15 | //引入数据库 16 | var mongoose = require('mongoose'); 17 | 18 | //设置bodyparser 19 | app.use(bodyParser.urlencoded({extended: true})); 20 | 21 | //在模板中使用cookies 22 | app.use(function(req,res, next){ 23 | req.cookies = new cookies(req, res); 24 | //解析用户登陆信息的cookie 25 | req.userInfo = {}; 26 | if(req.cookies.get('userInfo')){ 27 | try{ 28 | req.userInfo = JSON.parse(req.cookies.get('userInfo')); 29 | User.findById(req.userInfo._id).then(function(userInfo){ 30 | req.userInfo.isAdmin = userInfo.isAdmin; 31 | }); 32 | next(); 33 | }catch(e){ 34 | next(); 35 | } 36 | }else{ 37 | next(); 38 | } 39 | }) 40 | 41 | //设置文件静态托管,当使用public的路由就会从下面找到文件 42 | app.use('/public', express.static(__dirname + '/public')) 43 | 44 | //模板配置 45 | //定义当前使用的模板引擎, 46 | //第一个参数,模板引擎的名称,同时也是模板文本 47 | //第二个参数解析处理模板内容的函数 48 | app.engine('html', swig.renderFile); 49 | 50 | //设置模板文件存放的目录,第一个必须是views,第二个是路径 51 | app.set('views', './views'); 52 | 53 | //注册所有使用的模板引擎,第一个必须是view engine,第二个参数是和swig.engine的第一个参数必须是一致的 54 | app.set('view engine','html'); 55 | 56 | //swig.renderFile默认是会缓存到内存,当向客户端提供数据会从缓存中去 57 | //线上提高性能,开发开发时,模板文件改变之后,刷新会从缓存中去来,内容和上次不变 58 | //所以要关掉 59 | swig.setDefaults({ 60 | cache:false 61 | }); 62 | 63 | //首页,根目录路由 64 | /* 65 | *req request对象 66 | *res response对象 67 | *next 函数 68 | * 69 | * 可以把路由都放在router模块下面,就可以把下面app.get政略掉,条例惊喜,用app.use 70 | * */ 71 | /*app.get('/', function(res, res, next) { 72 | //res.send('

欢迎访问我的博客

') 73 | //读取views下的指定目录文件,解析返回客户端 74 | //第一个参数,表示模板的文件,相对于views目录 75 | //第二个参数是传递给模板引擎的数据 76 | //相当于views/index.html 77 | res.render('index'); 78 | })*/ 79 | 80 | 81 | /* 82 | * 83 | *根据不同功能划分木块 84 | * 85 | **/ 86 | 87 | app.use('/admin',require('./routers/admin')); 88 | app.use('/api', require('./routers/api')); 89 | app.use('/', require('./routers/main')); 90 | 91 | 92 | 93 | /*//当一个html里面有个link href="/main.css"时也是一个请求,所以也是需要配置路由的 94 | //可以用文件静态托管处理 95 | app.get('/main.css',function(req, res, next) { 96 | res.setHeader('Content-Type','text/css'); 97 | res.send('body {background:red}');//这个默认的文件和app.engine的第一个参数一样是heml文件,所以沿设置header 98 | })*/ 99 | 100 | //监听 101 | //app.listen(4080); 102 | 103 | mongoose.Promise = global.Promise; 104 | //连接数据库 105 | mongoose.connect('mongodb://localhost:27017/blog', function(err) { 106 | if(err){ 107 | console.log('数据库连接失败'); 108 | }else{ 109 | console.log('数据库连接成功'); 110 | app.listen(4080); 111 | } 112 | }) 113 | 114 | 115 | 116 | //用户发送http请求->url->解析路由->找到文件匹配规则->实行指定的函数绑定,返回客户端 117 | // /public->静态文件->读取返回给客户 118 | // 其他路由->动态->处理业务逻辑,加载模板,解析模板->返回数据 -------------------------------------------------------------------------------- /views/main/layout.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 博客 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 |
14 |
15 |
16 | 30 |
31 |
32 |
33 |
34 | {% block main %} 35 | {% endblock %} 36 |
37 |
38 | {% if userInfo._id %} 39 |
40 |

41 | 用户信息 42 |

43 | {{userInfo.username}} 44 | {% if userInfo.isAdmin %} 45 |

你好,你是管理员点击进入管理

46 | {% else %} 47 |

你好,欢迎光临我的博客

48 | {% endif %} 49 | 退出 50 |
51 | {% else %} 52 |
53 |

用户登陆

54 | 71 |
72 | {% endif %} 73 | 97 |
98 |

社区

99 | 103 |
104 |
105 |
106 | 107 | -------------------------------------------------------------------------------- /routers/api.js: -------------------------------------------------------------------------------- 1 | var express = require('express'); 2 | var router = express.Router(); 3 | var User = require('../models/User'); 4 | var Content = require('../models/Content'); 5 | 6 | var responseData; 7 | router.use(function(req, res , next){ 8 | //每次调用api下面的这个都被初始化,code为0 9 | responseData = { 10 | code:0, 11 | message:'' 12 | }; 13 | next(); 14 | }) 15 | 16 | 17 | router.post('/user/register',function(req, res, next) { 18 | var username = req.body.username; 19 | var password = req.body.password; 20 | var repassword = req.body.password2; 21 | 22 | //用户名是否为空; 23 | if(username === ''){ 24 | responseData.code =1; 25 | responseData.message = '用户名不能为空'; 26 | res.json(responseData); 27 | return; 28 | } 29 | 30 | //密码不能为空 31 | if(password === ''){ 32 | responseData.code = 2; 33 | responseData.message = '密码不能为空'; 34 | res.json(responseData); 35 | return; 36 | } 37 | 38 | //两次密码要一样 39 | if(password !== repassword){ 40 | responseData.code = 3; 41 | responseData.message = '两次密码不一样'; 42 | res.json(responseData); 43 | return; 44 | } 45 | 46 | User.findOne({ 47 | username:username 48 | }).then(function(userinfo){ 49 | if(userinfo){ 50 | //表示有数 51 | responseData.code = 4; 52 | responseData.message = '用户名已经存在'; 53 | res.json(responseData); 54 | return; 55 | }else{ 56 | //表示没有数据 57 | var user = new User({ 58 | username:username, 59 | password:password 60 | }); 61 | return user.save(); 62 | } 63 | }).then(function(newUserinfo){ 64 | if(newUserinfo){ 65 | responseData.message = '注册成功'; 66 | res.json(responseData); 67 | } 68 | }) 69 | 70 | }) 71 | 72 | router.post('/user/login',function(req, res, next) { 73 | var username = req.body.username; 74 | var password = req.body.password; 75 | if(!username) { 76 | responseData.code = 1; 77 | responseData.message = '用户名不能为空'; 78 | res.json(responseData); 79 | return; 80 | } 81 | 82 | if(!password) { 83 | responseData.code = 2; 84 | responseData.message ='密码不能为空'; 85 | res.json(responseData); 86 | return; 87 | } 88 | 89 | User.findOne({ 90 | username:username, 91 | password:password 92 | }).then(function(userinfo) { 93 | 94 | if(!userinfo){ 95 | responseData.code = 3; 96 | responseData.message = '用户不存在或密码错误'; 97 | res.json(responseData); 98 | return; 99 | } 100 | responseData.userInfo = { 101 | _id:userinfo._id, 102 | username:userinfo.username 103 | }; 104 | //每次都会把cookies请求数据到服务端 105 | req.cookies.set('userInfo',JSON.stringify({ 106 | _id:userinfo._id, 107 | username:userinfo.username, 108 | isAdmin:userinfo.isAdmin 109 | })); 110 | responseData.message = '登陆成功'; 111 | res.json(responseData); 112 | }) 113 | }) 114 | 115 | router.get('/user/logout',function(req,res,next){ 116 | req.cookies.set('userInfo', null); 117 | res.json(responseData); 118 | }) 119 | 120 | 121 | /** 122 | * 评论提交 123 | * @type {[type]} 124 | */ 125 | 126 | router.post('/comment/post',function(req, res, next){ 127 | var contentId = req.body.contentId || ''; 128 | var postData = { 129 | username:req.userInfo.username, 130 | userId:req.userInfo._id.toString(), 131 | postDate:new Date(), 132 | content:req.body.content 133 | } 134 | console.log(contentId) 135 | 136 | if(!req.body.content){ 137 | responseData.message = '评论不能为空'; 138 | responseData.code = 1; 139 | res.json(responseData); 140 | return; 141 | } 142 | //查找该条内容 143 | Content.findOne({ 144 | _id:contentId 145 | }).then(function(content){ 146 | //content是entity类型,有save方法 147 | content.comment.push(postData); 148 | return content.save();//返回的是保存之后的表 149 | }).then(function(newContent){ 150 | if(newContent){ 151 | responseData.message = '评论成功'; 152 | responseData.data = newContent; 153 | res.json(responseData); 154 | } 155 | }) 156 | }); 157 | 158 | 159 | /** 160 | * 获取评论 161 | */ 162 | 163 | router.get('/comment',function(req, res, next){ 164 | var id = req.query.content || ''; 165 | Content.findOne({ 166 | _id:id 167 | }).then(function(contentInfo){ 168 | console.log(contentInfo) 169 | responseData.data = contentInfo.comment; 170 | res.json(responseData); 171 | }) 172 | }) 173 | 174 | 175 | module.exports = router; -------------------------------------------------------------------------------- /public/js/index.js: -------------------------------------------------------------------------------- 1 | $(function(){ 2 | var loginBox = $('#login'); 3 | var logoutBox = $('#logout'); 4 | var userBox = $('#user-info'); 5 | 6 | 7 | $('.blog-nav li').on('click',function(){ 8 | $('.blog-nav li').filter('.active').removeClass('active'); 9 | $(this).addClass('active'); 10 | }) 11 | loginBox.find('a').on('click', function() { 12 | logoutBox.show(); 13 | loginBox.hide(); 14 | }) 15 | logoutBox.find('a').on('click', function() { 16 | loginBox.show(); 17 | logoutBox.hide(); 18 | }) 19 | loginBox.find('button').on('click',function() { 20 | $.ajax({ 21 | type:'post', 22 | url:'/api/user/login', 23 | data:{ 24 | username:loginBox.find('[name="username"]').val(), 25 | password:loginBox.find('[name="password"]').val() 26 | }, 27 | dataType:'json', 28 | success:function(data){ 29 | loginBox.find('.login-message').html(data.message); 30 | if(!data.code){ 31 | window.location.reload(); 32 | } 33 | } 34 | }); 35 | }); 36 | logoutBox.find('button').on('click',function() { 37 | var username = logoutBox.find('[name="username"]').val(); 38 | var password = logoutBox.find('[name="password"]').val(); 39 | var password2 = logoutBox.find('[name="password2"]').val(); 40 | $.ajax({ 41 | type:'post', 42 | url:'/api/user/register', 43 | data:{ 44 | username:username, 45 | password:password, 46 | password2:password2 47 | }, 48 | dataType:'json', 49 | success:function(data){ 50 | logoutBox.find('.register-message').html(data.message); 51 | if(!data.code){ 52 | setTimeout(function(){ 53 | loginBox.show(); 54 | logoutBox.hide(); 55 | },1000) 56 | } 57 | } 58 | 59 | }) 60 | }); 61 | 62 | var commentList = $('.comment-page li'); 63 | var curPage = $('.cur-page span'); 64 | var start = 0; 65 | var limit = 4; 66 | var end = 0; 67 | var resData; 68 | var totalPage = 0; 69 | var page = 1; 70 | 71 | //和获取评论信息 72 | $.ajax({ 73 | type:'get', 74 | url:'/api/comment', 75 | data:{ 76 | content:$('#contentId').val() 77 | }, 78 | dataType:'json', 79 | success:function(response){ 80 | resData = response.data.reverse(); 81 | renderView(response.data.reverse()); 82 | } 83 | }); 84 | commentList.eq(0).on('click',function(){ 85 | page--; 86 | renderView(resData); 87 | }); 88 | commentList.eq(1).on('click',function(){ 89 | page++; 90 | renderView(resData); 91 | }); 92 | 93 | function renderView(comments){ 94 | if(comments.length === 0){ 95 | $('.comment-page').hide(); 96 | return; 97 | }else{ 98 | $('.no-msg').hide(); 99 | } 100 | var html = ''; 101 | totalPage = Math.ceil(comments.length/limit); 102 | if(page<=1){ 103 | page = 1; 104 | commentList.eq(0).html('上一页'); 105 | }else{ 106 | commentList.eq(0).html('上一页'); 107 | } 108 | if(page>=totalPage){ 109 | page = totalPage; 110 | commentList.eq(1).html('下一页') 111 | }else{ 112 | commentList.eq(1).html('下一页'); 113 | } 114 | start =(page-1)*limit; 115 | end = start+limit; 116 | if(end>comments.length){ 117 | end = comments.length; 118 | } 119 | curPage.eq(0).html(page); 120 | curPage.eq(1).html(totalPage); 121 | $('.comment-total').html('一共有'+comments.length+'条评论'); 122 | for(var i = start; i'+dateFmat(comments[i].postDate)+'

'+comments[i].content+'

'; 124 | } 125 | $('#content').val(''); 126 | $('.comment-list').html(html); 127 | } 128 | 129 | $('.logout').eq(0).on('click', function () { 130 | $.ajax({ 131 | type:'get', 132 | url:'/api/user/logout', 133 | dataType:'json', 134 | success:function(res){ 135 | if(!res.code){ 136 | window.location.reload(); 137 | } 138 | } 139 | }) 140 | }) 141 | $('.submit').on('click',function(){ 142 | 143 | $.ajax({ 144 | type:'post', 145 | url:'/api/comment/post', 146 | data:{ 147 | contentId:$('#contentId').val(), 148 | content:$('#content').val() 149 | }, 150 | dataType:'json', 151 | success:function(response){ 152 | if(!response.code){ 153 | page = 1; 154 | resData = response.data.comment.reverse(); 155 | renderView(response.data.comment.reverse()); 156 | } 157 | } 158 | }); 159 | }) 160 | }) 161 | 162 | 163 | function dateFmat(time){ 164 | var date = new Date(time); 165 | var str =''; 166 | str = date.getFullYear()+'-' + dateGetTwo((date.getMonth()+1)) + '月'+ dateGetTwo(date.getDate()) +'日'+ ' ' + dateGetTwo(date.getHours())+':'+dateGetTwo(date.getMinutes())+':'+dateGetTwo(date.getSeconds()); 167 | return str 168 | } 169 | 170 | function dateGetTwo(num){ 171 | return num>10? num:'0'+num; 172 | } -------------------------------------------------------------------------------- /public/css/main.css: -------------------------------------------------------------------------------- 1 | *{ 2 | margin: 0; 3 | padding: 0; 4 | } 5 | 6 | ul,li{ 7 | list-style: none; 8 | } 9 | a{ 10 | text-decoration: none 11 | } 12 | 13 | .clear-fix{ 14 | overflow: hidden; 15 | zoom: 1; 16 | } 17 | 18 | .hidden{ 19 | display: none; 20 | } 21 | 22 | /* 23 | blog 头 24 | */ 25 | .blog-header{ 26 | height: 180px; 27 | } 28 | .blog-header .blog-log{ 29 | height: 80%; 30 | width: 100%; 31 | background-size: 100% 100%; 32 | background-repeat: no-repeat; 33 | background-image: url('../image/header-log.jpg'); 34 | } 35 | .blog-nav{ 36 | height: 20%; 37 | } 38 | .blog-nav ul{ 39 | height: 100%; 40 | display: flex; 41 | justify-content: center; 42 | } 43 | .blog-nav ul li{ 44 | height: 100%; 45 | padding: 0 15px; 46 | display: flex; 47 | align-items: center; 48 | } 49 | .blog-nav ul li a{ 50 | color: #999; 51 | font-size: 16px; 52 | font-weight: bold; 53 | } 54 | .blog-nav ul li:hover{ 55 | border-bottom: 2px solid red; 56 | } 57 | .blog-nav ul li.active{ 58 | border-bottom: 2px solid red; 59 | } 60 | 61 | /* 62 | blog-content 博客内容部分 63 | */ 64 | 65 | .blog-content{ 66 | padding: 10px; 67 | padding-bottom: 30px; 68 | background: #eee; 69 | } 70 | 71 | .blog-content-left{ 72 | width: 59.6%; 73 | float: left; 74 | margin-right: 0.4%; 75 | } 76 | .blog-content-left .blog-item{ 77 | width: 70%; 78 | float: right; 79 | box-sizing: border-box; 80 | padding: 0 20px 15px 20px; 81 | margin-top: 15px; 82 | background: #fff; 83 | text-align: center; 84 | padding-top: 20px; 85 | } 86 | 87 | .blog-item h2{ 88 | height: 30px; 89 | line-height: 30px; 90 | color: #666; 91 | font-size: 20px; 92 | padding-bottom: 10px; 93 | } 94 | .message{ 95 | font-size: 12px; 96 | color: #999; 97 | padding-right: 30px; 98 | } 99 | .blog-item span{ 100 | color: #2eaa2199; 101 | } 102 | .all-acticle,.item-desc{ 103 | text-indent: 40px; 104 | text-align: left; 105 | padding: 10px 0 15px 0; 106 | font-size: 13px; 107 | color: #666; 108 | } 109 | .all-acticle{ 110 | padding: 0; 111 | } 112 | .all-acticle a{ 113 | border: 0; 114 | padding: 2px 6px; 115 | border-radius: 4px; 116 | color: #fff; 117 | font-size: 12px; 118 | background:#de9b12; 119 | } 120 | 121 | .blog-content-right{ 122 | float: left; 123 | width: 39%; 124 | margin-left: 1%; 125 | box-sizing: border-box; 126 | } 127 | 128 | .user-action{ 129 | float: left; 130 | width: 52%; 131 | background: #fff; 132 | margin-top: 15px; 133 | box-sizing: border-box; 134 | padding: 10px; 135 | color: #666; 136 | } 137 | .user-action h4{ 138 | height: 30px; 139 | line-height: 30px; 140 | font-size: 14px; 141 | font-weight: normal; 142 | border-bottom: 1px solid #ccc; 143 | color: #666; 144 | } 145 | .user-action h4 span{ 146 | height: 100%; 147 | display: inline-block; 148 | border-bottom: 1px solid red; 149 | } 150 | .username{ 151 | display: block; 152 | height: 30px; 153 | line-height: 30px; 154 | font-size: 13px; 155 | } 156 | .user-action p{ 157 | font-size: 12px; 158 | 159 | } 160 | .user-action .logout{ 161 | font-size: 12px; 162 | display: inline-block; 163 | padding-top: 5px; 164 | } 165 | .form-ul{ 166 | width: 90%; 167 | margin: 0 auto; 168 | padding: 20px 0 0 0; 169 | } 170 | .form-ul li{ 171 | height: 30px; 172 | line-height: 30px; 173 | font-size: 13px; 174 | box-sizing: border-box; 175 | } 176 | .form-ul li input{ 177 | border: 1px solid #ccc; 178 | font-size: 12px; 179 | height: 20px; 180 | line-height: 15px; 181 | text-indent: 6px; 182 | } 183 | .form-ul li:last-child button:focus,.form-ul li input:focus{ 184 | outline: none; 185 | } 186 | 187 | .form-ul li:last-child button{ 188 | margin-right: 30px; 189 | width: 30%; 190 | border: 0; 191 | color: #fff; 192 | background:#de9b12; 193 | } 194 | .shequ{ 195 | padding-top: 10px; 196 | } 197 | .shequ li{ 198 | font-size: 13px; 199 | height: 20px; 200 | line-height: 20px; 201 | } 202 | 203 | .register-message,.login-message{ 204 | color: red; 205 | font-size: 13px; 206 | } 207 | 208 | .content-page, .comment{ 209 | width: 70%; 210 | float: right; 211 | box-sizing: border-box; 212 | padding: 0 20px 15px 20px; 213 | margin-top: 15px; 214 | background: #fff; 215 | padding-top: 20px; 216 | } 217 | .content-page li{ 218 | text-align: center; 219 | } 220 | .content-page .prev{ 221 | float: left; 222 | font-size: 13px; 223 | } 224 | 225 | .content-page .next{ 226 | float: right; 227 | font-size: 13px; 228 | } 229 | 230 | .comment-total{ 231 | line-height: 1; 232 | float: right; 233 | font-size: 12px; 234 | color: #666; 235 | margin-bottom: 25px; 236 | } 237 | .name{ 238 | float: left; 239 | font-size: 15px; 240 | color: #333; 241 | margin: 0; 242 | } 243 | .login-msg,.no-msg{ 244 | background: #ff750099; 245 | text-align: center; 246 | padding: 2px; 247 | font-size: 12px; 248 | margin-top: 10px; 249 | } 250 | .login-msg span{ 251 | color: #fff; 252 | line-height: 1; 253 | } 254 | .no-msg{ 255 | background: #fff; 256 | } 257 | .comment-list{ 258 | padding: 15px 10px 0 10px; 259 | } 260 | .comment-list li p{ 261 | font-size: 12px; 262 | padding: 6px 0; 263 | color: #666; 264 | } 265 | .comment-list li span{ 266 | font-size: 11px; 267 | color: #999; 268 | } 269 | .comment-list li{ 270 | padding:-top 10px; 271 | } 272 | .comment-page{ 273 | width: 100%; 274 | margin: 0; 275 | } -------------------------------------------------------------------------------- /routers/admin.js: -------------------------------------------------------------------------------- 1 | var express = require('express'); 2 | 3 | var router = express.Router(); 4 | var User = require('../models/User'); 5 | var Category = require('../models/Category'); 6 | var Content = require('../models/Content'); 7 | 8 | 9 | //相当于 admin/user 10 | // router.get('/user', function(req, res) { 11 | // res.send('User'); 12 | // }) 13 | router.use(function(req, res, next){ 14 | if(!req.userInfo.isAdmin) { 15 | res.send('对不起,只有管理员才有权限进入后台管理'); 16 | return; 17 | } 18 | next(); 19 | }) 20 | 21 | router.get('/',function(req , res, next){ 22 | res.render('admin/index',{ 23 | userInfo:req.userInfo 24 | }); 25 | }) 26 | 27 | router.get('/user',function(req, res, next){ 28 | var page; 29 | var limit = 4; 30 | var totalPage = 0; 31 | var skip; 32 | if(!isNaN(req.query.page)){ 33 | page = Number(req.query.page); 34 | }else{ 35 | page = 1; 36 | } 37 | User.find().count().then(function(num){ 38 | totalPage = Math.ceil(num/limit); 39 | page = Math.min(totalPage,page); 40 | page = Math.max(page,1); 41 | skip = (page - 1)*limit; 42 | User.find().skip(skip).limit(limit).then(function(users){ 43 | res.render('admin/user_admin',{ 44 | userInfo:req.userInfo, 45 | users:users, 46 | count: totalPage, 47 | page:page 48 | }); 49 | }) 50 | }); 51 | 52 | }) 53 | 54 | 55 | /* 56 | * 57 | * 分类管理 58 | */ 59 | 60 | router.get('/category',function(req, res, next){ 61 | var page; 62 | var limit = 2; 63 | var totalPage; 64 | var skip; 65 | if(req.query.page){ 66 | page = Number(req.query.page); 67 | }else{ 68 | page = 1; 69 | } 70 | 71 | Category.count().then(function(num){ 72 | totalPage = Math.ceil(num/limit); 73 | skip = (page-1)*limit; 74 | Category.find().sort({_id:-1}).skip(skip).limit(limit).then(function(cates){ 75 | 76 | res.render('admin/category_index',{ 77 | userInfo: req.userInfo, 78 | cates:cates, 79 | count: totalPage, 80 | page:page 81 | }) 82 | }); 83 | }); 84 | }) 85 | 86 | router.get('/category/edit',function(req,res, next){ 87 | var id = req.query.id || ''; 88 | Category.findOne({ 89 | _id:id 90 | }).then(function(cate){ 91 | 92 | if(!cate){ 93 | res.render('admin/error',{ 94 | userInfo:req.userInfo, 95 | error:'类名不存在' 96 | }) 97 | return Promise.reject(); 98 | }else{ 99 | res.render('admin/cate_edit',{ 100 | userInfo:req.userInfo, 101 | cate:cate 102 | }); 103 | } 104 | }) 105 | }) 106 | 107 | /* 108 | * 109 | * 110 | * 如果form没有默认action的请求地址,就会请求道form所在的页面地址栏 111 | * /admin/category/edit?id=59676c61d2a6d51f0cdf9c10 112 | */ 113 | 114 | router.post('/category/edit',function(req, res, next){ 115 | 116 | var name = req.body.catename; 117 | var id = req.query.id; 118 | 119 | Category.findOne({ 120 | _id:id 121 | }).then(function(cate){ 122 | if(!cate){ 123 | res.render('admin/error',{ 124 | userInfo:req.userInfo, 125 | error:'该类不存在', 126 | url:'/admin/category' 127 | }) 128 | return Promise.reject(); 129 | }else{ 130 | if(name === ''){ 131 | res.render('admin/error',{ 132 | userInfo:req.userInfo, 133 | error:'该命名不存在', 134 | url:'/admin/category' 135 | }) 136 | return Promise.reject(); 137 | }else{ 138 | if(name === cate.name){ 139 | res.render('admin/error',{ 140 | userInfo:req.userInfo, 141 | error:'编辑成功', 142 | url:'/admin/category' 143 | }) 144 | return Promise.reject(); 145 | }else{ 146 | return Category.findOne({ 147 | _id:{$ne:id}, 148 | name:name 149 | }); 150 | } 151 | } 152 | } 153 | }).then(function(hadCate){ 154 | if(hadCate){ 155 | res.render('admin/error',{ 156 | userInfo:req.userInfo, 157 | error:'该类名已经存在', 158 | url:'/admin/category' 159 | }) 160 | return Promise.reject(); 161 | }else{ 162 | return Category.update({ 163 | _id:id 164 | },{ 165 | name:name 166 | }) 167 | } 168 | }).then(function(){ 169 | res.render('admin/success',{ 170 | userInfo:req.userInfo, 171 | message:'类名编辑成功', 172 | url:'/admin/category' 173 | }) 174 | }) 175 | }) 176 | 177 | 178 | 179 | router.get('/category/delete',function(req, res, next){ 180 | var id = req.query._id || ''; 181 | console.log(id); 182 | Category.remove({ 183 | _id:id 184 | }).then(function(data){ 185 | res.render('admin/success',{ 186 | userInfo:req.userInfo, 187 | message:'类名删除成功', 188 | url:'/admin/category' 189 | }) 190 | }); 191 | }); 192 | 193 | /* 194 | * 195 | * 分类添加 196 | */ 197 | router.get('/category/add',function(req, res, next){ 198 | res.render('admin/category_add',{ 199 | userInfo:req.userInfo 200 | }) 201 | }) 202 | 203 | /* 204 | * 205 | *baocunshuju,处理表单 206 | */ 207 | 208 | router.post('/category/add',function(req,res){ 209 | var name = req.body.catename; 210 | if(name === ''){ 211 | res.render('admin/error',{ 212 | userInfo:req.userInfo, 213 | error:'类名不能为空' 214 | }) 215 | } 216 | 217 | 218 | Category.findOne({ 219 | name:name 220 | }).then(function(cateInfo){ 221 | console.log(cateInfo) 222 | if(cateInfo){ 223 | res.render('admin/error',{ 224 | userInfo:req.userInfo, 225 | error:'类名已经存在' 226 | }); 227 | return Promise.reject(); 228 | }else{ 229 | return new Category({ 230 | name:name 231 | }).save(); 232 | } 233 | }).then(function(cateInfo){ 234 | if(cateInfo){ 235 | res.render('admin/success',{ 236 | cateInfo:cateInfo, 237 | userInfo:req.userInfo, 238 | message:'添加类名成功', 239 | url:'/admin/category' 240 | }) 241 | } 242 | }) 243 | }) 244 | 245 | 246 | /** 247 | * 文章列表 248 | */ 249 | 250 | router.get('/content',function(req,res, next){ 251 | var limit,page,totalPage,skip; 252 | limit = 10; 253 | if(req.query.page){ 254 | page = Number(req.query.page); 255 | }else{ 256 | page = 1; 257 | } 258 | 259 | Content.count().then(function(num){ 260 | totalPage = Math.ceil(num/limit); 261 | page = Math.min(page,totalPage); 262 | page = Math.max(1,page); 263 | skip = (page - 1)*limit; 264 | Content.find().sort({_id:-1}).limit(limit).skip(skip).populate(['category','user']).then(function(contents){ 265 | console.log(contents); 266 | res.render('admin/content_index',{ 267 | userInfo: req.userInfo, 268 | contents:contents, 269 | count: totalPage, 270 | page:page 271 | }); 272 | }) 273 | }); 274 | }); 275 | 276 | router.get('/content/add',function(req, res, next){ 277 | Category.find().then(function(cates){ 278 | res.render('admin/content_add',{ 279 | userInfo:req.userInfo, 280 | cates:cates 281 | }) 282 | }) 283 | }) 284 | 285 | router.post('/content/add',function(req,res, next){ 286 | 287 | var title = req.body.title; 288 | var description = req.body.description; 289 | var content = req.body.content; 290 | var category = req.body.category; 291 | var userId = req.userInfo._id.toString(); 292 | 293 | if(title === ''){ 294 | res.render('admin/error',{ 295 | userInfo:req.userInfo, 296 | error:'标题不能为空' 297 | }) 298 | return; 299 | } 300 | 301 | if(content === ''){ 302 | res.render('admin/error',{ 303 | userInfo:req.userInfo, 304 | error:'内容不能为空' 305 | }) 306 | return; 307 | } 308 | 309 | new Content({ 310 | category:category, 311 | title:title, 312 | description:description, 313 | content:content, 314 | user:userId 315 | }).save().then(function(contentInfo){ 316 | if(contentInfo){ 317 | res.render('admin/success',{ 318 | userInfo:req.userInfo, 319 | message:'内容保存成功', 320 | url:'/admin/content' 321 | }) 322 | }else{ 323 | res.render('admin/error',{ 324 | userInfo:req.userInfo, 325 | message:'内容保存失败' 326 | }) 327 | } 328 | }) 329 | 330 | }) 331 | 332 | router.get('/content/edit',function(req, res, next){ 333 | var id = req.query.id || ''; 334 | Content.findOne({ 335 | _id:id 336 | }).then(function(contentInfo){ 337 | if(!contentInfo){ 338 | res.render('admin/error',{ 339 | userInfo:req.userInfo, 340 | error:'该内容不存在' 341 | }); 342 | return Promise.reject(); 343 | } else { 344 | Category.find().then(function(cates){ 345 | res.render('admin/content_edit',{ 346 | userInfo:req.userInfo, 347 | contents:contentInfo, 348 | cates:cates 349 | }) 350 | }) 351 | } 352 | }) 353 | }) 354 | 355 | 356 | /** 357 | * 内容修改 358 | * @type {[type]} 359 | */ 360 | router.post('/content/edit',function(req, res, next){ 361 | var id = req.query.id || ''; 362 | var title = req.body.title; 363 | var description = req.body.description; 364 | var contents = req.body.content; 365 | var category = req.body.category; 366 | 367 | if(title === ''){ 368 | res.render('admin/error',{ 369 | userInfo:req.userInfo, 370 | error:'标题不嫩为空' 371 | }) 372 | return; 373 | } 374 | 375 | if(contents === ''){ 376 | res.render('admin/error',{ 377 | userInfo:req.userInfo, 378 | error:'内容不嫩为空' 379 | }) 380 | return; 381 | } 382 | 383 | Content.findOne({ 384 | _id:id 385 | }).then(function(content){ 386 | console.log(content) 387 | if(!content){ 388 | res.render('admin/error',{ 389 | userInfo:req.userInfo, 390 | error:'内容不存在' 391 | }) 392 | return Promise.reject(); 393 | }else{ 394 | if(content.title === title&& content.description === description&& 395 | content.category === category&&content.content === contents){ 396 | res.render('admin/success',{ 397 | userInfo:req.userInfo, 398 | message:'内容编辑成功', 399 | url:'/admin/content' 400 | }) 401 | } else { 402 | return Content.update({ 403 | _id:id 404 | },{ 405 | $set:{ 406 | content:contents, 407 | category:category, 408 | description:description, 409 | title:title 410 | } 411 | }); 412 | } 413 | } 414 | }).then(function(rs){ 415 | if(rs){ 416 | res.render('admin/success',{ 417 | userInfo:req.userInfo, 418 | message:'内容编辑成功', 419 | url:'/admin/content' 420 | }) 421 | } 422 | }) 423 | }) 424 | 425 | router.get('/content/delete',function(req, res, next){ 426 | var id = req.query.id || ''; 427 | if(!id){ 428 | res.render('admin/error',{ 429 | userInfo:req.userInfo, 430 | error:'id不存在' 431 | }) 432 | return; 433 | } 434 | 435 | Content.findOne({ 436 | _id:id 437 | }).then(function(content){ 438 | if(!content){ 439 | res.render('admin/error',{ 440 | userInfo:req.userInfo, 441 | error:'内容不存在' 442 | }) 443 | return Promise.reject(); 444 | }else{ 445 | return Content.remove({ 446 | _id:id 447 | }) 448 | } 449 | }).then(function(rs){ 450 | if(rs){ 451 | res.render('admin/success',{ 452 | userInfo:req.userInfo, 453 | message:'删除成功', 454 | url:'/admin/content' 455 | }) 456 | } 457 | }) 458 | }) 459 | 460 | module.exports = router; -------------------------------------------------------------------------------- /public/js/bootstrap.min.js: -------------------------------------------------------------------------------- 1 | /*! 2 | * Bootstrap v3.3.5 (http://getbootstrap.com) 3 | * Copyright 2011-2015 Twitter, Inc. 4 | * Licensed under the MIT license 5 | */ 6 | if("undefined"==typeof jQuery)throw new Error("Bootstrap's JavaScript requires jQuery");+function(a){"use strict";var b=a.fn.jquery.split(" ")[0].split(".");if(b[0]<2&&b[1]<9||1==b[0]&&9==b[1]&&b[2]<1)throw new Error("Bootstrap's JavaScript requires jQuery version 1.9.1 or higher")}(jQuery),+function(a){"use strict";function b(){var a=document.createElement("bootstrap"),b={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"};for(var c in b)if(void 0!==a.style[c])return{end:b[c]};return!1}a.fn.emulateTransitionEnd=function(b){var c=!1,d=this;a(this).one("bsTransitionEnd",function(){c=!0});var e=function(){c||a(d).trigger(a.support.transition.end)};return setTimeout(e,b),this},a(function(){a.support.transition=b(),a.support.transition&&(a.event.special.bsTransitionEnd={bindType:a.support.transition.end,delegateType:a.support.transition.end,handle:function(b){return a(b.target).is(this)?b.handleObj.handler.apply(this,arguments):void 0}})})}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var c=a(this),e=c.data("bs.alert");e||c.data("bs.alert",e=new d(this)),"string"==typeof b&&e[b].call(c)})}var c='[data-dismiss="alert"]',d=function(b){a(b).on("click",c,this.close)};d.VERSION="3.3.5",d.TRANSITION_DURATION=150,d.prototype.close=function(b){function c(){g.detach().trigger("closed.bs.alert").remove()}var e=a(this),f=e.attr("data-target");f||(f=e.attr("href"),f=f&&f.replace(/.*(?=#[^\s]*$)/,""));var g=a(f);b&&b.preventDefault(),g.length||(g=e.closest(".alert")),g.trigger(b=a.Event("close.bs.alert")),b.isDefaultPrevented()||(g.removeClass("in"),a.support.transition&&g.hasClass("fade")?g.one("bsTransitionEnd",c).emulateTransitionEnd(d.TRANSITION_DURATION):c())};var e=a.fn.alert;a.fn.alert=b,a.fn.alert.Constructor=d,a.fn.alert.noConflict=function(){return a.fn.alert=e,this},a(document).on("click.bs.alert.data-api",c,d.prototype.close)}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.button"),f="object"==typeof b&&b;e||d.data("bs.button",e=new c(this,f)),"toggle"==b?e.toggle():b&&e.setState(b)})}var c=function(b,d){this.$element=a(b),this.options=a.extend({},c.DEFAULTS,d),this.isLoading=!1};c.VERSION="3.3.5",c.DEFAULTS={loadingText:"loading..."},c.prototype.setState=function(b){var c="disabled",d=this.$element,e=d.is("input")?"val":"html",f=d.data();b+="Text",null==f.resetText&&d.data("resetText",d[e]()),setTimeout(a.proxy(function(){d[e](null==f[b]?this.options[b]:f[b]),"loadingText"==b?(this.isLoading=!0,d.addClass(c).attr(c,c)):this.isLoading&&(this.isLoading=!1,d.removeClass(c).removeAttr(c))},this),0)},c.prototype.toggle=function(){var a=!0,b=this.$element.closest('[data-toggle="buttons"]');if(b.length){var c=this.$element.find("input");"radio"==c.prop("type")?(c.prop("checked")&&(a=!1),b.find(".active").removeClass("active"),this.$element.addClass("active")):"checkbox"==c.prop("type")&&(c.prop("checked")!==this.$element.hasClass("active")&&(a=!1),this.$element.toggleClass("active")),c.prop("checked",this.$element.hasClass("active")),a&&c.trigger("change")}else this.$element.attr("aria-pressed",!this.$element.hasClass("active")),this.$element.toggleClass("active")};var d=a.fn.button;a.fn.button=b,a.fn.button.Constructor=c,a.fn.button.noConflict=function(){return a.fn.button=d,this},a(document).on("click.bs.button.data-api",'[data-toggle^="button"]',function(c){var d=a(c.target);d.hasClass("btn")||(d=d.closest(".btn")),b.call(d,"toggle"),a(c.target).is('input[type="radio"]')||a(c.target).is('input[type="checkbox"]')||c.preventDefault()}).on("focus.bs.button.data-api blur.bs.button.data-api",'[data-toggle^="button"]',function(b){a(b.target).closest(".btn").toggleClass("focus",/^focus(in)?$/.test(b.type))})}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.carousel"),f=a.extend({},c.DEFAULTS,d.data(),"object"==typeof b&&b),g="string"==typeof b?b:f.slide;e||d.data("bs.carousel",e=new c(this,f)),"number"==typeof b?e.to(b):g?e[g]():f.interval&&e.pause().cycle()})}var c=function(b,c){this.$element=a(b),this.$indicators=this.$element.find(".carousel-indicators"),this.options=c,this.paused=null,this.sliding=null,this.interval=null,this.$active=null,this.$items=null,this.options.keyboard&&this.$element.on("keydown.bs.carousel",a.proxy(this.keydown,this)),"hover"==this.options.pause&&!("ontouchstart"in document.documentElement)&&this.$element.on("mouseenter.bs.carousel",a.proxy(this.pause,this)).on("mouseleave.bs.carousel",a.proxy(this.cycle,this))};c.VERSION="3.3.5",c.TRANSITION_DURATION=600,c.DEFAULTS={interval:5e3,pause:"hover",wrap:!0,keyboard:!0},c.prototype.keydown=function(a){if(!/input|textarea/i.test(a.target.tagName)){switch(a.which){case 37:this.prev();break;case 39:this.next();break;default:return}a.preventDefault()}},c.prototype.cycle=function(b){return b||(this.paused=!1),this.interval&&clearInterval(this.interval),this.options.interval&&!this.paused&&(this.interval=setInterval(a.proxy(this.next,this),this.options.interval)),this},c.prototype.getItemIndex=function(a){return this.$items=a.parent().children(".item"),this.$items.index(a||this.$active)},c.prototype.getItemForDirection=function(a,b){var c=this.getItemIndex(b),d="prev"==a&&0===c||"next"==a&&c==this.$items.length-1;if(d&&!this.options.wrap)return b;var e="prev"==a?-1:1,f=(c+e)%this.$items.length;return this.$items.eq(f)},c.prototype.to=function(a){var b=this,c=this.getItemIndex(this.$active=this.$element.find(".item.active"));return a>this.$items.length-1||0>a?void 0:this.sliding?this.$element.one("slid.bs.carousel",function(){b.to(a)}):c==a?this.pause().cycle():this.slide(a>c?"next":"prev",this.$items.eq(a))},c.prototype.pause=function(b){return b||(this.paused=!0),this.$element.find(".next, .prev").length&&a.support.transition&&(this.$element.trigger(a.support.transition.end),this.cycle(!0)),this.interval=clearInterval(this.interval),this},c.prototype.next=function(){return this.sliding?void 0:this.slide("next")},c.prototype.prev=function(){return this.sliding?void 0:this.slide("prev")},c.prototype.slide=function(b,d){var e=this.$element.find(".item.active"),f=d||this.getItemForDirection(b,e),g=this.interval,h="next"==b?"left":"right",i=this;if(f.hasClass("active"))return this.sliding=!1;var j=f[0],k=a.Event("slide.bs.carousel",{relatedTarget:j,direction:h});if(this.$element.trigger(k),!k.isDefaultPrevented()){if(this.sliding=!0,g&&this.pause(),this.$indicators.length){this.$indicators.find(".active").removeClass("active");var l=a(this.$indicators.children()[this.getItemIndex(f)]);l&&l.addClass("active")}var m=a.Event("slid.bs.carousel",{relatedTarget:j,direction:h});return a.support.transition&&this.$element.hasClass("slide")?(f.addClass(b),f[0].offsetWidth,e.addClass(h),f.addClass(h),e.one("bsTransitionEnd",function(){f.removeClass([b,h].join(" ")).addClass("active"),e.removeClass(["active",h].join(" ")),i.sliding=!1,setTimeout(function(){i.$element.trigger(m)},0)}).emulateTransitionEnd(c.TRANSITION_DURATION)):(e.removeClass("active"),f.addClass("active"),this.sliding=!1,this.$element.trigger(m)),g&&this.cycle(),this}};var d=a.fn.carousel;a.fn.carousel=b,a.fn.carousel.Constructor=c,a.fn.carousel.noConflict=function(){return a.fn.carousel=d,this};var e=function(c){var d,e=a(this),f=a(e.attr("data-target")||(d=e.attr("href"))&&d.replace(/.*(?=#[^\s]+$)/,""));if(f.hasClass("carousel")){var g=a.extend({},f.data(),e.data()),h=e.attr("data-slide-to");h&&(g.interval=!1),b.call(f,g),h&&f.data("bs.carousel").to(h),c.preventDefault()}};a(document).on("click.bs.carousel.data-api","[data-slide]",e).on("click.bs.carousel.data-api","[data-slide-to]",e),a(window).on("load",function(){a('[data-ride="carousel"]').each(function(){var c=a(this);b.call(c,c.data())})})}(jQuery),+function(a){"use strict";function b(b){var c,d=b.attr("data-target")||(c=b.attr("href"))&&c.replace(/.*(?=#[^\s]+$)/,"");return a(d)}function c(b){return this.each(function(){var c=a(this),e=c.data("bs.collapse"),f=a.extend({},d.DEFAULTS,c.data(),"object"==typeof b&&b);!e&&f.toggle&&/show|hide/.test(b)&&(f.toggle=!1),e||c.data("bs.collapse",e=new d(this,f)),"string"==typeof b&&e[b]()})}var d=function(b,c){this.$element=a(b),this.options=a.extend({},d.DEFAULTS,c),this.$trigger=a('[data-toggle="collapse"][href="#'+b.id+'"],[data-toggle="collapse"][data-target="#'+b.id+'"]'),this.transitioning=null,this.options.parent?this.$parent=this.getParent():this.addAriaAndCollapsedClass(this.$element,this.$trigger),this.options.toggle&&this.toggle()};d.VERSION="3.3.5",d.TRANSITION_DURATION=350,d.DEFAULTS={toggle:!0},d.prototype.dimension=function(){var a=this.$element.hasClass("width");return a?"width":"height"},d.prototype.show=function(){if(!this.transitioning&&!this.$element.hasClass("in")){var b,e=this.$parent&&this.$parent.children(".panel").children(".in, .collapsing");if(!(e&&e.length&&(b=e.data("bs.collapse"),b&&b.transitioning))){var f=a.Event("show.bs.collapse");if(this.$element.trigger(f),!f.isDefaultPrevented()){e&&e.length&&(c.call(e,"hide"),b||e.data("bs.collapse",null));var g=this.dimension();this.$element.removeClass("collapse").addClass("collapsing")[g](0).attr("aria-expanded",!0),this.$trigger.removeClass("collapsed").attr("aria-expanded",!0),this.transitioning=1;var h=function(){this.$element.removeClass("collapsing").addClass("collapse in")[g](""),this.transitioning=0,this.$element.trigger("shown.bs.collapse")};if(!a.support.transition)return h.call(this);var i=a.camelCase(["scroll",g].join("-"));this.$element.one("bsTransitionEnd",a.proxy(h,this)).emulateTransitionEnd(d.TRANSITION_DURATION)[g](this.$element[0][i])}}}},d.prototype.hide=function(){if(!this.transitioning&&this.$element.hasClass("in")){var b=a.Event("hide.bs.collapse");if(this.$element.trigger(b),!b.isDefaultPrevented()){var c=this.dimension();this.$element[c](this.$element[c]())[0].offsetHeight,this.$element.addClass("collapsing").removeClass("collapse in").attr("aria-expanded",!1),this.$trigger.addClass("collapsed").attr("aria-expanded",!1),this.transitioning=1;var e=function(){this.transitioning=0,this.$element.removeClass("collapsing").addClass("collapse").trigger("hidden.bs.collapse")};return a.support.transition?void this.$element[c](0).one("bsTransitionEnd",a.proxy(e,this)).emulateTransitionEnd(d.TRANSITION_DURATION):e.call(this)}}},d.prototype.toggle=function(){this[this.$element.hasClass("in")?"hide":"show"]()},d.prototype.getParent=function(){return a(this.options.parent).find('[data-toggle="collapse"][data-parent="'+this.options.parent+'"]').each(a.proxy(function(c,d){var e=a(d);this.addAriaAndCollapsedClass(b(e),e)},this)).end()},d.prototype.addAriaAndCollapsedClass=function(a,b){var c=a.hasClass("in");a.attr("aria-expanded",c),b.toggleClass("collapsed",!c).attr("aria-expanded",c)};var e=a.fn.collapse;a.fn.collapse=c,a.fn.collapse.Constructor=d,a.fn.collapse.noConflict=function(){return a.fn.collapse=e,this},a(document).on("click.bs.collapse.data-api",'[data-toggle="collapse"]',function(d){var e=a(this);e.attr("data-target")||d.preventDefault();var f=b(e),g=f.data("bs.collapse"),h=g?"toggle":e.data();c.call(f,h)})}(jQuery),+function(a){"use strict";function b(b){var c=b.attr("data-target");c||(c=b.attr("href"),c=c&&/#[A-Za-z]/.test(c)&&c.replace(/.*(?=#[^\s]*$)/,""));var d=c&&a(c);return d&&d.length?d:b.parent()}function c(c){c&&3===c.which||(a(e).remove(),a(f).each(function(){var d=a(this),e=b(d),f={relatedTarget:this};e.hasClass("open")&&(c&&"click"==c.type&&/input|textarea/i.test(c.target.tagName)&&a.contains(e[0],c.target)||(e.trigger(c=a.Event("hide.bs.dropdown",f)),c.isDefaultPrevented()||(d.attr("aria-expanded","false"),e.removeClass("open").trigger("hidden.bs.dropdown",f))))}))}function d(b){return this.each(function(){var c=a(this),d=c.data("bs.dropdown");d||c.data("bs.dropdown",d=new g(this)),"string"==typeof b&&d[b].call(c)})}var e=".dropdown-backdrop",f='[data-toggle="dropdown"]',g=function(b){a(b).on("click.bs.dropdown",this.toggle)};g.VERSION="3.3.5",g.prototype.toggle=function(d){var e=a(this);if(!e.is(".disabled, :disabled")){var f=b(e),g=f.hasClass("open");if(c(),!g){"ontouchstart"in document.documentElement&&!f.closest(".navbar-nav").length&&a(document.createElement("div")).addClass("dropdown-backdrop").insertAfter(a(this)).on("click",c);var h={relatedTarget:this};if(f.trigger(d=a.Event("show.bs.dropdown",h)),d.isDefaultPrevented())return;e.trigger("focus").attr("aria-expanded","true"),f.toggleClass("open").trigger("shown.bs.dropdown",h)}return!1}},g.prototype.keydown=function(c){if(/(38|40|27|32)/.test(c.which)&&!/input|textarea/i.test(c.target.tagName)){var d=a(this);if(c.preventDefault(),c.stopPropagation(),!d.is(".disabled, :disabled")){var e=b(d),g=e.hasClass("open");if(!g&&27!=c.which||g&&27==c.which)return 27==c.which&&e.find(f).trigger("focus"),d.trigger("click");var h=" li:not(.disabled):visible a",i=e.find(".dropdown-menu"+h);if(i.length){var j=i.index(c.target);38==c.which&&j>0&&j--,40==c.which&&jdocument.documentElement.clientHeight;this.$element.css({paddingLeft:!this.bodyIsOverflowing&&a?this.scrollbarWidth:"",paddingRight:this.bodyIsOverflowing&&!a?this.scrollbarWidth:""})},c.prototype.resetAdjustments=function(){this.$element.css({paddingLeft:"",paddingRight:""})},c.prototype.checkScrollbar=function(){var a=window.innerWidth;if(!a){var b=document.documentElement.getBoundingClientRect();a=b.right-Math.abs(b.left)}this.bodyIsOverflowing=document.body.clientWidth
',trigger:"hover focus",title:"",delay:0,html:!1,container:!1,viewport:{selector:"body",padding:0}},c.prototype.init=function(b,c,d){if(this.enabled=!0,this.type=b,this.$element=a(c),this.options=this.getOptions(d),this.$viewport=this.options.viewport&&a(a.isFunction(this.options.viewport)?this.options.viewport.call(this,this.$element):this.options.viewport.selector||this.options.viewport),this.inState={click:!1,hover:!1,focus:!1},this.$element[0]instanceof document.constructor&&!this.options.selector)throw new Error("`selector` option must be specified when initializing "+this.type+" on the window.document object!");for(var e=this.options.trigger.split(" "),f=e.length;f--;){var g=e[f];if("click"==g)this.$element.on("click."+this.type,this.options.selector,a.proxy(this.toggle,this));else if("manual"!=g){var h="hover"==g?"mouseenter":"focusin",i="hover"==g?"mouseleave":"focusout";this.$element.on(h+"."+this.type,this.options.selector,a.proxy(this.enter,this)),this.$element.on(i+"."+this.type,this.options.selector,a.proxy(this.leave,this))}}this.options.selector?this._options=a.extend({},this.options,{trigger:"manual",selector:""}):this.fixTitle()},c.prototype.getDefaults=function(){return c.DEFAULTS},c.prototype.getOptions=function(b){return b=a.extend({},this.getDefaults(),this.$element.data(),b),b.delay&&"number"==typeof b.delay&&(b.delay={show:b.delay,hide:b.delay}),b},c.prototype.getDelegateOptions=function(){var b={},c=this.getDefaults();return this._options&&a.each(this._options,function(a,d){c[a]!=d&&(b[a]=d)}),b},c.prototype.enter=function(b){var c=b instanceof this.constructor?b:a(b.currentTarget).data("bs."+this.type);return c||(c=new this.constructor(b.currentTarget,this.getDelegateOptions()),a(b.currentTarget).data("bs."+this.type,c)),b instanceof a.Event&&(c.inState["focusin"==b.type?"focus":"hover"]=!0),c.tip().hasClass("in")||"in"==c.hoverState?void(c.hoverState="in"):(clearTimeout(c.timeout),c.hoverState="in",c.options.delay&&c.options.delay.show?void(c.timeout=setTimeout(function(){"in"==c.hoverState&&c.show()},c.options.delay.show)):c.show())},c.prototype.isInStateTrue=function(){for(var a in this.inState)if(this.inState[a])return!0;return!1},c.prototype.leave=function(b){var c=b instanceof this.constructor?b:a(b.currentTarget).data("bs."+this.type);return c||(c=new this.constructor(b.currentTarget,this.getDelegateOptions()),a(b.currentTarget).data("bs."+this.type,c)),b instanceof a.Event&&(c.inState["focusout"==b.type?"focus":"hover"]=!1),c.isInStateTrue()?void 0:(clearTimeout(c.timeout),c.hoverState="out",c.options.delay&&c.options.delay.hide?void(c.timeout=setTimeout(function(){"out"==c.hoverState&&c.hide()},c.options.delay.hide)):c.hide())},c.prototype.show=function(){var b=a.Event("show.bs."+this.type);if(this.hasContent()&&this.enabled){this.$element.trigger(b);var d=a.contains(this.$element[0].ownerDocument.documentElement,this.$element[0]);if(b.isDefaultPrevented()||!d)return;var e=this,f=this.tip(),g=this.getUID(this.type);this.setContent(),f.attr("id",g),this.$element.attr("aria-describedby",g),this.options.animation&&f.addClass("fade");var h="function"==typeof this.options.placement?this.options.placement.call(this,f[0],this.$element[0]):this.options.placement,i=/\s?auto?\s?/i,j=i.test(h);j&&(h=h.replace(i,"")||"top"),f.detach().css({top:0,left:0,display:"block"}).addClass(h).data("bs."+this.type,this),this.options.container?f.appendTo(this.options.container):f.insertAfter(this.$element),this.$element.trigger("inserted.bs."+this.type);var k=this.getPosition(),l=f[0].offsetWidth,m=f[0].offsetHeight;if(j){var n=h,o=this.getPosition(this.$viewport);h="bottom"==h&&k.bottom+m>o.bottom?"top":"top"==h&&k.top-mo.width?"left":"left"==h&&k.left-lg.top+g.height&&(e.top=g.top+g.height-i)}else{var j=b.left-f,k=b.left+f+c;jg.right&&(e.left=g.left+g.width-k)}return e},c.prototype.getTitle=function(){var a,b=this.$element,c=this.options;return a=b.attr("data-original-title")||("function"==typeof c.title?c.title.call(b[0]):c.title)},c.prototype.getUID=function(a){do a+=~~(1e6*Math.random());while(document.getElementById(a));return a},c.prototype.tip=function(){if(!this.$tip&&(this.$tip=a(this.options.template),1!=this.$tip.length))throw new Error(this.type+" `template` option must consist of exactly 1 top-level element!");return this.$tip},c.prototype.arrow=function(){return this.$arrow=this.$arrow||this.tip().find(".tooltip-arrow")},c.prototype.enable=function(){this.enabled=!0},c.prototype.disable=function(){this.enabled=!1},c.prototype.toggleEnabled=function(){this.enabled=!this.enabled},c.prototype.toggle=function(b){var c=this;b&&(c=a(b.currentTarget).data("bs."+this.type),c||(c=new this.constructor(b.currentTarget,this.getDelegateOptions()),a(b.currentTarget).data("bs."+this.type,c))),b?(c.inState.click=!c.inState.click,c.isInStateTrue()?c.enter(c):c.leave(c)):c.tip().hasClass("in")?c.leave(c):c.enter(c)},c.prototype.destroy=function(){var a=this;clearTimeout(this.timeout),this.hide(function(){a.$element.off("."+a.type).removeData("bs."+a.type),a.$tip&&a.$tip.detach(),a.$tip=null,a.$arrow=null,a.$viewport=null})};var d=a.fn.tooltip;a.fn.tooltip=b,a.fn.tooltip.Constructor=c,a.fn.tooltip.noConflict=function(){return a.fn.tooltip=d,this}}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.popover"),f="object"==typeof b&&b;(e||!/destroy|hide/.test(b))&&(e||d.data("bs.popover",e=new c(this,f)),"string"==typeof b&&e[b]())})}var c=function(a,b){this.init("popover",a,b)};if(!a.fn.tooltip)throw new Error("Popover requires tooltip.js");c.VERSION="3.3.5",c.DEFAULTS=a.extend({},a.fn.tooltip.Constructor.DEFAULTS,{placement:"right",trigger:"click",content:"",template:''}),c.prototype=a.extend({},a.fn.tooltip.Constructor.prototype),c.prototype.constructor=c,c.prototype.getDefaults=function(){return c.DEFAULTS},c.prototype.setContent=function(){var a=this.tip(),b=this.getTitle(),c=this.getContent();a.find(".popover-title")[this.options.html?"html":"text"](b),a.find(".popover-content").children().detach().end()[this.options.html?"string"==typeof c?"html":"append":"text"](c),a.removeClass("fade top bottom left right in"),a.find(".popover-title").html()||a.find(".popover-title").hide()},c.prototype.hasContent=function(){return this.getTitle()||this.getContent()},c.prototype.getContent=function(){var a=this.$element,b=this.options;return a.attr("data-content")||("function"==typeof b.content?b.content.call(a[0]):b.content)},c.prototype.arrow=function(){return this.$arrow=this.$arrow||this.tip().find(".arrow")};var d=a.fn.popover;a.fn.popover=b,a.fn.popover.Constructor=c,a.fn.popover.noConflict=function(){return a.fn.popover=d,this}}(jQuery),+function(a){"use strict";function b(c,d){this.$body=a(document.body),this.$scrollElement=a(a(c).is(document.body)?window:c),this.options=a.extend({},b.DEFAULTS,d),this.selector=(this.options.target||"")+" .nav li > a",this.offsets=[],this.targets=[],this.activeTarget=null,this.scrollHeight=0,this.$scrollElement.on("scroll.bs.scrollspy",a.proxy(this.process,this)),this.refresh(),this.process()}function c(c){return this.each(function(){var d=a(this),e=d.data("bs.scrollspy"),f="object"==typeof c&&c;e||d.data("bs.scrollspy",e=new b(this,f)),"string"==typeof c&&e[c]()})}b.VERSION="3.3.5",b.DEFAULTS={offset:10},b.prototype.getScrollHeight=function(){return this.$scrollElement[0].scrollHeight||Math.max(this.$body[0].scrollHeight,document.documentElement.scrollHeight)},b.prototype.refresh=function(){var b=this,c="offset",d=0;this.offsets=[],this.targets=[],this.scrollHeight=this.getScrollHeight(),a.isWindow(this.$scrollElement[0])||(c="position",d=this.$scrollElement.scrollTop()),this.$body.find(this.selector).map(function(){var b=a(this),e=b.data("target")||b.attr("href"),f=/^#./.test(e)&&a(e);return f&&f.length&&f.is(":visible")&&[[f[c]().top+d,e]]||null}).sort(function(a,b){return a[0]-b[0]}).each(function(){b.offsets.push(this[0]),b.targets.push(this[1])})},b.prototype.process=function(){var a,b=this.$scrollElement.scrollTop()+this.options.offset,c=this.getScrollHeight(),d=this.options.offset+c-this.$scrollElement.height(),e=this.offsets,f=this.targets,g=this.activeTarget;if(this.scrollHeight!=c&&this.refresh(),b>=d)return g!=(a=f[f.length-1])&&this.activate(a);if(g&&b=e[a]&&(void 0===e[a+1]||b .dropdown-menu > .active").removeClass("active").end().find('[data-toggle="tab"]').attr("aria-expanded",!1),b.addClass("active").find('[data-toggle="tab"]').attr("aria-expanded",!0),h?(b[0].offsetWidth,b.addClass("in")):b.removeClass("fade"),b.parent(".dropdown-menu").length&&b.closest("li.dropdown").addClass("active").end().find('[data-toggle="tab"]').attr("aria-expanded",!0),e&&e()}var g=d.find("> .active"),h=e&&a.support.transition&&(g.length&&g.hasClass("fade")||!!d.find("> .fade").length);g.length&&h?g.one("bsTransitionEnd",f).emulateTransitionEnd(c.TRANSITION_DURATION):f(),g.removeClass("in")};var d=a.fn.tab;a.fn.tab=b,a.fn.tab.Constructor=c,a.fn.tab.noConflict=function(){return a.fn.tab=d,this};var e=function(c){c.preventDefault(),b.call(a(this),"show")};a(document).on("click.bs.tab.data-api",'[data-toggle="tab"]',e).on("click.bs.tab.data-api",'[data-toggle="pill"]',e)}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.affix"),f="object"==typeof b&&b;e||d.data("bs.affix",e=new c(this,f)),"string"==typeof b&&e[b]()})}var c=function(b,d){this.options=a.extend({},c.DEFAULTS,d),this.$target=a(this.options.target).on("scroll.bs.affix.data-api",a.proxy(this.checkPosition,this)).on("click.bs.affix.data-api",a.proxy(this.checkPositionWithEventLoop,this)),this.$element=a(b),this.affixed=null,this.unpin=null,this.pinnedOffset=null,this.checkPosition()};c.VERSION="3.3.5",c.RESET="affix affix-top affix-bottom",c.DEFAULTS={offset:0,target:window},c.prototype.getState=function(a,b,c,d){var e=this.$target.scrollTop(),f=this.$element.offset(),g=this.$target.height();if(null!=c&&"top"==this.affixed)return c>e?"top":!1;if("bottom"==this.affixed)return null!=c?e+this.unpin<=f.top?!1:"bottom":a-d>=e+g?!1:"bottom";var h=null==this.affixed,i=h?e:f.top,j=h?g:b;return null!=c&&c>=e?"top":null!=d&&i+j>=a-d?"bottom":!1},c.prototype.getPinnedOffset=function(){if(this.pinnedOffset)return this.pinnedOffset;this.$element.removeClass(c.RESET).addClass("affix");var a=this.$target.scrollTop(),b=this.$element.offset();return this.pinnedOffset=b.top-a},c.prototype.checkPositionWithEventLoop=function(){setTimeout(a.proxy(this.checkPosition,this),1)},c.prototype.checkPosition=function(){if(this.$element.is(":visible")){var b=this.$element.height(),d=this.options.offset,e=d.top,f=d.bottom,g=Math.max(a(document).height(),a(document.body).height());"object"!=typeof d&&(f=e=d),"function"==typeof e&&(e=d.top(this.$element)),"function"==typeof f&&(f=d.bottom(this.$element));var h=this.getState(g,b,e,f);if(this.affixed!=h){null!=this.unpin&&this.$element.css("top","");var i="affix"+(h?"-"+h:""),j=a.Event(i+".bs.affix");if(this.$element.trigger(j),j.isDefaultPrevented())return;this.affixed=h,this.unpin="bottom"==h?this.getPinnedOffset():null,this.$element.removeClass(c.RESET).addClass(i).trigger(i.replace("affix","affixed")+".bs.affix")}"bottom"==h&&this.$element.offset({top:g-b-f})}};var d=a.fn.affix;a.fn.affix=b,a.fn.affix.Constructor=c,a.fn.affix.noConflict=function(){return a.fn.affix=d,this},a(window).on("load",function(){a('[data-spy="affix"]').each(function(){var c=a(this),d=c.data();d.offset=d.offset||{},null!=d.offsetBottom&&(d.offset.bottom=d.offsetBottom),null!=d.offsetTop&&(d.offset.top=d.offsetTop),b.call(c,d)})})}(jQuery); -------------------------------------------------------------------------------- /public/fonts/glyphicons-halflings-regular.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 130 | 131 | 132 | 133 | 134 | 135 | 136 | 137 | 138 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 | 167 | 168 | 169 | 170 | 171 | 172 | 173 | 174 | 175 | 176 | 177 | 178 | 179 | 180 | 181 | 182 | 183 | 184 | 185 | 186 | 187 | 188 | 189 | 190 | 191 | 192 | 193 | 194 | 195 | 196 | 197 | 198 | 199 | 200 | 201 | 202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 | 211 | 212 | 213 | 214 | 215 | 216 | 217 | 218 | 219 | 220 | 221 | 222 | 223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 | 233 | 234 | 235 | 236 | 237 | 238 | 239 | 240 | 241 | 242 | 243 | 244 | 245 | 246 | 247 | 248 | 249 | 250 | 251 | 252 | 253 | 254 | 255 | 256 | 257 | 258 | 259 | 260 | 261 | 262 | 263 | 264 | 265 | 266 | 267 | 268 | 269 | 270 | 271 | 272 | 273 | 274 | 275 | 276 | 277 | 278 | 279 | 280 | 281 | 282 | 283 | 284 | 285 | 286 | 287 | 288 | --------------------------------------------------------------------------------