-
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
app and vendor based on ember-app-kit.
- Loading branch information
Showing
36 changed files
with
59,213 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 @@ | ||
*.tmp |
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 @@ | ||
The MIT License (MIT) | ||
|
||
Copyright (c) 2013 Jo Liss | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. |
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,6 @@ | ||
# Broccoli | ||
|
||
A fast, reliable asset builder. Hard-coded to build Ember apps for now, to be | ||
generalized later. | ||
|
||
Work in progress, not usable for anything yet. |
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,2 @@ | ||
var FixtureAdapter = DS.FixtureAdapter.extend(); | ||
export default FixtureAdapter; |
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,22 @@ | ||
import Resolver from '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: 'appkit', // TODO: loaded via config | ||
Resolver: Resolver.default | ||
}); | ||
|
||
Ember.RSVP.configure('onerror', function(error) { | ||
// ensure unhandled promises raise awareness. | ||
// may result in false negatives, but visibility is more imporant | ||
if (error instanceof Error) { | ||
Ember.Logger.assert(false, error); | ||
Ember.Logger.error(error.stack); | ||
} | ||
}); | ||
|
||
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,9 @@ | ||
var PrettyColor = Ember.Component.extend({ | ||
classNames: ['pretty-color'], | ||
attributeBindings: ['style'], | ||
style: function(){ | ||
return 'color: ' + this.get('name') + ';'; | ||
}.property('name') | ||
}); | ||
|
||
export default PrettyColor; |
Empty file.
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,5 @@ | ||
var reverseWord = Ember.Handlebars.makeBoundHelper(function(word) { | ||
return word.split('').reverse().join(''); | ||
}); | ||
|
||
export default reverseWord; |
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,80 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>App</title> | ||
|
||
<!-- build:css(tmp/result) assets/app.min.css --> | ||
<link rel="stylesheet" href="/assets/app.css"> | ||
<!-- endbuild --> | ||
|
||
|
||
<!-- for more details visit: https://github.com/yeoman/grunt-usemin --> | ||
|
||
<!-- build:js(tmp/result) assets/vendor.min.js --> | ||
|
||
<script src="/vendor/jquery/jquery.js"></script> | ||
|
||
<!-- @if dist=false --> | ||
<script src="/vendor/handlebars/handlebars.js"></script> | ||
<script src="/vendor/ember/ember.js"></script> | ||
<!-- @endif --><!-- @if dist=true --> | ||
<script src="/vendor/handlebars/handlebars.runtime.js"></script> | ||
<script src="/vendor/ember/ember.prod.js"></script> | ||
<!-- @endif --> | ||
|
||
<script src="/vendor/ember-data-shim/ember-data.js"></script> | ||
<script src="/vendor/almond.js"></script> | ||
<script src="/vendor/ember-resolver/dist/ember-resolver.js"></script> | ||
|
||
<!-- endbuild --> | ||
|
||
<!-- build:js(tmp/result) assets/app.min.js --> | ||
|
||
<script src="app.js"></script> | ||
<script src="/assets/templates.js"></script> | ||
|
||
<!-- endbuild --> | ||
|
||
<!-- @if tests=true --> | ||
<link rel="stylesheet" href="/vendor/qunit/qunit/qunit.css"> | ||
<script src="/vendor/qunit/qunit/qunit.js"></script> | ||
|
||
<style> | ||
#ember-testing-container { | ||
position: absolute; | ||
background: white; | ||
bottom: 0; | ||
right: 0; | ||
width: 640px; | ||
height: 384px; | ||
overflow: auto; | ||
z-index: 9999; | ||
border: 1px solid #ccc; | ||
} | ||
#ember-testing { | ||
zoom: 50%; | ||
} | ||
</style> | ||
<!-- @endif --> | ||
|
||
</head> | ||
<body> | ||
|
||
OK | ||
|
||
<!-- @if tests=true --> | ||
<div id="qunit"></div> | ||
<div id="qunit-fixture"></div> | ||
<script src="/tests/tests.js"></script> | ||
<script src="/tests/test_helper.js"></script> | ||
<script src="/tests/test_loader.js"></script> | ||
<!-- @endif --> | ||
|
||
<!-- @if tests=false --> | ||
<script> | ||
window.App = require('appkit/app').default.create(); | ||
</script> | ||
<!-- @endif --> | ||
|
||
</body> | ||
</html> |
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,11 @@ | ||
var Router = Ember.Router.extend(); // ensure we don't share routes between all Router instances | ||
|
||
Router.map(function() { | ||
this.route('component-test'); | ||
this.route('helper-test'); | ||
// this.resource('posts', function() { | ||
// this.route('new'); | ||
// }); | ||
}); | ||
|
||
export default Router; |
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,8 @@ | ||
var ComponentTestRoute = Ember.Route.extend({ | ||
model: function() { | ||
return ['purple', 'green', 'orange']; | ||
} | ||
}); | ||
|
||
export default ComponentTestRoute; | ||
|
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,9 @@ | ||
var HelperTestRoute = Ember.Route.extend({ | ||
model: function() { | ||
return { | ||
name: "rebmE" | ||
}; | ||
} | ||
}); | ||
|
||
export default HelperTestRoute; |
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 @@ | ||
var IndexRoute = Ember.Route.extend({ | ||
model: function() { | ||
return ['red', 'yellow', 'blue']; | ||
} | ||
}); | ||
|
||
export default IndexRoute; |
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,8 @@ | ||
/* Put your CSS here */ | ||
html, body { | ||
margin: 20px; | ||
} | ||
|
||
@keyframes domChanged { from { background: yellow; } } | ||
@-webkit-keyframes domChanged { from { background: yellow; } } | ||
.ember-view { animation: domChanged 1s; -webkit-animation: domChanged 1s; } |
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,3 @@ | ||
<h2 id='title'>Welcome to Ember.js</h2> | ||
|
||
{{outlet}} |
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 @@ | ||
{{#each}} | ||
{{pretty-color name=this}} | ||
{{/each}} |
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 @@ | ||
Pretty Color: {{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 @@ | ||
<h3>My name is {{reverse-word name}}.</h3> |
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,5 @@ | ||
<ul> | ||
{{#each}} | ||
<li>{{this}}</li> | ||
{{/each}} | ||
</ul> |
Empty file.
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,154 @@ | ||
var fs = require('fs') | ||
var path = require('path') | ||
var mktemp = require('mktemp') | ||
var rimraf = require('rimraf') | ||
var walk = require('walk') | ||
var hapi = require('hapi') | ||
var synchronized = require('synchronized') | ||
var Gaze = require('gaze').Gaze | ||
var es6Compiler = require("es6-module-transpiler").Compiler; | ||
|
||
|
||
var Generator | ||
exports.Generator = Generator = function (src) { | ||
this.src = src | ||
} | ||
|
||
Generator.prototype.regenerate = function () { | ||
var self = this | ||
// Should debounce, e.g. when you do `touch *` | ||
synchronized(this, function (done) { | ||
self.cleanup() | ||
self.createDest() | ||
|
||
self.writeAppJs(function () { | ||
self.copyHtmlFiles(function () { | ||
console.log('Regenerated') | ||
done() | ||
}) | ||
}) | ||
}) | ||
} | ||
|
||
Generator.prototype.writeAppJs = function (callback) { | ||
appJs = fs.createWriteStream(this.dest + '/app.js') | ||
|
||
// Write vendor files (this needs to go away) | ||
var files = fs.readdirSync(__dirname + '/vendor') | ||
for (var i = 0; i < files.length; i++) { | ||
contents = fs.readFileSync(__dirname + '/vendor/' + files[i]) | ||
appJs.write(contents) | ||
} | ||
|
||
// Write app files | ||
var modulePrefix = 'appkit/' | ||
walkFiles(this.src, 'js', function (fileInfo, fileStats, next) { | ||
var fileContents = fs.readFileSync(fileInfo.fullPath).toString() | ||
var compiler = new es6Compiler(fileContents, modulePrefix + fileInfo.moduleName) | ||
var output = compiler.toAMD() // ERR: handle exceptions | ||
appJs.write(output + "\n") | ||
next() | ||
}, function () { | ||
appJs.end() | ||
callback() | ||
}) | ||
} | ||
|
||
Generator.prototype.copyHtmlFiles = function (callback) { | ||
var self = this | ||
walkFiles(this.src, 'html', function (fileInfo, fileStats, next) { | ||
var contents = fs.readFileSync(fileInfo.fullPath) | ||
fs.writeFileSync(self.dest + '/' + fileInfo.relativePath, contents) | ||
next() | ||
}, function () { | ||
callback() | ||
}) | ||
} | ||
|
||
Generator.prototype.createDest = function () { | ||
if (this.dest == null) { | ||
this.dest = mktemp.createDirSync('broccoli-XXXXXX.tmp') | ||
} | ||
return this.dest | ||
} | ||
|
||
Generator.prototype.cleanup = function () { | ||
if (this.dest != null) { | ||
// This is asynchronous, but we don't wait for the directory to disappear | ||
rimraf(this.dest, function () { }) | ||
} | ||
this.dest = null | ||
} | ||
|
||
Generator.prototype.serve = function () { | ||
var self = this | ||
|
||
this.regenerate() | ||
|
||
var gaze = new Gaze([this.src + '/**/*', __dirname + '/vendor/**/*']); | ||
gaze.on('all', function () { | ||
self.regenerate() | ||
}) | ||
|
||
var server = hapi.createServer('localhost', 8000); | ||
|
||
// Add the route | ||
server.route({ | ||
method: 'GET', | ||
path: '/{path*}', | ||
handler: { | ||
directory: { | ||
path: function (request) { | ||
return self.dest | ||
} | ||
} | ||
} | ||
}); | ||
|
||
server.ext('onRequest', function (request, next) { | ||
// `synchronized` delays serving until we've finished regenerating | ||
synchronized(self, function (done) { | ||
next() | ||
done() | ||
}) | ||
}) | ||
|
||
// Start the server | ||
server.start(); | ||
} | ||
|
||
|
||
// Tree recursion helper to iterate over files with given extension | ||
var walkFiles = function (root, extension, fileCallback, endCallback) { | ||
var walker = walk.walk(root, {}) | ||
|
||
walker.on('names', function (fileRoot, nodeNamesArray) { | ||
nodeNamesArray.sort() | ||
}) | ||
|
||
walker.on('file', function (fileRoot, fileStats, next) { | ||
if (fileStats.name.slice(-(extension.length + 1)) === '.' + extension) { | ||
var fileInfo = {} | ||
fileInfo.fullPath = fileRoot + '/' + fileStats.name | ||
fileInfo.relativePath = fileInfo.fullPath.slice(root.length + 1) | ||
fileInfo.moduleName = fileInfo.relativePath.slice(0, -(extension.length + 1)) | ||
fileCallback(fileInfo, fileStats, next) | ||
} else { | ||
next() | ||
} | ||
}) | ||
|
||
walker.on('errors', function (fileRoot, nodeStatsArray, next) { | ||
// ERR | ||
console.error('Warning: unhandled error(s)', nodeStatsArray) | ||
next() | ||
}) | ||
|
||
walker.on('end', function () { | ||
endCallback() | ||
}) | ||
} | ||
|
||
|
||
var generator = new Generator('app') | ||
generator.serve() |
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,22 @@ | ||
{ | ||
"name": "broccoli", | ||
"description": "Fast client-side asset builder", | ||
"version": "0.0.2", | ||
"author": "Jo Liss <joliss42@gmail.com>", | ||
"main": "index.js", | ||
"license": "MIT", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/joliss/broccoli" | ||
}, | ||
|
||
"dependencies" : { | ||
"mktemp": "latest", | ||
"rimraf": "latest", | ||
"walk": "latest", | ||
"hapi": "latest", | ||
"gaze": "latest", | ||
"es6-module-transpiler": "latest", | ||
"synchronized": "latest" | ||
} | ||
} |
Oops, something went wrong.