Skip to content
Permalink
Browse files

Part 1

  • Loading branch information...
Alex Young
Alex Young committed Nov 8, 2010
0 parents commit 904d3a184ff4932410601ad1a44ad759663acdc0
Showing with 120 additions and 0 deletions.
  1. +4 −0 .gitignore
  2. +30 −0 README.textile
  3. +35 −0 app.js
  4. +14 −0 models.js
  5. +4 −0 public/stylesheets/style.css
  6. +4 −0 public/stylesheets/style.less
  7. +21 −0 test/app.test.js
  8. +2 −0 views/index.jade
  9. +6 −0 views/layout.jade
@@ -0,0 +1,4 @@
*.sw?
.DS_Store
tmp/*
log/*
@@ -0,0 +1,30 @@
h3. Nodepad

This is a Node notepad, written for a tutorial series on "DailyJS":http://dailyjs.com.

h3. Dependencies

* "Node":http://nodejs.org/
* "MongoDB":http://www.mongodb.org/
* "Mongoose":https://github.com/LearnBoost/mongoose
* "Express":http://expressjs.com/
* "Expresso":http://visionmedia.github.com/expresso/
* "Jade":http://jade-lang.com/
* "less":https://github.com/cloudhead/less.js

h3. License (GPL)

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see "http://www.gnu.org/licenses/":http://www.gnu.org/licenses/.


35 app.js
@@ -0,0 +1,35 @@
var express = require('express'),
app = module.exports = express.createServer(),
mongoose = require('mongoose').Mongoose,
db = mongoose.connect('mongodb://localhost/nodepad'),
Document = require('./models.js').Document(db);

app.configure(function() {
app.set('views', __dirname + '/views');
app.use(express.bodyDecoder());
app.use(express.methodOverride());
app.use(express.compiler({ src: __dirname + '/public', enable: ['less'] }));
app.use(app.router);
app.use(express.staticProvider(__dirname + '/public'));
});

app.configure('development', function() {
app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
});

app.configure('production', function() {
app.use(express.errorHandler());
});

app.get('/', function(req, res) {
res.render('index.jade', {
locals: {
title: 'Express'
}
});
});

if (!module.parent) {
app.listen(3000);
console.log("Express server listening on port %d, environment: %s", app.address().port, app.settings.env)
}
@@ -0,0 +1,14 @@
var mongoose = require('mongoose').Mongoose;

mongoose.model('Document', {
properties: ['title', 'data', 'tags'],

indexes: [
'title'
]
});

exports.Document = function(db) {
return db.model('Document');
};

@@ -0,0 +1,4 @@
body {
padding: 50px;
font: 14px "Lucida Grande", "Helvetica Nueue", Arial, sans-serif;
}
@@ -0,0 +1,4 @@
body {
padding: 50px;
font: 14px "Lucida Grande", "Helvetica Nueue", Arial, sans-serif;
}
@@ -0,0 +1,21 @@

// Run $ expresso

/**
* Module dependencies.
*/

var app = require('../app');

module.exports = {
'GET /': function(assert) {
assert.response(app,
{ url: '/' },
{ status: 200, headers: { 'Content-Type': 'text/html; charset=utf-8' }},
function(res) {
assert.includes(res.body, '<title>Express</title>');
process.exit();
});
}
};

@@ -0,0 +1,2 @@
h1= title
p Welcome to #{title}
@@ -0,0 +1,6 @@
!!!
html
head
title= title
link(rel='stylesheet', href='/stylesheets/style.css')
body!= body

2 comments on commit 904d3a1

@andruhazp

This comment has been minimized.

Copy link

replied May 15, 2015

лгоро

@andruhazp

This comment has been minimized.

Copy link

replied May 15, 2015

ропол

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