Skip to content
Permalink
Browse files

寒假在网吧写了雏形,接下来慢慢填坑

  • Loading branch information...
shuiRong committed Feb 13, 2017
0 parents commit ea09358e25971d6694914d62a8fcac1e755eadf1
Showing with 20,493 additions and 0 deletions.
  1. +1 −0 .gitignore
  2. +80 −0 app.js
  3. +25 −0 bin/npm-debug.log
  4. +90 −0 bin/www
  5. +17 −0 database/conn.js
  6. +76 −0 database/test.js
  7. +2,337 −0 font-awesome-4.7.0/css/font-awesome.css
  8. +4 −0 font-awesome-4.7.0/css/font-awesome.min.css
  9. 0 font-awesome-4.7.0/fonts/fontawesome-webfont.eot
  10. +20 −0 package.json
  11. BIN public/images/lana.jpg
  12. BIN public/images/peo.jpg
  13. +19 −0 public/javascripts/content-grid.js
  14. 0 public/javascripts/homePage.js
  15. +4 −0 public/javascripts/jquery-3.1.1.min.js
  16. +4 −0 public/javascripts/jquery.min.js
  17. +45 −0 public/javascripts/main.js
  18. +9 −0 public/javascripts/test.js
  19. +8,568 −0 public/javascripts/vue.js
  20. +13 −0 public/json/index.json
  21. +40 −0 public/stylesheets/content-grid.css
  22. +27 −0 public/stylesheets/content.css
  23. +7 −0 public/stylesheets/font-awesome-4.7.0/HELP-US-OUT.txt
  24. +2,337 −0 public/stylesheets/font-awesome-4.7.0/css/font-awesome.css
  25. +4 −0 public/stylesheets/font-awesome-4.7.0/css/font-awesome.min.css
  26. BIN public/stylesheets/font-awesome-4.7.0/fonts/FontAwesome.otf
  27. BIN public/stylesheets/font-awesome-4.7.0/fonts/fontawesome-webfont.eot
  28. +2,671 −0 public/stylesheets/font-awesome-4.7.0/fonts/fontawesome-webfont.svg
  29. BIN public/stylesheets/font-awesome-4.7.0/fonts/fontawesome-webfont.ttf
  30. BIN public/stylesheets/font-awesome-4.7.0/fonts/fontawesome-webfont.woff
  31. BIN public/stylesheets/font-awesome-4.7.0/fonts/fontawesome-webfont.woff2
  32. +34 −0 public/stylesheets/font-awesome-4.7.0/less/animated.less
  33. +25 −0 public/stylesheets/font-awesome-4.7.0/less/bordered-pulled.less
  34. +12 −0 public/stylesheets/font-awesome-4.7.0/less/core.less
  35. +6 −0 public/stylesheets/font-awesome-4.7.0/less/fixed-width.less
  36. +18 −0 public/stylesheets/font-awesome-4.7.0/less/font-awesome.less
  37. +789 −0 public/stylesheets/font-awesome-4.7.0/less/icons.less
  38. +13 −0 public/stylesheets/font-awesome-4.7.0/less/larger.less
  39. +19 −0 public/stylesheets/font-awesome-4.7.0/less/list.less
  40. +60 −0 public/stylesheets/font-awesome-4.7.0/less/mixins.less
  41. +15 −0 public/stylesheets/font-awesome-4.7.0/less/path.less
  42. +20 −0 public/stylesheets/font-awesome-4.7.0/less/rotated-flipped.less
  43. +5 −0 public/stylesheets/font-awesome-4.7.0/less/screen-reader.less
  44. +20 −0 public/stylesheets/font-awesome-4.7.0/less/stacked.less
  45. +800 −0 public/stylesheets/font-awesome-4.7.0/less/variables.less
  46. +34 −0 public/stylesheets/font-awesome-4.7.0/scss/_animated.scss
  47. +25 −0 public/stylesheets/font-awesome-4.7.0/scss/_bordered-pulled.scss
  48. +12 −0 public/stylesheets/font-awesome-4.7.0/scss/_core.scss
  49. +6 −0 public/stylesheets/font-awesome-4.7.0/scss/_fixed-width.scss
  50. +789 −0 public/stylesheets/font-awesome-4.7.0/scss/_icons.scss
  51. +13 −0 public/stylesheets/font-awesome-4.7.0/scss/_larger.scss
  52. +19 −0 public/stylesheets/font-awesome-4.7.0/scss/_list.scss
  53. +60 −0 public/stylesheets/font-awesome-4.7.0/scss/_mixins.scss
  54. +15 −0 public/stylesheets/font-awesome-4.7.0/scss/_path.scss
  55. +20 −0 public/stylesheets/font-awesome-4.7.0/scss/_rotated-flipped.scss
  56. +5 −0 public/stylesheets/font-awesome-4.7.0/scss/_screen-reader.scss
  57. +20 −0 public/stylesheets/font-awesome-4.7.0/scss/_stacked.scss
  58. +800 −0 public/stylesheets/font-awesome-4.7.0/scss/_variables.scss
  59. +18 −0 public/stylesheets/font-awesome-4.7.0/scss/font-awesome.scss
  60. +62 −0 public/stylesheets/header.css
  61. +12 −0 public/stylesheets/main.css
  62. +94 −0 public/stylesheets/new-debate-dialog.css
  63. +30 −0 public/stylesheets/profile.css
  64. +15 −0 routes/index-api.js
  65. +108 −0 routes/index.js
  66. +15 −0 routes/users.js
  67. +3 −0 test2.js
  68. +6 −0 views/error.pug
  69. +6 −0 views/includes/header.pug
  70. +11 −0 views/includes/newDebateDialog.pug
  71. +25 −0 views/index.pug
  72. +19 −0 views/layout.pug
  73. +10 −0 views/profile.pug
  74. +7 −0 views/question/123.pug
