You can email me here if you get stuck on any of these steps: kg@papercloud.com.au
-
Clone the startup generator:
git clone git@github.com:KarlGl/Startup.git
-
Include these libraries:
handlebars.js, ember.js
-
Include a template:
<script type="text/x-handlebars"> <b>FOO</b> </script>
-
Create an Ember Application:
Ember.Application.create()
With only this, we have content on the page. But you have an empty body element.
-
Add an outlet to the main template in the element.
-
Add some routes:
app.Router.map(function() { this.route('route_name', { path: '/:dynamic_segments' });
}) ```
-
Add a class for the route, add model function to this class:
model: function(params) { return params.idea_string; }
-
Another template with the id attribute set:
id="route_name"
-
Add a generate action on the Application controller, make it:
transitionToRoute 'route_name' with window.runGenerator().join(" ")
-
Add a link (link-to helper) that goes to the seeds page.
-
Add Seeds route, with a model function that is the window.genrationSeeds.
-
Add a computed propery for the types: array of 3 types, type has a name (string) and seeds (array of strings)
types: function() { return [{ name: 'adjectives', list: this.get('content.adjectives') }, { name: 'nouns', list: this.get('content.nouns'), }, { name: 'modifiers', list: this.get('content.modifiers') }]; }.property()
-
Template that lists seeds.
type in types type.name seed in type.list
-
Search bar in template linked to "search" {{input value=search}}
-
Filtering all words
var filterModule = { search: "", filter: function(words) { if (words) return words.filter(function(word) { return (word.indexOf(this.get('search')) > -1); }.bind(this)) } };
-
Filter each list in types.
list: this.filter.call(this, this.get('content.adjectives'))
- "Clear all" button
```
<button {{action deleteAll}}>
```
- deleteAll action (with this code in the function body)
```
this.changeSeeds({
"adjectives": [],
"nouns": [],
"modifiers": []
})
```
```
changeSeeds: function(newV) {
this.set("content", newV)
window.seedGenerator(newV)
window.genrationSeeds = newV
localStorage.setItem('seeds', JSON.stringify(newV))
},
```
-
Notice this won't work untill the types function observes 'content'
-
Add input helpers for adding new types {{input value=newType}}
-
Button to add new seed.
```
{{action addNew type.name newType}}
```
- addNew action with this body
```
this.get('content')[typeName].pushObject(newV);
this.changeSeeds(this.get('content'));
16. Normal types also must observe the, but we are setting content each time anyway...
'content.adjectives.length'
18. Persitance:
// to load in seeds:
var persistedSeeds = JSON.parse(localStorage.getItem('seeds'));
if (persistedSeeds) {
window.genrationSeeds = persistedSeeds;
}
LEVEL 5: BONUS LEVEL: BUILD TOOLS:
===
git clone git@github.com:KarlGl/gulp-ember-skeliton.git
put all your templates in the js/templates folder.
Startup Idea Generator
=======
Randomly generates startup ideas from a list of ```adjectives```, ```nouns``` and ```modifiers```. The modifiers are words or sentences tacked on to the end — these only have a 30% chance of occurring.
The list of words can be edited in the json file /data/data.json
Please feel free to give me any feedback here or on twitter <a href="https://twitter.com/krystalfister">@krystalfister</a>
[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/krystalfister/startup/trend.png)](https://bitdeli.com/free "Bitdeli Badge")