-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f3ded4d
commit df43c41
Showing
57 changed files
with
878 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"directory": "vendor" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# compiled output | ||
/dist | ||
/tmp | ||
|
||
# dependencies | ||
/node_modules | ||
/vendor/* | ||
!/vendor/ember-shim.js | ||
!/vendor/qunit-shim.js | ||
|
||
# misc | ||
/.sass-cache | ||
/connect.lock | ||
/libpeerconnection.log | ||
.DS_Store | ||
Thumbs.db | ||
/coverage/* | ||
npm-debug.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
{ | ||
"predef": { | ||
"document": true, | ||
"window": true, | ||
"location": true, | ||
"setTimeout": true, | ||
"Ember": true, | ||
"Em": true, | ||
"DS": true, | ||
"$": true | ||
}, | ||
"node" : false, | ||
"browser" : false, | ||
"boss" : true, | ||
"curly": false, | ||
"debug": false, | ||
"devel": false, | ||
"eqeqeq": true, | ||
"evil": true, | ||
"forin": false, | ||
"immed": false, | ||
"laxbreak": false, | ||
"newcap": true, | ||
"noarg": true, | ||
"noempty": false, | ||
"nonew": false, | ||
"nomen": false, | ||
"onevar": false, | ||
"plusplus": false, | ||
"regexp": false, | ||
"undef": true, | ||
"sub": true, | ||
"strict": false, | ||
"white": false, | ||
"eqnull": true, | ||
"esnext": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# See http://help.github.com/ignore-files/ for more about ignoring files. | ||
|
||
# compiled output | ||
/dist | ||
/tmp | ||
|
||
# dependencies | ||
/node_modules | ||
/vendor/* | ||
!/vendor/loader.js | ||
!/vendor/ember-shim.js | ||
!/vendor/qunit-shim.js | ||
|
||
# misc | ||
/.sass-cache | ||
/connect.lock | ||
/libpeerconnection.log | ||
.DS_Store | ||
Thumbs.db | ||
/coverage/* | ||
npm-debug.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
/* global require, module */ | ||
|
||
var uglifyJavaScript = require('broccoli-uglify-js'); | ||
var compileES6 = require('broccoli-es6-concatenator'); | ||
var p = require('ember-cli/lib/preprocessors'); | ||
var pickFiles = require('broccoli-static-compiler'); | ||
var env = require('broccoli-env').getEnv(); | ||
|
||
var preprocessCss = p.preprocessCss; | ||
var preprocessTemplates = p.preprocessTemplates; | ||
var preprocessJs = p.preprocessJs; | ||
|
||
module.exports = function (broccoli) { | ||
var app = 'app'; | ||
var tests = 'tests'; | ||
var publicFiles = 'public'; | ||
var vendor = 'vendor'; | ||
var config = 'config'; | ||
var styles; | ||
var qunit; | ||
var testsIndex; | ||
|
||
app = pickFiles(app, { | ||
srcDir: '/', | ||
destDir: 'ember-flows-generator/' | ||
}); | ||
|
||
app = preprocessTemplates(app); | ||
|
||
config = pickFiles(config, { | ||
srcDir: '/', | ||
files: [ | ||
'environment.*', | ||
'environments/' + env + '.*' | ||
], | ||
destDir: 'ember-flows-generator/config' | ||
}); | ||
|
||
testsIndex = pickFiles(tests, { | ||
srcDir: '/', | ||
files: ['index.html'], | ||
destDir: '/tests' | ||
}); | ||
|
||
tests = pickFiles(tests, { | ||
srcDir: '/', | ||
destDir: 'ember-flows-generator/tests' | ||
}); | ||
|
||
qunit = pickFiles(vendor, { | ||
srcDir: '/qunit/qunit', | ||
files: ['qunit.css'], | ||
destDir: '/assets/' | ||
}); | ||
|
||
tests = preprocessTemplates(tests); | ||
|
||
var sourceTrees = [ | ||
app, | ||
config, | ||
vendor | ||
]; | ||
|
||
var legacyFilesToAppend = [ | ||
'ember-flows-generator/config/environment.js', | ||
'ember-flows-generator/config/environments/' + env + '.js', | ||
'jquery.js', | ||
'handlebars.js', | ||
'ember.js', | ||
'ic-ajax/main.js', | ||
'ember-data.js', | ||
'ember-resolver.js' | ||
]; | ||
|
||
if (env !== 'production') { | ||
legacyFilesToAppend.push( | ||
'ember-shim.js', | ||
'qunit/qunit/qunit.js', | ||
'qunit-shim.js', | ||
'ember-qunit/dist/named-amd/main.js' | ||
); | ||
|
||
sourceTrees.push(tests); | ||
} | ||
|
||
sourceTrees = sourceTrees.concat(broccoli.bowerTrees()); | ||
|
||
var appAndDependencies = new broccoli.MergedTree(sourceTrees); | ||
|
||
appAndDependencies = preprocessJs(appAndDependencies, '/', 'ember-flows-generator'); | ||
|
||
var applicationJs = compileES6(appAndDependencies, { | ||
loaderFile: 'loader.js', | ||
ignoredModules: [ | ||
'ember/resolver', | ||
'ember-qunit' | ||
], | ||
inputFiles: [ | ||
'ember-flows-generator/**/*.js' | ||
], | ||
legacyFilesToAppend: legacyFilesToAppend, | ||
|
||
wrapInEval: env !== 'production', | ||
outputFile: '/assets/app.js' | ||
}); | ||
|
||
styles = preprocessCss(sourceTrees, 'ember-flows-generator/styles', '/assets'); | ||
|
||
if (env === 'production') { | ||
applicationJs = uglifyJavaScript(applicationJs, { | ||
mangle: false, | ||
compress: false | ||
}); | ||
} | ||
|
||
var outputTrees = [ | ||
applicationJs, | ||
publicFiles, | ||
styles | ||
]; | ||
|
||
if (env !== 'production') { | ||
outputTrees.push(qunit, testsIndex); | ||
} | ||
|
||
return outputTrees; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
API Stub | ||
======== | ||
|
||
The stub allows you to implement express routes to fake API calls. | ||
Simply add API routes in the routes.js file. The benefit of an API | ||
stub is that you can use the REST adapter from the get go. It's a | ||
way to use fixtures without having to use the fixture adapter. | ||
|
||
As development progresses, the API stub becomes a functioning spec | ||
for the real backend. Once you have a separate development API | ||
server running, then switch from the stub to the proxy pass through. | ||
|
||
To configure which API method to use edit **package.json**. | ||
|
||
* Set the **APIMethod** to 'stub' to use these express stub routes. | ||
|
||
* Set the method to 'proxy' and define the **proxyURL** to pass all API requests to the proxy URL. | ||
|
||
Default Example | ||
---------------- | ||
|
||
1. Create the following models: | ||
|
||
app/models/post.js | ||
|
||
``` | ||
var attr = DS.attr, | ||
hasMany = DS.hasMany, | ||
belongsTo = DS.belongsTo; | ||
|
||
var Post = DS.Model.extend({ | ||
title: attr(), | ||
comments: hasMany('comment'), | ||
user: attr(), | ||
}); | ||
|
||
export default Post; | ||
``` | ||
|
||
app/models/comment.js | ||
|
||
``` | ||
var attr = DS.attr, | ||
hasMany = DS.hasMany, | ||
belongsTo = DS.belongsTo; | ||
|
||
var Comment = DS.Model.extend({ | ||
body: attr() | ||
}); | ||
|
||
export default Comment; | ||
``` | ||
|
||
2. Setup the REST adapter for the application: | ||
|
||
app/adapters/application.js | ||
|
||
``` | ||
var ApplicationAdapter = DS.RESTAdapter.extend({ | ||
namespace: 'api' | ||
}); | ||
|
||
export default ApplicationAdapter; | ||
``` | ||
|
||
3. Tell the Index router to query for a post: | ||
|
||
app/routes/index.js | ||
|
||
``` | ||
var IndexRoute = Ember.Route.extend({ | ||
model: function() { | ||
return this.store.find('post', 1); | ||
} | ||
}); | ||
|
||
export default IndexRoute; | ||
``` | ||
|
||
|
||
4. Expose the model properties in the index.hbs template | ||
|
||
app/templates/index.hbs | ||
|
||
``` | ||
<h2>{{title}}</h2> | ||
<p>{{body}}</p> | ||
<section class="comments"> | ||
<ul> | ||
{{#each comment in comments}} | ||
<li> | ||
<div>{{comment.body}}</div> | ||
</li> | ||
{{/each}} | ||
</ul> | ||
</section> | ||
``` | ||
|
||
When Ember Data queries the store for the post, it will make an API call to | ||
http://localhost:8000/api/posts/1, to which the express server will respond with | ||
some mock data: | ||
|
||
``` | ||
{ | ||
"post": { | ||
"id": 1, | ||
"title": "Rails is omakase", | ||
"comments": ["1", "2"], | ||
"user" : "dhh" | ||
}, | ||
"comments": [{ | ||
"id": "1", | ||
"body": "Rails is unagi" | ||
}, { | ||
"id": "2", | ||
"body": "Omakase O_o" | ||
}] | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* global module */ | ||
module.exports = function(server) { | ||
|
||
// Create an API namespace, so that the root does not | ||
// have to be repeated for each end point. | ||
server.namespace('/api', function() { | ||
|
||
// Return fixture data for '/api/posts/:id' | ||
server.get('/posts/:id', function(req, res) { | ||
var post = { | ||
"post": { | ||
"id": 1, | ||
"title": "Rails is omakase", | ||
"comments": ["1", "2"], | ||
"user" : "dhh" | ||
}, | ||
|
||
"comments": [{ | ||
"id": "1", | ||
"body": "Rails is unagi" | ||
}, { | ||
"id": "2", | ||
"body": "Omakase O_o" | ||
}] | ||
}; | ||
|
||
res.send(post); | ||
}); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export default DS.FixtureAdapter.extend(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import Resolver from 'ember/resolver'; | ||
|
||
var App = Ember.Application.extend({ | ||
LOG_ACTIVE_GENERATION: true, | ||
LOG_MODULE_RESOLVER: true, | ||
// LOG_TRANSITIONS: true, | ||
// LOG_TRANSITIONS_INTERNAL: true, | ||
LOG_VIEW_LOOKUPS: true, | ||
modulePrefix: 'ember-flows-generator', // TODO: loaded via config | ||
Resolver: Resolver | ||
}); | ||
|
||
export default App; |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
export default Ember.Component.extend({ | ||
classNames: ['pretty-color'], | ||
attributeBindings: ['style'], | ||
style: function(){ | ||
return 'color: ' + this.get('name') + ';'; | ||
}.property('name') | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export default Ember.Component.extend({ | ||
classNames: ['look-ma-no-template'], | ||
tagName: ['span'] | ||
}); |
Empty file.
Empty file.
Oops, something went wrong.