Commit 850036a

mo khan <mo@mokhan.ca>
2014-11-22 16:31:38
add tutorials listing.
1 parent 1061a6a
Changed files (10)
app
controllers
tutorials
models
routes
tutorials
templates
tests
unit
controllers
tutorials
models
routes
tutorials
app/controllers/tutorials/index.js
@@ -0,0 +1,3 @@
+import Ember from 'ember';
+
+export default Ember.ArrayController.extend({ });
app/models/tutorial.js
@@ -0,0 +1,9 @@
+import DS from 'ember-data';
+
+export default DS.Model.extend({
+  heading: DS.attr('string'),
+  description: DS.attr('string'),
+  url: DS.attr('string'),
+  imageUrl: DS.attr('string'),
+  author: DS.belongsTo('user')
+})
app/routes/tutorials/index.js
@@ -0,0 +1,7 @@
+import Ember from 'ember';
+
+export default Ember.Route.extend({
+  model: function(params){
+    return this.store.find('tutorial', params);
+  }
+});
app/templates/tutorials/index.hbs
@@ -0,0 +1,12 @@
+<div class="row">
+    <h1>Tutorials</h1>
+    {{#each}}
+    <div class="col-sm-3 col-md-3">
+      {{#link-to 'tutorial' this}}
+        <img {{bind-attr src=imageUrl}} {{bind-attr alt=heading}} >
+      {{/link-to}}
+      <p>{{heading}}</p>
+    </div>
+    {{/each}}
+</div>
+{{outlet}}
app/templates/application.hbs
@@ -13,12 +13,12 @@
       <ul class="nav navbar-nav navbar-right">
         <li>{{link-to 'Home' 'index'}}</li>
         <li>{{link-to 'Cakes' 'cakes'}}</li>
+        <li>{{link-to 'Tutorials' 'tutorials'}}</li>
       </ul>
     </div>
   </div>
 </div>
 
-<<br />
 <div class="container-fluid">
   {{outlet}}
 </div>
app/templates/tutorial.hbs
@@ -0,0 +1,9 @@
+<div class="row">
+  <div class="sm-col-12 md-col-12 lg-col-12">
+    <h1>{{heading}}</h1>
+    <img {{bind-attr src=imageUrl}} {{bind-attr alt=heading}} >
+    <p>{{description}}</p>
+
+    <a {{bind-attr href=url}}>View Original</a>
+  </div>
+</div>
app/router.js
@@ -9,6 +9,9 @@ Router.map(function() {
   this.resource('cakes', function() {
     this.resource('cake', { path: '/:cake_id' });
   });
+  this.resource('tutorials', function() {
+    this.resource('tutorial', { path: '/:tutorial_id' });
+  });
 });
 
 export default Router;
tests/unit/controllers/tutorials/index-test.js
@@ -0,0 +1,15 @@
+import {
+  moduleFor,
+  test
+} from 'ember-qunit';
+
+moduleFor('controller:tutorials/index', 'TutorialsIndexController', {
+  // Specify the other units that are required for this test.
+  // needs: ['controller:foo']
+});
+
+// Replace this with your real tests.
+test('it exists', function() {
+  var controller = this.subject();
+  ok(controller);
+});
tests/unit/models/tutorial-test.js
@@ -0,0 +1,15 @@
+import {
+  moduleForModel,
+  test
+} from 'ember-qunit';
+
+moduleForModel('tutorial', 'Tutorial', {
+  // Specify the other units that are required for this test.
+  needs: []
+});
+
+test('it exists', function() {
+  var model = this.subject();
+  // var store = this.store();
+  ok(!!model);
+});
tests/unit/routes/tutorials/index-test.js
@@ -0,0 +1,14 @@
+import {
+  moduleFor,
+  test
+} from 'ember-qunit';
+
+moduleFor('route:tutorials/index', 'TutorialsIndexRoute', {
+  // Specify the other units that are required for this test.
+  // needs: ['controller:foo']
+});
+
+test('it exists', function() {
+  var route = this.subject();
+  ok(route);
+});