Last active
March 6, 2017 06:39
Revisions
-
jurebajt renamed this gist
Mar 6, 2017 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
jurebajt revised this gist
Mar 27, 2014 . 1 changed file with 3 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -56,7 +56,7 @@ Start Express server. nodemon app.js ``` Additional: remove route definitions from app.js by changing app.js to this ... ``` /** * Module dependencies. @@ -92,7 +92,7 @@ http.createServer(app).listen(app.get('port'), function() { }); ``` ... and routes/index.js to this ... ``` app = require('../app'); @@ -103,7 +103,7 @@ app.get('/', function(req, res) { require('./user'); ``` ... and routes/user.js to this. ``` app.get('/user', function(req, res) { res.render('index', { title: 'User page' }); -
jurebajt created this gist
Mar 27, 2014 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,111 @@ # Create node.js app with Express web aplication framework + Hogan and Compass Install express and nodemon. ``` sudo npm install -g express sudo npm install -g nodemon ``` Create express project. ``` express MyProject --hogan cd MyProject npm install ``` Init compass project ``` compass init ``` Change config.rb to this. ``` # Require any additional compass plugins here. # Set this to the root of your project when deployed: http_path = "/" css_dir = "public/stylesheets" sass_dir = "sass" images_dir = "public/images" javascripts_dir = "public/javascripts" # You can select your preferred output style here (can be overridden via the command line): output_style = :expanded # :expanded or :nested or :compact or :compressed # To enable relative paths to assets via compass helper functions. Uncomment: # relative_assets = true # To disable debugging comments that display the original location of your selectors. Uncomment: # line_comments = false # If you prefer the indented syntax, you might want to regenerate this # project again passing --syntax sass, or you can uncomment this: # preferred_syntax = :sass # and then run: # sass-convert -R --from scss --to sass sass scss && rm -rf sass && mv scss sass ``` Start compass. ``` compass watch ``` Start Express server. ``` nodemon app.js ``` Additional: remove route definitions from app.js by changing app.js to this ``` /** * Module dependencies. */ var express = require('express'); var http = require('http'); var path = require('path'); var app = module.exports = express(); // all environments app.set('port', process.env.PORT || 3000); app.set('views', path.join(__dirname, 'views')); app.set('view engine', 'hjs'); app.use(express.favicon()); app.use(express.logger('dev')); app.use(express.json()); app.use(express.urlencoded()); app.use(express.methodOverride()); app.use(app.router); app.use(express.static(path.join(__dirname, 'public'))); // development only if ('development' == app.get('env')) { app.use(express.errorHandler()); } var routes = require('./routes'); http.createServer(app).listen(app.get('port'), function() { console.log('Express server listening on port ' + app.get('port')); }); ``` ... and routes/index.js to this ``` app = require('../app'); app.get('/', function(req, res) { res.render('index', { title: 'Express' }); }); require('./user'); ``` ... and routes/user.js to this ``` app.get('/user', function(req, res) { res.render('index', { title: 'User page' }); }); ```