Skip to content

Commit

Permalink
change project layout to ember-skeleton, this closes #7
Browse files Browse the repository at this point in the history
  • Loading branch information
pangratz committed Apr 7, 2012
1 parent 5c3db2b commit f318053
Show file tree
Hide file tree
Showing 35 changed files with 31,103 additions and 67 deletions.
133 changes: 133 additions & 0 deletions Assetfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
APPNAME = 'ember-skeleton'

require 'json'
require 'rake-pipeline-web-filters'

WebFilters = Rake::Pipeline::Web::Filters

class LoaderFilter < WebFilters::MinispadeFilter
def generate_output(inputs, output)
inputs.each do |input|
code = input.read
module_id = @module_id_generator.call(input)
contents = "function(require) {\n#{code}\n}"
ret = "\nloader.register('#{module_id}', #{contents});\n"
output.write ret
end
end
end

class EmberAssertFilter < Filter
def generate_output(inputs, output)
inputs.each do |input|
result = input.read
result.gsub!(/ember_assert\((.*)\);/, '')
output.write(result)
end
end
end

class HandlebarsFilter < Filter
def generate_output(inputs, output)
inputs.each do |input|
code = input.read.to_json
name = File.basename(input.path, '.handlebars')
output.write "\nreturn Ember.Handlebars.compile(#{code});\n"
end
end
end

output 'assets'

