Permalink
Browse files

JSHTML adds a lot of defaults.

  • Loading branch information...
1 parent 616ed5d commit 7a845c578a6ec928d91cc2a982cbb15a030d8b56 @Havvy committed Jan 4, 2013
Showing with 92 additions and 6 deletions.
  1. +35 −0 app.js
  2. +15 −2 lib/index.js
  3. +6 −4 package.json
  4. +8 −0 public/stylesheets/style.css
  5. +8 −0 routes/index.js
  6. +8 −0 routes/user.js
  7. 0 static/stylesheets/styles.css
  8. +2 −0 views/index.jshtml
  9. +10 −0 views/layout.jshtml
View
35 app.js
@@ -0,0 +1,35 @@
+
+/**
+ * Module dependencies.
+ */
+
+var express = require('express')
+ , routes = require('./routes')
+ , user = require('./routes/user')
+ , http = require('http')
+ , path = require('path');
+
+var app = express();
+
+app.configure(function(){
+ app.set('port', process.env.PORT || 3000);
+ app.set('views', __dirname + '/views');
+ app.set('view engine', 'jshtml');
+ app.use(express.favicon());
+ app.use(express.logger('dev'));
+ app.use(express.bodyParser());
+ app.use(express.methodOverride());
+ app.use(app.router);
+ app.use(express.static(path.join(__dirname, 'public')));
+});
+
+app.configure('development', function(){
+ app.use(express.errorHandler());
+});
+
+app.get('/', routes.index);
+app.get('/users', user.list);
+
+http.createServer(app).listen(app.get('port'), function(){
+ console.log("Express server listening on port " + app.get('port'));
+});
View
@@ -5,11 +5,24 @@ var app = new express();
// Defaults to Connects or Express's Favicon. Better than no favicon.
app.use(express.favicon());
-app.use(express.static(__dirname + "/../static/"));
+// Silly fix to 'static is a reserved word'.
+app.use(express['static'](__dirname + "/../static/"));
app.all("/", function (req, res) {
res.send("<!doctype html><html><body>TEST</body></html>");
});
-app.listen(3000);
+app.error(function (err, req, res, next){
+ if (err instanceof NotFound) {
+ res.render('404.jade');
+ } else {
+ next(err);
+ }
+});
+
+app.error(function (err, req, res, next) {
+ res.send(500);
+});
+
+app.listen(80);
console.log("Started!");
View
@@ -1,10 +1,12 @@
{
- "author" : "Havvy",
- "name": "mdWiki",
- "description": "Markdown wiki written using Node.js",
+ "name": "application-name",
"version": "0.0.1",
"private": true,
+ "scripts": {
+ "start": "node app"
+ },
"dependencies": {
- "express": "3.x"
+ "express": "3.0.5",
+ "jshtml": "*"
}
}
@@ -0,0 +1,8 @@
+body {
+ padding: 50px;
+ font: 14px "Lucida Grande", Helvetica, Arial, sans-serif;
+}
+
+a {
+ color: #00B7FF;
+}
View
@@ -0,0 +1,8 @@
+
+/*
+ * GET home page.
+ */
+
+exports.index = function(req, res){
+ res.render('index', { title: 'Express' });
+};
View
@@ -0,0 +1,8 @@
+
+/*
+ * GET users listing.
+ */
+
+exports.list = function(req, res){
+ res.send("respond with a resource");
+};
No changes.
View
@@ -0,0 +1,2 @@
+<h1>@write(title)</h1>
+<p>Welcome to @write(title)</p>
View
@@ -0,0 +1,10 @@
+<!DOCTYPE html>
+<html>
+ <head>
+ <title> @write(title) </title>
+ <link rel='stylesheet' href='/stylesheets/style.css' />
+ </head>
+ <body>
+ @write(body)
+ </body>
+</html>

0 comments on commit 7a845c5

Please sign in to comment.