-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
244 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
- Collaborative editing | ||
- Backed by node.js | ||
- Drag and drop layout/image uploading. Don't worry about how things are formatted. | ||
- Git integration. Tag commit messages with comment/item IDs. | ||
- Email integration. Email when someone comments on a comment, email reply threads are imported into the app. | ||
- Branch off new documents from existing ones, reference parent documents. | ||
- Comment on individual words/blocks of text, display these inband. | ||
- SQLite or file based nosql database | ||
- Quick zipping for backup/retiring documents. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
/*** | ||
* 如果开启了mongoDB,将下面代码注释去掉, | ||
* 并将dbUserName, dbPassword和dbName都 | ||
* 替换成分配得到的值。即可查看 mongoDB | ||
* 测试程序。否则则开启hello world程序。 | ||
***/ | ||
/* | ||
var mongo = require("mongoskin"); | ||
var db_url = exports.db_url = "dbUserName:[email protected]:20088/dbName"; | ||
exports.db = mongo.db(db_url); | ||
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// global config options | ||
function apply(app, express) { | ||
app.configure(function(){ | ||
app.use(express.static(__dirname + '/public')); | ||
}); | ||
require('./../config/environment/development.js').apply(app, express); | ||
require('./../config/environment/production.js').apply(app, express); | ||
}; | ||
exports.apply = apply; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// development environment | ||
function apply(app, express) { | ||
app.configure('development', function(){ | ||
app.use(express.errorHandler({ dumpExceptions: true, showStack: true })); | ||
}); | ||
}; | ||
exports.apply = apply; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
function apply(app, express){ | ||
}; | ||
exports.apply = apply; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
function apply(app, express) { | ||
|
||
// todo: build an mvc setup so that we can redirect routes to controllers | ||
|
||
app.get('/', function(request, response) { | ||
response.render('index.jade', { layout: false }); | ||
}); | ||
|
||
// simple catch all, right now just look for a template with the name | ||
app.get('/:template', function(request, response) { | ||
response.render(request.params.template + '.jade', { layout: false }); | ||
}); | ||
|
||
/* | ||
app.get('/:controller/:action/:id', function(request, response) { | ||
// find some way to dispatch to a controller | ||
}); | ||
*/ | ||
|
||
}; | ||
exports.apply = apply; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
var http = require('http'); | ||
var url = require("url"); | ||
var logs = new Array(); | ||
//中文支持可以吗 | ||
http.createServer(function (req, res) { | ||
res.writeHead(200, {'Content-Type': 'text/plain'}); | ||
var uri = url.parse(req.url).pathname; | ||
var query = url.parse(req.url, true).query || {}; | ||
if(uri == "/") { | ||
res.end("yes,it is me,thanks. good"); | ||
} | ||
else if (uri=="/put"){ | ||
var user= query.u; | ||
if(logs.indexOf(user)<0 && user!="") //if user not exists | ||
logs.push(user); | ||
res.write("var visit_users = "+JSON.stringify(logs)+";"); | ||
res.end(); | ||
} | ||
}).listen(80, "127.0.0.1"); | ||
console.log('Server running at http://127.0.0.1/'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"name" : "visitonce", | ||
"main" : "server.js" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
devlog | ||
====== | ||
|
||
devlog is a living design and development log. | ||
|
||
Based off of the following blog post: | ||
http://www.lostgarden.com/2011/05/game-design-logs.html | ||
|
||
requirements | ||
------------ | ||
|
||
node.js | ||
express | ||
jade | ||
|
||
installing | ||
---------- | ||
|
||
- Install node.js on your server | ||
- Install npm | ||
- npm install express | ||
- npm install jade | ||
|
||
Note: later, will try to build some sort of package manager |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
var express =require('express'), | ||
app = express.createServer(); | ||
|
||
// bootstrap routing | ||
require('./../config/routes').apply(app, express); | ||
|
||
// bootstrap settings | ||
require('./../config/environment').apply(app, express); | ||
|
||
// start server - hardocded port for now | ||
app.listen(80) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
var http = require('http'); | ||
var url = require("url"); | ||
var visitors = require("./visitors"); | ||
var logs = new Array(); | ||
http.createServer(function (req, res) { | ||
res.writeHead(200, {'Content-Type': 'text/plain'}); | ||
var uri = url.parse(req.url).pathname; | ||
var query = url.parse(req.url, true).query || {}; | ||
if(uri == "/") { | ||
res.end("yes,it is me, kongwu site"); | ||
} | ||
else if (uri=="/put"){ | ||
var user= query.u; | ||
var msg = query.msg; | ||
var thisurl = query.url; | ||
if(logs.indexOf(user)<0 && user!="") //if user not exists | ||
logs.push(user); | ||
var list_func = function(){ | ||
visitors.getList(thisurl,function(data){ | ||
res.writeHead(200, {'Content-Type': 'application/json;charset=gbk'}); | ||
res.write("var visit_users = "+JSON.stringify(data)+";"); | ||
res.end(); | ||
}); | ||
} | ||
if(user!="" && thisurl!="" && msg!=null && msg.length<50) | ||
visitors.findUser(user,thisurl,msg,list_func); | ||
else | ||
list_func(); | ||
} | ||
}).listen(80, "127.0.0.1"); | ||
console.log('Server running at http://127.0.0.1/'); | ||
//visitors.list(); | ||
//just for test | ||
//visitors.getList(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
p bar! |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
h1 HELLO WORLD! | ||
h2 just a test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
var mongoose = require('mongoose'), | ||
//db = mongoose.connect('mongodb://localhost/kongwu'); | ||
db = mongoose.connect('mongodb://7w2oigjkbkmah:[email protected]:20088/94lg0rk0awkmo'); | ||
var Schema = mongoose.Schema; | ||
var events = require("events"); | ||
Visitors = new Schema({ | ||
id : {type:Number,index: true, default: 1}, | ||
username : {type:String,index: true}, | ||
url : {type:String,index: true}, | ||
visit_time : { type: Date, default: Date.now }, | ||
visit_count: { type:Number,default: 1}, | ||
msg: {type:String} | ||
}).method('update', function(){ | ||
this.visit_count += 1; | ||
this.visit_time = new Date(); | ||
return this.visit_count; | ||
}); | ||
var Visitor = mongoose.model('Visitors', Visitors); | ||
//var username = "kongwu"; | ||
exports.findUser = function(username,url,msg,callback) {Visitor.findOne({"username":username,"url":url},function(err,visit) { | ||
if(visit){ //exists | ||
console.log("duplicated:"+username); | ||
visit.update(); | ||
} | ||
else { | ||
var visit = new Visitor(); | ||
visit.username = username; | ||
visit.url = url; | ||
console.log("new user:"+username); | ||
} | ||
if(msg!="") | ||
visit.msg = msg; | ||
visit.save(function(err) { | ||
if(!err) console.log("save sucess:"+username); | ||
else console.log(err); | ||
callback(); | ||
}); | ||
}); | ||
}; | ||
exports.list = function(){Visitor.find({},function(err,records) { | ||
if(!err) { | ||
records.forEach(function(record) { | ||
//console.log('username='+record.username+",visit_count="+record.visit_count+",last_time="+record.visit_time.toString()); | ||
//record.remove(); | ||
|
||
}); | ||
} | ||
})}; | ||
//self.prototype = new events.EventEmitter; | ||
exports.getList = function(url,cb){ | ||
var logs = new Array(); | ||
//test-url: http://kongwu.cnodejs.net/put?u=cnsnoopy&msg=&url=trade.taobao.com%2F%2Ftrade%2Fitemlist%2Flist_bought_items.htm | ||
//Visitor.find({"url":url}).sort({visit_count:1},function(err,records) { | ||
//Visitor.find({"url":url}).sort([['last', 'descending']]).all(function (err, records) { | ||
Visitor.find({url:url, msg:{ $ne : null }}, ['username','visit_count','visit_time','msg'], // Columns to Return | ||
{ | ||
skip:0, // Starting Row | ||
limit:10, // Ending Row | ||
sort:{ | ||
visit_time: -1 //Sort by Date Added DESC | ||
} | ||
},function (err, records) { | ||
//Visitor.find({"url":url},function(err,records) { | ||
if(!err) { | ||
records.forEach(function(record) { | ||
//console.log('username='+record.username+",visit_count="+record.visit_count+",last_time="+record.visit_time.toString()); | ||
if(record.msg!="" && record.msg!=null && typeof(record.msg)!="undefined") | ||
logs.push({"username":record.username,"cnt":record.visit_count,"last":record.visit_time.toString(),"msg":record.msg}); | ||
|
||
}); | ||
//console.log(logs); | ||
} | ||
else | ||
console.log("error in getList 2"); | ||
cb(logs); | ||
//res.write("ver visit_users = "+JSON.stringify(logs)+";"); | ||
//res.end(); | ||
}); | ||
}; | ||
//exports.users = logs; | ||
console.log("db"); | ||
//db.connection.close(); |