Permalink
Browse files

Initial commit, woot!

  • Loading branch information...
0 parents commit bcef8f410b1d35fa47f1d0db3d504bb726767b86 @niczak committed Feb 29, 2012
Showing with 103 additions and 0 deletions.
  1. +1 −0 .gitignore
  2. +1 −0 README
  3. +52 −0 app.js
  4. +10 −0 package.json
  5. +8 −0 public/stylesheets/style.css
  6. +8 −0 routes/index.js
  7. +2 −0 views/_user.jade
  8. +4 −0 views/index.jade
  9. +6 −0 views/layout.jade
  10. +6 −0 views/links.jade
  11. +5 −0 views/users.jade
@@ -0,0 +1 @@
+node_modules
1 README
@@ -0,0 +1 @@
+A sample application with multiple routes and views build with Node.js, Express and Jade.
52 app.js
@@ -0,0 +1,52 @@
+
+/**
+ * Module dependencies.
+ */
+
+var express = require('express')
+ , routes = require('./routes');
+
+var app = module.exports = express.createServer();
+
+// Configuration
+
+app.configure(function(){
+ app.set('views', __dirname + '/views');
+ app.set('view engine', 'jade');
+ app.use(express.bodyParser());
+ app.use(express.methodOverride());
+ app.use(express.cookieParser());
+ app.use(express.session({ secret: 'your secret here' }));
+ app.use(app.router);
+ app.use(express.static(__dirname + '/public'));
+});
+
+app.configure('development', function(){
+ app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
+});
+
+app.configure('production', function(){
+ app.use(express.errorHandler());
+});
+
+// Fake user database
+var users = [
+ { name : "Nicholas Kreidberg", handle : "@niczak"},
+ { name : "Philip Carlson", handle : "@philipc"}
+];
+
+
+// Routes
+app.get('/', routes.index);
+//app.get('/users', routes.users);
+
+app.get('/users', function(req, res){
+ res.render('users', { users : users, title : "Elite Developers" });
+});
+
+app.get('/links', function(req, res){
+ res.render('links', { title : "Node Resources" });
+});
+
+app.listen(3000);
+console.log("Express server listening on port %d in %s mode", app.address().port, app.settings.env);
@@ -0,0 +1,10 @@
+{
+ "name": "application-name"
+ , "version": "0.0.1"
+ , "private": true
+ , "dependencies": {
+ "express": "2.5.8"
+ , "sass": ">= 0.0.1"
+ , "jade": ">= 0.0.1"
+ }
+}
@@ -0,0 +1,8 @@
+body {
+ padding: 50px;
+ font: 14px "Lucida Grande", Helvetica, Arial, sans-serif;
+}
+
+a {
+ color: #00B7FF;
+}
@@ -0,0 +1,8 @@
+
+/*
+ * GET home page.
+ */
+
+exports.index = function(req, res){
+ res.render('index', { title: "@niczak's Node/Express/Jade Example" })
+};
@@ -0,0 +1,2 @@
+ul#users
+li #{user.name} - <a href="http://twitter.com/#{user.handle}" target="_blank"> #{user.handle}</a>
@@ -0,0 +1,4 @@
+h1=title
+p Welcome to #{title}
+a(href="/users", title="l33t Developers") Elite Developers<br />
+a(href="/links", title="Node Links") Node Links<br />
@@ -0,0 +1,6 @@
+!!! 5
+html(lang="en")
+ head
+ title= title
+ link(rel='stylesheet', href='/stylesheets/style.css')
+ body!= body
@@ -0,0 +1,6 @@
+h1 Node References
+a(href="http://expressjs.com", title="Express", target="_blank") Express<br />
+a(href="http://jade-lang.com", title="Jade", target="_blank") Jade<br />
+a(href="http://nodejs.org", title="Node.js", target="_blank") Node.js<br />
+<br /><br />
+a(href="/", title="Home") Back To Home
@@ -0,0 +1,5 @@
+h1 Elite Developers
+ul#users
+ != partial('user', users)
+
+a(href="/", title="Home") Back To Home

0 comments on commit bcef8f4

Please sign in to comment.