input 'app' do
match 'lib/**/*.js' do
filter LoaderFilter,
:module_id_generator => proc { |input|
input.path.sub(/^lib\//, "#{APPNAME}/").sub(/\.js$/, '')
}

if ENV['RAKEP_MODE'] == 'production'
filter EmberAssertFilter
uglify {|input| input}
end
concat 'app.js'
end

match 'vendor/**/*.js' do
filter LoaderFilter,
:module_id_generator => proc { |input|
input.path.sub(/^vendor\//, '').sub(/\.js$/, '')
}

if ENV['RAKEP_MODE'] == 'production'
filter EmberAssertFilter
uglify {|input| input}
end
concat %w[
vendor/jquery.js
vendor/ember.js
vendor/ember-data.js
vendor/sproutcore-routing.js
], 'app.js'
end

match 'modules/**/*.js' do
if ENV['RAKEP_MODE'] == 'production'
filter EmberAssertFilter
uglify {|input| input}
end
concat 'app.js'
end

match 'plugins/**/*.js' do
if ENV['RAKEP_MODE'] == 'production'
uglify {|input| input}
end
concat do |input|
input.sub(/plugins\//, '')
end
end

match 'templates/**/*.handlebars' do
filter HandlebarsFilter
filter LoaderFilter,
:module_id_generator => proc { |input|
input.path.sub(/^templates\//, "#{APPNAME}/~templates/").sub(/\.handlebars$/, '')
}
if ENV['RAKEP_MODE'] == 'production'
uglify {|input| input}
end
concat 'app.js'
end

match 'tests/**/*.js' do
filter LoaderFilter,
:module_id_generator => proc { |input|
input.path.sub(/^lib\//, "#{APPNAME}/").sub(/\.js$/, '')
}
concat 'app-tests.js'
end

match 'css/**/*.css' do
if ENV['RAKEP_MODE'] == 'production'
yui_css
end
concat ['bootstrap.css', 'main.css'], 'app.css'
end

match 'css/**/*.scss' do
sass
if ENV['RAKEP_MODE'] == 'production'
yui_css
end
concat 'app.css'
end

match "static/**/*" do
concat do |input|
input.sub(/static\//, '')
end
end
end

# vim: filetype=ruby
19 changes: 19 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
source :rubygems

gem 'colored'

gem 'guard'
gem 'guard-rake'

gem 'rack'
gem 'rack-rewrite'
# gem 'rack-streaming-proxy'

gem 'sass'
gem 'compass'

gem 'uglifier'
gem 'yui-compressor'

gem 'rake-pipeline', :git => 'https://github.com/livingsocial/rake-pipeline.git'
gem 'rake-pipeline-web-filters', :git => 'https://github.com/wycats/rake-pipeline-web-filters.git'
67 changes: 67 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
GIT
remote: https://github.com/livingsocial/rake-pipeline.git
revision: b70ca6cad7655e58d13031f3e24df7dfc74f9030
specs:
rake-pipeline (0.6.0)
rake (~> 0.9.0)
thor

GIT
remote: https://github.com/wycats/rake-pipeline-web-filters.git
revision: ba0b8a00356b4c854930a8e849b5629d51ffd70f
specs:
rake-pipeline-web-filters (0.6.0)
rack
rake-pipeline (~> 0.6)

GEM
remote: http://rubygems.org/
specs:
POpen4 (0.1.4)
Platform (>= 0.4.0)
open4
Platform (0.4.0)
chunky_png (1.2.5)
colored (1.2)
compass (0.12.1)
chunky_png (~> 1.2)
fssm (>= 0.2.7)
sass (~> 3.1)
execjs (1.3.0)
multi_json (~> 1.0)
ffi (1.0.11)
fssm (0.2.8.1)
guard (1.0.1)
ffi (>= 0.5.0)
thor (~> 0.14.6)
guard-rake (0.0.5)
guard
rake
multi_json (1.2.0)
open4 (1.3.0)
rack (1.4.1)
rack-rewrite (1.2.1)
rake (0.9.2.2)
sass (3.1.15)
thor (0.14.6)
uglifier (1.2.4)
execjs (>= 0.3.0)
multi_json (>= 1.0.2)
yui-compressor (0.9.6)
POpen4 (>= 0.1.4)

PLATFORMS
ruby

DEPENDENCIES
colored
compass
guard
guard-rake
rack
rack-rewrite
rake-pipeline!
rake-pipeline-web-filters!
sass
uglifier
yui-compressor
3 changes: 3 additions & 0 deletions Guardfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
guard :rake, :task => :test do
watch(%r{^app/.+\.js$})
end
13 changes: 13 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
Copyright (c) Clemens Müller and contributors

Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted, provided that the above
copyright notice and this permission notice appear in all copies.

THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
29 changes: 29 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
APPNAME = 'ember-skeleton'

require 'colored'
require 'rake-pipeline'

desc "Build #{APPNAME}"
task :build do
Rake::Pipeline::Project.new('Assetfile').invoke
end

desc "Run tests with PhantomJS"
task :test => :build do
unless system("which phantomjs > /dev/null 2>&1")
abort "PhantomJS is not installed. Download from http://phantomjs.org/"
end

cmd = "phantomjs tests/qunit/run-qunit.js \"file://#{File.dirname(__FILE__)}/tests/index.html\""

# Run the tests
puts "Running #{APPNAME} tests"
success = system(cmd)

if success
puts "Tests Passed".green
else
puts "Tests Failed".red
exit(1)
end
end
File renamed without changes.
3 changes: 3 additions & 0 deletions app/css/main.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
a {
cursor: pointer;
}
File renamed without changes.
5 changes: 5 additions & 0 deletions app/lib/core.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
require('jquery');
require('ember');
require('twitter-text');
require('moment');
require('ember-skeleton/ext');
19 changes: 19 additions & 0 deletions app/lib/ext.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
var get = Ember.get;

Ember.View.reopen({
templateForName: function(name, type) {
if (!name) { return; }

var templates = get(this, 'templates'),
template = get(templates, name);

if (!template) {
template = require(name);
if (!template) {
throw new Ember.Error(fmt('%@ - Unable to find %@ "%@".', [this, type, name]));
}
}

return template;
}
});
2 changes: 2 additions & 0 deletions js/app.js → app/lib/main.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
require('ember-skeleton/core');

Ember.Handlebars.registerHelper('echo',
function(propertyName, options) {
return Ember.getPath(options.contexts[0], propertyName);
Expand Down
10 changes: 10 additions & 0 deletions app/lib/routes.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// require('sproutcore-routing');

require('ember-skeleton/core');

App.routes = {

mainRoute: function(params) {
}

};
11 changes: 11 additions & 0 deletions app/lib/state_manager.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
require('ember-skeleton/core');
require('ember-skeleton/states/start');

App.stateManager = Ember.StateManager.create({

rootElement: '#main',
initialState: 'start',

start: App.StartState

});
9 changes: 9 additions & 0 deletions app/lib/states/start.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require('ember-skeleton/core');

App.StartState = Ember.ViewState.extend({

view: Ember.View.extend({
templateName: 'ember-skeleton/~templates/main_page'
})

});
3 changes: 3 additions & 0 deletions app/lib/store.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
require('ember-skeleton/core');

App.store = DS.Store.create();
Loading

0 comments on commit f318053

Please sign in to comment.