@@ -0,0 +1 @@
node_modules/
80 app.js
@@ -0,0 +1,80 @@
var express = require('express');
var path = require('path');
var favicon = require('serve-favicon');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
/*----------------------------------------------------------------------------*/
/*var MongoClient = require('mongodb').MongoClient;
var assert = require('assert');*/
/*----------------------------------------------------------------------------*/

var index = require('./routes/index');
var users = require('./routes/users');
var indexApi = require('./routes/index-api');

var app = express();

// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'pug');

// uncomment after placing your favicon in /public
//app.use(favicon(path.join(__dirname, 'public', 'favicon.ico')));
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());

app.use(express.static(path.join(__dirname,('public'))));
app.use(express.static(path.join(__dirname,('routes'))));

app.use('/', index);
app.use('/users', users);
app.use('/api',indexApi);

// catch 404 and forward to error handler
app.use(function(req, res, next) {
var err = new Error('Not Found');
err.status = 404;
next(err);
});

// error handler
app.use(function(err, req, res, next) {
// set locals, only providing error in development
res.locals.message = err.message;
res.locals.error = req.app.get('env') === 'development' ? err : {};

// render the error page
res.status(err.status || 500);
res.render('error');
});

/*----------------------------------------------------------------------------*/

/*MongoClient.connect('mongodb://127.0.0.1:27017/test2',function(err,db){
/*assert.equal(null,err);*/
/* if(err){
throw err;
}
console.log('Connected successfully---------------');
insertDoc(db,function(){
db.close();
})
*/
/*db.collection('restaurants').find({'grades.score':{$gt:95}}).toArray(function(err,result){
if(err){
throw err;
}
console.log(result);
})*/
//})

//function insertDoc()


/*----------------------------------------------------------------------------*/

module.exports = app;
@@ -0,0 +1,25 @@
0 info it worked if it ends with ok
1 verbose cli [ 'E:\\nodejs\\node.exe',
1 verbose cli 'C:\\Users\\windows\\AppData\\Roaming\\npm\\node_modules\\cnpm\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli '--userconfig=C:\\Users\\windows\\.cnpmrc',
1 verbose cli '--disturl=https://npm.taobao.org/mirrors/node',
1 verbose cli '--registry=https://registry.npm.taobao.org',
1 verbose cli 'start' ]
2 info using npm@3.10.10
3 info using node@v6.9.4
4 verbose stack Error: ENOENT: no such file or directory, open 'E:\code\myapp1\bin\package.json'
4 verbose stack at Error (native)
5 verbose cwd E:\code\myapp1\bin
6 error Windows_NT 6.1.7601
7 error argv "E:\\nodejs\\node.exe" "C:\\Users\\windows\\AppData\\Roaming\\npm\\node_modules\\cnpm\\node_modules\\npm\\bin\\npm-cli.js" "--userconfig=C:\\Users\\windows\\.cnpmrc" "--disturl=https://npm.taobao.org/mirrors/node" "--registry=https://registry.npm.taobao.org" "start"
8 error node v6.9.4
9 error npm v3.10.10
10 error path E:\code\myapp1\bin\package.json
11 error code ENOENT
12 error errno -4058
13 error syscall open
14 error enoent ENOENT: no such file or directory, open 'E:\code\myapp1\bin\package.json'
15 error enoent ENOENT: no such file or directory, open 'E:\code\myapp1\bin\package.json'
15 error enoent This is most likely not a problem with npm itself
15 error enoent and is related to npm not being able to find a file.
16 verbose exit [ -4058, true ]
90 bin/www
@@ -0,0 +1,90 @@
#!/usr/bin/env node

