forked from sproutcore/abbot
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request sproutcore#76 from ChadEubanks/master
Statecharts by default when running sc-init. Use sc-init app --statechart
- Loading branch information
Showing
20 changed files
with
298 additions
and
16 deletions.
There are no files selected for viewing
Submodule sproutcore
deleted from
d79e36
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,36 @@ | ||
# ========================================================================== | ||
# Generator: APP | ||
# Copyright: ©2006-2011 Strobe Inc. and contributors | ||
# portions copyright ©2009 Apple Inc. | ||
# ========================================================================== | ||
|
||
namespace :generator do | ||
|
||
# Require a project then make sure the build root is always the project | ||
# root. | ||
task :prepare do | ||
GENERATOR.requires! :target_project | ||
|
||
# if the target name has a slash in it, then we are trying to create a | ||
# nested target. extract the final part (since this is the target name) | ||
# and then set the build root to the parent target. | ||
if GENERATOR.target_name && GENERATOR.target_name =~ /\// | ||
parent_target_name = GENERATOR.target_name.split('/') | ||
GENERATOR.target_name = parent_target_name.pop | ||
|
||
parent_target_name = parent_target_name * "/" | ||
project = GENERATOR.target_project | ||
|
||
GENERATOR.parent_target_name = parent_target_name | ||
GENERATOR.parent_target = project.target_for(parent_target_name) | ||
GENERATOR.requires! :parent_target, :parent_target_name | ||
|
||
GENERATOR.build_root = GENERATOR.parent_target.source_root | ||
|
||
# otherwise just use project_root | ||
else | ||
GENERATOR.build_root = GENERATOR.target_project.project_root | ||
end | ||
end | ||
|
||
end |
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 @@ | ||
Your application target is now ready to use! |
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 @@ | ||
statechart_app - Create a new SproutCore application target using statecharts. | ||
|
||
USAGE: | ||
|
||
sc-gen app AppName [--filename=FILENAME] [--target=TARGET_NAME] | ||
|
||
DISCUSSION: | ||
|
||
This generator will create a new SproutCore application with statecharts by default for a particular project. You should pass as the first parameter your AppName you want to create followed by the --statechart switch. For example: | ||
|
||
sc-gen app Todos --statechart | ||
|
||
This defines a new application called Todos in the file apps/todos/. Within the apps/Todos/resources directory you will have a statechart.js file and a states directory with the ready_state.js file. The statechart.js file sets the initial state of your app to ready. As your app grows. You will create new states within the statechart.js file. In your states folder you will describe the states declared in the statechart.js. |
9 changes: 9 additions & 0 deletions
9
lib/gen/statechart_app/templates/apps/@target_name@/Buildfile
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 @@ | ||
<%= copyright_block(namespace, :ruby) %> | ||
|
||
# This is your Buildfile for your app, <%= namespace %>. This tells SproutCore | ||
# how to build your app. These settings override those in your project | ||
# Buildfile, which contains default settings for all apps in your project. | ||
|
||
# It is better to add :required targets here than in the global Buildfile. | ||
config :<%= target_name %>, :required => :sproutcore | ||
|
24 changes: 24 additions & 0 deletions
24
lib/gen/statechart_app/templates/apps/@target_name@/core.js
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,24 @@ | ||
<%= copyright_block(namespace) %> | ||
/*globals <%= namespace %> */ | ||
|
||
/** @namespace | ||
My cool new app. Describe your application. | ||
@extends SC.Object | ||
*/ | ||
<%= namespace %> = SC.Application.create( | ||
/** @scope <%= namespace %>.prototype */ { | ||
|
||
NAMESPACE: '<%= namespace %>', | ||
VERSION: '0.1.0', | ||
|
||
// This is your application store. You will use this store to access all | ||
// of your model data. You can also set a data source on this store to | ||
// connect to a backend server. The default setup below connects the store | ||
// to any fixtures you define. | ||
store: SC.Store.create().from(SC.Record.fixtures) | ||
|
||
// TODO: Add global constants or singleton objects needed by your app here. | ||
|
||
}) ; |
26 changes: 26 additions & 0 deletions
26
lib/gen/statechart_app/templates/apps/@target_name@/main.js
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,26 @@ | ||
<%= copyright_block(namespace) %> | ||
/*globals <%= namespace %> */ | ||
|
||
// This is the function that will start your app running. The default | ||
// implementation will load any fixtures you have created then instantiate | ||
// your controllers and awake the elements on your page. | ||
// | ||
// As you develop your application you will probably want to override this. | ||
// See comments for some pointers on what to do next. | ||
// | ||
<%= namespace %>.main = function main() { | ||
|
||
// Step 1: Tell your app it will load via states | ||
var statechart = <%= namespace %>.statechart; | ||
SC.RootResponder.responder.set('defaultResponder', statechart); | ||
statechart.initStatechart(); | ||
|
||
// Step 2. Set the content property on your primary controller. | ||
// This will make your app come alive! | ||
|
||
// TODO: Set the content property on your primary controller | ||
// ex: MyApp.contactsController.set('content', MyApp.contacts); | ||
|
||
} ; | ||
|
||
function main() { <%= namespace %>.main(); } |
18 changes: 18 additions & 0 deletions
18
lib/gen/statechart_app/templates/apps/@target_name@/resources/_theme.css
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 @@ | ||
/* | ||
This defines the global $theme variable for use inside your CSS. | ||
The $theme variable holds the CSS class names for your theme. | ||
You can then theme your app by using CSS like this: | ||
$theme.button { | ||
color: blue; | ||
@include slices('white-button.png', $left: 3, $right: 3); | ||
} | ||
Any _theme.css file is prepended to all files inside its directory, | ||
and any subdirectories that don't define their own _theme.css file. | ||
This allows you to give different directories different values for | ||
$theme if you wish. | ||
*/ | ||
$theme: '.ace.<%= css_name %>'; |
9 changes: 9 additions & 0 deletions
9
lib/gen/statechart_app/templates/apps/@target_name@/resources/loading.rhtml
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 @@ | ||
<%% content_for :loading do %> | ||
<%% # Any HTML in this file will be visible on screen while your page loads | ||
# its application JavaScript. SproutCore applications are optimized for | ||
# caching and startup very fast, so your users will often only see this | ||
# content for a brief moment on their first app load, if at all. | ||
%> | ||
<p class="loading">Loading...<p> | ||
|
||
<%% end %> |
21 changes: 21 additions & 0 deletions
21
lib/gen/statechart_app/templates/apps/@target_name@/resources/main_page.js
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 @@ | ||
<%= copyright_block("#{namespace} - mainPage") %> | ||
/*globals <%= namespace %> */ | ||
|
||
// This page describes the main user interface for your application. | ||
<%= namespace %>.mainPage = SC.Page.design({ | ||
|
||
// The main pane is made visible on screen as soon as your app is loaded. | ||
// Add childViews to this pane for views to display immediately on page | ||
// load. | ||
mainPane: SC.MainPane.design({ | ||
childViews: 'labelView'.w(), | ||
|
||
labelView: SC.LabelView.design({ | ||
layout: { centerX: 0, centerY: 0, width: 200, height: 18 }, | ||
textAlign: SC.ALIGN_CENTER, | ||
tagName: "h1", | ||
value: "Welcome to SproutCore!" | ||
}) | ||
}) | ||
|
||
}); |
8 changes: 8 additions & 0 deletions
8
lib/gen/statechart_app/templates/apps/@target_name@/statechart.js
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 @@ | ||
<%= namespace %>.statechart = SC.Statechart.create({ | ||
|
||
initialState: 'readyState', | ||
|
||
readyState: SC.State.plugin('<%= namespace %>.ReadyState'), | ||
// someOtherState: SC.State.plugin('<%= namespace %>.SomeOtherState') | ||
|
||
}); |
12 changes: 12 additions & 0 deletions
12
lib/gen/statechart_app/templates/apps/@target_name@/states/ready_state.js
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,12 @@ | ||
<%= namespace %>.ReadyState = SC.State.extend({ | ||
|
||
enterState: function() { | ||
<%= namespace %>.getPath('mainPage.mainPane').append(); | ||
}, | ||
|
||
exitState: function() { | ||
<%= namespace %>.getPath('mainPage.mainPane').remove(); | ||
} | ||
|
||
}); | ||
|
24 changes: 24 additions & 0 deletions
24
lib/gen/statechart_app/templates/apps/@target_name@/theme.js
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,24 @@ | ||
<%= copyright_block(namespace) %> | ||
/*globals <%= namespace %> */ | ||
|
||
// This is the theme that defines how your app renders. | ||
// | ||
// Your app is given its own theme so it is easier and less | ||
// messy for you to override specific things just for your | ||
// app. | ||
// | ||
// You don't have to create the whole theme on your own, though: | ||
// your app's theme is based on SproutCore's Ace theme. | ||
// | ||
// NOTE: if you want to change the theme this one is based on, don't | ||
// forget to change the :css_theme property in your buildfile. | ||
<%= namespace %>.Theme = SC.AceTheme.create({ | ||
name: '<%= css_name %>' | ||
}); | ||
|
||
// SproutCore needs to know that your app's theme exists | ||
SC.Theme.addTheme(<%= namespace %>.Theme); | ||
|
||
// Setting it as the default theme makes every pane SproutCore | ||
// creates default to this theme unless otherwise specified. | ||
SC.defaultTheme = '<%= css_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,45 @@ | ||
# ========================================================================== | ||
# Generator: PROJECT | ||
# Copyright: ©2006-2011 Strobe Inc. and contributors | ||
# portions copyright ©2009 Apple Inc. | ||
# ========================================================================== | ||
|
||
namespace :generator do | ||
|
||
# Accept the following types of arguments: | ||
# | ||
# project . #=> Make current working directory. like sc-init | ||
# project project_name #=> Create project_name, namespace: ProjectName | ||
# project ProjectName #=> Create project_name, namespace: ProjectName | ||
# project NameSpace path/to/project #=> Create path/to/project, NameSpace | ||
# | ||
task :prepare do | ||
# get arguments & normalize | ||
gen = GENERATOR | ||
namespace = gen.arguments[1] | ||
project_path = gen.arguments[2] | ||
|
||
if project_path | ||
project_path = File.expand_path(project_path) | ||
namespace = File.basename(project_path) if namespace == '.' | ||
elsif namespace == '.' | ||
project_path = Dir.pwd | ||
namespace = File.basename(project_path) | ||
else | ||
project_path = Dir.pwd / gen.snake_case(namespace) | ||
end | ||
|
||
# Setup standard options for generating a project | ||
gen.target_name = gen.target = gen.method_name = gen.class_name = nil | ||
gen.build_root = File.dirname(project_path) # dir where project dir lives | ||
gen.filename = File.basename(project_path) # project dir name | ||
gen.namespace = gen.camel_case namespace | ||
end | ||
|
||
end | ||
|
||
# default behavior for a template is to just copy the contents of the | ||
# templates directory to the end destination. Add any additional configs here. | ||
config :templates, | ||
:root_dir => '_file_path_' | ||
|
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 @@ | ||
Your new SproutCore project with StateCharts is ready! | ||
|
||
To get started, you can find your initial application in the "apps" directory. | ||
|
||
Within the apps/appname directory you will have a statechart.js file and a states directory with the ready_state.js file. | ||
|
||
The statechart.js file sets the initial state of your app to ready. And as your app grows. You will create new states within the statechart.js file. In your states folder you will describe the states declared in the statechart.js. |
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 @@ | ||
Your project is now ready to use! |
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 @@ | ||
Usage: | ||
sc-gen project project_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,9 @@ | ||
<%= copyright_block(namespace, :ruby) %> | ||
|
||
# This is your Buildfile, which sets build settings for your project. | ||
# For example, this tells SproutCore's build tools that EVERYTHING | ||
# requires the SproutCore framework. | ||
config :all, :required => :sproutcore | ||
|
||
# In addition to this Buildfile, which gives settings for your entire project, | ||
# each of your apps has its own Buildfile with settings specific to that app. |
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 @@ | ||
<%= copyright_block(namespace, false) %> | ||
|
||
TODO: Describe Your Project |
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