├── .gitignore
├── public
├── files
│ └── luoran_cv.pdf
├── font
│ └── fontawesome-webfont.woff
├── pictures
│ └── glyphicons-halflings.png
├── stylesheets
│ └── bootstrap
│ │ ├── grunt
│ │ ├── .jshintrc
│ │ ├── bs-commonjs-generator.js
│ │ ├── configBridge.json
│ │ ├── bs-raw-files-generator.js
│ │ ├── bs-glyphicons-data-generator.js
│ │ └── sauce_browsers.yml
│ │ ├── fonts
│ │ ├── glyphicons-halflings-regular.eot
│ │ ├── glyphicons-halflings-regular.ttf
│ │ ├── glyphicons-halflings-regular.woff
│ │ └── glyphicons-halflings-regular.woff2
│ │ ├── less
│ │ ├── mixins
│ │ │ ├── center-block.less
│ │ │ ├── size.less
│ │ │ ├── opacity.less
│ │ │ ├── text-emphasis.less
│ │ │ ├── text-overflow.less
│ │ │ ├── background-variant.less
│ │ │ ├── tab-focus.less
│ │ │ ├── resize.less
│ │ │ ├── labels.less
│ │ │ ├── progress-bar.less
│ │ │ ├── reset-filter.less
│ │ │ ├── nav-divider.less
│ │ │ ├── alerts.less
│ │ │ ├── nav-vertical-align.less
│ │ │ ├── responsive-visibility.less
│ │ │ ├── border-radius.less
│ │ │ ├── reset-text.less
│ │ │ ├── pagination.less
│ │ │ ├── panels.less
│ │ │ ├── hide-text.less
│ │ │ ├── list-group.less
│ │ │ ├── clearfix.less
│ │ │ ├── table-row.less
│ │ │ ├── image.less
│ │ │ ├── buttons.less
│ │ │ ├── forms.less
│ │ │ ├── grid-framework.less
│ │ │ ├── grid.less
│ │ │ └── gradients.less
│ │ ├── wells.less
│ │ ├── breadcrumbs.less
│ │ ├── responsive-embed.less
│ │ ├── component-animations.less
│ │ ├── close.less
│ │ ├── thumbnails.less
│ │ ├── utilities.less
│ │ ├── pager.less
│ │ ├── media.less
│ │ ├── jumbotron.less
│ │ ├── mixins.less
│ │ ├── labels.less
│ │ ├── badges.less
│ │ ├── bootstrap.less
│ │ ├── code.less
│ │ ├── grid.less
│ │ ├── alerts.less
│ │ ├── progress-bars.less
│ │ ├── pagination.less
│ │ ├── print.less
│ │ ├── tooltip.less
│ │ ├── list-group.less
│ │ ├── scaffolding.less
│ │ ├── popovers.less
│ │ ├── modals.less
│ │ ├── buttons.less
│ │ ├── input-groups.less
│ │ ├── responsive-utilities.less
│ │ ├── tables.less
│ │ ├── dropdowns.less
│ │ ├── navs.less
│ │ └── carousel.less
│ │ ├── dist
│ │ ├── fonts
│ │ │ ├── glyphicons-halflings-regular.eot
│ │ │ ├── glyphicons-halflings-regular.ttf
│ │ │ ├── glyphicons-halflings-regular.woff
│ │ │ └── glyphicons-halflings-regular.woff2
│ │ └── js
│ │ │ └── npm.js
│ │ ├── LICENSE
│ │ ├── js
│ │ ├── transition.js
│ │ ├── alert.js
│ │ ├── popover.js
│ │ ├── button.js
│ │ ├── tab.js
│ │ ├── dropdown.js
│ │ ├── scrollspy.js
│ │ └── affix.js
│ │ └── package.json
└── javascripts
│ ├── login.js
│ ├── main.js
│ ├── form_validate.js
│ └── socket_client.js
├── views
├── error.jade
├── arrow_svg.jade
├── layout.jade
└── get_10.jade
├── models
├── blogs.js
├── users.js
└── site_info.js
├── routes
├── login_email.js
├── span_to_svg.js
├── get_logout.js
├── signup.js
├── post_get_10.js
├── post_posts.js
├── validate_email.js
├── post_content_modify.js
├── post_title_modify.js
├── login.js
├── post_comment.js
├── post_delate_comment.js
├── post_tag_delete.js
├── post_add_tag.js
├── get_download.js
├── post_watcher.js
├── get_single.js
├── post_vote.js
└── index.js
├── methods
└── array_contains.js
├── schemas
├── users.js
├── siteInfo.js
└── blogs.js
├── README.md
├── package.json
├── app.conf
├── websocket
└── server_socket.js
├── bae.js
└── server.js
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules
2 | bower_components
3 | npm-debug.log
--------------------------------------------------------------------------------
/public/files/luoran_cv.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Jocs/node_mongodb_blog_system/HEAD/public/files/luoran_cv.pdf
--------------------------------------------------------------------------------
/views/error.jade:
--------------------------------------------------------------------------------
1 | extends layout
2 |
3 | block content
4 | h1= message
5 | h2= error.status
6 | pre #{error.stack}
7 |
--------------------------------------------------------------------------------
/public/font/fontawesome-webfont.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Jocs/node_mongodb_blog_system/HEAD/public/font/fontawesome-webfont.woff
--------------------------------------------------------------------------------
/public/pictures/glyphicons-halflings.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Jocs/node_mongodb_blog_system/HEAD/public/pictures/glyphicons-halflings.png
--------------------------------------------------------------------------------
/models/blogs.js:
--------------------------------------------------------------------------------
1 | var mongoose = require('mongoose');
2 | var blogSchema = require('../schemas/blogs');
3 | var Blogs = mongoose.model('blog', blogSchema);
4 |
5 | module.exports = Blogs;
--------------------------------------------------------------------------------
/models/users.js:
--------------------------------------------------------------------------------
1 | var mongoose = require('mongoose');
2 | var userSchema = require('../schemas/users');
3 | var Users = mongoose.model('user', userSchema);
4 |
5 | module.exports = Users;
--------------------------------------------------------------------------------
/public/stylesheets/bootstrap/grunt/.jshintrc:
--------------------------------------------------------------------------------
1 | {
2 | "extends" : "../js/.jshintrc",
3 | "asi" : false,
4 | "browser" : false,
5 | "es3" : false,
6 | "node" : true
7 | }
8 |
--------------------------------------------------------------------------------
/public/stylesheets/bootstrap/fonts/glyphicons-halflings-regular.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Jocs/node_mongodb_blog_system/HEAD/public/stylesheets/bootstrap/fonts/glyphicons-halflings-regular.eot
--------------------------------------------------------------------------------
/public/stylesheets/bootstrap/fonts/glyphicons-halflings-regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Jocs/node_mongodb_blog_system/HEAD/public/stylesheets/bootstrap/fonts/glyphicons-halflings-regular.ttf
--------------------------------------------------------------------------------
/public/stylesheets/bootstrap/fonts/glyphicons-halflings-regular.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Jocs/node_mongodb_blog_system/HEAD/public/stylesheets/bootstrap/fonts/glyphicons-halflings-regular.woff
--------------------------------------------------------------------------------
/public/stylesheets/bootstrap/fonts/glyphicons-halflings-regular.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Jocs/node_mongodb_blog_system/HEAD/public/stylesheets/bootstrap/fonts/glyphicons-halflings-regular.woff2
--------------------------------------------------------------------------------
/public/stylesheets/bootstrap/less/mixins/center-block.less:
--------------------------------------------------------------------------------
1 | // Center-align a block level element
2 |
3 | .center-block() {
4 | display: block;
5 | margin-left: auto;
6 | margin-right: auto;
7 | }
8 |
--------------------------------------------------------------------------------
/models/site_info.js:
--------------------------------------------------------------------------------
1 | var mongoose = require('mongoose');
2 | var siteInfoSchema = require('../schemas/siteInfo');
3 | var Siteinfo = mongoose.model('siteinfo', siteInfoSchema);
4 |
5 | module.exports = Siteinfo;
--------------------------------------------------------------------------------
/public/stylesheets/bootstrap/dist/fonts/glyphicons-halflings-regular.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Jocs/node_mongodb_blog_system/HEAD/public/stylesheets/bootstrap/dist/fonts/glyphicons-halflings-regular.eot
--------------------------------------------------------------------------------
/public/stylesheets/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Jocs/node_mongodb_blog_system/HEAD/public/stylesheets/bootstrap/dist/fonts/glyphicons-halflings-regular.ttf
--------------------------------------------------------------------------------
/public/stylesheets/bootstrap/dist/fonts/glyphicons-halflings-regular.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Jocs/node_mongodb_blog_system/HEAD/public/stylesheets/bootstrap/dist/fonts/glyphicons-halflings-regular.woff
--------------------------------------------------------------------------------
/public/stylesheets/bootstrap/dist/fonts/glyphicons-halflings-regular.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Jocs/node_mongodb_blog_system/HEAD/public/stylesheets/bootstrap/dist/fonts/glyphicons-halflings-regular.woff2
--------------------------------------------------------------------------------
/public/stylesheets/bootstrap/less/mixins/size.less:
--------------------------------------------------------------------------------
1 | // Sizing shortcuts
2 |
3 | .size(@width; @height) {
4 | width: @width;
5 | height: @height;
6 | }
7 |
8 | .square(@size) {
9 | .size(@size; @size);
10 | }
11 |
--------------------------------------------------------------------------------
/views/arrow_svg.jade:
--------------------------------------------------------------------------------
1 | svg(class='arrow_svg',width='20',height='10').
2 |
3 |
--------------------------------------------------------------------------------
/public/stylesheets/bootstrap/less/mixins/opacity.less:
--------------------------------------------------------------------------------
1 | // Opacity
2 |
3 | .opacity(@opacity) {
4 | opacity: @opacity;
5 | // IE8 filter
6 | @opacity-ie: (@opacity * 100);
7 | filter: ~"alpha(opacity=@{opacity-ie})";
8 | }
9 |
--------------------------------------------------------------------------------
/public/stylesheets/bootstrap/less/mixins/text-emphasis.less:
--------------------------------------------------------------------------------
1 | // Typography
2 |
3 | .text-emphasis-variant(@color) {
4 | color: @color;
5 | a&:hover,
6 | a&:focus {
7 | color: darken(@color, 10%);
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/public/stylesheets/bootstrap/less/mixins/text-overflow.less:
--------------------------------------------------------------------------------
1 | // Text overflow
2 | // Requires inline-block or block for proper styling
3 |
4 | .text-overflow() {
5 | overflow: hidden;
6 | text-overflow: ellipsis;
7 | white-space: nowrap;
8 | }
9 |
--------------------------------------------------------------------------------
/public/stylesheets/bootstrap/less/mixins/background-variant.less:
--------------------------------------------------------------------------------
1 | // Contextual backgrounds
2 |
3 | .bg-variant(@color) {
4 | background-color: @color;
5 | a&:hover,
6 | a&:focus {
7 | background-color: darken(@color, 10%);
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/public/stylesheets/bootstrap/less/mixins/tab-focus.less:
--------------------------------------------------------------------------------
1 | // WebKit-style focus
2 |
3 | .tab-focus() {
4 | // Default
5 | outline: thin dotted;
6 | // WebKit
7 | outline: 5px auto -webkit-focus-ring-color;
8 | outline-offset: -2px;
9 | }
10 |
--------------------------------------------------------------------------------
/public/stylesheets/bootstrap/less/mixins/resize.less:
--------------------------------------------------------------------------------
1 | // Resize anything
2 |
3 | .resizable(@direction) {
4 | resize: @direction; // Options: horizontal, vertical, both
5 | overflow: auto; // Per CSS3 UI, `resize` only applies when `overflow` isn't `visible`
6 | }
7 |
--------------------------------------------------------------------------------
/public/stylesheets/bootstrap/less/mixins/labels.less:
--------------------------------------------------------------------------------
1 | // Labels
2 |
3 | .label-variant(@color) {
4 | background-color: @color;
5 |
6 | &[href] {
7 | &:hover,
8 | &:focus {
9 | background-color: darken(@color, 10%);
10 | }
11 | }
12 | }
13 |
--------------------------------------------------------------------------------
/routes/login_email.js:
--------------------------------------------------------------------------------
1 | var express = require('express');
2 | var router = express.Router();
3 |
4 | /* GET home page. */
5 | router.get('/login/:email', function(req, res, next) {
6 | res.render('index', {loginEmail: req.params.email});
7 | });
8 |
9 | module.exports = router;
--------------------------------------------------------------------------------
/routes/span_to_svg.js:
--------------------------------------------------------------------------------
1 | var express = require('express');
2 | var router = express.Router();
3 |
4 | /* GET logout page. */
5 | router.get('/span_to_svg', function(req, res ){
6 | //console.log('ssss');
7 | res.render('arrow_svg');
8 | });
9 |
10 | module.exports = router;
--------------------------------------------------------------------------------
/methods/array_contains.js:
--------------------------------------------------------------------------------
1 | function contains( array, element ){
2 | var isContain = false;
3 | for(var i = 0; i < array.length; i ++){
4 | if( array[i].toString() == element ){
5 | isContain = true;
6 | }
7 | }
8 | return isContain;
9 | }
10 | module.exports = contains;
--------------------------------------------------------------------------------
/public/stylesheets/bootstrap/less/mixins/progress-bar.less:
--------------------------------------------------------------------------------
1 | // Progress bars
2 |
3 | .progress-bar-variant(@color) {
4 | background-color: @color;
5 |
6 | // Deprecated parent class requirement as of v3.2.0
7 | .progress-striped & {
8 | #gradient > .striped();
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/public/stylesheets/bootstrap/less/mixins/reset-filter.less:
--------------------------------------------------------------------------------
1 | // Reset filters for IE
2 | //
3 | // When you need to remove a gradient background, do not forget to use this to reset
4 | // the IE filter for IE9 and below.
5 |
6 | .reset-filter() {
7 | filter: e(%("progid:DXImageTransform.Microsoft.gradient(enabled = false)"));
8 | }
9 |
--------------------------------------------------------------------------------
/routes/get_logout.js:
--------------------------------------------------------------------------------
1 | var express = require('express');
2 | var router = express.Router();
3 |
4 | /* GET logout page. */
5 | router.get('/logout', function(req, res ){
6 | //console.log('ssss');
7 | req.session.loggedIn = null;
8 | req.session.name = null;
9 | res.redirect('/');
10 | });
11 |
12 | module.exports = router;
--------------------------------------------------------------------------------
/public/stylesheets/bootstrap/less/mixins/nav-divider.less:
--------------------------------------------------------------------------------
1 | // Horizontal dividers
2 | //
3 | // Dividers (basically an hr) within dropdowns and nav lists
4 |
5 | .nav-divider(@color: #e5e5e5) {
6 | height: 1px;
7 | margin: ((@line-height-computed / 2) - 1) 0;
8 | overflow: hidden;
9 | background-color: @color;
10 | }
11 |
--------------------------------------------------------------------------------
/public/stylesheets/bootstrap/less/mixins/alerts.less:
--------------------------------------------------------------------------------
1 | // Alerts
2 |
3 | .alert-variant(@background; @border; @text-color) {
4 | background-color: @background;
5 | border-color: @border;
6 | color: @text-color;
7 |
8 | hr {
9 | border-top-color: darken(@border, 5%);
10 | }
11 | .alert-link {
12 | color: darken(@text-color, 10%);
13 | }
14 | }
15 |
--------------------------------------------------------------------------------
/routes/signup.js:
--------------------------------------------------------------------------------
1 | var express = require('express');
2 | var router = express.Router();
3 | var Users = require('../models/users');
4 |
5 | /* Post signup的数据 */
6 | router.post('/signup', function(req, res, next) {
7 | var user = new Users(req.body).save(function(err, user){
8 | if(err) {
9 | console.log(err);
10 | } else {
11 | res.redirect('/login/' + req.body.email );
12 | }
13 | });
14 | });
15 |
16 | module.exports = router;
--------------------------------------------------------------------------------
/public/stylesheets/bootstrap/less/mixins/nav-vertical-align.less:
--------------------------------------------------------------------------------
1 | // Navbar vertical align
2 | //
3 | // Vertically center elements in the navbar.
4 | // Example: an element has a height of 30px, so write out `.navbar-vertical-align(30px);` to calculate the appropriate top margin.
5 |
6 | .navbar-vertical-align(@element-height) {
7 | margin-top: ((@navbar-height - @element-height) / 2);
8 | margin-bottom: ((@navbar-height - @element-height) / 2);
9 | }
10 |
--------------------------------------------------------------------------------
/public/stylesheets/bootstrap/less/mixins/responsive-visibility.less:
--------------------------------------------------------------------------------
1 | // Responsive utilities
2 |
3 | //
4 | // More easily include all the states for responsive-utilities.less.
5 | .responsive-visibility() {
6 | display: block !important;
7 | table& { display: table !important; }
8 | tr& { display: table-row !important; }
9 | th&,
10 | td& { display: table-cell !important; }
11 | }
12 |
13 | .responsive-invisibility() {
14 | display: none !important;
15 | }
16 |
--------------------------------------------------------------------------------
/schemas/users.js:
--------------------------------------------------------------------------------
1 | var mongoose = require('mongoose');
2 | var Schema = mongoose.Schema;
3 |
4 | var users = new Schema({
5 | name: {
6 | first: String,
7 | last: String
8 | },
9 | email: {type: String, unique: true},
10 | password: {type: String, index: true},
11 | singupDate:{
12 | type:Date,
13 | default: Date.now()
14 | }
15 | });
16 |
17 | users.virtual('name.full').get(function(){
18 | return this.name.first + ' ' + this.name.last;
19 | });
20 |
21 | module.exports = users;
--------------------------------------------------------------------------------
/routes/post_get_10.js:
--------------------------------------------------------------------------------
1 | var express = require('express');
2 | var router = express.Router();
3 |
4 | /* POST get 10 blogs page. */
5 | router.post('/get_10', function(req, res, next) {
6 | console.log(req.body);
7 | res.render('get_10',{
8 | blogs:req.session.blogs.slice(req.body.blogNum, req.body.blogNum + 10)
9 | });
10 | /*res.send({
11 | html: html,
12 | num: req.session.blogs.slice(req.body.blogNum, req.body.blogNum + 10).length
13 | });*/
14 | });
15 |
16 | module.exports = router;
--------------------------------------------------------------------------------
/routes/post_posts.js:
--------------------------------------------------------------------------------
1 | var express = require('express');
2 | var router = express.Router();
3 | var Blogs = require('../models/blogs');
4 |
5 | /* GET home page. */
6 | router.post('/post', function(req, res, next) {
7 | console.log(req.body.content);
8 | req.body.tags = req.body.tags.split(' ');
9 | var post = new Blogs(req.body).save(function(err){
10 | if(err) return next(err);
11 | res.redirect('/');
12 | });
13 | });
14 |
15 | module.exports = router;
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # NodeJs + Mongodb + Express + Socket.io
2 |
3 | **a simple blog system powered by Nodejs, Mongoldb, Express and Socket.io**
4 |
5 | ### How to use?
6 |
7 | > npm install
8 |
9 | open the bae.js file. config your database name and password.
10 |
11 | ### How to start it?
12 |
13 | > npm start
14 |
15 | ### Last but not least
16 |
17 | This app is very simple, give you the basic practice of BAE USE and how to config Mongoose. Enjoy it, if you have any Questions, generate a issue and I'll fix it as soon as possible.
--------------------------------------------------------------------------------
/routes/validate_email.js:
--------------------------------------------------------------------------------
1 | var express = require('express');
2 | var router = express.Router();
3 | var Users = require('../models/users');
4 |
5 | /* POST content modify page. */
6 | router.post('/validate_email', function(req, res, next) {
7 | console.log(req.body);
8 | Users.find(req.body, function(err, msg){
9 | console.log(msg);
10 | if(err){
11 | console.log(err);
12 | } else {
13 | var data = {
14 | pass: msg.length == 0? true: false
15 | };
16 | res.send(data);
17 | }
18 | });
19 |
20 | });
21 |
22 | module.exports = router;
--------------------------------------------------------------------------------
/public/stylesheets/bootstrap/dist/js/npm.js:
--------------------------------------------------------------------------------
1 | // This file is autogenerated via the `commonjs` Grunt task. You can require() this file in a CommonJS environment.
2 | require('../../js/transition.js')
3 | require('../../js/alert.js')
4 | require('../../js/button.js')
5 | require('../../js/carousel.js')
6 | require('../../js/collapse.js')
7 | require('../../js/dropdown.js')
8 | require('../../js/modal.js')
9 | require('../../js/tooltip.js')
10 | require('../../js/popover.js')
11 | require('../../js/scrollspy.js')
12 | require('../../js/tab.js')
13 | require('../../js/affix.js')
--------------------------------------------------------------------------------
/routes/post_content_modify.js:
--------------------------------------------------------------------------------
1 | var express = require('express');
2 | var router = express.Router();
3 | var Blogs = require('../models/blogs');
4 |
5 | /* POST content modify page. */
6 | router.post('/content_modify/:blogId', function(req, res, next) {
7 | console.log(req.body);
8 | var date = {content: req.body.content, date:{updateAt: Date.now()}};
9 | Blogs.update({_id: req.params.blogId},date, function(err, msg){
10 | console.log(msg);
11 | if(err){
12 | console.log(err);
13 | } else {
14 | res.send(req.body);
15 | }
16 | });
17 |
18 | });
19 |
20 | module.exports = router;
--------------------------------------------------------------------------------
/routes/post_title_modify.js:
--------------------------------------------------------------------------------
1 | var express = require('express');
2 | var router = express.Router();
3 | var Blogs = require('../models/blogs');
4 |
5 | /* POST title modify page. */
6 | router.post('/title_modify/:blogId', function(req, res, next) {
7 | console.log(req.body);
8 | var data = {title:req.body.title, date:{updateAt:Date.now()}};
9 | Blogs.update({_id: req.params.blogId},data,
10 | function(err, msg){
11 | console.log(msg);
12 | if(err){
13 | console.log(err);
14 | } else {
15 | res.send(req.body);
16 | }
17 | });
18 |
19 | });
20 |
21 | module.exports = router;
--------------------------------------------------------------------------------
/public/stylesheets/bootstrap/less/mixins/border-radius.less:
--------------------------------------------------------------------------------
1 | // Single side border-radius
2 |
3 | .border-top-radius(@radius) {
4 | border-top-right-radius: @radius;
5 | border-top-left-radius: @radius;
6 | }
7 | .border-right-radius(@radius) {
8 | border-bottom-right-radius: @radius;
9 | border-top-right-radius: @radius;
10 | }
11 | .border-bottom-radius(@radius) {
12 | border-bottom-right-radius: @radius;
13 | border-bottom-left-radius: @radius;
14 | }
15 | .border-left-radius(@radius) {
16 | border-bottom-left-radius: @radius;
17 | border-top-left-radius: @radius;
18 | }
19 |
--------------------------------------------------------------------------------
/public/stylesheets/bootstrap/less/mixins/reset-text.less:
--------------------------------------------------------------------------------
1 | .reset-text() {
2 | font-family: @font-family-base;
3 | // We deliberately do NOT reset font-size.
4 | font-style: normal;
5 | font-weight: normal;
6 | letter-spacing: normal;
7 | line-break: auto;
8 | line-height: @line-height-base;
9 | text-align: left; // Fallback for where `start` is not supported
10 | text-align: start;
11 | text-decoration: none;
12 | text-shadow: none;
13 | text-transform: none;
14 | white-space: normal;
15 | word-break: normal;
16 | word-spacing: normal;
17 | word-wrap: normal;
18 | }
19 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "bae-Blog-nodejs",
3 | "version": "1.0.0",
4 | "author": "luoran",
5 | "description": "The first bae nodejs app!",
6 | "scripts": {
7 | "start": "node server.js"
8 | },
9 | "dependencies": {
10 | "body-parser": "~1.12.4",
11 | "cookie-parser": "~1.3.5",
12 | "debug": "~2.2.0",
13 | "express": "~4.12.4",
14 | "jade": "~1.9.2",
15 | "morgan": "~1.5.3",
16 | "serve-favicon": "~2.2.1",
17 | "express-session":"1.11.3",
18 | "mongoose":"4.0.6",
19 | "connect-mongo":"0.8.1",
20 | "moment":"2.10.3",
21 | "socket.io":"1.3.6"
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/public/stylesheets/bootstrap/less/mixins/pagination.less:
--------------------------------------------------------------------------------
1 | // Pagination
2 |
3 | .pagination-size(@padding-vertical; @padding-horizontal; @font-size; @line-height; @border-radius) {
4 | > li {
5 | > a,
6 | > span {
7 | padding: @padding-vertical @padding-horizontal;
8 | font-size: @font-size;
9 | line-height: @line-height;
10 | }
11 | &:first-child {
12 | > a,
13 | > span {
14 | .border-left-radius(@border-radius);
15 | }
16 | }
17 | &:last-child {
18 | > a,
19 | > span {
20 | .border-right-radius(@border-radius);
21 | }
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/public/stylesheets/bootstrap/less/mixins/panels.less:
--------------------------------------------------------------------------------
1 | // Panels
2 |
3 | .panel-variant(@border; @heading-text-color; @heading-bg-color; @heading-border) {
4 | border-color: @border;
5 |
6 | & > .panel-heading {
7 | color: @heading-text-color;
8 | background-color: @heading-bg-color;
9 | border-color: @heading-border;
10 |
11 | + .panel-collapse > .panel-body {
12 | border-top-color: @border;
13 | }
14 | .badge {
15 | color: @heading-bg-color;
16 | background-color: @heading-text-color;
17 | }
18 | }
19 | & > .panel-footer {
20 | + .panel-collapse > .panel-body {
21 | border-bottom-color: @border;
22 | }
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/routes/login.js:
--------------------------------------------------------------------------------
1 | var express = require('express');
2 | var router = express.Router();
3 | var User = require('../models/users');
4 |
5 | router.post('/login', function(req, res, next ){
6 | User.findOne({email: req.body.email, password: req.body.password},
7 | function(err, doc){
8 | if(err) return next(err);
9 | if(!doc) return res.send('
User not found, Go back and try again!
');
10 | req.session.loggedIn = doc._id.toString();
11 | req.session.name = doc.name.full;
12 | req.session.email = doc.email;
13 | //console.log(req.session.loggedIn);
14 | //console.log(req.session.name);
15 | res.redirect('/');
16 | });
17 | });
18 | module.exports = router;
--------------------------------------------------------------------------------
/public/stylesheets/bootstrap/less/wells.less:
--------------------------------------------------------------------------------
1 | //
2 | // Wells
3 | // --------------------------------------------------
4 |
5 |
6 | // Base class
7 | .well {
8 | min-height: 20px;
9 | padding: 19px;
10 | margin-bottom: 20px;
11 | background-color: @well-bg;
12 | border: 1px solid @well-border;
13 | border-radius: @border-radius-base;
14 | .box-shadow(inset 0 1px 1px rgba(0,0,0,.05));
15 | blockquote {
16 | border-color: #ddd;
17 | border-color: rgba(0,0,0,.15);
18 | }
19 | }
20 |
21 | // Sizes
22 | .well-lg {
23 | padding: 24px;
24 | border-radius: @border-radius-large;
25 | }
26 | .well-sm {
27 | padding: 9px;
28 | border-radius: @border-radius-small;
29 | }
30 |
--------------------------------------------------------------------------------
/routes/post_comment.js:
--------------------------------------------------------------------------------
1 | var express = require('express');
2 | var router = express.Router();
3 | var Blogs = require('../models/blogs');
4 |
5 | /* GET home page. */
6 | router.post('/comment/:blogId', function(req, res, next) {
7 | //console.log(req.body);
8 | Blogs.findById(req.params.blogId, function(err, blog){
9 | //console.log(blog);
10 | if(err){
11 | console.log(err);
12 | } else {
13 | blog[0].comments.addToSet(req.body);
14 | blog[0].save(function(err){
15 | if(err) {
16 | console.log(err);
17 | } else {
18 | res.send({comments:blog[0].comments,name:req.session.name});
19 | }
20 | });
21 | }
22 | });
23 |
24 | });
25 |
26 | module.exports = router;
--------------------------------------------------------------------------------
/views/layout.jade:
--------------------------------------------------------------------------------
1 | doctype html
2 | html
3 | head
4 | title Blog 社区
5 | link(rel='stylesheet', href='/stylesheets/bootstrap/dist/css/bootstrap.min.css')
6 | //-link(rel='stylesheet', href='stylesheets/bootstrap-combined.min.css')
7 | link(rel='stylesheet', href='/stylesheets/font-awesome.css')
8 | link(rel='stylesheet', href='/stylesheets/style.css')
9 | script(src='/javascripts/moment.js')
10 |
11 |
12 | //-link(rel="stylesheet", href="http://dreamsky.github.io/main/blog/common/init.css")
13 | //-script(src="http://dreamsky.github.io/main/blog/common/jquery.min.js")
14 | //-script(src="http://dreamsky.github.io/main/blog/common/init.js")
15 | body
16 | block content
--------------------------------------------------------------------------------
/public/stylesheets/bootstrap/less/mixins/hide-text.less:
--------------------------------------------------------------------------------
1 | // CSS image replacement
2 | //
3 | // Heads up! v3 launched with only `.hide-text()`, but per our pattern for
4 | // mixins being reused as classes with the same name, this doesn't hold up. As
5 | // of v3.0.1 we have added `.text-hide()` and deprecated `.hide-text()`.
6 | //
7 | // Source: https://github.com/h5bp/html5-boilerplate/commit/aa0396eae757
8 |
9 | // Deprecated as of v3.0.1 (will be removed in v4)
10 | .hide-text() {
11 | font: ~"0/0" a;
12 | color: transparent;
13 | text-shadow: none;
14 | background-color: transparent;
15 | border: 0;
16 | }
17 |
18 | // New mixin to use as of v3.0.1
19 | .text-hide() {
20 | .hide-text();
21 | }
22 |
--------------------------------------------------------------------------------
/routes/post_delate_comment.js:
--------------------------------------------------------------------------------
1 | var express = require('express');
2 | var router = express.Router();
3 | var Blogs = require('../models/blogs');
4 |
5 | /* GET home page. */
6 | router.post('/delate-comment/:blogId', function(req, res, next) {
7 | console.log(req.body);
8 | Blogs.findById(req.params.blogId, function(err, blog){
9 | console.log(blog);
10 | if(err){
11 | console.log(err);
12 | } else {
13 | blog[0].comments.id(req.body.commentId).remove();
14 | blog[0].save(function(err){
15 | if(err) {
16 | console.log(err);
17 | } else {
18 | res.send({comments:blog[0].comments,name:req.session.name});
19 | }
20 | });
21 | }
22 | });
23 |
24 | });
25 |
26 | module.exports = router;
--------------------------------------------------------------------------------
/public/stylesheets/bootstrap/less/mixins/list-group.less:
--------------------------------------------------------------------------------
1 | // List Groups
2 |
3 | .list-group-item-variant(@state; @background; @color) {
4 | .list-group-item-@{state} {
5 | color: @color;
6 | background-color: @background;
7 |
8 | a&,
9 | button& {
10 | color: @color;
11 |
12 | .list-group-item-heading {
13 | color: inherit;
14 | }
15 |
16 | &:hover,
17 | &:focus {
18 | color: @color;
19 | background-color: darken(@background, 5%);
20 | }
21 | &.active,
22 | &.active:hover,
23 | &.active:focus {
24 | color: #fff;
25 | background-color: @color;
26 | border-color: @color;
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/app.conf:
--------------------------------------------------------------------------------
1 | ########################## BAE application config file ######################
2 | #
3 | # app.conf 采用YAML格式, 请参考 http://yaml.org/
4 | # 请尽量不要在配置部分使用中文,以免发布失败
5 | # 请不要使用TAB键,应该使用空格
6 | # 一定要注意对齐,否则发布会失败
7 | # app.conf 详细功能,请参考:
8 | # http://developer.baidu.com/wiki/index.php?title=docs/cplat/rt/manage/conf
9 | # http://godbae.duapp.com/?p=654
10 | #
11 | ##############################################################################
12 |
13 | handlers:
14 | - url : (.*)
15 | script: $1.nodejs
16 |
17 | - expire : .jpg modify 10 years
18 | - expire : .swf modify 10 years
19 | - expire : .png modify 10 years
20 | - expire : .gif modify 10 years
21 | - expire : .JPG modify 10 years
22 | - expire : .ico modify 10 years
23 |
--------------------------------------------------------------------------------
/public/stylesheets/bootstrap/less/mixins/clearfix.less:
--------------------------------------------------------------------------------
1 | // Clearfix
2 | //
3 | // For modern browsers
4 | // 1. The space content is one way to avoid an Opera bug when the
5 | // contenteditable attribute is included anywhere else in the document.
6 | // Otherwise it causes space to appear at the top and bottom of elements
7 | // that are clearfixed.
8 | // 2. The use of `table` rather than `block` is only necessary if using
9 | // `:before` to contain the top-margins of child elements.
10 | //
11 | // Source: http://nicolasgallagher.com/micro-clearfix-hack/
12 |
13 | .clearfix() {
14 | &:before,
15 | &:after {
16 | content: " "; // 1
17 | display: table; // 2
18 | }
19 | &:after {
20 | clear: both;
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/public/stylesheets/bootstrap/less/breadcrumbs.less:
--------------------------------------------------------------------------------
1 | //
2 | // Breadcrumbs
3 | // --------------------------------------------------
4 |
5 |
6 | .breadcrumb {
7 | padding: @breadcrumb-padding-vertical @breadcrumb-padding-horizontal;
8 | margin-bottom: @line-height-computed;
9 | list-style: none;
10 | background-color: @breadcrumb-bg;
11 | border-radius: @border-radius-base;
12 |
13 | > li {
14 | display: inline-block;
15 |
16 | + li:before {
17 | content: "@{breadcrumb-separator}\00a0"; // Unicode space added since inline-block means non-collapsing white-space
18 | padding: 0 5px;
19 | color: @breadcrumb-color;
20 | }
21 | }
22 |
23 | > .active {
24 | color: @breadcrumb-active-color;
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/public/stylesheets/bootstrap/less/responsive-embed.less:
--------------------------------------------------------------------------------
1 | // Embeds responsive
2 | //
3 | // Credit: Nicolas Gallagher and SUIT CSS.
4 |
5 | .embed-responsive {
6 | position: relative;
7 | display: block;
8 | height: 0;
9 | padding: 0;
10 | overflow: hidden;
11 |
12 | .embed-responsive-item,
13 | iframe,
14 | embed,
15 | object,
16 | video {
17 | position: absolute;
18 | top: 0;
19 | left: 0;
20 | bottom: 0;
21 | height: 100%;
22 | width: 100%;
23 | border: 0;
24 | }
25 | }
26 |
27 | // Modifier class for 16:9 aspect ratio
28 | .embed-responsive-16by9 {
29 | padding-bottom: 56.25%;
30 | }
31 |
32 | // Modifier class for 4:3 aspect ratio
33 | .embed-responsive-4by3 {
34 | padding-bottom: 75%;
35 | }
36 |
--------------------------------------------------------------------------------
/schemas/siteInfo.js:
--------------------------------------------------------------------------------
1 | var mongoose = require('mongoose');
2 | var Schema = mongoose.Schema;
3 |
4 | //统计站点信息的collection。如CV下载次数等。
5 | var cvinfoSchema = new Schema({
6 | downloaderid: String,
7 | downloader: String,
8 | email: String,
9 | times:Number,
10 | date: {
11 | createAt:{
12 | type: Date, default: Date.now()
13 | },
14 | updateAt:{
15 | type:Date, default: Date.now()
16 | }
17 | }
18 | });
19 | cvinfoSchema.pre('save', function(next){
20 | if(this.isNew){
21 | this.date.createAt = this.date.updateAt = Date.now();
22 | this.times = 1;
23 | } else {
24 | this.date.updateAt = Date.now();
25 | this.times ++;
26 | }
27 | next();
28 | });
29 |
30 | module.exports = cvinfoSchema;
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/routes/post_tag_delete.js:
--------------------------------------------------------------------------------
1 | var express = require('express');
2 | var router = express.Router();
3 | var Blogs = require('../models/blogs');
4 |
5 | /* POST title modify page. */
6 | router.post('/tag_delete/:blogId', function(req, res, next) {
7 | console.log(req.body);
8 | Blogs.findById(req.params.blogId, function(err, blogs){
9 | var tags = blogs[0].tags;
10 | if(err){
11 | console.log(err);
12 | } else {
13 | for(var i = 0; i < tags.length; i ++){
14 | if(tags[i] == req.body.tag||tags[i] == ''){
15 | tags.splice(i, 1);
16 | }
17 | }
18 | blogs[0].date.updateAt = Date.now();
19 | blogs[0].save(function(err){
20 | if(err) console.log(err);
21 | res.send({delete: true});
22 | });
23 | }
24 | });
25 |
26 | });
27 |
28 | module.exports = router;
--------------------------------------------------------------------------------
/public/stylesheets/bootstrap/less/component-animations.less:
--------------------------------------------------------------------------------
1 | //
2 | // Component animations
3 | // --------------------------------------------------
4 |
5 | // Heads up!
6 | //
7 | // We don't use the `.opacity()` mixin here since it causes a bug with text
8 | // fields in IE7-8. Source: https://github.com/twbs/bootstrap/pull/3552.
9 |
10 | .fade {
11 | opacity: 0;
12 | .transition(opacity .15s linear);
13 | &.in {
14 | opacity: 1;
15 | }
16 | }
17 |
18 | .collapse {
19 | display: none;
20 |
21 | &.in { display: block; }
22 | tr&.in { display: table-row; }
23 | tbody&.in { display: table-row-group; }
24 | }
25 |
26 | .collapsing {
27 | position: relative;
28 | height: 0;
29 | overflow: hidden;
30 | .transition-property(~"height, visibility");
31 | .transition-duration(.35s);
32 | .transition-timing-function(ease);
33 | }
34 |
--------------------------------------------------------------------------------
/public/stylesheets/bootstrap/less/mixins/table-row.less:
--------------------------------------------------------------------------------
1 | // Tables
2 |
3 | .table-row-variant(@state; @background) {
4 | // Exact selectors below required to override `.table-striped` and prevent
5 | // inheritance to nested tables.
6 | .table > thead > tr,
7 | .table > tbody > tr,
8 | .table > tfoot > tr {
9 | > td.@{state},
10 | > th.@{state},
11 | &.@{state} > td,
12 | &.@{state} > th {
13 | background-color: @background;
14 | }
15 | }
16 |
17 | // Hover states for `.table-hover`
18 | // Note: this is not available for cells or rows within `thead` or `tfoot`.
19 | .table-hover > tbody > tr {
20 | > td.@{state}:hover,
21 | > th.@{state}:hover,
22 | &.@{state}:hover > td,
23 | &:hover > .@{state},
24 | &.@{state}:hover > th {
25 | background-color: darken(@background, 5%);
26 | }
27 | }
28 | }
29 |
--------------------------------------------------------------------------------
/routes/post_add_tag.js:
--------------------------------------------------------------------------------
1 | var express = require('express');
2 | var router = express.Router();
3 | var Blogs = require('../models/blogs');
4 |
5 | /* POST title modify page. */
6 | router.post('/tag_add/:blogId', function(req, res, next) {
7 | console.log(req.body);
8 | Blogs.findById(req.params.blogId, function(err, blogs){
9 | var tags = blogs[0].tags;
10 | var isPush = true;
11 | if(err){
12 | console.log(err);
13 | } else {
14 | for(var i = 0; i < tags.length; i ++){
15 | if(tags[i]==req.body.tag) isPush = false;
16 | }
17 | if(isPush) {
18 | tags.push(req.body.tag);
19 | blogs[0].date.updateAt = Date.now();
20 | blogs[0].save(function(err){
21 | if(err) console.log(err);
22 | res.send(req.body);
23 | });
24 | } else {
25 | res.send({add: '标签已存在'});
26 | }
27 | }
28 | });
29 |
30 | });
31 |
32 | module.exports = router;
--------------------------------------------------------------------------------
/public/javascripts/login.js:
--------------------------------------------------------------------------------
1 | window.onload = function(){
2 | var form_change = document.getElementById('form-change');
3 | var header_text = document.getElementById('header-text');
4 | var a_text = document.getElementById('a-text');
5 | var login = document.getElementById('login');
6 | var signup = document.getElementById('signup');
7 | form_change.onclick = function(){
8 | //alert(~a_text.innerHTML.indexOf('注册'));
9 | if(!(~a_text.innerHTML.indexOf('注册'))){
10 | a_text.innerHTML = '注册 ';
11 | header_text.innerHTML = "登陆Blog";
12 | form_change.setAttribute('href','#signup');
13 | login.style.display = 'block';
14 | signup.style.display = 'none';
15 | } else {
16 | a_text.innerHTML = '登陆 ';
17 | header_text.innerHTML = "注册Blog";
18 | form_change.setAttribute('href','#login');
19 | login.style.display = 'none';
20 | signup.style.display = 'block';
21 | }
22 | };
23 | };
--------------------------------------------------------------------------------
/routes/get_download.js:
--------------------------------------------------------------------------------
1 | var express = require('express');
2 | var router = express.Router();
3 | var Siteinfo = require('../models/site_info');
4 |
5 | /* GET download page. */
6 | router.get('/download/:fileName', function(req, res ){
7 | //console.log('ssss');
8 | var data = {
9 | downloaderid: req.session.loggedIn,
10 | downloader: req.session.name,
11 | email: req.session.email
12 | };
13 | Siteinfo.find(data, function(err, doc){
14 | if(err) console.log(err);
15 | if(doc.length == 0){
16 | var siteinfo = new Siteinfo(data).save(function(err){
17 | if(err) console.log(err);
18 | });
19 | } else {
20 | doc[0].save(function(err){
21 | if(err) console.log(err);
22 | });
23 | }
24 | });
25 | var fileName = req.params.fileName;
26 | console.log(fileName);
27 | var file = __dirname.slice(0,__dirname.indexOf('routes')) + 'public/files/' + fileName;
28 | res.download(file);
29 | });
30 |
31 | module.exports = router;
--------------------------------------------------------------------------------
/websocket/server_socket.js:
--------------------------------------------------------------------------------
1 | //socket.io模块
2 | var Blogs = require('../models/blogs');
3 |
4 | function serverSocket(server){
5 | var io = require('socket.io')(server);
6 | io.on('connection',function(socket){
7 | socket.on('subscribe',function(data){
8 | //console.log(data);
9 | data.rooms.forEach(function(ele){
10 | socket.join(ele);
11 | });
12 | });
13 | socket.on('add_comment',function(data){
14 | console.log(data);
15 | var blogId = data.blogId;
16 | var commenter = data.author;
17 | var comment = data.comment;
18 | var date = data.date;
19 | Blogs.findById(blogId,function(err,blogs){
20 | if(err) console.log(err);
21 | socket.broadcast.to(blogId).emit('render_comment',{
22 | date: date,
23 | commenter:commenter,
24 | blogTitle: blogs[0].title,
25 | blogId: blogId,
26 | comment: comment
27 | });
28 | });
29 | });
30 | });
31 | };
32 |
33 | module.exports = serverSocket;
--------------------------------------------------------------------------------
/public/stylesheets/bootstrap/less/close.less:
--------------------------------------------------------------------------------
1 | //
2 | // Close icons
3 | // --------------------------------------------------
4 |
5 |
6 | .close {
7 | float: right;
8 | font-size: (@font-size-base * 1.5);
9 | font-weight: @close-font-weight;
10 | line-height: 1;
11 | color: @close-color;
12 | text-shadow: @close-text-shadow;
13 | .opacity(.2);
14 |
15 | &:hover,
16 | &:focus {
17 | color: @close-color;
18 | text-decoration: none;
19 | cursor: pointer;
20 | .opacity(.5);
21 | }
22 |
23 | // Additional properties for button version
24 | // iOS requires the button element instead of an anchor tag.
25 | // If you want the anchor version, it requires `href="#"`.
26 | // See https://developer.mozilla.org/en-US/docs/Web/Events/click#Safari_Mobile
27 | button& {
28 | padding: 0;
29 | cursor: pointer;
30 | background: transparent;
31 | border: 0;
32 | -webkit-appearance: none;
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/public/stylesheets/bootstrap/less/thumbnails.less:
--------------------------------------------------------------------------------
1 | //
2 | // Thumbnails
3 | // --------------------------------------------------
4 |
5 |
6 | // Mixin and adjust the regular image class
7 | .thumbnail {
8 | display: block;
9 | padding: @thumbnail-padding;
10 | margin-bottom: @line-height-computed;
11 | line-height: @line-height-base;
12 | background-color: @thumbnail-bg;
13 | border: 1px solid @thumbnail-border;
14 | border-radius: @thumbnail-border-radius;
15 | .transition(border .2s ease-in-out);
16 |
17 | > img,
18 | a > img {
19 | &:extend(.img-responsive);
20 | margin-left: auto;
21 | margin-right: auto;
22 | }
23 |
24 | // Add a hover state for linked versions only
25 | a&:hover,
26 | a&:focus,
27 | a&.active {
28 | border-color: @link-color;
29 | }
30 |
31 | // Image captions
32 | .caption {
33 | padding: @thumbnail-caption-padding;
34 | color: @thumbnail-caption-color;
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/public/stylesheets/bootstrap/less/utilities.less:
--------------------------------------------------------------------------------
1 | //
2 | // Utility classes
3 | // --------------------------------------------------
4 |
5 |
6 | // Floats
7 | // -------------------------
8 |
9 | .clearfix {
10 | .clearfix();
11 | }
12 | .center-block {
13 | .center-block();
14 | }
15 | .pull-right {
16 | float: right !important;
17 | }
18 | .pull-left {
19 | float: left !important;
20 | }
21 |
22 |
23 | // Toggling content
24 | // -------------------------
25 |
26 | // Note: Deprecated .hide in favor of .hidden or .sr-only (as appropriate) in v3.0.1
27 | .hide {
28 | display: none !important;
29 | }
30 | .show {
31 | display: block !important;
32 | }
33 | .invisible {
34 | visibility: hidden;
35 | }
36 | .text-hide {
37 | .text-hide();
38 | }
39 |
40 |
41 | // Hide from screenreaders and browsers
42 | //
43 | // Credit: HTML5 Boilerplate
44 |
45 | .hidden {
46 | display: none !important;
47 | }
48 |
49 |
50 | // For Affix plugin
51 | // -------------------------
52 |
53 | .affix {
54 | position: fixed;
55 | }
56 |
--------------------------------------------------------------------------------
/routes/post_watcher.js:
--------------------------------------------------------------------------------
1 | var express = require('express');
2 | var router = express.Router();
3 | var Blogs = require('../models/blogs');
4 | var contains = require('../methods/array_contains');
5 |
6 | /* POST watch modify page. */
7 | router.post('/watch/:blogId', function(req, res, next) {
8 | console.log(req.body);
9 | Blogs.findById(req.params.blogId, function(err, blogs){
10 | if(err) console.log(err);
11 | var watchers = blogs[0].watcher;
12 | var isContain = contains(watchers, req.body.watcher);
13 | var condition = {_id: req.params.blogId};
14 |
15 | if( isContain ){
16 | var update = {'$pull':{'watcher': req.body.watcher}};
17 | Blogs.update(condition, update,function(err){
18 | if(err) console.log(err);
19 | res.send({watch: false});
20 | });
21 | } else {
22 | var update = {'$push':{'watcher': req.body.watcher}};
23 | Blogs.update(condition, update, function(err){
24 | if(err) console.log(err);
25 | res.send({watch: true});
26 | });
27 | }
28 | });
29 |
30 | });
31 |
32 | module.exports = router;
--------------------------------------------------------------------------------
/public/stylesheets/bootstrap/less/pager.less:
--------------------------------------------------------------------------------
1 | //
2 | // Pager pagination
3 | // --------------------------------------------------
4 |
5 |
6 | .pager {
7 | padding-left: 0;
8 | margin: @line-height-computed 0;
9 | list-style: none;
10 | text-align: center;
11 | &:extend(.clearfix all);
12 | li {
13 | display: inline;
14 | > a,
15 | > span {
16 | display: inline-block;
17 | padding: 5px 14px;
18 | background-color: @pager-bg;
19 | border: 1px solid @pager-border;
20 | border-radius: @pager-border-radius;
21 | }
22 |
23 | > a:hover,
24 | > a:focus {
25 | text-decoration: none;
26 | background-color: @pager-hover-bg;
27 | }
28 | }
29 |
30 | .next {
31 | > a,
32 | > span {
33 | float: right;
34 | }
35 | }
36 |
37 | .previous {
38 | > a,
39 | > span {
40 | float: left;
41 | }
42 | }
43 |
44 | .disabled {
45 | > a,
46 | > a:hover,
47 | > a:focus,
48 | > span {
49 | color: @pager-disabled-color;
50 | background-color: @pager-bg;
51 | cursor: @cursor-disabled;
52 | }
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/public/stylesheets/bootstrap/grunt/bs-commonjs-generator.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * Bootstrap Grunt task for the CommonJS module generation
3 | * http://getbootstrap.com
4 | * Copyright 2014-2015 Twitter, Inc.
5 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
6 | */
7 |
8 | 'use strict';
9 |
10 | var fs = require('fs');
11 | var path = require('path');
12 |
13 | var COMMONJS_BANNER = '// This file is autogenerated via the `commonjs` Grunt task. You can require() this file in a CommonJS environment.\n';
14 |
15 | module.exports = function generateCommonJSModule(grunt, srcFiles, destFilepath) {
16 | var destDir = path.dirname(destFilepath);
17 |
18 | function srcPathToDestRequire(srcFilepath) {
19 | var requirePath = path.relative(destDir, srcFilepath).replace(/\\/g, '/');
20 | return 'require(\'' + requirePath + '\')';
21 | }
22 |
23 | var moduleOutputJs = COMMONJS_BANNER + srcFiles.map(srcPathToDestRequire).join('\n');
24 | try {
25 | fs.writeFileSync(destFilepath, moduleOutputJs);
26 | } catch (err) {
27 | grunt.fail.warn(err);
28 | }
29 | grunt.log.writeln('File ' + destFilepath.cyan + ' created.');
30 | };
31 |
--------------------------------------------------------------------------------
/public/stylesheets/bootstrap/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2011-2015 Twitter, Inc
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
13 | all 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
21 | THE SOFTWARE.
22 |
--------------------------------------------------------------------------------
/public/stylesheets/bootstrap/less/media.less:
--------------------------------------------------------------------------------
1 | .media {
2 | // Proper spacing between instances of .media
3 | margin-top: 15px;
4 |
5 | &:first-child {
6 | margin-top: 0;
7 | }
8 | }
9 |
10 | .media,
11 | .media-body {
12 | zoom: 1;
13 | overflow: hidden;
14 | }
15 |
16 | .media-body {
17 | width: 10000px;
18 | }
19 |
20 | .media-object {
21 | display: block;
22 |
23 | // Fix collapse in webkit from max-width: 100% and display: table-cell.
24 | &.img-thumbnail {
25 | max-width: none;
26 | }
27 | }
28 |
29 | .media-right,
30 | .media > .pull-right {
31 | padding-left: 10px;
32 | }
33 |
34 | .media-left,
35 | .media > .pull-left {
36 | padding-right: 10px;
37 | }
38 |
39 | .media-left,
40 | .media-right,
41 | .media-body {
42 | display: table-cell;
43 | vertical-align: top;
44 | }
45 |
46 | .media-middle {
47 | vertical-align: middle;
48 | }
49 |
50 | .media-bottom {
51 | vertical-align: bottom;
52 | }
53 |
54 | // Reset margins on headings for tighter default spacing
55 | .media-heading {
56 | margin-top: 0;
57 | margin-bottom: 5px;
58 | }
59 |
60 | // Media list variation
61 | //
62 | // Undo default ul/ol styles
63 | .media-list {
64 | padding-left: 0;
65 | list-style: none;
66 | }
67 |
--------------------------------------------------------------------------------
/public/stylesheets/bootstrap/less/mixins/image.less:
--------------------------------------------------------------------------------
1 | // Image Mixins
2 | // - Responsive image
3 | // - Retina image
4 |
5 |
6 | // Responsive image
7 | //
8 | // Keep images from scaling beyond the width of their parents.
9 | .img-responsive(@display: block) {
10 | display: @display;
11 | max-width: 100%; // Part 1: Set a maximum relative to the parent
12 | height: auto; // Part 2: Scale the height according to the width, otherwise you get stretching
13 | }
14 |
15 |
16 | // Retina image
17 | //
18 | // Short retina mixin for setting background-image and -size. Note that the
19 | // spelling of `min--moz-device-pixel-ratio` is intentional.
20 | .img-retina(@file-1x; @file-2x; @width-1x; @height-1x) {
21 | background-image: url("@{file-1x}");
22 |
23 | @media
24 | only screen and (-webkit-min-device-pixel-ratio: 2),
25 | only screen and ( min--moz-device-pixel-ratio: 2),
26 | only screen and ( -o-min-device-pixel-ratio: 2/1),
27 | only screen and ( min-device-pixel-ratio: 2),
28 | only screen and ( min-resolution: 192dpi),
29 | only screen and ( min-resolution: 2dppx) {
30 | background-image: url("@{file-2x}");
31 | background-size: @width-1x @height-1x;
32 | }
33 | }
34 |
--------------------------------------------------------------------------------
/public/stylesheets/bootstrap/less/jumbotron.less:
--------------------------------------------------------------------------------
1 | //
2 | // Jumbotron
3 | // --------------------------------------------------
4 |
5 |
6 | .jumbotron {
7 | padding-top: @jumbotron-padding;
8 | padding-bottom: @jumbotron-padding;
9 | margin-bottom: @jumbotron-padding;
10 | color: @jumbotron-color;
11 | background-color: @jumbotron-bg;
12 |
13 | h1,
14 | .h1 {
15 | color: @jumbotron-heading-color;
16 | }
17 |
18 | p {
19 | margin-bottom: (@jumbotron-padding / 2);
20 | font-size: @jumbotron-font-size;
21 | font-weight: 200;
22 | }
23 |
24 | > hr {
25 | border-top-color: darken(@jumbotron-bg, 10%);
26 | }
27 |
28 | .container &,
29 | .container-fluid & {
30 | border-radius: @border-radius-large; // Only round corners at higher resolutions if contained in a container
31 | }
32 |
33 | .container {
34 | max-width: 100%;
35 | }
36 |
37 | @media screen and (min-width: @screen-sm-min) {
38 | padding-top: (@jumbotron-padding * 1.6);
39 | padding-bottom: (@jumbotron-padding * 1.6);
40 |
41 | .container &,
42 | .container-fluid & {
43 | padding-left: (@jumbotron-padding * 2);
44 | padding-right: (@jumbotron-padding * 2);
45 | }
46 |
47 | h1,
48 | .h1 {
49 | font-size: @jumbotron-heading-font-size;
50 | }
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/public/stylesheets/bootstrap/less/mixins.less:
--------------------------------------------------------------------------------
1 | // Mixins
2 | // --------------------------------------------------
3 |
4 | // Utilities
5 | @import "mixins/hide-text.less";
6 | @import "mixins/opacity.less";
7 | @import "mixins/image.less";
8 | @import "mixins/labels.less";
9 | @import "mixins/reset-filter.less";
10 | @import "mixins/resize.less";
11 | @import "mixins/responsive-visibility.less";
12 | @import "mixins/size.less";
13 | @import "mixins/tab-focus.less";
14 | @import "mixins/reset-text.less";
15 | @import "mixins/text-emphasis.less";
16 | @import "mixins/text-overflow.less";
17 | @import "mixins/vendor-prefixes.less";
18 |
19 | // Components
20 | @import "mixins/alerts.less";
21 | @import "mixins/buttons.less";
22 | @import "mixins/panels.less";
23 | @import "mixins/pagination.less";
24 | @import "mixins/list-group.less";
25 | @import "mixins/nav-divider.less";
26 | @import "mixins/forms.less";
27 | @import "mixins/progress-bar.less";
28 | @import "mixins/table-row.less";
29 |
30 | // Skins
31 | @import "mixins/background-variant.less";
32 | @import "mixins/border-radius.less";
33 | @import "mixins/gradients.less";
34 |
35 | // Layout
36 | @import "mixins/clearfix.less";
37 | @import "mixins/center-block.less";
38 | @import "mixins/nav-vertical-align.less";
39 | @import "mixins/grid-framework.less";
40 | @import "mixins/grid.less";
41 |
--------------------------------------------------------------------------------
/public/stylesheets/bootstrap/less/labels.less:
--------------------------------------------------------------------------------
1 | //
2 | // Labels
3 | // --------------------------------------------------
4 |
5 | .label {
6 | display: inline;
7 | padding: .2em .6em .3em;
8 | font-size: 75%;
9 | font-weight: bold;
10 | line-height: 1;
11 | color: @label-color;
12 | text-align: center;
13 | white-space: nowrap;
14 | vertical-align: baseline;
15 | border-radius: .25em;
16 |
17 | // Add hover effects, but only for links
18 | a& {
19 | &:hover,
20 | &:focus {
21 | color: @label-link-hover-color;
22 | text-decoration: none;
23 | cursor: pointer;
24 | }
25 | }
26 |
27 | // Empty labels collapse automatically (not available in IE8)
28 | &:empty {
29 | display: none;
30 | }
31 |
32 | // Quick fix for labels in buttons
33 | .btn & {
34 | position: relative;
35 | top: -1px;
36 | }
37 | }
38 |
39 | // Colors
40 | // Contextual variations (linked labels get darker on :hover)
41 |
42 | .label-default {
43 | .label-variant(@label-default-bg);
44 | }
45 |
46 | .label-primary {
47 | .label-variant(@label-primary-bg);
48 | }
49 |
50 | .label-success {
51 | .label-variant(@label-success-bg);
52 | }
53 |
54 | .label-info {
55 | .label-variant(@label-info-bg);
56 | }
57 |
58 | .label-warning {
59 | .label-variant(@label-warning-bg);
60 | }
61 |
62 | .label-danger {
63 | .label-variant(@label-danger-bg);
64 | }
65 |
--------------------------------------------------------------------------------
/routes/get_single.js:
--------------------------------------------------------------------------------
1 | var express = require('express');
2 | var router = express.Router();
3 | var Blogs = require('../models/blogs');
4 |
5 |
6 | /* GET single page. */
7 | router.get('/blogs/:blogId', function(req, res, next) {
8 | Blogs.findOne({_id: req.params.blogId})
9 | .populate('voter')
10 | .exec(function(err, blog){
11 | if(err){
12 | console.log(err);
13 | } else {
14 | Blogs.find({watcher:req.session.loggedIn},
15 | {title:1,comments:1},
16 | {skip:0,sort:{'date.allUpdateAt':-1}},
17 | function( err, articles ){
18 | //console.log(articles);
19 | if(err) {
20 | console.log(err);
21 | } else {
22 | Blogs.where('tags').in(blog.tags)
23 | .where('_id').ne(blog._id)
24 | .skip(0)
25 | .limit(5)
26 | .select('title voter')
27 | .sort('-date.allUpdateAt')
28 | .exec(function(err,docs){
29 | //console.log(docs);
30 | if(err) console.log(err);
31 | var art = articles.slice(0,5);
32 | var array = [];
33 | articles.forEach(function(ele){
34 | array.push(ele._id);
35 | });
36 | var ids = array.join(',');
37 |
38 | //console.log(ids);
39 | res.render('single', {blogs: [blog],
40 | articles: art,
41 | docs: docs,
42 | ids:ids});
43 | });
44 | }
45 | });
46 | }
47 | });
48 |
49 | });
50 |
51 | module.exports = router;
52 |
--------------------------------------------------------------------------------
/public/stylesheets/bootstrap/less/badges.less:
--------------------------------------------------------------------------------
1 | //
2 | // Badges
3 | // --------------------------------------------------
4 |
5 |
6 | // Base class
7 | .badge {
8 | display: inline-block;
9 | min-width: 10px;
10 | padding: 3px 7px;
11 | font-size: @font-size-small;
12 | font-weight: @badge-font-weight;
13 | color: @badge-color;
14 | line-height: @badge-line-height;
15 | vertical-align: middle;
16 | white-space: nowrap;
17 | text-align: center;
18 | background-color: @badge-bg;
19 | border-radius: @badge-border-radius;
20 |
21 | // Empty badges collapse automatically (not available in IE8)
22 | &:empty {
23 | display: none;
24 | }
25 |
26 | // Quick fix for badges in buttons
27 | .btn & {
28 | position: relative;
29 | top: -1px;
30 | }
31 |
32 | .btn-xs &,
33 | .btn-group-xs > .btn & {
34 | top: 0;
35 | padding: 1px 5px;
36 | }
37 |
38 | // Hover state, but only for links
39 | a& {
40 | &:hover,
41 | &:focus {
42 | color: @badge-link-hover-color;
43 | text-decoration: none;
44 | cursor: pointer;
45 | }
46 | }
47 |
48 | // Account for badges in navs
49 | .list-group-item.active > &,
50 | .nav-pills > .active > a > & {
51 | color: @badge-active-color;
52 | background-color: @badge-active-bg;
53 | }
54 |
55 | .list-group-item > & {
56 | float: right;
57 | }
58 |
59 | .list-group-item > & + & {
60 | margin-right: 5px;
61 | }
62 |
63 | .nav-pills > li > a > & {
64 | margin-left: 3px;
65 | }
66 | }
67 |
--------------------------------------------------------------------------------
/public/stylesheets/bootstrap/grunt/configBridge.json:
--------------------------------------------------------------------------------
1 | {
2 | "paths": {
3 | "customizerJs": [
4 | "../assets/js/vendor/autoprefixer.js",
5 | "../assets/js/vendor/less.min.js",
6 | "../assets/js/vendor/jszip.min.js",
7 | "../assets/js/vendor/uglify.min.js",
8 | "../assets/js/vendor/Blob.js",
9 | "../assets/js/vendor/FileSaver.js",
10 | "../assets/js/raw-files.min.js",
11 | "../assets/js/src/customizer.js"
12 | ],
13 | "docsJs": [
14 | "../assets/js/vendor/holder.min.js",
15 | "../assets/js/vendor/ZeroClipboard.min.js",
16 | "../assets/js/vendor/anchor.js",
17 | "../assets/js/src/application.js"
18 | ]
19 | },
20 | "config": {
21 | "autoprefixerBrowsers": [
22 | "Android 2.3",
23 | "Android >= 4",
24 | "Chrome >= 20",
25 | "Firefox >= 24",
26 | "Explorer >= 8",
27 | "iOS >= 6",
28 | "Opera >= 12",
29 | "Safari >= 6"
30 | ],
31 | "jqueryCheck": [
32 | "if (typeof jQuery === 'undefined') {",
33 | " throw new Error('Bootstrap\\'s JavaScript requires jQuery')",
34 | "}\n"
35 | ],
36 | "jqueryVersionCheck": [
37 | "+function ($) {",
38 | " 'use strict';",
39 | " var version = $.fn.jquery.split(' ')[0].split('.')",
40 | " if ((version[0] < 2 && version[1] < 9) || (version[0] == 1 && version[1] == 9 && version[2] < 1)) {",
41 | " throw new Error('Bootstrap\\'s JavaScript requires jQuery version 1.9.1 or higher')",
42 | " }",
43 | "}(jQuery);\n\n"
44 | ]
45 | }
46 | }
--------------------------------------------------------------------------------
/public/stylesheets/bootstrap/less/bootstrap.less:
--------------------------------------------------------------------------------
1 | /*!
2 | * Bootstrap v3.3.5 (http://getbootstrap.com)
3 | * Copyright 2011-2015 Twitter, Inc.
4 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
5 | */
6 |
7 | // Core variables and mixins
8 | @import "variables.less";
9 | @import "mixins.less";
10 |
11 | // Reset and dependencies
12 | @import "normalize.less";
13 | @import "print.less";
14 | @import "glyphicons.less";
15 |
16 | // Core CSS
17 | @import "scaffolding.less";
18 | @import "type.less";
19 | @import "code.less";
20 | @import "grid.less";
21 | @import "tables.less";
22 | @import "forms.less";
23 | @import "buttons.less";
24 |
25 | // Components
26 | @import "component-animations.less";
27 | @import "dropdowns.less";
28 | @import "button-groups.less";
29 | @import "input-groups.less";
30 | @import "navs.less";
31 | @import "navbar.less";
32 | @import "breadcrumbs.less";
33 | @import "pagination.less";
34 | @import "pager.less";
35 | @import "labels.less";
36 | @import "badges.less";
37 | @import "jumbotron.less";
38 | @import "thumbnails.less";
39 | @import "alerts.less";
40 | @import "progress-bars.less";
41 | @import "media.less";
42 | @import "list-group.less";
43 | @import "panels.less";
44 | @import "responsive-embed.less";
45 | @import "wells.less";
46 | @import "close.less";
47 |
48 | // Components w/ JavaScript
49 | @import "modals.less";
50 | @import "tooltip.less";
51 | @import "popovers.less";
52 | @import "carousel.less";
53 |
54 | // Utility classes
55 | @import "utilities.less";
56 | @import "responsive-utilities.less";
57 |
--------------------------------------------------------------------------------
/public/stylesheets/bootstrap/grunt/bs-raw-files-generator.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * Bootstrap Grunt task for generating raw-files.min.js for the Customizer
3 | * http://getbootstrap.com
4 | * Copyright 2014-2015 Twitter, Inc.
5 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
6 | */
7 |
8 | 'use strict';
9 |
10 | var fs = require('fs');
11 | var btoa = require('btoa');
12 | var glob = require('glob');
13 |
14 | function getFiles(type) {
15 | var files = {};
16 | var recursive = type === 'less';
17 | var globExpr = recursive ? '/**/*' : '/*';
18 | glob.sync(type + globExpr)
19 | .filter(function (path) {
20 | return type === 'fonts' ? true : new RegExp('\\.' + type + '$').test(path);
21 | })
22 | .forEach(function (fullPath) {
23 | var relativePath = fullPath.replace(/^[^/]+\//, '');
24 | files[relativePath] = type === 'fonts' ? btoa(fs.readFileSync(fullPath)) : fs.readFileSync(fullPath, 'utf8');
25 | });
26 | return 'var __' + type + ' = ' + JSON.stringify(files) + '\n';
27 | }
28 |
29 | module.exports = function generateRawFilesJs(grunt, banner) {
30 | if (!banner) {
31 | banner = '';
32 | }
33 | var dirs = ['js', 'less', 'fonts'];
34 | var files = banner + dirs.map(getFiles).reduce(function (combined, file) {
35 | return combined + file;
36 | }, '');
37 | var rawFilesJs = 'docs/assets/js/raw-files.min.js';
38 | try {
39 | fs.writeFileSync(rawFilesJs, files);
40 | } catch (err) {
41 | grunt.fail.warn(err);
42 | }
43 | grunt.log.writeln('File ' + rawFilesJs.cyan + ' created.');
44 | };
45 |
--------------------------------------------------------------------------------
/routes/post_vote.js:
--------------------------------------------------------------------------------
1 | var express = require('express');
2 | var router = express.Router();
3 | var Blogs = require('../models/blogs');
4 | var Users = require('../models/users');
5 |
6 | /* GET home page. */
7 | router.post('/vote/:blogId', function(req, res, next) {
8 | console.log(req.body);
9 | Blogs.findById(req.params.blogId, function(err, blog){
10 | if(err){
11 | console.log(err);
12 | } else {
13 | var isNew = true;
14 | blog[0].voter.forEach(function(e){
15 | if(e == req.body.userId) isNew = false;
16 | });
17 | if(isNew&&req.body.isVote==='true'){
18 | blog[0].voter.unshift(req.body.userId);
19 | blog[0].save(function(err){
20 | if(err) console.log(err);
21 | });
22 | } else if(!isNew){
23 | for(var i = 0; i < blog[0].voter.length; i ++){
24 | if(blog[0].voter[i] == req.body.userId || blog[0].voter[i] == ''){
25 | blog[0].voter.splice(i,1);
26 | }
27 | }
28 | blog[0].save(function(err){
29 | if(err) console.log(err);
30 | });
31 | }
32 | var nameArray = [],len = Math.min(3,blog[0].voter.length);
33 | if(len != 0){
34 | for(var i = 0; i < len; i ++){
35 | Users.findById(blog[0].voter[i],function(err, doc){
36 | console.log(doc);
37 | nameArray.push(doc.name.full);
38 | if(nameArray.length == len){
39 | res.send({length: blog[0].voter.length,nameArray: nameArray});
40 | }
41 | });
42 | }
43 | } else {
44 | res.send({length:0,nameArray:[]});
45 | }
46 |
47 |
48 | }
49 | });
50 |
51 | });
52 |
53 | module.exports = router;
--------------------------------------------------------------------------------
/schemas/blogs.js:
--------------------------------------------------------------------------------
1 | var mongoose = require('mongoose');
2 | var Schema = mongoose.Schema;
3 | var User = require('../models/users');
4 |
5 | var commentsSchema = new Schema({
6 | author: String,
7 | reply: String,
8 | comment: String,
9 | hidden: {type: Boolean, default:false},
10 | date: {type: Date, default: Date.now()}
11 | });
12 |
13 | var blogSchema = new Schema({
14 | title: String,
15 | author: String,
16 | content: String,
17 | comments: [commentsSchema],
18 | tags:[String],
19 | date: {
20 | createAt:{
21 | type:Date,
22 | default: Date.now()
23 | },
24 | updateAt:{
25 | type:Date,
26 | default: Date.now()
27 | },
28 | allUpdateAt:{
29 | type: Date,
30 | default: Date.now()
31 | }
32 | },
33 | hidden: {
34 | type: Boolean,
35 | default:false
36 | },
37 | voter: [{type:Schema.Types.ObjectId, ref: 'user'}],
38 | watcher:[{type:Schema.Types.ObjectId, ref: 'user'}]
39 |
40 | });
41 |
42 |
43 |
44 |
45 | blogSchema.pre('save', function(next){
46 | if(this.isNew){
47 | this.date.createAt = this.date.updateAt = this.date.allUpdateAt = Date.now();
48 | } else {
49 | this.date.allUpdateAt = Date.now();
50 | }
51 | next();
52 | });
53 |
54 | blogSchema.statics = {
55 | fetch: function( cb ){
56 | return this.find({})
57 | .sort({'date.allUpdateAt':-1})
58 | .exec( cb );
59 | },
60 | findById: function( id, cb ){
61 | return this.find({_id: id})
62 | .exec( cb );
63 | }
64 | };
65 |
66 | module.exports = blogSchema;
67 |
68 |
69 |
70 |
71 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
--------------------------------------------------------------------------------
/public/stylesheets/bootstrap/grunt/bs-glyphicons-data-generator.js:
--------------------------------------------------------------------------------
1 | /*!
2 | * Bootstrap Grunt task for Glyphicons data generation
3 | * http://getbootstrap.com
4 | * Copyright 2014-2015 Twitter, Inc.
5 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
6 | */
7 |
8 | 'use strict';
9 |
10 | var fs = require('fs');
11 |
12 | module.exports = function generateGlyphiconsData(grunt) {
13 | // Pass encoding, utf8, so `readFileSync` will return a string instead of a
14 | // buffer
15 | var glyphiconsFile = fs.readFileSync('less/glyphicons.less', 'utf8');
16 | var glyphiconsLines = glyphiconsFile.split('\n');
17 |
18 | // Use any line that starts with ".glyphicon-" and capture the class name
19 | var iconClassName = /^\.(glyphicon-[a-zA-Z0-9-]+)/;
20 | var glyphiconsData = '# This file is generated via Grunt task. **Do not edit directly.**\n' +
21 | '# See the \'build-glyphicons-data\' task in Gruntfile.js.\n\n';
22 | var glyphiconsYml = 'docs/_data/glyphicons.yml';
23 | for (var i = 0, len = glyphiconsLines.length; i < len; i++) {
24 | var match = glyphiconsLines[i].match(iconClassName);
25 |
26 | if (match !== null) {
27 | glyphiconsData += '- ' + match[1] + '\n';
28 | }
29 | }
30 |
31 | // Create the `_data` directory if it doesn't already exist
32 | if (!fs.existsSync('docs/_data')) {
33 | fs.mkdirSync('docs/_data');
34 | }
35 |
36 | try {
37 | fs.writeFileSync(glyphiconsYml, glyphiconsData);
38 | } catch (err) {
39 | grunt.fail.warn(err);
40 | }
41 | grunt.log.writeln('File ' + glyphiconsYml.cyan + ' created.');
42 | };
43 |
--------------------------------------------------------------------------------
/public/stylesheets/bootstrap/less/code.less:
--------------------------------------------------------------------------------
1 | //
2 | // Code (inline and block)
3 | // --------------------------------------------------
4 |
5 |
6 | // Inline and block code styles
7 | code,
8 | kbd,
9 | pre,
10 | samp {
11 | font-family: @font-family-monospace;
12 | }
13 |
14 | // Inline code
15 | code {
16 | padding: 2px 4px;
17 | font-size: 90%;
18 | color: @code-color;
19 | background-color: @code-bg;
20 | border-radius: @border-radius-base;
21 | }
22 |
23 | // User input typically entered via keyboard
24 | kbd {
25 | padding: 2px 4px;
26 | font-size: 90%;
27 | color: @kbd-color;
28 | background-color: @kbd-bg;
29 | border-radius: @border-radius-small;
30 | box-shadow: inset 0 -1px 0 rgba(0,0,0,.25);
31 |
32 | kbd {
33 | padding: 0;
34 | font-size: 100%;
35 | font-weight: bold;
36 | box-shadow: none;
37 | }
38 | }
39 |
40 | // Blocks of code
41 | pre {
42 | display: block;
43 | padding: ((@line-height-computed - 1) / 2);
44 | margin: 0 0 (@line-height-computed / 2);
45 | font-size: (@font-size-base - 1); // 14px to 13px
46 | line-height: @line-height-base;
47 | word-break: break-all;
48 | word-wrap: break-word;
49 | color: @pre-color;
50 | background-color: @pre-bg;
51 | border: 1px solid @pre-border-color;
52 | border-radius: @border-radius-base;
53 |
54 | // Account for some code outputs that place code tags in pre tags
55 | code {
56 | padding: 0;
57 | font-size: inherit;
58 | color: inherit;
59 | white-space: pre-wrap;
60 | background-color: transparent;
61 | border-radius: 0;
62 | }
63 | }
64 |
65 | // Enable scrollable blocks of code
66 | .pre-scrollable {
67 | max-height: @pre-scrollable-max-height;
68 | overflow-y: scroll;
69 | }
70 |
--------------------------------------------------------------------------------
/public/stylesheets/bootstrap/less/grid.less:
--------------------------------------------------------------------------------
1 | //
2 | // Grid system
3 | // --------------------------------------------------
4 |
5 |
6 | // Container widths
7 | //
8 | // Set the container width, and override it for fixed navbars in media queries.
9 |
10 | .container {
11 | .container-fixed();
12 |
13 | @media (min-width: @screen-sm-min) {
14 | width: @container-sm;
15 | }
16 | @media (min-width: @screen-md-min) {
17 | width: @container-md;
18 | }
19 | @media (min-width: @screen-lg-min) {
20 | width: @container-lg;
21 | }
22 | }
23 |
24 |
25 | // Fluid container
26 | //
27 | // Utilizes the mixin meant for fixed width containers, but without any defined
28 | // width for fluid, full width layouts.
29 |
30 | .container-fluid {
31 | .container-fixed();
32 | }
33 |
34 |
35 | // Row
36 | //
37 | // Rows contain and clear the floats of your columns.
38 |
39 | .row {
40 | .make-row();
41 | }
42 |
43 |
44 | // Columns
45 | //
46 | // Common styles for small and large grid columns
47 |
48 | .make-grid-columns();
49 |
50 |
51 | // Extra small grid
52 | //
53 | // Columns, offsets, pushes, and pulls for extra small devices like
54 | // smartphones.
55 |
56 | .make-grid(xs);
57 |
58 |
59 | // Small grid
60 | //
61 | // Columns, offsets, pushes, and pulls for the small device range, from phones
62 | // to tablets.
63 |
64 | @media (min-width: @screen-sm-min) {
65 | .make-grid(sm);
66 | }
67 |
68 |
69 | // Medium grid
70 | //
71 | // Columns, offsets, pushes, and pulls for the desktop device range.
72 |
73 | @media (min-width: @screen-md-min) {
74 | .make-grid(md);
75 | }
76 |
77 |
78 | // Large grid
79 | //
80 | // Columns, offsets, pushes, and pulls for the large desktop device range.
81 |
82 | @media (min-width: @screen-lg-min) {
83 | .make-grid(lg);
84 | }
85 |
--------------------------------------------------------------------------------
/public/stylesheets/bootstrap/less/mixins/buttons.less:
--------------------------------------------------------------------------------
1 | // Button variants
2 | //
3 | // Easily pump out default styles, as well as :hover, :focus, :active,
4 | // and disabled options for all buttons
5 |
6 | .button-variant(@color; @background; @border) {
7 | color: @color;
8 | background-color: @background;
9 | border-color: @border;
10 |
11 | &:focus,
12 | &.focus {
13 | color: @color;
14 | background-color: darken(@background, 10%);
15 | border-color: darken(@border, 25%);
16 | }
17 | &:hover {
18 | color: @color;
19 | background-color: darken(@background, 10%);
20 | border-color: darken(@border, 12%);
21 | }
22 | &:active,
23 | &.active,
24 | .open > .dropdown-toggle& {
25 | color: @color;
26 | background-color: darken(@background, 10%);
27 | border-color: darken(@border, 12%);
28 |
29 | &:hover,
30 | &:focus,
31 | &.focus {
32 | color: @color;
33 | background-color: darken(@background, 17%);
34 | border-color: darken(@border, 25%);
35 | }
36 | }
37 | &:active,
38 | &.active,
39 | .open > .dropdown-toggle& {
40 | background-image: none;
41 | }
42 | &.disabled,
43 | &[disabled],
44 | fieldset[disabled] & {
45 | &,
46 | &:hover,
47 | &:focus,
48 | &.focus,
49 | &:active,
50 | &.active {
51 | background-color: @background;
52 | border-color: @border;
53 | }
54 | }
55 |
56 | .badge {
57 | color: @background;
58 | background-color: @color;
59 | }
60 | }
61 |
62 | // Button sizes
63 | .button-size(@padding-vertical; @padding-horizontal; @font-size; @line-height; @border-radius) {
64 | padding: @padding-vertical @padding-horizontal;
65 | font-size: @font-size;
66 | line-height: @line-height;
67 | border-radius: @border-radius;
68 | }
69 |
--------------------------------------------------------------------------------
/public/stylesheets/bootstrap/grunt/sauce_browsers.yml:
--------------------------------------------------------------------------------
1 | [
2 | # Docs: https://saucelabs.com/docs/platforms/webdriver
3 |
4 | {
5 | browserName: "safari",
6 | platform: "OS X 10.10"
7 | },
8 | {
9 | browserName: "chrome",
10 | platform: "OS X 10.10"
11 | },
12 | {
13 | browserName: "firefox",
14 | platform: "OS X 10.10"
15 | },
16 |
17 | # Mac Opera not currently supported by Sauce Labs
18 |
19 | {
20 | browserName: "internet explorer",
21 | version: "11",
22 | platform: "Windows 8.1"
23 | },
24 | {
25 | browserName: "internet explorer",
26 | version: "10",
27 | platform: "Windows 8"
28 | },
29 | {
30 | browserName: "internet explorer",
31 | version: "9",
32 | platform: "Windows 7"
33 | },
34 | {
35 | browserName: "internet explorer",
36 | version: "8",
37 | platform: "Windows 7"
38 | },
39 |
40 | # { # Unofficial
41 | # browserName: "internet explorer",
42 | # version: "7",
43 | # platform: "Windows XP"
44 | # },
45 |
46 | {
47 | browserName: "chrome",
48 | platform: "Windows 8.1"
49 | },
50 | {
51 | browserName: "firefox",
52 | platform: "Windows 8.1"
53 | },
54 |
55 | # Win Opera 15+ not currently supported by Sauce Labs
56 |
57 | {
58 | browserName: "iphone",
59 | platform: "OS X 10.10",
60 | version: "8.2"
61 | },
62 |
63 | # iOS Chrome not currently supported by Sauce Labs
64 |
65 | # Linux (unofficial)
66 | {
67 | browserName: "chrome",
68 | platform: "Linux"
69 | },
70 | {
71 | browserName: "firefox",
72 | platform: "Linux"
73 | }
74 |
75 | # Android Chrome not currently supported by Sauce Labs
76 |
77 | # { # Android Browser (super-unofficial)
78 | # browserName: "android",
79 | # version: "4.0",
80 | # platform: "Linux"
81 | # }
82 | ]
83 |
--------------------------------------------------------------------------------
/public/stylesheets/bootstrap/less/alerts.less:
--------------------------------------------------------------------------------
1 | //
2 | // Alerts
3 | // --------------------------------------------------
4 |
5 |
6 | // Base styles
7 | // -------------------------
8 |
9 | .alert {
10 | padding: @alert-padding;
11 | margin-bottom: @line-height-computed;
12 | border: 1px solid transparent;
13 | border-radius: @alert-border-radius;
14 |
15 | // Headings for larger alerts
16 | h4 {
17 | margin-top: 0;
18 | // Specified for the h4 to prevent conflicts of changing @headings-color
19 | color: inherit;
20 | }
21 |
22 | // Provide class for links that match alerts
23 | .alert-link {
24 | font-weight: @alert-link-font-weight;
25 | }
26 |
27 | // Improve alignment and spacing of inner content
28 | > p,
29 | > ul {
30 | margin-bottom: 0;
31 | }
32 |
33 | > p + p {
34 | margin-top: 5px;
35 | }
36 | }
37 |
38 | // Dismissible alerts
39 | //
40 | // Expand the right padding and account for the close button's positioning.
41 |
42 | .alert-dismissable, // The misspelled .alert-dismissable was deprecated in 3.2.0.
43 | .alert-dismissible {
44 | padding-right: (@alert-padding + 20);
45 |
46 | // Adjust close link position
47 | .close {
48 | position: relative;
49 | top: -2px;
50 | right: -21px;
51 | color: inherit;
52 | }
53 | }
54 |
55 | // Alternate styles
56 | //
57 | // Generate contextual modifier classes for colorizing the alert.
58 |
59 | .alert-success {
60 | .alert-variant(@alert-success-bg; @alert-success-border; @alert-success-text);
61 | }
62 |
63 | .alert-info {
64 | .alert-variant(@alert-info-bg; @alert-info-border; @alert-info-text);
65 | }
66 |
67 | .alert-warning {
68 | .alert-variant(@alert-warning-bg; @alert-warning-border; @alert-warning-text);
69 | }
70 |
71 | .alert-danger {
72 | .alert-variant(@alert-danger-bg; @alert-danger-border; @alert-danger-text);
73 | }
74 |
--------------------------------------------------------------------------------
/public/stylesheets/bootstrap/js/transition.js:
--------------------------------------------------------------------------------
1 | /* ========================================================================
2 | * Bootstrap: transition.js v3.3.5
3 | * http://getbootstrap.com/javascript/#transitions
4 | * ========================================================================
5 | * Copyright 2011-2015 Twitter, Inc.
6 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
7 | * ======================================================================== */
8 |
9 |
10 | +function ($) {
11 | 'use strict';
12 |
13 | // CSS TRANSITION SUPPORT (Shoutout: http://www.modernizr.com/)
14 | // ============================================================
15 |
16 | function transitionEnd() {
17 | var el = document.createElement('bootstrap')
18 |
19 | var transEndEventNames = {
20 | WebkitTransition : 'webkitTransitionEnd',
21 | MozTransition : 'transitionend',
22 | OTransition : 'oTransitionEnd otransitionend',
23 | transition : 'transitionend'
24 | }
25 |
26 | for (var name in transEndEventNames) {
27 | if (el.style[name] !== undefined) {
28 | return { end: transEndEventNames[name] }
29 | }
30 | }
31 |
32 | return false // explicit for ie8 ( ._.)
33 | }
34 |
35 | // http://blog.alexmaccaw.com/css-transitions
36 | $.fn.emulateTransitionEnd = function (duration) {
37 | var called = false
38 | var $el = this
39 | $(this).one('bsTransitionEnd', function () { called = true })
40 | var callback = function () { if (!called) $($el).trigger($.support.transition.end) }
41 | setTimeout(callback, duration)
42 | return this
43 | }
44 |
45 | $(function () {
46 | $.support.transition = transitionEnd()
47 |
48 | if (!$.support.transition) return
49 |
50 | $.event.special.bsTransitionEnd = {
51 | bindType: $.support.transition.end,
52 | delegateType: $.support.transition.end,
53 | handle: function (e) {
54 | if ($(e.target).is(this)) return e.handleObj.handler.apply(this, arguments)
55 | }
56 | }
57 | })
58 |
59 | }(jQuery);
60 |
--------------------------------------------------------------------------------
/public/stylesheets/bootstrap/less/progress-bars.less:
--------------------------------------------------------------------------------
1 | //
2 | // Progress bars
3 | // --------------------------------------------------
4 |
5 |
6 | // Bar animations
7 | // -------------------------
8 |
9 | // WebKit
10 | @-webkit-keyframes progress-bar-stripes {
11 | from { background-position: 40px 0; }
12 | to { background-position: 0 0; }
13 | }
14 |
15 | // Spec and IE10+
16 | @keyframes progress-bar-stripes {
17 | from { background-position: 40px 0; }
18 | to { background-position: 0 0; }
19 | }
20 |
21 |
22 | // Bar itself
23 | // -------------------------
24 |
25 | // Outer container
26 | .progress {
27 | overflow: hidden;
28 | height: @line-height-computed;
29 | margin-bottom: @line-height-computed;
30 | background-color: @progress-bg;
31 | border-radius: @progress-border-radius;
32 | .box-shadow(inset 0 1px 2px rgba(0,0,0,.1));
33 | }
34 |
35 | // Bar of progress
36 | .progress-bar {
37 | float: left;
38 | width: 0%;
39 | height: 100%;
40 | font-size: @font-size-small;
41 | line-height: @line-height-computed;
42 | color: @progress-bar-color;
43 | text-align: center;
44 | background-color: @progress-bar-bg;
45 | .box-shadow(inset 0 -1px 0 rgba(0,0,0,.15));
46 | .transition(width .6s ease);
47 | }
48 |
49 | // Striped bars
50 | //
51 | // `.progress-striped .progress-bar` is deprecated as of v3.2.0 in favor of the
52 | // `.progress-bar-striped` class, which you just add to an existing
53 | // `.progress-bar`.
54 | .progress-striped .progress-bar,
55 | .progress-bar-striped {
56 | #gradient > .striped();
57 | background-size: 40px 40px;
58 | }
59 |
60 | // Call animation for the active one
61 | //
62 | // `.progress.active .progress-bar` is deprecated as of v3.2.0 in favor of the
63 | // `.progress-bar.active` approach.
64 | .progress.active .progress-bar,
65 | .progress-bar.active {
66 | .animation(progress-bar-stripes 2s linear infinite);
67 | }
68 |
69 |
70 | // Variations
71 | // -------------------------
72 |
73 | .progress-bar-success {
74 | .progress-bar-variant(@progress-bar-success-bg);
75 | }
76 |
77 | .progress-bar-info {
78 | .progress-bar-variant(@progress-bar-info-bg);
79 | }
80 |
81 | .progress-bar-warning {
82 | .progress-bar-variant(@progress-bar-warning-bg);
83 | }
84 |
85 | .progress-bar-danger {
86 | .progress-bar-variant(@progress-bar-danger-bg);
87 | }
88 |
--------------------------------------------------------------------------------
/routes/index.js:
--------------------------------------------------------------------------------
1 | var express = require('express');
2 | var router = express.Router();
3 | var Blogs = require('../models/blogs');
4 | var Users = require('../models/users');
5 |
6 | //populate用法
7 | /*Blogs.findOne({_id:'55b7a434800a3fca44c2815c'})
8 | .populate('voter')
9 | .exec(function(err ,doc){
10 | console.log(doc);
11 | });*/
12 |
13 | //把返回的文章按点赞数量进行排序的方法
14 | function compare( array ){
15 | for(var i = 0; i < array.length; i ++){
16 | for(var j = 0; j < array.length - i -1; j ++){
17 | if(array[j].voter.length < array[j + 1].voter.length){
18 | var swap = array[j];
19 | array[j] = array[j+1];
20 | array[j+1] = swap;
21 | }
22 | }
23 | }
24 | }
25 |
26 | /* GET home page. */
27 | router.get('/', function(req, res, next) {
28 | Blogs.fetch(function(err, blogs){
29 | if(err){
30 | console.log(err);
31 | } else {
32 | var blogsArray = [];
33 | if(blogs.length !== 0){
34 | for(var i = 0; i < blogs.length; i ++){
35 | Blogs.findOne({_id:blogs[i]._id.toString()})
36 | .populate('voter')
37 | .exec(function(err,doc){
38 | blogsArray.push(doc);
39 | if(blogsArray.length == blogs.length){
40 | req.session.blogs = blogsArray;
41 | renderPage();
42 | }
43 | });
44 | }
45 | } else {
46 | req.session.blogs = blogsArray;
47 | renderPage();
48 | }
49 |
50 | function renderPage(){
51 | Blogs.find({watcher:req.session.loggedIn},
52 | {title:1,comments:1},
53 | {skip:0,sort:{'date.allUpdateAt':-1}},
54 | function( err, articles ){
55 | //console.log(articles);
56 | if(err) {
57 | console.log(err);
58 | } else {
59 | Blogs.find({},
60 | function(err,docs){
61 | if(err) console.log(err);
62 | compare(docs);
63 | var docs5 = docs.slice(0,5);
64 | var art = articles.slice(0,5);
65 | var blogs10 = req.session.blogs.slice(0,10);
66 | var array = [];
67 | articles.forEach(function(ele){
68 | array.push(ele._id);
69 | });
70 | var ids = array.join(',');
71 | //console.log(ids);
72 | res.render('index', {blogs: blogs10,
73 | articles: art,
74 | docs: docs5,
75 | ids:ids});
76 | });
77 | }
78 | });
79 | }
80 |
81 | }
82 | });
83 | });
84 |
85 | module.exports = router;
86 |
--------------------------------------------------------------------------------
/public/stylesheets/bootstrap/less/pagination.less:
--------------------------------------------------------------------------------
1 | //
2 | // Pagination (multiple pages)
3 | // --------------------------------------------------
4 | .pagination {
5 | display: inline-block;
6 | padding-left: 0;
7 | margin: @line-height-computed 0;
8 | border-radius: @border-radius-base;
9 |
10 | > li {
11 | display: inline; // Remove list-style and block-level defaults
12 | > a,
13 | > span {
14 | position: relative;
15 | float: left; // Collapse white-space
16 | padding: @padding-base-vertical @padding-base-horizontal;
17 | line-height: @line-height-base;
18 | text-decoration: none;
19 | color: @pagination-color;
20 | background-color: @pagination-bg;
21 | border: 1px solid @pagination-border;
22 | margin-left: -1px;
23 | }
24 | &:first-child {
25 | > a,
26 | > span {
27 | margin-left: 0;
28 | .border-left-radius(@border-radius-base);
29 | }
30 | }
31 | &:last-child {
32 | > a,
33 | > span {
34 | .border-right-radius(@border-radius-base);
35 | }
36 | }
37 | }
38 |
39 | > li > a,
40 | > li > span {
41 | &:hover,
42 | &:focus {
43 | z-index: 3;
44 | color: @pagination-hover-color;
45 | background-color: @pagination-hover-bg;
46 | border-color: @pagination-hover-border;
47 | }
48 | }
49 |
50 | > .active > a,
51 | > .active > span {
52 | &,
53 | &:hover,
54 | &:focus {
55 | z-index: 2;
56 | color: @pagination-active-color;
57 | background-color: @pagination-active-bg;
58 | border-color: @pagination-active-border;
59 | cursor: default;
60 | }
61 | }
62 |
63 | > .disabled {
64 | > span,
65 | > span:hover,
66 | > span:focus,
67 | > a,
68 | > a:hover,
69 | > a:focus {
70 | color: @pagination-disabled-color;
71 | background-color: @pagination-disabled-bg;
72 | border-color: @pagination-disabled-border;
73 | cursor: @cursor-disabled;
74 | }
75 | }
76 | }
77 |
78 | // Sizing
79 | // --------------------------------------------------
80 |
81 | // Large
82 | .pagination-lg {
83 | .pagination-size(@padding-large-vertical; @padding-large-horizontal; @font-size-large; @line-height-large; @border-radius-large);
84 | }
85 |
86 | // Small
87 | .pagination-sm {
88 | .pagination-size(@padding-small-vertical; @padding-small-horizontal; @font-size-small; @line-height-small; @border-radius-small);
89 | }
90 |
--------------------------------------------------------------------------------
/public/stylesheets/bootstrap/less/print.less:
--------------------------------------------------------------------------------
1 | /*! Source: https://github.com/h5bp/html5-boilerplate/blob/master/src/css/main.css */
2 |
3 | // ==========================================================================
4 | // Print styles.
5 | // Inlined to avoid the additional HTTP request: h5bp.com/r
6 | // ==========================================================================
7 |
8 | @media print {
9 | *,
10 | *:before,
11 | *:after {
12 | background: transparent !important;
13 | color: #000 !important; // Black prints faster: h5bp.com/s
14 | box-shadow: none !important;
15 | text-shadow: none !important;
16 | }
17 |
18 | a,
19 | a:visited {
20 | text-decoration: underline;
21 | }
22 |
23 | a[href]:after {
24 | content: " (" attr(href) ")";
25 | }
26 |
27 | abbr[title]:after {
28 | content: " (" attr(title) ")";
29 | }
30 |
31 | // Don't show links that are fragment identifiers,
32 | // or use the `javascript:` pseudo protocol
33 | a[href^="#"]:after,
34 | a[href^="javascript:"]:after {
35 | content: "";
36 | }
37 |
38 | pre,
39 | blockquote {
40 | border: 1px solid #999;
41 | page-break-inside: avoid;
42 | }
43 |
44 | thead {
45 | display: table-header-group; // h5bp.com/t
46 | }
47 |
48 | tr,
49 | img {
50 | page-break-inside: avoid;
51 | }
52 |
53 | img {
54 | max-width: 100% !important;
55 | }
56 |
57 | p,
58 | h2,
59 | h3 {
60 | orphans: 3;
61 | widows: 3;
62 | }
63 |
64 | h2,
65 | h3 {
66 | page-break-after: avoid;
67 | }
68 |
69 | // Bootstrap specific changes start
70 |
71 | // Bootstrap components
72 | .navbar {
73 | display: none;
74 | }
75 | .btn,
76 | .dropup > .btn {
77 | > .caret {
78 | border-top-color: #000 !important;
79 | }
80 | }
81 | .label {
82 | border: 1px solid #000;
83 | }
84 |
85 | .table {
86 | border-collapse: collapse !important;
87 |
88 | td,
89 | th {
90 | background-color: #fff !important;
91 | }
92 | }
93 | .table-bordered {
94 | th,
95 | td {
96 | border: 1px solid #ddd !important;
97 | }
98 | }
99 |
100 | // Bootstrap specific changes end
101 | }
102 |
--------------------------------------------------------------------------------
/public/stylesheets/bootstrap/js/alert.js:
--------------------------------------------------------------------------------
1 | /* ========================================================================
2 | * Bootstrap: alert.js v3.3.5
3 | * http://getbootstrap.com/javascript/#alerts
4 | * ========================================================================
5 | * Copyright 2011-2015 Twitter, Inc.
6 | * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
7 | * ======================================================================== */
8 |
9 |
10 | +function ($) {
11 | 'use strict';
12 |
13 | // ALERT CLASS DEFINITION
14 | // ======================
15 |
16 | var dismiss = '[data-dismiss="alert"]'
17 | var Alert = function (el) {
18 | $(el).on('click', dismiss, this.close)
19 | }
20 |
21 | Alert.VERSION = '3.3.5'
22 |
23 | Alert.TRANSITION_DURATION = 150
24 |
25 | Alert.prototype.close = function (e) {
26 | var $this = $(this)
27 | var selector = $this.attr('data-target')
28 |
29 | if (!selector) {
30 | selector = $this.attr('href')
31 | selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') // strip for ie7
32 | }
33 |
34 | var $parent = $(selector)
35 |
36 | if (e) e.preventDefault()
37 |
38 | if (!$parent.length) {
39 | $parent = $this.closest('.alert')
40 | }
41 |
42 | $parent.trigger(e = $.Event('close.bs.alert'))
43 |
44 | if (e.isDefaultPrevented()) return
45 |
46 | $parent.removeClass('in')
47 |
48 | function removeElement() {
49 | // detach from parent, fire event then clean up data
50 | $parent.detach().trigger('closed.bs.alert').remove()
51 | }
52 |
53 | $.support.transition && $parent.hasClass('fade') ?
54 | $parent
55 | .one('bsTransitionEnd', removeElement)
56 | .emulateTransitionEnd(Alert.TRANSITION_DURATION) :
57 | removeElement()
58 | }
59 |
60 |
61 | // ALERT PLUGIN DEFINITION
62 | // =======================
63 |
64 | function Plugin(option) {
65 | return this.each(function () {
66 | var $this = $(this)
67 | var data = $this.data('bs.alert')
68 |
69 | if (!data) $this.data('bs.alert', (data = new Alert(this)))
70 | if (typeof option == 'string') data[option].call($this)
71 | })
72 | }
73 |
74 | var old = $.fn.alert
75 |
76 | $.fn.alert = Plugin
77 | $.fn.alert.Constructor = Alert
78 |
79 |
80 | // ALERT NO CONFLICT
81 | // =================
82 |
83 | $.fn.alert.noConflict = function () {
84 | $.fn.alert = old
85 | return this
86 | }
87 |
88 |
89 | // ALERT DATA-API
90 | // ==============
91 |
92 | $(document).on('click.bs.alert.data-api', dismiss, Alert.prototype.close)
93 |
94 | }(jQuery);
95 |
--------------------------------------------------------------------------------
/bae.js:
--------------------------------------------------------------------------------
1 |
2 | /**
3 | * 连接到mongodb
4 | * 使用mongoose而非mongodb中间件
5 | **/
6 | var mongoose = require('mongoose');
7 | var host,port,username,password,database,url;
8 |
9 | if (process.env.SERVER_SOFTWARE == 'bae/3.0') {
10 | host = 'mongo.duapp.com';
11 | username ="78b39e5c37054e82865b9d2bda504946",
12 | password ="d61d4f7285e44b7083000c287f65074f",
13 | database = 'PjglzFtxflHrqMcLpLuu';
14 | port = 8908;
15 | url ="mongodb://"+ username +":"+ password +"@"+ host +":"+ port +"/"+ database;
16 | } else {
17 | host = '127.0.0.1';
18 | database = 'blog';
19 | port = 12345;
20 | url = "mongodb://127.0.0.1:12345/blog";
21 | }
22 |
23 |
24 | var recon =true;
25 | function getConnect(){
26 | var opts ={
27 | db:{native_parser:true},
28 | server:{ poolSize:5, auto_reconnect:true },
29 | user: username,
30 | pass: password
31 | };
32 | // mongoose.connect("mongodb://HahMqSkZWUq9QWHsWceXmG83:XH82hOf5MGzoMUMUkCNj0KdBvecF3mzP@mongo.duapp.com:8908/pQPzvWlctdHpUjrbtFnX");//需要验证账户
33 | // mongoose.connect("mongodb://" + username + ":" + password +"@"+ host + ":" + port + "/" + dbName);//需要验证账户
34 | mongoose.connect(url, opts);
35 | var dbcon = mongoose.connection;
36 | // var dbcon = mongoose.createConnection(url, opts);
37 | dbcon.on('error',function(error){
38 | console.log('connection error');
39 | // throw new Error('disconnected,restart');
40 | dbcon.close();
41 | });
42 |
43 | //监听关闭事件并重连
44 | dbcon.on('disconnected',function(){
45 | console.log('disconnected');
46 | dbcon.close();
47 | });
48 | dbcon.on('open',function(){
49 | console.log('connection success open');
50 | recon =true;
51 | });
52 | dbcon.on('close',function(err){
53 | console.log('closed');
54 | // dbcon.open(host, dbName, port, opts, function() {
55 | // console.log('closed-opening');
56 | // });
57 | reConnect('*');
58 | });
59 | function reConnect(msg){
60 | console.log('reConnect'+msg);
61 | if(recon){
62 | console.log('reConnect-**');
63 | dbcon.open(host, database, port, opts,function(){
64 | console.log('closed-opening');
65 | });
66 | recon =false;
67 | console.log('reConnect-***');
68 | };
69 | console.log('reConnect-end');
70 | }
71 | }
72 |
73 | exports.getConnect = getConnect;//包含到module.exports对象中,
74 | // 如果module.exports中包含属性或方法则export.XX将被忽略
75 | // Module.exports才是真正的接口,exports只不过是它的一个辅助工具。
76 | // 最终返回给调用的是Module.exports而不是exports。
77 | // 所有的exports收集到的属性和方法,都赋值给了Module.exports。
78 | // 当然,这有个前提,就是Module.exports本身不具备任何属性和方法。
79 | // 如果,Module.exports已经具备一些属性和方法,那么exports收集来的信息将被忽略。
80 | //module.exports = getConnection;//直接导出这个对象
81 | exports.mongoose = mongoose;
--------------------------------------------------------------------------------
/public/javascripts/main.js:
--------------------------------------------------------------------------------
1 | window.onload = function(){
2 | var genArticle = document.getElementById('generate-article');
3 | var forClose = document.getElementById('blog-form-close');
4 | var postBlog = document.getElementById('post-blog');
5 | var body = document.getElementsByTagName('body');
6 |
7 | var hiddenBody = document.getElementById('hidden-body');
8 | var textarea = document.getElementById('editor');
9 |
10 | /*var writeComment = document.getElementsByClassName('write-comment');*/
11 | /*var showComments = document.getElementsByClassName('show-comments');
12 | var commentHeader = document.getElementsByClassName('comment-header');*/
13 |
14 | //console.log(showComments);
15 |
16 | genArticle.onclick = function(){
17 | postBlog.style.display = 'block';
18 | body[0].style.overflow = 'hidden';
19 | };
20 | forClose.onclick = function(){
21 | postBlog.style.display = 'none';
22 | body[0].style.overflow = 'auto';
23 | };
24 | textarea.onblur = function(){
25 | var _html = textarea.innerHTML;
26 | console.log(_html);
27 | hiddenBody.value = _html;
28 | };
29 | //以下进行了修改,一篇文章只能有一个id属性。
30 | /*for(var i = 0; i < writeComment.length; i++){
31 | //getLabel(writeComment[i]);
32 | writeComment[i].onfocus = function(){
33 | var commentWrapper = this.parentNode.getElementsByClassName('comment-wrapper');
34 | var closeComment = this.parentNode.getElementsByClassName('close-comment')[0];
35 | commentWrapper[0].style.display = 'block';
36 | closeComment.onclick = function(){
37 | commentWrapper[0].style.display = 'none';
38 | };
39 | };
40 | }*/
41 | /*for(var i = 0; i < showComments.length; i ++){
42 | showComments[i].onclick = function(){
43 | //console.log(showComments[i]);
44 | var getComments = this.parentNode.nextSibling;
45 | var commentCount = this.getElementsByClassName('comments-count')[0];
46 | var hiddenComments = this.getElementsByClassName('hidden-comments')[0];
47 | if(getComments.style.display == 'none'){
48 | getComments.style.display = 'block';
49 | commentCount.style.display = 'none';
50 | hiddenComments.style.display = 'inline-block';
51 | } else {
52 | getComments.style.display = 'none';
53 | commentCount.style.display = 'inline-block';
54 | hiddenComments.style.display = 'none';
55 | }
56 | };
57 | }*/
58 |
59 | /*for(var i = 0; i < commentHeader.length; i ++){
60 | commentHeader[i].getElementsByTagName('a')[0].onclick = function(){
61 | var inputBox = this.parentNode.parentNode.parentNode.parentNode.getElementsByClassName('textarea')[0];
62 | var replyTo = this.parentNode.getAttribute('comment-author');
63 | inputBox.focus();
64 | inputBox.setAttribute('reply-to', replyTo );
65 | //getLabel(inputBox);
66 | };
67 | }*/
68 | /*function getLabel(element){
69 | element.innerHTML = element.getAttribute('aria-label');
70 | }*/
71 |
72 | };
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
82 |
83 |
84 |
85 |
86 |
--------------------------------------------------------------------------------
/public/stylesheets/bootstrap/less/mixins/forms.less:
--------------------------------------------------------------------------------
1 | // Form validation states
2 | //
3 | // Used in forms.less to generate the form validation CSS for warnings, errors,
4 | // and successes.
5 |
6 | .form-control-validation(@text-color: #555; @border-color: #ccc; @background-color: #f5f5f5) {
7 | // Color the label and help text
8 | .help-block,
9 | .control-label,
10 | .radio,
11 | .checkbox,
12 | .radio-inline,
13 | .checkbox-inline,
14 | &.radio label,
15 | &.checkbox label,
16 | &.radio-inline label,
17 | &.checkbox-inline label {
18 | color: @text-color;
19 | }
20 | // Set the border and box shadow on specific inputs to match
21 | .form-control {
22 | border-color: @border-color;
23 | .box-shadow(inset 0 1px 1px rgba(0,0,0,.075)); // Redeclare so transitions work
24 | &:focus {
25 | border-color: darken(@border-color, 10%);
26 | @shadow: inset 0 1px 1px rgba(0,0,0,.075), 0 0 6px lighten(@border-color, 20%);
27 | .box-shadow(@shadow);
28 | }
29 | }
30 | // Set validation states also for addons
31 | .input-group-addon {
32 | color: @text-color;
33 | border-color: @border-color;
34 | background-color: @background-color;
35 | }
36 | // Optional feedback icon
37 | .form-control-feedback {
38 | color: @text-color;
39 | }
40 | }
41 |
42 |
43 | // Form control focus state
44 | //
45 | // Generate a customized focus state and for any input with the specified color,
46 | // which defaults to the `@input-border-focus` variable.
47 | //
48 | // We highly encourage you to not customize the default value, but instead use
49 | // this to tweak colors on an as-needed basis. This aesthetic change is based on
50 | // WebKit's default styles, but applicable to a wider range of browsers. Its
51 | // usability and accessibility should be taken into account with any change.
52 | //
53 | // Example usage: change the default blue border and shadow to white for better
54 | // contrast against a dark gray background.
55 | .form-control-focus(@color: @input-border-focus) {
56 | @color-rgba: rgba(red(@color), green(@color), blue(@color), .6);
57 | &:focus {
58 | border-color: @color;
59 | outline: 0;
60 | .box-shadow(~"inset 0 1px 1px rgba(0,0,0,.075), 0 0 8px @{color-rgba}");
61 | }
62 | }
63 |
64 | // Form control sizing
65 | //
66 | // Relative text size, padding, and border-radii changes for form controls. For
67 | // horizontal sizing, wrap controls in the predefined grid classes. `