Instructions for building this [Meteor CRUD](https://github.com/andersr/meteor_crud) app, a basic app for teaching Meteor basics. ## Step 0: Create app/basic dev setup - Run ```git clone git@github.com:andersr/meteor_crud``` from your terminal, followed by ```cd meteor_crud``` - Open the current directory in a text editor (eg using ```edit .```) - (If you were creating this app from scratch, you would simply have typed ```meteor create app``` in this directory.) - Cd into the "app" directory and run ```meteor``` from the command line. - Open a browser window and enter the URL: http://localhost:3000 - Leave this window open while building the app. Meteor will auto-refresh as you make changes. - Why have your app in an "app" sub-directory? Making your app a sub-directory of your working directory allows for making external files, such as config files, build files, etc, be part of your repo without being mixed in with actual app files. ## Step 1: App File Structure 1. Delete the default files: app.html, app.js, app.css (```eg using rm app.*```) 1. Add client, lib, and server directories: ```mkdir client lib server``` (Files in 'client' will only run on the client, files in 'server' will only run on the server, while files in 'lib' will be loaded first and run on both the server and client.) 2. Learn more about recommended Meteor file structure: http://meteortips.com/first-meteor-tutorial/structure/ 2. Run ```git checkout step1-file-structure``` for the finalized version of this step. ## Step 2: Basic Setup - Add a meteor bootstrap package: ``` meteor add twbs:bootstrap``` (Optional: add a [Sass](http://sass-lang.com/) package, which we'll use later: ``` meteor add fourseven:scss```) - In client/templates/, add an index page with `````` and `````` blocks only, containing some basic markup for layout. This will be the core app page. ```html Meteor CRUD
(Main page content goes here)
``` - (Optional) Add a scss.json file to the root directory with: ```{ "enableAutoprefixer": true}``` - Run ```git checkout step2-basic-setup`` for the finalized version of this step. ## Step 3: Create an Items List - In /lib/collections, add an items.js file with a 'items' Mongo collection: ```js Items = new Mongo.Collection('items'); ``` - Open your browser console (eg using Option + Cmd + J) and insert some items into your new collection: ```Items.insert({title:"My first item", createdAt: Date()});``` (If all goes well, Mongo should return the id of the newly created item. - In /client/templates/itemsList, add a itemList.js file containing a itemsList helper, which will reactively find all items in the 'items' collection: ```js Template.itemsList.helpers({ allItems: function () { return Items.find(); } }); ``` - Add the following view template files (we need to break out each individual item instance into a "singleItem" template to support editing of an item in a later step): */client/templates/itemsList/itemsList.html:* ```html ``` */client/templates/singleItem/singleItem.html:* ```html ``` - Invoke your "itemsList" template in the main index file to display its contents in your app: */client/templates/index.html* ```html ...
{{> itemsList}}
... ``` - Run ```git checkout step3-items-list``` for the finalized version of this step. ## Step 4: Add a form for adding items - Add the following form: */client/templates/addItem/addItem.html* ```html ``` - Insert the form into the itemsList template: ```html ...