Permalink
Browse files

upgraded to node 8

  • Loading branch information...
1 parent e59fc79 commit bca62ebf687f20f12a75e59300b64664527250e1 @twilson63 committed Aug 5, 2012
View
@@ -1,12 +1,13 @@
fs = require 'fs'
{print} = require 'util'
{spawn, exec} = require 'child_process'
+which = require 'which'
# ANSI Terminal Colors
-bold = '\033[0;1m'
-green = '\033[0;32m'
-reset = '\033[0m'
-red = '\033[0;31m'
+bold = '\x1B[0;1m'
+red = '\x1B[0;31m'
+green = '\x1B[0;32m'
+reset = '\x1B[0m'
log = (message, color, explanation) ->
console.log color + message + reset + ' ' + (explanation or '')
@@ -15,7 +16,7 @@ build = (watch, callback) ->
if typeof watch is 'function'
callback = watch
watch = false
- options = ['-c', '-b', '-o', '.', 'src']
+ options = ['-c', '-b', '-o', 'app', 'src']
options.unshift '-w' if watch
coffee = spawn 'coffee', options
@@ -25,4 +26,17 @@ build = (watch, callback) ->
task 'build', -> build -> log ":)", green
-task 'watch', -> build true, -> log ":)", green
+task 'dev', 'start dev env', ->
+ # watch_coffee
+ options = ['-c', '-b', '-w', '-o', 'app', 'src']
+ cmd = which.sync 'coffee'
+ coffee = spawn cmd, options
+ coffee.stdout.pipe process.stdout
+ coffee.stderr.pipe process.stderr
+ log 'Watching coffee files', green
+ # watch_js
+ supervisor = spawn 'node', ['./node_modules/supervisor/lib/cli-wrapper.js','-w','app,views', '-e', 'js|jade', 'server']
+ supervisor.stdout.pipe process.stdout
+ supervisor.stderr.pipe process.stderr
+ log 'Watching js files and running server', green
+
View
31 app.js
@@ -1,31 +0,0 @@
-var app, coffeecup, flatiron;
-
-require('coffee-script');
-
-coffeecup = require('coffeecup');
-
-flatiron = require('flatiron');
-
-app = flatiron.app;
-
-app.use(flatiron.plugins.http);
-
-app.router.get('/', function() {
- this.res.writeHead(200, {
- 'Content-Type': 'text/html'
- });
- return this.res.end(coffeecup.render(function() {
- doctype(5);
- return html(function() {
- head(function() {
- return title('Foo');
- });
- return body(function() {
- h1('Welcome to Iron-Coffee');
- return h3('CoffeeScript Flatiron http server template!');
- });
- });
- }));
-});
-
-app.start(3000);
View
Oops, something went wrong.
View
@@ -0,0 +1,7 @@
+extends layout
+
+block content
+ div.container.content
+ div.hero-unit
+ h1 Iron Coffee
+ p A Flat-Iron CoffeeScript Template
View
@@ -0,0 +1,21 @@
+!!!
+html(lang="en")
+ head
+ meta(charset='utf-8')
+ link(rel="stylesheet", href="/css/bootstrap.min.css")
+ link(rel="stylesheet", href="/css/bootstrap-responsive.min.css")
+ link(rel="stylesheet", href="/css/app.css")
+ title Iron-Coffee
+ script(src="http://cdnjs.cloudflare.com/ajax/libs/jquery/1.7.2/jquery.min.js")
+ script(src="/js/bootstrap.min.js")
+
+ body
+ div.navbar.navbar-fixed-top
+ div.navbar-inner
+ div.container
+ a.brand(href="/") Iron-Coffee
+ ul.nav
+ li: a(href="/") Home
+ li: a(href="/about") About
+ li: a(href="/contact") Contact
+ block content
View
@@ -2,7 +2,7 @@
"author": "Tom Wilson <tom@jackhq.com> (http://www.jackhq.com)",
"name": "iron-coffee",
"description": "A flatiron coffee-script template",
- "version": "0.0.1",
+ "version": "0.1.0",
"repository": {
"type": "git",
"url": "git://github.com/twilson63/iron-coffee.git"
@@ -11,18 +11,20 @@
"scripts": {
"test": "mocha"
},
- "engines": {
- "node": "0.6 || 0.7 || 0.8"
- },
"dependencies": {
- "flatiron": "0.1.13",
- "union": "0.1.7",
- "coffee-script": "1.2.0",
- "coffeecup": "0.3.5"
+ "flatiron": "*",
+ "union": "*",
+ "ecstatic": "*",
+ "coffee-script": "*",
+ "jade.plugin": "*",
+ "supervisor": "*",
+ "docco": "*"
+
},
"devDependencies": {
- "mocha": "0.12.1",
- "should": "0.5.1",
+ "which": "*",
+ "mocha": "*",
+ "should": "*",
"request": "*"
}
}
View
@@ -0,0 +1,21 @@
+body {
+ padding-top: 90px;
+}
+
+.hero-unit h1 {
+ font-family: 'Times New Roman';
+ font-size: 3em;
+}
+
+article h1 {
+ margin-bottom: 20px;
+}
+article .body {
+ margin-bottom: 10px;
+}
+
+article .body {
+ font-size: 2em;
+ line-height: 30px;
+ color: rgba(0,0,0,.6);
+}
Oops, something went wrong.
Oops, something went wrong.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
@@ -0,0 +1,81 @@
+function assertEqual(a, b) {
+ if (a === b) {
+ console.log('GREEN LIGHT....');
+ } else {
+ console.log('RED LIGHT....');
+ }
+}
+
+function FindCtrl($scope, $http) {
+ $scope.country = { name: 'USA' };
+ $scope.state = { name: 'SC' };
+ $scope.city = { name: 'Charleston' };
+
+ $http.get('/country.json').success(function(data){
+ $scope.countries = data;
+ });
+
+ $scope.countryChanged = function() {
+ $http.get('/states?country=' + $scope.country.name).success(function(data){
+ $scope.states = data;
+ });
+ $scope.states = ['SC', 'GA'];
+ }
+ $scope.stateChanged = function() {
+ $scope.cities = ['Charleston', 'Atlanta'];
+ }
+}
+
+// Tests
+function findControllerTest() {
+ var scope = {}, http = {
+ get: function() {
+ return {
+ success: function(cb) {
+ cb([{ name:"USA"},{name:"UK"}]);
+ }
+ }
+ }
+ }
+
+ FindCtrl(scope, http);
+ console.log('Test Country');
+ assertEqual(scope.country, 'USA');
+ console.log('Test Countries');
+ assertEqual(scope.countries.length, 2);
+}
+
+// function CountryCtrl($scope, $http) {
+// $scope.foo = "Where are you now? ";
+// $scope.mylocation = { country: 'USA', state: 'South Carolina', city: 'Charleston'}
+//
+// $scope.states = ['Georgia', 'South Carolina', 'New Jersey'];
+// $scope.cities = ['Atlanta', 'Charleston', 'Moorestown'];
+// $scope.change = function(){
+// // http request....
+// $scope.results = [{value: "Foo"}, {value: "bar"}]
+// if($scope.mylocation.country === 'UK') {
+// $scope.states = ['Scotland', 'England', 'Wales'];
+// $scope.cities = ['London', 'York', 'Jersey'];
+// } else {
+// $scope.states = ['Georgia', 'South Carolina', 'New Jersey'];
+// $scope.cities = ['Atlanta', 'Charleston', 'Moorestown'];
+// }
+// }
+// $scope.stateChanged = function(){
+// console.log('State Changed...');
+// if($scope.mylocation.state === 'Scotland') {
+// $scope.cities = ['Jersey'];
+// } else if ($scope.mylocation.country === 'USA') {
+// $scope.cities = ['Atlanta', 'Charleston', 'Moorestown'];
+// } else {
+// $scope.cities = ['London', 'York', 'Jersey'];
+// }
+// }
+// $scope.cityChanged = function(){
+// console.log('City Changed...')
+// }
+// $scope.clickFoo = function(){
+// $scope.foo = "Bar..."
+// }
+// }
Oops, something went wrong.
View
@@ -1,18 +0,0 @@
-require 'coffee-script'
-coffeecup = require 'coffeecup'
-
-flatiron = require 'flatiron'
-app = flatiron.app
-app.use flatiron.plugins.http
-app.router.get '/', ->
- @res.writeHead 200, 'Content-Type': 'text/html'
- @res.end coffeecup.render ->
- doctype 5
- html ->
- head ->
- title 'Foo'
- body ->
- h1 'Welcome to Iron-Coffee'
- h3 'CoffeeScript Flatiron http server template!'
-
-app.start 3000
View
@@ -0,0 +1,22 @@
+flatiron = require 'flatiron'
+ecstatic = require 'ecstatic'
+jade = require 'jade.plugin'
+app = flatiron.app
+port = process.env.PORT or 3000
+
+# plugins
+app.use(flatiron.plugins.http)
+app.use(jade.plugin, dir: "#{__dirname}/views", ext: '.jade')
+
+app.http.before = [
+ ecstatic(__dirname + '/../public', { autoIndex: false })
+]
+# routes
+app.router.get '/', -> app.render @res, 'index'
+
+# start server
+app.start port, ->
+ console.log """
+ Server Running on port #{port}
+ Press CTRL-C to quit...
+ """

0 comments on commit bca62eb

Please sign in to comment.