restfulx 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/History.txt +7 -0
- data/Manifest.txt +127 -0
- data/README.rdoc +50 -0
- data/Rakefile +42 -0
- data/app_generators/rx_app/USAGE +22 -0
- data/app_generators/rx_app/rx_app_generator.rb +94 -0
- data/app_generators/rx_app/templates/actionscript.properties +16 -0
- data/app_generators/rx_app/templates/actionscriptair.properties +16 -0
- data/app_generators/rx_app/templates/app.yaml.erb +12 -0
- data/app_generators/rx_app/templates/default_tasks.rake +51 -0
- data/app_generators/rx_app/templates/empty.txt +0 -0
- data/app_generators/rx_app/templates/expressInstall.swf +0 -0
- data/app_generators/rx_app/templates/flex.properties +2 -0
- data/app_generators/rx_app/templates/generate.rb +17 -0
- data/app_generators/rx_app/templates/html-template/AC_OETags.js +276 -0
- data/app_generators/rx_app/templates/html-template/history/history.css +6 -0
- data/app_generators/rx_app/templates/html-template/history/history.js +645 -0
- data/app_generators/rx_app/templates/html-template/history/historyFrame.html +29 -0
- data/app_generators/rx_app/templates/html-template/index.template.html +121 -0
- data/app_generators/rx_app/templates/html-template/playerProductInstall.swf +0 -0
- data/app_generators/rx_app/templates/index.html.erb +18 -0
- data/app_generators/rx_app/templates/index.yaml +11 -0
- data/app_generators/rx_app/templates/mainair-app.xml +134 -0
- data/app_generators/rx_app/templates/mainapp-config.xml +21 -0
- data/app_generators/rx_app/templates/mainapp.mxml +31 -0
- data/app_generators/rx_app/templates/project-textmate.erb +52 -0
- data/app_generators/rx_app/templates/project.properties +18 -0
- data/app_generators/rx_app/templates/projectair.properties +24 -0
- data/app_generators/rx_app/templates/swfobject.js +5 -0
- data/bin/rx-gen +31 -0
- data/generators/rx_config/USAGE +5 -0
- data/generators/rx_config/rx_config_generator.rb +19 -0
- data/generators/rx_controller/USAGE +10 -0
- data/generators/rx_controller/rx_controller_generator.rb +39 -0
- data/generators/rx_controller/templates/assist.py +65 -0
- data/generators/rx_controller/templates/controller.as.erb +36 -0
- data/generators/rx_controller/templates/restful.py +136 -0
- data/generators/rx_main_app/USAGE +8 -0
- data/generators/rx_main_app/rx_main_app_generator.rb +60 -0
- data/generators/rx_main_app/templates/main.py.erb +29 -0
- data/generators/rx_main_app/templates/mainapp.mxml +35 -0
- data/generators/rx_scaffold/USAGE +29 -0
- data/generators/rx_scaffold/rx_scaffold_generator.rb +146 -0
- data/generators/rx_scaffold/templates/component.mxml.erb +149 -0
- data/generators/rx_scaffold/templates/controller.py.erb +27 -0
- data/generators/rx_scaffold/templates/model.as.erb +42 -0
- data/generators/rx_scaffold/templates/model.py.erb +14 -0
- data/generators/rx_yaml_scaffold/USAGE +45 -0
- data/generators/rx_yaml_scaffold/rx_yaml_scaffold_generator.rb +47 -0
- data/lib/restfulx/active_foo.rb +186 -0
- data/lib/restfulx/active_record_tasks.rb +81 -0
- data/lib/restfulx/configuration.rb +76 -0
- data/lib/restfulx/datamapper_foo.rb +31 -0
- data/lib/restfulx/rails/recipes.rb +60 -0
- data/lib/restfulx/rails/swf_helper.rb +60 -0
- data/lib/restfulx/tasks.rb +85 -0
- data/lib/restfulx.rb +117 -0
- data/rails_generators/rx_config/USAGE +18 -0
- data/rails_generators/rx_config/rx_config_generator.rb +115 -0
- data/rails_generators/rx_config/templates/actionscript.properties +16 -0
- data/rails_generators/rx_config/templates/actionscriptair.properties +16 -0
- data/rails_generators/rx_config/templates/expressInstall.swf +0 -0
- data/rails_generators/rx_config/templates/flex.properties +2 -0
- data/rails_generators/rx_config/templates/html-template/AC_OETags.js +276 -0
- data/rails_generators/rx_config/templates/html-template/history/history.css +6 -0
- data/rails_generators/rx_config/templates/html-template/history/history.js +645 -0
- data/rails_generators/rx_config/templates/html-template/history/historyFrame.html +29 -0
- data/rails_generators/rx_config/templates/html-template/index.template.html +121 -0
- data/rails_generators/rx_config/templates/html-template/playerProductInstall.swf +0 -0
- data/rails_generators/rx_config/templates/index.html.erb +18 -0
- data/rails_generators/rx_config/templates/mainair-app.xml +134 -0
- data/rails_generators/rx_config/templates/mainapp-config.xml +21 -0
- data/rails_generators/rx_config/templates/mainapp.mxml +31 -0
- data/rails_generators/rx_config/templates/project-textmate.erb +52 -0
- data/rails_generators/rx_config/templates/project.properties +18 -0
- data/rails_generators/rx_config/templates/projectair.properties +24 -0
- data/rails_generators/rx_config/templates/restfulx.yml +14 -0
- data/rails_generators/rx_config/templates/restfulx_tasks.rake +6 -0
- data/rails_generators/rx_config/templates/swfobject.js +5 -0
- data/rails_generators/rx_controller/USAGE +10 -0
- data/rails_generators/rx_controller/rx_controller_generator.rb +28 -0
- data/rails_generators/rx_controller/templates/controller.as.erb +40 -0
- data/rails_generators/rx_scaffold/USAGE +35 -0
- data/rails_generators/rx_scaffold/rx_scaffold_generator.rb +179 -0
- data/rails_generators/rx_scaffold/templates/component.mxml.erb +149 -0
- data/rails_generators/rx_scaffold/templates/controller.rb.erb +97 -0
- data/rails_generators/rx_scaffold/templates/fixtures.yml.erb +35 -0
- data/rails_generators/rx_scaffold/templates/migration.rb.erb +19 -0
- data/rails_generators/rx_scaffold/templates/model.as.erb +42 -0
- data/rails_generators/rx_scaffold/templates/model.rb.erb +11 -0
- data/rails_generators/rx_yaml_scaffold/USAGE +51 -0
- data/rails_generators/rx_yaml_scaffold/rx_yaml_scaffold_generator.rb +49 -0
- data/rdoc/generators/template/html/jamis.rb +588 -0
- data/spec/restfulx_spec.rb +7 -0
- data/spec/spec_helper.rb +16 -0
- data/tasks/ann.rake +80 -0
- data/tasks/bones.rake +20 -0
- data/tasks/gem.rake +201 -0
- data/tasks/git.rake +40 -0
- data/tasks/manifest.rake +48 -0
- data/tasks/notes.rake +27 -0
- data/tasks/post_load.rake +39 -0
- data/tasks/rdoc.rake +50 -0
- data/tasks/rubyforge.rake +55 -0
- data/tasks/setup.rb +279 -0
- data/tasks/spec.rake +54 -0
- data/tasks/svn.rake +47 -0
- data/tasks/test.rake +40 -0
- data/test/rails/controllers/application.rb +15 -0
- data/test/rails/controllers/locations_controller.rb +93 -0
- data/test/rails/controllers/notes_controller.rb +96 -0
- data/test/rails/controllers/projects_controller.rb +93 -0
- data/test/rails/controllers/tasks_controller.rb +93 -0
- data/test/rails/controllers/users_controller.rb +93 -0
- data/test/rails/database.yml +4 -0
- data/test/rails/fixtures/locations.yml +8 -0
- data/test/rails/fixtures/notes.yml +17 -0
- data/test/rails/fixtures/projects.yml +25 -0
- data/test/rails/fixtures/simple_properties.yml +19 -0
- data/test/rails/fixtures/tasks.yml +46 -0
- data/test/rails/fixtures/users.yml +13 -0
- data/test/rails/helpers/functional_test_helper.rb +21 -0
- data/test/rails/helpers/test_helper.rb +61 -0
- data/test/rails/helpers/unit_test_helper.rb +30 -0
- data/test/rails/model.yml +35 -0
- data/test/rails/models/location.rb +4 -0
- data/test/rails/models/note.rb +3 -0
- data/test/rails/models/project.rb +4 -0
- data/test/rails/models/simple_property.rb +2 -0
- data/test/rails/models/task.rb +18 -0
- data/test/rails/models/user.rb +20 -0
- data/test/rails/playing_around_in_a_console.txt +71 -0
- data/test/rails/schema.rb +77 -0
- data/test/rails/test.swf +1 -0
- data/test/rails/test_active_foo.rb +36 -0
- data/test/rails/test_rails_integration_functional.rb +22 -0
- data/test/rails/test_to_fxml.rb +35 -0
- data/test/rails/test_to_json.rb +23 -0
- data/test/rails/views/notes/empty_params_action.html.erb +1 -0
- data/test/rails/views/notes/index.html.erb +1 -0
- metadata +227 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
# Rake tasks for building RestfulX-based Flex and AIR applications
|
|
2
|
+
require 'rake'
|
|
3
|
+
require 'ftools'
|
|
4
|
+
require 'rexml/document'
|
|
5
|
+
require File.join(File.dirname(__FILE__), 'configuration')
|
|
6
|
+
|
|
7
|
+
APP_ROOT = RestfulX::Configuration::APP_ROOT
|
|
8
|
+
|
|
9
|
+
namespace :rx do
|
|
10
|
+
# Compile the main Flex/AIR application using given executable to the given
|
|
11
|
+
# destination folder
|
|
12
|
+
def compile_app(executable, destination, opts = '')
|
|
13
|
+
app_properties = REXML::Document.new(File.open(File.join(APP_ROOT, ".actionScriptProperties")))
|
|
14
|
+
app_properties.elements.each("*/applications/application") do |elm|
|
|
15
|
+
app_path = elm.attributes['path']
|
|
16
|
+
project_path = File.join(APP_ROOT, "app/flex", app_path)
|
|
17
|
+
target_project_path = project_path.sub(/.mxml$/, '.swf')
|
|
18
|
+
target_project_air_descriptor = project_path.sub(/.mxml$/, '-app.xml')
|
|
19
|
+
|
|
20
|
+
libs = Dir.glob(File.join(APP_ROOT, 'lib', '*.swc')).map {|lib| lib.gsub(' ', '\ ')}
|
|
21
|
+
|
|
22
|
+
cmd = "#{executable} #{opts} -library-path+=#{libs.join(',')} " <<
|
|
23
|
+
"-keep-as3-metadata+=Resource,HasOne,HasMany,BelongsTo,DateTime,Lazy,Ignored #{project_path.gsub(' ', '\ ')}"
|
|
24
|
+
puts "Compiling #{project_path}"
|
|
25
|
+
if system(cmd)
|
|
26
|
+
FileUtils.makedirs File.join(APP_ROOT, destination)
|
|
27
|
+
puts "Moving #{target_project_path} to " + File.join(APP_ROOT, destination)
|
|
28
|
+
FileUtils.mv target_project_path, File.join(APP_ROOT, destination), :force => true
|
|
29
|
+
if File.exist?(target_project_air_descriptor)
|
|
30
|
+
descriptor = File.read(target_project_air_descriptor)
|
|
31
|
+
descriptor_name = target_project_air_descriptor.split("/").last
|
|
32
|
+
app_swf = target_project_path.split("/").last
|
|
33
|
+
descriptor.gsub!("[This value will be overwritten by Flex Builder in the output app.xml]",
|
|
34
|
+
app_swf)
|
|
35
|
+
|
|
36
|
+
File.open("#{APP_ROOT}/#{destination}/#{descriptor_name}", "w") do |file|
|
|
37
|
+
file.print descriptor
|
|
38
|
+
end
|
|
39
|
+
puts "Created #{APP_ROOT}/#{destination}/#{descriptor_name} descriptor."
|
|
40
|
+
end
|
|
41
|
+
puts 'Done!'
|
|
42
|
+
else
|
|
43
|
+
puts "The application was not compiled. Check console for errors. " <<
|
|
44
|
+
"It is possible that '(a)mxmlc' executable was not found or there are compilation errors."
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
# Find what the main application is based on .actionScriptProperties file
|
|
50
|
+
def get_main_application
|
|
51
|
+
app_properties = REXML::Document.new(File.open(File.join(APP_ROOT, ".actionScriptProperties")))
|
|
52
|
+
app_properties.root.attributes['mainApplicationPath'].split("/").last
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
# Get appropriate executable based on platform
|
|
56
|
+
def get_executable(executable)
|
|
57
|
+
if RUBY_PLATFORM =~ /mswin32/
|
|
58
|
+
executable << '.exe'
|
|
59
|
+
end
|
|
60
|
+
executable
|
|
61
|
+
end
|
|
62
|
+
|
|
63
|
+
namespace :flex do
|
|
64
|
+
desc "Build project swf file and move it into public/bin folder"
|
|
65
|
+
task :build do
|
|
66
|
+
compile_app(get_executable('mxmlc'), 'public/bin')
|
|
67
|
+
end
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
namespace :air do
|
|
71
|
+
desc "Build project swf file as an AIR application and move it into bin-debug folder"
|
|
72
|
+
task :build do
|
|
73
|
+
compile_app(get_executable('mxmlc'), 'bin-debug', '+configname=air')
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
desc "Run the AIR application (if this project is configured as an AIR project)"
|
|
77
|
+
task :run do
|
|
78
|
+
target = get_main_application.gsub(/.mxml$/, '-app.xml')
|
|
79
|
+
puts "Running AIR application with descriptor: #{target}"
|
|
80
|
+
if !system("#{get_executable('adl')} bin-debug/#{target}")
|
|
81
|
+
puts "Could not run the application with descriptor: #{target}. Check console for errors."
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
end
|
|
85
|
+
end
|
data/lib/restfulx.rb
ADDED
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
# Sets up all the relevant configuration options and brings together
|
|
2
|
+
# patches for Rails, Merb, ActiveRecord and Data Mapper.
|
|
3
|
+
#
|
|
4
|
+
# Loads RestfulX specific rake tasks if appropriate.
|
|
5
|
+
module RestfulX
|
|
6
|
+
|
|
7
|
+
# :stopdoc:
|
|
8
|
+
VERSION = '1.2.0'
|
|
9
|
+
FRAMEWORK_VERSION = '1.2.0'
|
|
10
|
+
LIB_DIR = File.join(File.dirname(__FILE__), 'restfulx/')
|
|
11
|
+
# :startdoc:
|
|
12
|
+
|
|
13
|
+
# Returns the version string for the library.
|
|
14
|
+
#
|
|
15
|
+
def self.version
|
|
16
|
+
VERSION
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
# Utility method used to require all files ending in .rb that lie in the
|
|
20
|
+
# directory below this file that has the same name as the filename passed
|
|
21
|
+
# in. Optionally, a specific _directory_ name can be passed in such that
|
|
22
|
+
# the _filename_ does not have to be equivalent to the directory.
|
|
23
|
+
#
|
|
24
|
+
def self.require_all_libs_relative_to( fname, dir = nil )
|
|
25
|
+
dir ||= ::File.basename(fname, '.*')
|
|
26
|
+
search_me = ::File.expand_path(
|
|
27
|
+
::File.join(::File.dirname(fname), dir, '*', '*.rb'))
|
|
28
|
+
|
|
29
|
+
Dir.glob(search_me).sort.each {|rb| require rb}
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
require RestfulX::LIB_DIR + 'configuration'
|
|
35
|
+
|
|
36
|
+
# make sure we're running inside Merb
|
|
37
|
+
if defined?(Merb::Plugins)
|
|
38
|
+
Merb::Plugins.add_rakefiles RestfulX::LIB_DIR + 'tasks'
|
|
39
|
+
|
|
40
|
+
Merb::BootLoader.before_app_loads do
|
|
41
|
+
|
|
42
|
+
if defined?(ActiveRecord::Base)
|
|
43
|
+
Merb.add_mime_type(:fxml, :to_fxml, %w[application/xml text/xml application/x-xml], :charset => "utf-8")
|
|
44
|
+
['active_foo', 'active_record_default_methods'].each { |lib| require RestfulX::LIB_DIR + lib }
|
|
45
|
+
Merb::Plugins.add_rakefiles RestfulX::LIB_DIR + 'active_record_tasks'
|
|
46
|
+
else
|
|
47
|
+
Merb.add_mime_type(:fxml, :to_xml, %w[application/xml text/xml application/x-xml], :charset => "utf-8")
|
|
48
|
+
if defined?(Merb::Orms::DataMapper)
|
|
49
|
+
require RestfulX::LIB_DIR + 'datamapper_foo'
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
end
|
|
53
|
+
elsif defined?(ActionController::Base)
|
|
54
|
+
# if we are not running in Merb, try to hook up Rails
|
|
55
|
+
Mime::Type.register_alias "application/xml", :fxml
|
|
56
|
+
|
|
57
|
+
['active_foo', 'rails/swf_helper'].each { |lib| require RestfulX::LIB_DIR + lib }
|
|
58
|
+
|
|
59
|
+
ActionView::Base.send :include, SWFHelper unless ActionView::Base.included_modules.include?(SWFHelper)
|
|
60
|
+
|
|
61
|
+
# We mess with default +render+ implementation a bit to add support for expressions
|
|
62
|
+
# such as format.fxml { render :fxml => @foo }
|
|
63
|
+
module ActionController
|
|
64
|
+
# Override render to add support for render :fxml
|
|
65
|
+
class Base
|
|
66
|
+
alias_method :old_render, :render unless method_defined?(:old_render)
|
|
67
|
+
|
|
68
|
+
# so that we can have handling for :fxml option and write code like
|
|
69
|
+
# format.fxml { render :fxml => @projects }
|
|
70
|
+
def render(options = nil, extra_options = {}, &block)
|
|
71
|
+
if options.is_a?(Hash) && options[:fxml]
|
|
72
|
+
xml = options[:fxml]
|
|
73
|
+
response.content_type ||= Mime::XML
|
|
74
|
+
render_for_text(xml.respond_to?(:to_fxml) ? xml.to_fxml : xml, options[:status])
|
|
75
|
+
else
|
|
76
|
+
old_render(options, extra_options, &block)
|
|
77
|
+
end
|
|
78
|
+
end
|
|
79
|
+
end
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
# It is possible to pass metadata with any RestfulX model. This module adds support for
|
|
83
|
+
# extracting that metadata into the standard params hash.
|
|
84
|
+
module RxController
|
|
85
|
+
private
|
|
86
|
+
|
|
87
|
+
# Extract any keys named _metadata from the models in the params hash
|
|
88
|
+
# and put them in the root of the params hash.
|
|
89
|
+
def extract_metadata_from_params
|
|
90
|
+
metadata = {}
|
|
91
|
+
metadata.merge!(params.delete('_metadata')) if params.has_key?('_metadata')
|
|
92
|
+
params.each do |k, v|
|
|
93
|
+
next unless v.respond_to?(:has_key?) and v.has_key?('_metadata')
|
|
94
|
+
metadata.merge!(v.delete('_metadata'))
|
|
95
|
+
end
|
|
96
|
+
params.merge!(metadata) unless metadata.empty?
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
module ActiveRecord
|
|
101
|
+
# ActiveRecord named scopes are computed *before* restfulx gem gets loaded
|
|
102
|
+
# this patch addresses that and makes sure +to_fxml+ calls are properly
|
|
103
|
+
# delegated
|
|
104
|
+
module NamedScope
|
|
105
|
+
# make sure we properly delegate +to_fxml+ calls to the proxy
|
|
106
|
+
class Scope
|
|
107
|
+
delegate :to_fxml, :to => :proxy_found
|
|
108
|
+
end
|
|
109
|
+
end
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
ActionController::Base.send :include, RxController
|
|
113
|
+
ActionController::Base.send :prepend_before_filter, :extract_metadata_from_params
|
|
114
|
+
|
|
115
|
+
# temporarily disable forgery protection site-wise
|
|
116
|
+
ActionController::Base.allow_forgery_protection = false
|
|
117
|
+
end
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
Description:
|
|
2
|
+
Generates the primary RestfulX directory structure, sets up Flex Builder
|
|
3
|
+
specific descriptor files and options fetches the latest published
|
|
4
|
+
RestfulX Framework SWC file.
|
|
5
|
+
|
|
6
|
+
You can generate Flex Builder configuration for either *pure* Flex
|
|
7
|
+
project or an AIR project. To generate AIR configuration pass the -a
|
|
8
|
+
(--air) option to the generator.
|
|
9
|
+
|
|
10
|
+
Examples:
|
|
11
|
+
`./script/generate rx_config` # generates project structure and a
|
|
12
|
+
# default Flex app configuration. Fetches
|
|
13
|
+
# latest RestfulX framework SWC to "lib"
|
|
14
|
+
# folder
|
|
15
|
+
`./script/generate rx_config -a` # as above but generates an AIR app
|
|
16
|
+
# and configuration
|
|
17
|
+
`./script/generate rx_config -s` # generates Flex app but does not fetch
|
|
18
|
+
# the RestfulX framework SWC.
|
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
require 'open-uri'
|
|
2
|
+
require File.join(File.dirname(__FILE__), '..', '..', 'lib', 'restfulx') if !defined?(RestfulX)
|
|
3
|
+
|
|
4
|
+
class RxConfigGenerator < Rails::Generator::Base
|
|
5
|
+
include RestfulX::Configuration
|
|
6
|
+
|
|
7
|
+
attr_reader :project_name,
|
|
8
|
+
:flex_project_name,
|
|
9
|
+
:base_package,
|
|
10
|
+
:base_folder,
|
|
11
|
+
:command_controller_name,
|
|
12
|
+
:component_names,
|
|
13
|
+
:application_tag,
|
|
14
|
+
:use_air
|
|
15
|
+
|
|
16
|
+
def initialize(runtime_args, runtime_options = {})
|
|
17
|
+
super
|
|
18
|
+
@project_name, @flex_project_name, @command_controller_name, @base_package, @base_folder = extract_names
|
|
19
|
+
|
|
20
|
+
# if we are updating main file only we probably want to maintain the type of project it is
|
|
21
|
+
if options[:main_only]
|
|
22
|
+
project_file_name = APP_ROOT + '/.project'
|
|
23
|
+
if File.exist?(project_file_name)
|
|
24
|
+
puts "Cannot combine -m (--main-app) and -a (--air) flags at the same time for an existing application.\n" <<
|
|
25
|
+
'If you want to convert to AIR, remove -m flag.' if options[:air_config]
|
|
26
|
+
@use_air = true if File.read(project_file_name) =~/com.adobe.flexbuilder.apollo.apollobuilder/m
|
|
27
|
+
else
|
|
28
|
+
puts "Flex Builder project file doesn't exist. You should run 'rx_config' with -a (--air) option " <<
|
|
29
|
+
"or no arguments first to generate primary project structure."
|
|
30
|
+
exit 0;
|
|
31
|
+
end
|
|
32
|
+
else
|
|
33
|
+
@use_air = options[:air_config]
|
|
34
|
+
end
|
|
35
|
+
|
|
36
|
+
if @use_air
|
|
37
|
+
@application_tag = 'WindowedApplication'
|
|
38
|
+
else
|
|
39
|
+
@application_tag = 'Application'
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
@component_names = []
|
|
43
|
+
if File.exists?("app/flex/#{base_folder}/components/generated")
|
|
44
|
+
@component_names = list_mxml_files("app/flex/#{base_folder}/components/generated")
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
def manifest
|
|
49
|
+
record do |m|
|
|
50
|
+
if !options[:main_only]
|
|
51
|
+
m.file 'restfulx_tasks.rake', 'lib/tasks/restfulx_tasks.rake'
|
|
52
|
+
m.file 'flex.properties', '.flexProperties'
|
|
53
|
+
m.file 'restfulx.yml', 'config/restfulx.yml'
|
|
54
|
+
if @use_air
|
|
55
|
+
m.template 'actionscriptair.properties', '.actionScriptProperties'
|
|
56
|
+
m.template 'projectair.properties', '.project'
|
|
57
|
+
else
|
|
58
|
+
m.template 'actionscript.properties', '.actionScriptProperties'
|
|
59
|
+
m.template 'project.properties', '.project'
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
m.directory 'html-template/history'
|
|
63
|
+
%w(index.template.html AC_OETags.js playerProductInstall.swf).each do |file|
|
|
64
|
+
m.file "html-template/#{file}", "html-template/#{file}"
|
|
65
|
+
end
|
|
66
|
+
|
|
67
|
+
%w(history.css history.js historyFrame.html).each do |file|
|
|
68
|
+
m.file "html-template/history/#{file}", "html-template/history/#{file}"
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
%w(components controllers commands models events).each do |dir|
|
|
72
|
+
m.directory "app/flex/#{base_folder}/#{dir}"
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
m.directory "app/flex/#{base_folder}/components/generated"
|
|
76
|
+
|
|
77
|
+
framework_release = RestfulX::FRAMEWORK_VERSION
|
|
78
|
+
framework_distribution_url = "http://restfulx.github.com/releases/restfulx-#{framework_release}.swc"
|
|
79
|
+
framework_destination_file = "lib/restfulx-#{framework_release}.swc"
|
|
80
|
+
|
|
81
|
+
if !options[:skip_framework] && !File.exist?(framework_destination_file)
|
|
82
|
+
puts "fetching #{framework_release} framework binary from: #{framework_distribution_url} ..."
|
|
83
|
+
open(framework_destination_file, "wb").write(open(framework_distribution_url).read)
|
|
84
|
+
puts "done. saved to #{framework_destination_file}"
|
|
85
|
+
end
|
|
86
|
+
|
|
87
|
+
m.file 'swfobject.js', 'public/javascripts/swfobject.js'
|
|
88
|
+
m.file 'expressInstall.swf', 'public/expressInstall.swf'
|
|
89
|
+
m.template 'index.html.erb', 'public/index.html'
|
|
90
|
+
|
|
91
|
+
m.dependency 'rx_controller', @args
|
|
92
|
+
end
|
|
93
|
+
m.template 'project-textmate.erb', "#{project_name.underscore}.tmproj"
|
|
94
|
+
m.template 'mainapp.mxml', File.join('app/flex', "#{project_name}.mxml")
|
|
95
|
+
m.template 'mainapp-config.xml', File.join('app/flex', "#{project_name}-config.xml")
|
|
96
|
+
m.template 'mainair-app.xml', File.join('app/flex', "#{project_name}-app.xml") if @use_air
|
|
97
|
+
end
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
protected
|
|
101
|
+
def add_options!(opt)
|
|
102
|
+
opt.separator ''
|
|
103
|
+
opt.separator 'Options:'
|
|
104
|
+
opt.on("-m", "--main-only", "Only generate the main Flex/AIR application file.",
|
|
105
|
+
"Default: false") { |v| options[:main_only] = v }
|
|
106
|
+
opt.on("-a", "--air", "Configure AIR project instead of Flex. Flex is default.",
|
|
107
|
+
"Default: false") { |v| options[:air_config] = v }
|
|
108
|
+
opt.on("--skip-framework", "Don't fetch the latest framework binary. You'll have to link/build the framework yourself.",
|
|
109
|
+
"Default: false") { |v| options[:skip_framework] = v }
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
def banner
|
|
113
|
+
"Usage: #{$0} #{spec.name}"
|
|
114
|
+
end
|
|
115
|
+
end
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<actionScriptProperties mainApplicationPath="<%= project_name %>.mxml" version="3">
|
|
3
|
+
<compiler additionalCompilerArguments="-locale en_US -keep-as3-metadata+=Resource,HasOne,HasMany,BelongsTo,DateTime,Lazy,Ignored" copyDependentFiles="true" enableModuleDebug="true" generateAccessible="false" htmlExpressInstall="true" htmlGenerate="true" htmlHistoryManagement="true" htmlPlayerVersion="9.0.28" htmlPlayerVersionCheck="true" outputFolderPath="public/bin" rootURL="http://localhost:3000/bin" sourceFolderPath="app/flex" strict="true" useApolloConfig="false" verifyDigests="true" warn="true">
|
|
4
|
+
<compilerSourcePath/>
|
|
5
|
+
<libraryPath defaultLinkType="1">
|
|
6
|
+
<libraryPathEntry kind="4" path=""/>
|
|
7
|
+
<libraryPathEntry kind="1" linkType="1" path="lib"/>
|
|
8
|
+
</libraryPath>
|
|
9
|
+
<sourceAttachmentPath/>
|
|
10
|
+
</compiler>
|
|
11
|
+
<applications>
|
|
12
|
+
<application path="<%= project_name %>.mxml"/>
|
|
13
|
+
</applications>
|
|
14
|
+
<modules/>
|
|
15
|
+
<buildCSSFiles/>
|
|
16
|
+
</actionScriptProperties>
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<actionScriptProperties mainApplicationPath="<%= project_name %>.mxml" version="3">
|
|
3
|
+
<compiler additionalCompilerArguments="-locale en_US -keep-as3-metadata+=Resource,HasOne,HasMany,BelongsTo,DateTime,Lazy,Ignored" copyDependentFiles="true" enableModuleDebug="true" generateAccessible="false" htmlExpressInstall="true" htmlGenerate="false" htmlHistoryManagement="false" htmlPlayerVersion="9.0.28" htmlPlayerVersionCheck="true" outputFolderPath="bin-debug" sourceFolderPath="app/flex" strict="true" useApolloConfig="true" verifyDigests="true" warn="true">
|
|
4
|
+
<compilerSourcePath/>
|
|
5
|
+
<libraryPath defaultLinkType="1">
|
|
6
|
+
<libraryPathEntry kind="4" path=""/>
|
|
7
|
+
<libraryPathEntry kind="1" linkType="1" path="lib"/>
|
|
8
|
+
</libraryPath>
|
|
9
|
+
<sourceAttachmentPath/>
|
|
10
|
+
</compiler>
|
|
11
|
+
<applications>
|
|
12
|
+
<application path="<%= project_name %>.mxml"/>
|
|
13
|
+
</applications>
|
|
14
|
+
<modules/>
|
|
15
|
+
<buildCSSFiles/>
|
|
16
|
+
</actionScriptProperties>
|
|
Binary file
|
|
@@ -0,0 +1,276 @@
|
|
|
1
|
+
// Flash Player Version Detection - Rev 1.6
|
|
2
|
+
// Detect Client Browser type
|
|
3
|
+
// Copyright(c) 2005-2006 Adobe Macromedia Software, LLC. All rights reserved.
|
|
4
|
+
var isIE = (navigator.appVersion.indexOf("MSIE") != -1) ? true : false;
|
|
5
|
+
var isWin = (navigator.appVersion.toLowerCase().indexOf("win") != -1) ? true : false;
|
|
6
|
+
var isOpera = (navigator.userAgent.indexOf("Opera") != -1) ? true : false;
|
|
7
|
+
|
|
8
|
+
function ControlVersion()
|
|
9
|
+
{
|
|
10
|
+
var version;
|
|
11
|
+
var axo;
|
|
12
|
+
var e;
|
|
13
|
+
|
|
14
|
+
// NOTE : new ActiveXObject(strFoo) throws an exception if strFoo isn't in the registry
|
|
15
|
+
|
|
16
|
+
try {
|
|
17
|
+
// version will be set for 7.X or greater players
|
|
18
|
+
axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.7");
|
|
19
|
+
version = axo.GetVariable("$version");
|
|
20
|
+
} catch (e) {
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (!version)
|
|
24
|
+
{
|
|
25
|
+
try {
|
|
26
|
+
// version will be set for 6.X players only
|
|
27
|
+
axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.6");
|
|
28
|
+
|
|
29
|
+
// installed player is some revision of 6.0
|
|
30
|
+
// GetVariable("$version") crashes for versions 6.0.22 through 6.0.29,
|
|
31
|
+
// so we have to be careful.
|
|
32
|
+
|
|
33
|
+
// default to the first public version
|
|
34
|
+
version = "WIN 6,0,21,0";
|
|
35
|
+
|
|
36
|
+
// throws if AllowScripAccess does not exist (introduced in 6.0r47)
|
|
37
|
+
axo.AllowScriptAccess = "always";
|
|
38
|
+
|
|
39
|
+
// safe to call for 6.0r47 or greater
|
|
40
|
+
version = axo.GetVariable("$version");
|
|
41
|
+
|
|
42
|
+
} catch (e) {
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (!version)
|
|
47
|
+
{
|
|
48
|
+
try {
|
|
49
|
+
// version will be set for 4.X or 5.X player
|
|
50
|
+
axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
|
|
51
|
+
version = axo.GetVariable("$version");
|
|
52
|
+
} catch (e) {
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
if (!version)
|
|
57
|
+
{
|
|
58
|
+
try {
|
|
59
|
+
// version will be set for 3.X player
|
|
60
|
+
axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash.3");
|
|
61
|
+
version = "WIN 3,0,18,0";
|
|
62
|
+
} catch (e) {
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (!version)
|
|
67
|
+
{
|
|
68
|
+
try {
|
|
69
|
+
// version will be set for 2.X player
|
|
70
|
+
axo = new ActiveXObject("ShockwaveFlash.ShockwaveFlash");
|
|
71
|
+
version = "WIN 2,0,0,11";
|
|
72
|
+
} catch (e) {
|
|
73
|
+
version = -1;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
return version;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// JavaScript helper required to detect Flash Player PlugIn version information
|
|
81
|
+
function GetSwfVer(){
|
|
82
|
+
// NS/Opera version >= 3 check for Flash plugin in plugin array
|
|
83
|
+
var flashVer = -1;
|
|
84
|
+
|
|
85
|
+
if (navigator.plugins != null && navigator.plugins.length > 0) {
|
|
86
|
+
if (navigator.plugins["Shockwave Flash 2.0"] || navigator.plugins["Shockwave Flash"]) {
|
|
87
|
+
var swVer2 = navigator.plugins["Shockwave Flash 2.0"] ? " 2.0" : "";
|
|
88
|
+
var flashDescription = navigator.plugins["Shockwave Flash" + swVer2].description;
|
|
89
|
+
var descArray = flashDescription.split(" ");
|
|
90
|
+
var tempArrayMajor = descArray[2].split(".");
|
|
91
|
+
var versionMajor = tempArrayMajor[0];
|
|
92
|
+
var versionMinor = tempArrayMajor[1];
|
|
93
|
+
var versionRevision = descArray[3];
|
|
94
|
+
if (versionRevision == "") {
|
|
95
|
+
versionRevision = descArray[4];
|
|
96
|
+
}
|
|
97
|
+
if (versionRevision[0] == "d") {
|
|
98
|
+
versionRevision = versionRevision.substring(1);
|
|
99
|
+
} else if (versionRevision[0] == "r") {
|
|
100
|
+
versionRevision = versionRevision.substring(1);
|
|
101
|
+
if (versionRevision.indexOf("d") > 0) {
|
|
102
|
+
versionRevision = versionRevision.substring(0, versionRevision.indexOf("d"));
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
var flashVer = versionMajor + "." + versionMinor + "." + versionRevision;
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
// MSN/WebTV 2.6 supports Flash 4
|
|
109
|
+
else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.6") != -1) flashVer = 4;
|
|
110
|
+
// WebTV 2.5 supports Flash 3
|
|
111
|
+
else if (navigator.userAgent.toLowerCase().indexOf("webtv/2.5") != -1) flashVer = 3;
|
|
112
|
+
// older WebTV supports Flash 2
|
|
113
|
+
else if (navigator.userAgent.toLowerCase().indexOf("webtv") != -1) flashVer = 2;
|
|
114
|
+
else if ( isIE && isWin && !isOpera ) {
|
|
115
|
+
flashVer = ControlVersion();
|
|
116
|
+
}
|
|
117
|
+
return flashVer;
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
// When called with reqMajorVer, reqMinorVer, reqRevision returns true if that version or greater is available
|
|
121
|
+
function DetectFlashVer(reqMajorVer, reqMinorVer, reqRevision)
|
|
122
|
+
{
|
|
123
|
+
versionStr = GetSwfVer();
|
|
124
|
+
if (versionStr == -1 ) {
|
|
125
|
+
return false;
|
|
126
|
+
} else if (versionStr != 0) {
|
|
127
|
+
if(isIE && isWin && !isOpera) {
|
|
128
|
+
// Given "WIN 2,0,0,11"
|
|
129
|
+
tempArray = versionStr.split(" "); // ["WIN", "2,0,0,11"]
|
|
130
|
+
tempString = tempArray[1]; // "2,0,0,11"
|
|
131
|
+
versionArray = tempString.split(","); // ['2', '0', '0', '11']
|
|
132
|
+
} else {
|
|
133
|
+
versionArray = versionStr.split(".");
|
|
134
|
+
}
|
|
135
|
+
var versionMajor = versionArray[0];
|
|
136
|
+
var versionMinor = versionArray[1];
|
|
137
|
+
var versionRevision = versionArray[2];
|
|
138
|
+
|
|
139
|
+
// is the major.revision >= requested major.revision AND the minor version >= requested minor
|
|
140
|
+
if (versionMajor > parseFloat(reqMajorVer)) {
|
|
141
|
+
return true;
|
|
142
|
+
} else if (versionMajor == parseFloat(reqMajorVer)) {
|
|
143
|
+
if (versionMinor > parseFloat(reqMinorVer))
|
|
144
|
+
return true;
|
|
145
|
+
else if (versionMinor == parseFloat(reqMinorVer)) {
|
|
146
|
+
if (versionRevision >= parseFloat(reqRevision))
|
|
147
|
+
return true;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return false;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
function AC_AddExtension(src, ext)
|
|
155
|
+
{
|
|
156
|
+
if (src.indexOf('?') != -1)
|
|
157
|
+
return src.replace(/\?/, ext+'?');
|
|
158
|
+
else
|
|
159
|
+
return src + ext;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
function AC_Generateobj(objAttrs, params, embedAttrs)
|
|
163
|
+
{
|
|
164
|
+
var str = '';
|
|
165
|
+
if (isIE && isWin && !isOpera)
|
|
166
|
+
{
|
|
167
|
+
str += '<object ';
|
|
168
|
+
for (var i in objAttrs)
|
|
169
|
+
str += i + '="' + objAttrs[i] + '" ';
|
|
170
|
+
str += '>';
|
|
171
|
+
for (var i in params)
|
|
172
|
+
str += '<param name="' + i + '" value="' + params[i] + '" /> ';
|
|
173
|
+
str += '</object>';
|
|
174
|
+
} else {
|
|
175
|
+
str += '<embed ';
|
|
176
|
+
for (var i in embedAttrs)
|
|
177
|
+
str += i + '="' + embedAttrs[i] + '" ';
|
|
178
|
+
str += '> </embed>';
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
document.write(str);
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function AC_FL_RunContent(){
|
|
185
|
+
var ret =
|
|
186
|
+
AC_GetArgs
|
|
187
|
+
( arguments, ".swf", "movie", "clsid:d27cdb6e-ae6d-11cf-96b8-444553540000"
|
|
188
|
+
, "application/x-shockwave-flash"
|
|
189
|
+
);
|
|
190
|
+
AC_Generateobj(ret.objAttrs, ret.params, ret.embedAttrs);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
function AC_GetArgs(args, ext, srcParamName, classid, mimeType){
|
|
194
|
+
var ret = new Object();
|
|
195
|
+
ret.embedAttrs = new Object();
|
|
196
|
+
ret.params = new Object();
|
|
197
|
+
ret.objAttrs = new Object();
|
|
198
|
+
for (var i=0; i < args.length; i=i+2){
|
|
199
|
+
var currArg = args[i].toLowerCase();
|
|
200
|
+
|
|
201
|
+
switch (currArg){
|
|
202
|
+
case "classid":
|
|
203
|
+
break;
|
|
204
|
+
case "pluginspage":
|
|
205
|
+
ret.embedAttrs[args[i]] = args[i+1];
|
|
206
|
+
break;
|
|
207
|
+
case "src":
|
|
208
|
+
case "movie":
|
|
209
|
+
args[i+1] = AC_AddExtension(args[i+1], ext);
|
|
210
|
+
ret.embedAttrs["src"] = args[i+1];
|
|
211
|
+
ret.params[srcParamName] = args[i+1];
|
|
212
|
+
break;
|
|
213
|
+
case "onafterupdate":
|
|
214
|
+
case "onbeforeupdate":
|
|
215
|
+
case "onblur":
|
|
216
|
+
case "oncellchange":
|
|
217
|
+
case "onclick":
|
|
218
|
+
case "ondblClick":
|
|
219
|
+
case "ondrag":
|
|
220
|
+
case "ondragend":
|
|
221
|
+
case "ondragenter":
|
|
222
|
+
case "ondragleave":
|
|
223
|
+
case "ondragover":
|
|
224
|
+
case "ondrop":
|
|
225
|
+
case "onfinish":
|
|
226
|
+
case "onfocus":
|
|
227
|
+
case "onhelp":
|
|
228
|
+
case "onmousedown":
|
|
229
|
+
case "onmouseup":
|
|
230
|
+
case "onmouseover":
|
|
231
|
+
case "onmousemove":
|
|
232
|
+
case "onmouseout":
|
|
233
|
+
case "onkeypress":
|
|
234
|
+
case "onkeydown":
|
|
235
|
+
case "onkeyup":
|
|
236
|
+
case "onload":
|
|
237
|
+
case "onlosecapture":
|
|
238
|
+
case "onpropertychange":
|
|
239
|
+
case "onreadystatechange":
|
|
240
|
+
case "onrowsdelete":
|
|
241
|
+
case "onrowenter":
|
|
242
|
+
case "onrowexit":
|
|
243
|
+
case "onrowsinserted":
|
|
244
|
+
case "onstart":
|
|
245
|
+
case "onscroll":
|
|
246
|
+
case "onbeforeeditfocus":
|
|
247
|
+
case "onactivate":
|
|
248
|
+
case "onbeforedeactivate":
|
|
249
|
+
case "ondeactivate":
|
|
250
|
+
case "type":
|
|
251
|
+
case "codebase":
|
|
252
|
+
ret.objAttrs[args[i]] = args[i+1];
|
|
253
|
+
break;
|
|
254
|
+
case "id":
|
|
255
|
+
case "width":
|
|
256
|
+
case "height":
|
|
257
|
+
case "align":
|
|
258
|
+
case "vspace":
|
|
259
|
+
case "hspace":
|
|
260
|
+
case "class":
|
|
261
|
+
case "title":
|
|
262
|
+
case "accesskey":
|
|
263
|
+
case "name":
|
|
264
|
+
case "tabindex":
|
|
265
|
+
ret.embedAttrs[args[i]] = ret.objAttrs[args[i]] = args[i+1];
|
|
266
|
+
break;
|
|
267
|
+
default:
|
|
268
|
+
ret.embedAttrs[args[i]] = ret.params[args[i]] = args[i+1];
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
ret.objAttrs["classid"] = classid;
|
|
272
|
+
if (mimeType) ret.embedAttrs["type"] = mimeType;
|
|
273
|
+
return ret;
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/* This CSS stylesheet defines styles used by required elements in a flex application page that supports browser history */
|
|
2
|
+
|
|
3
|
+
#ie_historyFrame { width: 0px; height: 0px; display:none }
|
|
4
|
+
#firefox_anchorDiv { width: 0px; height: 0px; display:none }
|
|
5
|
+
#safari_formDiv { width: 0px; height: 0px; display:none }
|
|
6
|
+
#safari_rememberDiv { width: 0px; height: 0px; display:none }
|