Skip to content

Commit 5774fab

Browse files
committed
Init commit. Home page and header ready
0 parents  commit 5774fab

26 files changed

+12620
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
*~
2+
node_modules/

app.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/**
2+
* Module dependencies.
3+
*/
4+
5+
var express = require('express')
6+
, mongoose = require('mongoose')
7+
, http = require('http');
8+
9+
var app = express();
10+
11+
app.configure(function(){
12+
app.set('port', process.env.PORT || 3000);
13+
app.use(express.favicon());
14+
app.use(express.logger('dev'));
15+
app.use(express.bodyParser());
16+
app.use(express.methodOverride());
17+
app.use(app.router);
18+
app.use(express.static(__dirname + '/public'));
19+
});
20+
21+
app.configure('development', function(){
22+
app.use(express.errorHandler());
23+
});
24+
25+
// config routers
26+
['post'].forEach(function (route) {
27+
require('./routes/' + route)(app);
28+
});
29+
30+
http.createServer(app).listen(app.get('port'), function(){
31+
console.log("Express server listening on port " + app.get('port'));
32+
});

config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
exports = {
2+
API: '/api/v1'
3+
};

config/db.json

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
{
2+
"test": {
3+
"main" : {
4+
"USER" : "",
5+
"PASS" : "",
6+
"HOST" : "localhost",
7+
"PORT" : "27017",
8+
"DATABASE" : "clients-test"
9+
}
10+
},
11+
"development": {
12+
"main" : {
13+
"USER" : "",
14+
"PASS" : "",
15+
"HOST" : "localhost",
16+
"PORT" : "27017",
17+
"DATABASE" : "clients-dev"
18+
}
19+
},
20+
"production": {
21+
"main" : {
22+
"USER" : "",
23+
"PASS" : "",
24+
"HOST" : "localhost",
25+
"PORT" : "27017",
26+
"DATABASE" : "clients-main"
27+
}
28+
}
29+
}

config/environments/development.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"HTTPS" : false,
3+
"HOST" : "127.0.0.1",
4+
"PORT" : 3000
5+
}

config/environments/production.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"HTTPS" : false,
3+
"HOST" : "127.0.0.1",
4+
"REQ_TIMEOUT" : 60000,
5+
"PORT" : 3000
6+
}

config/environments/test.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"HTTPS" : false,
3+
"HOST" : "127.0.0.1",
4+
"PORT" : 3000
5+
}

config/error_messages.json

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"NAME" : "Name field is invalid, please enter a name with a length of 2-100 chars.",
3+
"EMAIL" : "Email address is invalid.",
4+
"BORN" : "Birth date is invalid, please check the date format and make sure the age is above 18.",
5+
"COMPANY" : "Company field is invalid, please enter a company name with a length of 5-100 chars.",
6+
"DUPLICATE" : "Email address already exists, please choose a different one."
7+
}

models/post.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
var mongoose = require('mongoose')
2+
, PostSchema = require('./schemas').PostSchema
3+
, PostModel = mongoose.model('Post', PostSchema);
4+
5+
module.exports = PostModel;

models/schemas.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
var mongoose = require('mongoose')
2+
, Schema = mongoose.Schema
3+
, ObjectId = Schema.ObjectId;
4+
5+
var PostSchema = new Schema({
6+
title: String
7+
, author: String
8+
, body: String
9+
, creataAt: {
10+
type: Date
11+
, default: Date.now
12+
}
13+
});
14+
15+
module.exports.PostSchema = PostSchema;

package.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"name": "application-name"
3+
, "version": "0.0.1"
4+
, "private": true
5+
, "scripts": {
6+
"start": "node app"
7+
}
8+
, "dependencies": {
9+
"express": "3.0.0beta4"
10+
, "mongoose": "*"
11+
, "underscore": "*"
12+
}
13+
}

public/index.html

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<!DOCTYPE HTML>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Node-Backbone Sample Blog</title>
6+
7+
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
8+
<!--[if lt IE 9]>
9+
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
10+
<![endif]-->
11+
12+
<!-- Le styles -->
13+
<link rel="stylesheet" href="/stylesheets/style.css" />
14+
</head>
15+
<body>
16+
17+
<header>
18+
</header>
19+
20+
<div class="container">
21+
22+
<section class="page-content"></section>
23+
24+
</div> <!-- /container -->
25+
26+
<footer>
27+
</footer>
28+
29+
<!-- Le javascript
30+
================================================== -->
31+
<!-- Placed at the end of the document so the pages load faster -->
32+
<script data-main="/javascripts/main" src="/javascripts/lib/require.min.js"></script>
33+
34+
</body>
35+
</html>

public/javascripts/app.js

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
define('app', [
2+
'jquery'
3+
, 'underscore'
4+
, 'backbone'
5+
, 'router'
6+
], function ($, _, backbone, router) {
7+
var initialize = function () {
8+
var app = new router();
9+
backbone.history.start();
10+
}
11+
12+
// TODO: error handling with window.onerror
13+
// http://www.slideshare.net/nzakas/enterprise-javascript-error-handling-presentation
14+
15+
return {
16+
initialize: initialize
17+
};
18+
});

0 commit comments

Comments
 (0)