{{note.noteBody}}
-{{noteBody}}
-Edit Note -Delete Note -``` - -We use href link in this case as I find them easier to work with than the backbone -navigate feature. Although if you change your routing they will all have to be -update, tradeoffs. Next update the collection view to look like this: - -```html -New Note -Internet Relay Chat (IRC) despite being an ancient chat protocol, is highly + used in the JavaScript, Node.js, and general web development community. It's + important that you're familiar with it and can utilize it for help and to + connect with others in the community. We have our own channel to model this + community. The channel has two "bots", a logging bot written in Ruby, and a fun + bot called "codehue" written in NodeJS.
+/msg NickServ help to get started from your IRC client.There is no submission for this assignment. We'll see you on the #codefellows +channel in class, and on Gitter.IM. They are very useful for sending links to +everyone during class, asking questions in the evening, or just socializing.
+We also use Gitter.IM +as a chatroom just for our class. Click on this button to join.
+ + + +Set up your computer with the following tools:
+Latest version of Ruby (for Sass, and other tools) Node.js, PostgreSQL, +MongoDB, Redis,
+Editors: We use Atom.io or Sublime Text 3 in class, and I'm betting you already do too +(unless you rock Vim or Emacs). Sublime Text has a fully-featured, unlimited time Trial mode.
+Optional: if you are coming from an IDE like Visual Studio or Eclipse, you +may like WebStorm (trial version) better +than Sublime Text because of the autocompletion and debugging tools. It's also +cheaper for an academic license ($29 vs $79)
+And if you're a strict proponent of open source, or want to dogwood and +customize your editor in JavaScript, there are two great free editors: +Brackets and Light Table.
+Homebrew http://brew.sh Note: the instructions are at the end of the web page.
+rbenv, ruby-build, ruby 2.1.1 and the sass gem
+brew doctorbrew updatebrew install rbenv ruby-build rbenv-gem-rehashecho 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profileecho 'eval "$(rbenv init -)"' >> ~/.bash_profilerbenv install 2.1.1rbenv global 2.1.1gem install sassNode.js
+brew install nvmnvm install 0.10nvm alias default 0.10source $(brew --prefix nvm)/nvm.sh to your .bash_profile or .zshrcnpm -g install grunt-cli jshintPostgreSQL
+Pick a programmer's editor:
+MongoDB
+brew install mongodbbrew info mongobrew services start mongobrew services stop redisRedis
+brew install redisbrew info redisbrew services start redisbrew services stop redisHeroku Toolbelt
+brew install heroku-toolbeltnpm -g install grunt-cliBy testing to see if grunt works on a project we can see if you have done most
+of the setup tasks needed.
Let's just make sure your computer is set up with node and npm and can run tests.
+npm installSend a Pull Request to the class repo, with your own folder.
+Inside your folder should be a single readme.md file that contains some basic
+info about you. You should include your GitHub username, linked to your GitHub
+profile. Also link to your Twitter account, your LinkedIn page, and any other
+relevant information or online presence you'd like to share with your classmates.
I have created an example folder for myself.
+ + +Use the node REPL - Read, Evaluate, Print Loop
+Simply type node from the command line.
var truth_value = false;
+process.nextTick(function() {
+ console.log(truth_value)
+});
+truth_value = true;
+
+What will the output be? False or True?
+The answer is that the output will be true. Why? You might have thought +it would be false, right? It's like the statements are having out of order.
+It's because we are placing our function with conosole.log on the event queue.
+ + +Express is a minimalistic web framework built on top of Node.js. Based on +Ruby's Sinatra framework it abstracts away a lot of the boiler plate +code required to get a Node web server up and running. Created by + TJ Holowaychuck Express is built +using Connect another abstraction +for creating web servers with Node. Express 3.x includes a suite of middleware +that were abstracted into their own modules with Express 4. Read more about it here
+The first step in creating an express application from scratch is to create
+a new folder with mkdir hello_express. Change into the director with cd hello_express
+and create a file with the name package.json. Inside of the file place the following:
{
+ "name" : "hello-express",
+ "description" : "a hello world web application written in express",
+ "version" : "0.0.1",
+ "dependencies" : {
+ "express" : "^4.0"
+ }
+}
+A package.json file is found in nearly every Node packag or application. It tells npm about our
+ application. The name and description would appear in npm if we were creatin a node
+package. The version is the Semantic Versioning version
+of our application and the dependencies tell npm what packages we need in order to
+run our application. In this case the only package that we need is express. After saving
+this file run npm install from the command in our hello_express directory and npm
+will install Express and all of it's dependencies and save them into a folder called node_modules.
+Now seems like a perfect time to create a git repository for our application.
git init
+touch .gitignore
+echo "node_modules/" >> .gitignore
+git add .
+git commit -m "add package.json and .gitignore"
+First we need to create a .gitignore file. This file tells git not include our node_modules +folder in our version control. This folder can get quite large and we already have our +dependencies declared in our package.json file, so it becomes redundant. Now we need to +create a simple web server. Create a file called server.js and add the following code:
+var express = require('express');
+var http = require('http');
+
+var app = express();
+
+app.get('/', function(req, res){
+ res.send('hello world!');
+});
+
+var server = http.createServer(app);
+server.listen(3000, function(){
+ console.log('the server is running on port 3000');
+});
+In this file we first require the express package within our server.js file. We then require
+http which will be used to create the actual server. Then we create our app by calling the root
+express function. The app.get line is a REST
+get request to our root url that simple writes 'hello world!' to the browser. In the final section
+we create a server and start it listening on port 3000, we pass a callback that gets called
+when the server is running that simple outputs 'the server is running on port 3000' to the console.
+To start our server simply run node server.js from the command line. Then point your preferred
+browser to http://localhost:3000, you should see the text hello world!.
Now this particular server isn't especially useful or interesting but we can modify it to serve +static html pages using one of the few optional middlewares that didn't get abstracted out of +Express 4, static. Modify your server.js file to look like this:
+var express = require('express');
+var http = require('http');
+
+var app = express();
+
+app.use(express.static(__dirname + '/public'));
+
+var server = http.createServer(app);
+server.listen(3000, function() {
+ console.log('the server is listening on port 3000');
+});
+Our server now serves any file located in the /public directory. The __dirname in this version of the server.js
+points to the root directory of our application. This is a node global and is available anywhere in a
+node program. Next we need to create the /public directory, run mkdir public from the console.
+Now place create an index.html file in the public directory and add the following to it:
<!doctype html>
+<html lang="en">
+ <head>
+ <meta charset="UTF-8"/>
+ <title>Hello World Express</title>
+ </head>
+ <body>
+ Hello World from an html document!
+ </body>
+</html>
+If you close the server we had running and run node server.js again, when you browse to http://localhost:3000
+you should see the text Hello World from an html document. You can also serve up anything you place in the
+public directory, including javascript files, images, css stylesheets and other html files. Don't forget to commit
+the changes!
git add .
+git commit -m "serving static files"
+
+
+ This is a simple blog made as teaching example.
+brew install nvm on Mac OS X instead of brew install node.
+See the nvm README for more details.npm install -g yo grunt-cliGrab my copy of generator-browserify (until this pull request is closed).
+npm -g install ivanoats/generator-browserify
+Generate the app skeleton
+mkdir blog && cd blog
+yo browserify
+You'll see a lot of text scroll by, and on my system I saw the last lines like this:
+grunt-sass@0.9.0 node_modules/grunt-sass
+├── async@0.2.10
+└── node-sass@0.7.0 (node-watch@0.3.4, colors@0.6.0-1, mkdirp@0.3.5, optimist@0.6.1, mocha@1.13.0)
+Your directory listing should look something like this:
+total 80
+drwxr-xr-x 13 ivan staff 442 Apr 17 12:40 .
+drwxr-xr-x 256 ivan staff 8704 Apr 17 12:36 ..
+-rw-r--r-- 1 ivan staff 42 Apr 16 15:14 .bowerrc
+-rw-r--r-- 1 ivan staff 214 Apr 16 15:14 .editorconfig
+-rw-r--r-- 1 ivan staff 11 Apr 16 15:14 .gitattributes
+-rw-r--r-- 1 ivan staff 65 Apr 16 15:14 .gitignore
+-rw-r--r-- 1 ivan staff 390 Apr 16 15:14 .jshintrc
+-rw-r--r-- 1 ivan staff 11094 Apr 17 12:40 Gruntfile.js
+drwxr-xr-x 7 ivan staff 238 Apr 17 12:40 app
+-rw-r--r-- 1 ivan staff 213 Apr 16 15:14 bower.json
+drwxr-xr-x 2 ivan staff 68 Apr 17 12:40 dist
+drwxr-xr-x 32 ivan staff 1088 Apr 17 12:40 node_modules
+-rw-r--r-- 1 ivan staff 1277 Apr 17 12:40 package.json
+Now type grunt serve to launch the app in a web browser. You should see something
+like this:

That's great but let's start with a simpler blog layout: Go to + http://foundation.zurb.com/templates.html
+and download the blog layout HTML. Put that in the body tag of app/index.html in
+your project.
You can now start customizing your blog with the following files:
+Here's what I did:
+
Go to town! This generator also includes BackboneJS so you can even make your +blog a single-page app.
+Tested Pull-Requests welcome! I will list you as a contributor.
+ + +On day three, we will cover:
+Let's get our site LIVE ON THE WEB!! This process is called deployment.
+Slides from class introducing Heroku.
+Make sure you have the Heroku Toolbelt installed.
+You can usually brew install heroku-toolbelt or sudo apt-get install heroku-toolbelt. If those don't work you may need to donwload it.
Also, if you haven't already, sign up for an account on Heroku.com.
+Use heroku login to log in to heroku from the command line.
If you're already logged in, you can use heroku auth:whoami to see who you are logged in as.
You'll want a nice name for your app instead of the random ones Heroku gives you.
+E.g. heroku create ivan-hello-world-express
You need a file to tell heroku how to launch your app.
+Edit Procfile which should be in the root directory of your project. No file extension on this file, and it needs to start with a Capital letter. The procfile is simply:
web: node server.js
+This tells heroku that to start your web server, it needs to run the command node server.js
You can use a npm package called foreman to test that your Procfile works as expected. Install this globally.
+npm install -g foreman
This will give you the nf command. Try it out.
nf --help
And, now, try starting your server via foreman.
+nf start
It should start up your server on port 5000 as a default.
+This means that your server should not have any port 'hard-coded' as a default (like 3000). Make sure your server code looks something like this:
+var server = http.createServer(app);
+app.set('port', process.env.PORT || 3000);
+
+server.listen(app.get('port'), function() {
+ console.log('the server is NOW running on port', app.get('port'));
+});
+
+Make sure to commit any changes you made to your app, like adding the Procfile, etc.
+git add .
git commit -m 'preparing for heroku'
Make sure you're on the master branch or that you merge you changes back to master.
+And now, to deploy your app to the web on Heroku:
+git push heroku master
You'll see a bunch of info scroll by from Heroku, but it should look something like this:
+$ git push heroku master
+Fetching repository, done.
+Counting objects: 7, done.
+Delta compression using up to 8 threads.
+Compressing objects: 100% (3/3), done.
+Writing objects: 100% (4/4), 343 bytes | 0 bytes/s, done.
+Total 4 (delta 2), reused 0 (delta 0)
+
+-----> Node.js app detected
+
+ PRO TIP: Specify a node version in package.json
+ See https://devcenter.heroku.com/articles/nodejs-support
+
+-----> Defaulting to latest stable node: 0.10.28
+-----> Downloading and installing node
+-----> Restoring node_modules directory from cache
+-----> Pruning cached dependencies not specified in package.json
+ npm WARN package.json hello-express@ No repository field.
+-----> Writing a custom .npmrc to circumvent npm bugs
+-----> Exporting config vars to environment
+-----> Installing dependencies
+ npm WARN package.json hello-express@ No repository field.
+-----> Caching node_modules directory for future builds
+-----> Cleaning up node-gyp and npm artifacts
+-----> Building runtime environment
+-----> Discovering process types
+ Procfile declares types -> web
+
+-----> Compressing... done, 5.3MB
+-----> Launching... done, v4
+ http://ivan-hello-world-express.herokuapp.com/ deployed to Heroku
+
+To git@heroku.com:ivan-hello-world-express.git
+ 3d47745..3f34feb master -> master
+And you can open your browser, and visit your app on the web!
+ + +Credit is due to Dale Sande for preparing this material.
+Sass is an extension of CSS that adds power and elegance to the basic language. It allows you to use variables, nested rules, mixins, inline imports, and more, all with a fully CSS-compatible syntax. Sass helps keep large stylesheets well-organized, and get small stylesheets up and running quickly, particularly with the help of the Compass style library.
+Is Sass somewhat of a mystery to you? How does it work? Why do some say that it is better then CSS?
+ + +Sass was orignally a Ruby gem, but it is also available as an npm package now. You can npm install node-sass in your projects.
Acceptance testing is also known as "Outside-in", or "black-box" testing. It +tests a system just like a web browser does. Except, instead of a person clicking +on a web browser, a "headless" browser operates in the command line, a bit more +behind the scenes.
+
There are many options for acceptance testing, but we will be using one called +CasperJS.
+Let's just test to see if the home page is loading o.k., and that the title tag
+and H1 tags are what we expect. Here's the code, it goes in
+test/acceptance/home_page_test.js:
BTW, if you want to make a new directory multiple levels deep, you can use:
+mkdir -p test/acceptance from your project's home directory.
'use strict';
+/*global casper*/
+
+casper.test.begin('home page', 3, function suite(test) {
+
+ casper.start('http://localhost:3000/', function() {
+ test.assertHttpStatus(200);
+ });
+
+ casper.then(function(){
+ test.assertTitle('Hello World Express', 'title is Hello World Express');
+ });
+
+ casper.then(function() {
+ test.assertSelectorHasText('h1','Hello World');
+ });
+
+ casper.run(function(){
+ test.done();
+ });
+
+});
+
+So, we have three assertions that we expect to be true. The status should be 200 +OK, the title should be "Hello World Express", and the h1 should include the text +"Hello World".
+To run our acceptance test we'll need to make sure to start the express server. +We will use a grunt plugin to automate this.
+You can do this on your personal portfolio site, or your hello world express code.
+From the command line:
+npm install grunt-express-server --save-dev
And in Gruntfile.js add:
+grunt.loadNpmTasks('grunt-express-server');
Install Casper and PhantomJS globally, and Grunt integration locally
+npm install -g phantomjs casperjs
+npm install grunt-casper --save-dev
+npm install grunt-express-server --save-dev
+Edit your Gruntfile.js to include tasks like these below:
'use strict';
+module.exports = function(grunt) {
+
+ grunt.loadNpmTasks('grunt-contrib-jshint');
+ grunt.loadNpmTasks('grunt-express-server');
+ grunt.loadNpmTasks('grunt-casper');
+
+ grunt.initConfig({
+ express: {
+ options: {
+ // Override defaults here
+ },
+ dev: {
+ options: {
+ script: 'server.js'
+ }
+ },
+ prod: {
+ options: {
+ script: 'server.js',
+ node_env: 'production'
+ }
+ },
+ test: {
+ options: {
+ script: 'server.js'
+ }
+ }
+ },
+ casper: {
+ acceptance : {
+ options : {
+ test : true,
+ },
+ files : {
+ 'test/acceptance/casper-results.xml' : ['test/acceptance/*_test.js']
+ }
+ }
+ }
+ });
+
+ grunt.registerTask('server', [ 'jshint', 'express:dev' ]);
+ grunt.registerTask('test',['express:dev','casper']);
+ grunt.registerTask('default', ['jshint', 'test']);
+
+};
+
+server task that runs the express server after JSHint passes.test task that sets up the express server in dev mode, and then runs
+the casper tests.Now try grunt test from the command line and see what happens…
Use your modules, plus already existing node core modules, in the browser
+Anything you want to use on the server and in the browser.
+



bower install does not modify package.json<script> tags, but that’s missing out on the good stuff