/Readme.md

https://github.com/andersjanmyr/zoo · Markdown · 179 lines · 116 code · 63 blank · 0 comment · 0 complexity · 831232af735a83cb0fda070747501891 MD5 · raw file

  1. # Backbone Lab
  2. ## 0. Setup
  3. Use one of the provided servers, Express (Node), Sinatra (Ruby),
  4. or Jersey (Java)
  5. ### Node
  6. # Install Node - https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager
  7. $ curl http://npmjs.org/install.sh | sh # Install NPM
  8. $ npm install -g coffee-script # Install Coffeescript
  9. $ npm install -g express # Install Express (server)
  10. Update: The npm install may not work. In that case you may have to build
  11. it yourself. Instruction are here: http://search.npmjs.org/#/_install
  12. If `npm install -g coffee-script` does not work you can either use
  13. `sudo` or install into the local directory without the `-g`.
  14. $ cd $zoo_home
  15. $ npm install coffee-script # Install Coffeescript locally
  16. $ npm install express # Install Express locally (server)
  17. Update 2: The node installation in Ubuntu may be old, then you have to
  18. install from source.
  19. $ git clone https://github.com/joyent/node.git
  20. $ cd node
  21. $ git co v0.4.9
  22. $ ./configure
  23. $ sudo make install
  24. ### Sinatra
  25. $ Install XCode (OSX)
  26. $ bash < <(curl -s https://rvm.beginrescueend.com/install/rvm)
  27. $ DO WHAT THE INSTALLER TELLS YOU TO DO (update .profile)
  28. $ rvm install 1.9.2
  29. $ rvm use 1.9.2 --default
  30. $ gem install sinatra
  31. $ gem install guard guard-coffeescript
  32. ### Jersey
  33. Do what you have to!
  34. ### Unpack the files.
  35. <pre>
  36. |-- client # The client
  37. | |-- index.html # The application page.
  38. | |-- lib # The Javascript source
  39. | | |-- zoo.js # The application code.
  40. | | |-- jasmine-1.1.0.rc1 # Test support files
  41. | | |-- spec
  42. | | | |-- zoo_spec.js # Spec files for the app
  43. | | | `-- fixtures.js # Fixtures for the specs
  44. | | `-- vendor # Third party files
  45. | | |-- backbone.js
  46. | | |-- jquery-1.6.3.js
  47. | | |-- json2.js
  48. | | `-- underscore.js
  49. | |-- Readme.md # This file
  50. | |-- SpecRunner.html # The spec runner
  51. | `-- src # The Coffescript source
  52. | |-- zoo.js.coffee # The application code
  53. | `-- spec
  54. | |-- zoo_spec.js.coffee # The Coffeescript specs
  55. | `-- fixtures.js.coffee # The Coffeescript fixtures
  56. `-- server # The server
  57. |-- lib
  58. | |-- server.js # Node Javascript
  59. | `-- server.rb # Sinatra Ruby
  60. `-- src
  61. `-- server.js.coffee # Node Coffeescript
  62. </pre>
  63. ### cd into $zoo_home/client
  64. You will do most of the work with the files in the client directory.
  65. ### Open SpecRunner.html
  66. If you want to use [LiveReload](http://livereload.com/), open it from a server,
  67. otherwise it is fine to open it as a file.
  68. To open it from a server, you can start node.
  69. $ node $zoo_home/server/lib/server.js
  70. ....zoo/server/lib/../../client
  71. Starting on port 4000
  72. And then you can access the specs at http://localhost:4000/SpecRunner.html
  73. ### Verify setup
  74. Verify that the sanity spec is showing green, and that all other specs fails.
  75. Open up the files `zoo_spec.js.coffee` and `zoo.js` or
  76. `zoo.js.coffee`.
  77. ### Optionally
  78. Start coffeescript compilation by running `guard`, if you installed it.
  79. $ gem install guard guard-coffeescript
  80. $ guard
  81. Start coffescript compilation by running `coffee -cwo lib src`, if you
  82. installed coffeescript.
  83. $ coffee -cwo lib src
  84. ## 1. Fix the Animal
  85. The first tests consists of creating a Backbone.Model. Enter the code
  86. into the source file, Javascript ($zoo_home/client/lib/zoo.js)
  87. or Coffeescript ($zoo_home/client/src/zoo.js.coffee) as you like. Look at
  88. the spec file to see what needs to be done. Coffeescript is easier to
  89. read.
  90. ## 2. Fix the AnimalView
  91. In order to do this you need to create an AnimalView that takes an
  92. Animal as a model parameter. You need to set the properties and you need
  93. to update the template in the SpecRunner.html to hold the values you
  94. need. You also need to setup the proper events to trigger on change.
  95. ## 3. Fix the Animals
  96. Animals should be a collection holding animals :)
  97. ## 4. Fix the AnimalsView
  98. The AnimalsView need to have the proper attributes set.
  99. ## 5. Fix the AnimalsView.render method
  100. The AnimalsView should render all its sub-views when called. After
  101. that you need to setup the event handling to make sure the view is
  102. updated when the collection changes. You may need to make changes to
  103. both the AnimalsView and the AnimalView.
  104. ## 6. Events, Handle click events on AnimalView
  105. The Events spec contains a spec that will succeed when an animal's age
  106. is incremented when it is clicked. Be sure to put the proper
  107. functionality in the view and in the model.
  108. ## 7. Router, Create a router that will respond to the proper routes.
  109. This spec is heavily dependent on mocks, even though the mocks are there
  110. you are supposed to create the methods that will be called when the
  111. proper route is selected.
  112. ## 8. Server, Setup communication with the server.
  113. The Server specs will test the communication with the server.
  114. It is dependent on some kind of restful service that responds to the
  115. /animals path.
  116. FEEL FREE TO IMPROVE THE DOCUMENTATION AS YOU COMPLETE THE SPECS!