/**
* Module dependencies.
*/

var app = require('../app');
var debug = require('debug')('myapp1:server');
var http = require('http');

/**
* Get port from environment and store in Express.
*/

var port = normalizePort(process.env.PORT || '3000');
app.set('port', port);

/**
* Create HTTP server.
*/

var server = http.createServer(app);

/**
* Listen on provided port, on all network interfaces.
*/

server.listen(port);
server.on('error', onError);
server.on('listening', onListening);

/**
* Normalize a port into a number, string, or false.
*/

function normalizePort(val) {
var port = parseInt(val, 10);

if (isNaN(port)) {
// named pipe
return val;
}

if (port >= 0) {
// port number
return port;
}

return false;
}

/**
* Event listener for HTTP server "error" event.
*/

function onError(error) {
if (error.syscall !== 'listen') {
throw error;
}

var bind = typeof port === 'string'
? 'Pipe ' + port
: 'Port ' + port;

// handle specific listen errors with friendly messages
switch (error.code) {
case 'EACCES':
console.error(bind + ' requires elevated privileges');
process.exit(1);
break;
case 'EADDRINUSE':
console.error(bind + ' is already in use');
process.exit(1);
break;
default:
throw error;
}
}

/**
* Event listener for HTTP server "listening" event.
*/

function onListening() {
var addr = server.address();
var bind = typeof addr === 'string'
? 'pipe ' + addr
: 'port ' + addr.port;
debug('Listening on ' + bind);
}
@@ -0,0 +1,17 @@
var MongoClient = require('mongodb').MongoClient;

MongoClient.connect('mongodb://127.0.0.1:27017/test',function(err,db){
if(err){
throw err;
}

db.collection('restaurants').find({'grades.score':{$gt:95}}).toArray(function(err,result){
if(err){
throw err;
}

console.log(result);
})
})

module.exports = MongoClient;
@@ -0,0 +1,76 @@
var mongodb = require('mongodb');
var server = new mongodb.Server('localhost',27017,{auto_reconnect:true});
var db = new mongodb.Db('local',server);
/*
db.open(function(err,db){
if(!err){
console.log('connect db --ing');
db.collection('content',function(err,collection){
if(err){
console.log(err);
}else{
var temp1 = {id:'1',title:'hello',number:1};
var temp2 = {id:'2',title:'world',number:2};
collection.insert([temp1,temp2],function(err,result){
if(err){
throw err;
}
console.log('result----------------');
console.log(result);
console.log('++++++++++++++++++++++');
});
collection.find().toArray(function(err,docs){
if(err){
throw err;
}
console.log('find---------------');
console.log(docs);
console.log('++++++++++++++++++++++');
});
collection.update({title:'hello'}, {$set:{number:5}},{multi:true},function(err,result){
});
collection.find().toArray(function(err,docs){
if(err){
throw err;
}
console.log('find2--------------');
console.log(docs);
console.log('++++++++++++++++++++++');
});
}
});
}else{
console.log(err);
}
})
*/

function insertFunc(jsonData){
db.open(function(err,db){
if(!err){
console.log('connectting database !');
db.collection('content',function(err,collection){
if(err){
console.log(err);
}else{
collection.insert(jsonData,function(err,result){
if(err){
throw err;
}
console.log('insert jsonData into collection! DONE!');
});
}
})
}else{
console.log(err);
}
})
}

module.exports = insertFunc;

0 comments on commit ea09358

Please sign in to comment.
You can’t perform that action at this time.