captproton-restfulx 1.2.3
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/README.rdoc +50 -0
- data/Rakefile +79 -0
- data/VERSION.yml +4 -0
- data/app_generators/rx_app/USAGE +22 -0
- data/app_generators/rx_app/rx_app_generator.rb +110 -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 +38 -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 +22 -0
- data/app_generators/rx_app/templates/mainapp.mxml +152 -0
- data/app_generators/rx_app/templates/project-textmate.erb +72 -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/restfulx.yml +46 -0
- data/app_generators/rx_app/templates/swfobject.js +5 -0
- data/bin/rx-gen +31 -0
- data/lib/restfulx.rb +90 -0
- data/lib/restfulx/active_foo.rb +181 -0
- data/lib/restfulx/active_record_tasks.rb +90 -0
- data/lib/restfulx/active_record_uuid_helper.rb +17 -0
- data/lib/restfulx/configuration.rb +75 -0
- data/lib/restfulx/datamapper_foo.rb +81 -0
- data/lib/restfulx/rails/recipes.rb +60 -0
- data/lib/restfulx/rails/schema_to_yaml.rb +112 -0
- data/lib/restfulx/rails/schema_to_yaml/extensions/enumerable.rb +8 -0
- data/lib/restfulx/rails/schema_to_yaml/settings/config.rb +17 -0
- data/lib/restfulx/rails/schema_to_yaml/settings/core.rb +73 -0
- data/lib/restfulx/rails/swf_helper.rb +59 -0
- data/lib/restfulx/tasks.rb +110 -0
- data/rails_generators/rx_config/USAGE +19 -0
- data/rails_generators/rx_config/rx_config_generator.rb +151 -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/flex_controller.erb +4 -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.erb +16 -0
- data/rails_generators/rx_config/templates/mainair-app.xml +134 -0
- data/rails_generators/rx_config/templates/mainapp-config.xml +22 -0
- data/rails_generators/rx_config/templates/mainapp.mxml +129 -0
- data/rails_generators/rx_config/templates/project-textmate.erb +72 -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.erb +75 -0
- data/rails_generators/rx_config/templates/restfulx.yml +65 -0
- data/rails_generators/rx_config/templates/restfulx_tasks.rake +9 -0
- data/rails_generators/rx_config/templates/routes.erb +47 -0
- data/rails_generators/rx_config/templates/session_store_flash.erb +1 -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 +31 -0
- data/rails_generators/rx_controller/templates/controller.as.erb +38 -0
- data/rails_generators/rx_main_app/USAGE +8 -0
- data/rails_generators/rx_main_app/rx_main_app_generator.rb +60 -0
- data/rails_generators/rx_main_app/templates/mainapp.mxml +129 -0
- data/rails_generators/rx_scaffold/USAGE +35 -0
- data/rails_generators/rx_scaffold/rx_scaffold_generator.rb +242 -0
- data/rails_generators/rx_scaffold/templates/controllers/default.rb.erb +125 -0
- data/rails_generators/rx_scaffold/templates/controllers/resource_controller.rb.erb +23 -0
- data/rails_generators/rx_scaffold/templates/fixtures.yml.erb +39 -0
- data/rails_generators/rx_scaffold/templates/functional_test.rb +45 -0
- data/rails_generators/rx_scaffold/templates/helper_test.rb +4 -0
- data/rails_generators/rx_scaffold/templates/layouts/default.erb +167 -0
- data/rails_generators/rx_scaffold/templates/migration.rb.erb +46 -0
- data/rails_generators/rx_scaffold/templates/model.as.erb +73 -0
- data/rails_generators/rx_scaffold/templates/model.rb.erb +46 -0
- data/rails_generators/rx_yaml_scaffold/USAGE +51 -0
- data/rails_generators/rx_yaml_scaffold/rx_yaml_scaffold_generator.rb +68 -0
- data/rxgen_generators/rx_config/USAGE +5 -0
- data/rxgen_generators/rx_config/rx_config_generator.rb +21 -0
- data/rxgen_generators/rx_controller/USAGE +10 -0
- data/rxgen_generators/rx_controller/rx_controller_generator.rb +41 -0
- data/rxgen_generators/rx_controller/templates/assist.py +65 -0
- data/rxgen_generators/rx_controller/templates/controller.as.erb +38 -0
- data/rxgen_generators/rx_controller/templates/iso8601.py +92 -0
- data/rxgen_generators/rx_controller/templates/restful.py +136 -0
- data/rxgen_generators/rx_main_app/USAGE +8 -0
- data/rxgen_generators/rx_main_app/rx_main_app_generator.rb +65 -0
- data/rxgen_generators/rx_main_app/templates/main.py.erb +29 -0
- data/rxgen_generators/rx_main_app/templates/mainapp.mxml +152 -0
- data/rxgen_generators/rx_scaffold/USAGE +29 -0
- data/rxgen_generators/rx_scaffold/rx_scaffold_generator.rb +194 -0
- data/rxgen_generators/rx_scaffold/templates/controller.py.erb +27 -0
- data/rxgen_generators/rx_scaffold/templates/layouts/default.erb +167 -0
- data/rxgen_generators/rx_scaffold/templates/model.as.erb +73 -0
- data/rxgen_generators/rx_scaffold/templates/model.py.erb +14 -0
- data/rxgen_generators/rx_yaml_scaffold/USAGE +45 -0
- data/rxgen_generators/rx_yaml_scaffold/rx_yaml_scaffold_generator.rb +47 -0
- data/spec/restfulx_spec.rb +4 -0
- data/spec/spec_helper.rb +13 -0
- data/tasks/restfulx.rake +2 -0
- data/test/rails/controllers/application_controller.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 +54 -0
- data/test/rails/helpers/unit_test_helper.rb +29 -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/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 +234 -0
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
|
3
|
+
<plist version="1.0">
|
|
4
|
+
<dict>
|
|
5
|
+
<key>currentDocument</key>
|
|
6
|
+
<string>app/flex/<%= flex_project_name %>.mxml</string>
|
|
7
|
+
<key>documents</key>
|
|
8
|
+
<array>
|
|
9
|
+
<dict>
|
|
10
|
+
<key>expanded</key>
|
|
11
|
+
<true/>
|
|
12
|
+
<key>name</key>
|
|
13
|
+
<string><%= project_name %></string>
|
|
14
|
+
<key>regexFolderFilter</key>
|
|
15
|
+
<string>!.*/(\.[^/]*|CVS|_darcs|_MTN|\{arch\}|blib|.*~\.nib|.*\.(framework|app|pbproj|pbxproj|xcode(proj)?|bundle))$</string>
|
|
16
|
+
<key>sourceDirectory</key>
|
|
17
|
+
<string></string>
|
|
18
|
+
</dict>
|
|
19
|
+
</array>
|
|
20
|
+
<key>fileHierarchyDrawerWidth</key>
|
|
21
|
+
<integer>299</integer>
|
|
22
|
+
<key>metaData</key>
|
|
23
|
+
<dict/>
|
|
24
|
+
<key>shellVariables</key>
|
|
25
|
+
<array>
|
|
26
|
+
<dict>
|
|
27
|
+
<key>enabled</key>
|
|
28
|
+
<true/>
|
|
29
|
+
<key>value</key>
|
|
30
|
+
<string>app/flex/<%= flex_project_name %>.mxml</string>
|
|
31
|
+
<key>variable</key>
|
|
32
|
+
<string>TM_FLEX_FILE_SPECS</string>
|
|
33
|
+
</dict>
|
|
34
|
+
<dict>
|
|
35
|
+
<key>enabled</key>
|
|
36
|
+
<true/>
|
|
37
|
+
<key>value</key>
|
|
38
|
+
<string>public/bin/<%= flex_project_name %>.swf</string>
|
|
39
|
+
<key>variable</key>
|
|
40
|
+
<string>TM_FLEX_OUTPUT</string>
|
|
41
|
+
</dict>
|
|
42
|
+
<dict>
|
|
43
|
+
<key>enabled</key>
|
|
44
|
+
<true/>
|
|
45
|
+
<key>value</key>
|
|
46
|
+
<string>app/flex</string>
|
|
47
|
+
<key>variable</key>
|
|
48
|
+
<string>TM_AS3_USUAL_SRC_DIRS</string>
|
|
49
|
+
</dict>
|
|
50
|
+
<dict>
|
|
51
|
+
<key>enabled</key>
|
|
52
|
+
<true/>
|
|
53
|
+
<key>value</key>
|
|
54
|
+
<string>/Users/Dima/Projects/dev/restfulx_framework/framework/src</string>
|
|
55
|
+
<key>variable</key>
|
|
56
|
+
<string>TM_AS3_LIB_SRC_DIRS</string>
|
|
57
|
+
</dict>
|
|
58
|
+
<dict>
|
|
59
|
+
<key>enabled</key>
|
|
60
|
+
<true/>
|
|
61
|
+
<key>value</key>
|
|
62
|
+
<string><%= use_air ? 'air' : 'flex' %></string>
|
|
63
|
+
<key>variable</key>
|
|
64
|
+
<string>TM_FLEX_RUNTIME</string>
|
|
65
|
+
</dict>
|
|
66
|
+
</array>
|
|
67
|
+
<key>showFileHierarchyDrawer</key>
|
|
68
|
+
<false/>
|
|
69
|
+
<key>windowFrame</key>
|
|
70
|
+
<string>{{53, 14}, {1221, 864}}</string>
|
|
71
|
+
</dict>
|
|
72
|
+
</plist>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<projectDescription>
|
|
3
|
+
<name><%= project_name %></name>
|
|
4
|
+
<comment></comment>
|
|
5
|
+
<projects>
|
|
6
|
+
</projects>
|
|
7
|
+
<buildSpec>
|
|
8
|
+
<buildCommand>
|
|
9
|
+
<name>com.adobe.flexbuilder.project.flexbuilder</name>
|
|
10
|
+
<arguments>
|
|
11
|
+
</arguments>
|
|
12
|
+
</buildCommand>
|
|
13
|
+
</buildSpec>
|
|
14
|
+
<natures>
|
|
15
|
+
<nature>com.adobe.flexbuilder.project.flexnature</nature>
|
|
16
|
+
<nature>com.adobe.flexbuilder.project.actionscriptnature</nature>
|
|
17
|
+
</natures>
|
|
18
|
+
</projectDescription>
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<projectDescription>
|
|
3
|
+
<name><%= project_name %></name>
|
|
4
|
+
<comment></comment>
|
|
5
|
+
<projects>
|
|
6
|
+
</projects>
|
|
7
|
+
<buildSpec>
|
|
8
|
+
<buildCommand>
|
|
9
|
+
<name>com.adobe.flexbuilder.project.flexbuilder</name>
|
|
10
|
+
<arguments>
|
|
11
|
+
</arguments>
|
|
12
|
+
</buildCommand>
|
|
13
|
+
<buildCommand>
|
|
14
|
+
<name>com.adobe.flexbuilder.apollo.apollobuilder</name>
|
|
15
|
+
<arguments>
|
|
16
|
+
</arguments>
|
|
17
|
+
</buildCommand>
|
|
18
|
+
</buildSpec>
|
|
19
|
+
<natures>
|
|
20
|
+
<nature>com.adobe.flexbuilder.apollo.apollonature</nature>
|
|
21
|
+
<nature>com.adobe.flexbuilder.project.flexnature</nature>
|
|
22
|
+
<nature>com.adobe.flexbuilder.project.actionscriptnature</nature>
|
|
23
|
+
</natures>
|
|
24
|
+
</projectDescription>
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
# the following patches allow us to overwrite session key on file uploads from Flash,
|
|
2
|
+
# which ends up creating a new session for every File.upload() invocation.
|
|
3
|
+
|
|
4
|
+
<% if RAILS_GEM_VERSION =~ /^2.3/ -%>
|
|
5
|
+
require 'rack/utils'
|
|
6
|
+
|
|
7
|
+
class FlashSessionCookieMiddleware
|
|
8
|
+
def initialize(app, session_key = '_session_id')
|
|
9
|
+
@app = app
|
|
10
|
+
@session_key = session_key
|
|
11
|
+
@session_token = "_session_id"
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def call(env)
|
|
15
|
+
if env['HTTP_USER_AGENT'] =~ /^(Adobe|Shockwave) Flash/
|
|
16
|
+
params = ::Rack::Utils.parse_query(env['QUERY_STRING'])
|
|
17
|
+
env['HTTP_COOKIE'] = [ @session_key, params[@session_token] ].join('=').freeze unless params[@session_token].nil?
|
|
18
|
+
end
|
|
19
|
+
@app.call(env)
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
class FlexNestedAttributeMiddleware
|
|
24
|
+
def initialize(app)
|
|
25
|
+
@app = app
|
|
26
|
+
end
|
|
27
|
+
|
|
28
|
+
def call(env)
|
|
29
|
+
req = Rack::Request.new(env)
|
|
30
|
+
if req && req.path_info =~ /\.fxml$/
|
|
31
|
+
if req.put? || req.post? || req.delete?
|
|
32
|
+
req.params.each do |key,value|
|
|
33
|
+
value.select { |k,v| k =~ /\_attributes$/ }.each do |match|
|
|
34
|
+
env['rack.request.form_hash'][key][match[0]] = ActiveSupport::JSON.decode(match[1])
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
end
|
|
38
|
+
end
|
|
39
|
+
@app.call(env)
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
ActionController::Dispatcher.middleware.insert_after 'ActionController::ParamsParser', FlexNestedAttributeMiddleware
|
|
44
|
+
<% else -%>
|
|
45
|
+
class CGI::Session
|
|
46
|
+
alias original_initialize initialize
|
|
47
|
+
|
|
48
|
+
def initialize(request, option = {})
|
|
49
|
+
option = scan_for_session_id(request, '_session_id', option) unless option['session_id']
|
|
50
|
+
original_initialize(request, option)
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def scan_for_session_id(request, session_key = '_session_id', option = {})
|
|
54
|
+
query_string = if (qs = request.env_table["QUERY_STRING"]) and qs != ""
|
|
55
|
+
qs
|
|
56
|
+
elsif (ru = request.env_table["REQUEST_URI"][0..-1]).include?("?")
|
|
57
|
+
ru[(ru.index("?") + 1)..-1]
|
|
58
|
+
end
|
|
59
|
+
if query_string and query_string.include?(session_key)
|
|
60
|
+
option['session_id'] = query_string.scan(/#{session_key}=(.*?)(&.*?)*$/).flatten.first
|
|
61
|
+
end
|
|
62
|
+
return option
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
<% end -%>
|
|
66
|
+
|
|
67
|
+
# If you have configured your Rails/Flex/AIR application to share authenticity_token
|
|
68
|
+
# comment this out to enable forgery protection. By default, this is disabled to allow
|
|
69
|
+
# generated code to work out of the box.
|
|
70
|
+
ActionController::Base.allow_forgery_protection = false
|
|
71
|
+
|
|
72
|
+
<% if distributed -%>
|
|
73
|
+
# If we are in distributed mode we need to make sure that the RestfulX::UUIDHelper is loaded
|
|
74
|
+
require "restfulx/active_record_uuid_helper"
|
|
75
|
+
<% end -%>
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# RestfulX code generation configuration options
|
|
2
|
+
|
|
3
|
+
# This option controls what the main Flex application file will be called.
|
|
4
|
+
# By default it will be equal to the name of your rails project camelized
|
|
5
|
+
project_name: <%= project_name %>
|
|
6
|
+
|
|
7
|
+
# This options determines what the root folder for generated Flex code is.
|
|
8
|
+
# By default 'app/flex'
|
|
9
|
+
flex_root: <%= flex_root %>
|
|
10
|
+
|
|
11
|
+
# By default flex models, commands, controllers and components are genearated into
|
|
12
|
+
# <flex-root>/<your rails project name> folder. If you'd like to customize the target folder
|
|
13
|
+
# (to say append a "com" package before your rails project name) uncomment the line below
|
|
14
|
+
# base-package must follow the usual flex package notation (a string separated by ".")
|
|
15
|
+
base_package: <%= base_package %>
|
|
16
|
+
|
|
17
|
+
# Main RestfulX controller is typically named AppicationController. This controller is created in
|
|
18
|
+
# <base-package>.controllers folder. You can customize the name by uncommenting the following line
|
|
19
|
+
# and changing the controller name.
|
|
20
|
+
controller_name: <%= command_controller_name %>
|
|
21
|
+
|
|
22
|
+
# If you are using Rails on the back-end and Adobe AIR as the client you can generate Rails/Flex/AIR
|
|
23
|
+
# code to take advantage of synchronization (online/offline) support in RestfulX by changing the following
|
|
24
|
+
# option to true. By default distribution is disabled.
|
|
25
|
+
distributed: <%= distributed %>
|
|
26
|
+
|
|
27
|
+
# These options control code-generation options for view components, Flex and Rails models and so on.
|
|
28
|
+
# Allowing you to choose what controller patterns, layouts, attachment plugin you want to use, etc.
|
|
29
|
+
defaults: &defaults
|
|
30
|
+
attachment_plugin: 'paperclip' # => paperclip/attachment_fu
|
|
31
|
+
controller_pattern: 'default' # => default/resource_controller
|
|
32
|
+
layouts:
|
|
33
|
+
default: 'default' # => default (more coming soon)
|
|
34
|
+
ignored: # => ignored tables/fields won't appear in model.yml
|
|
35
|
+
tables: [table1 table2]
|
|
36
|
+
fields: [field1 field2]
|
|
37
|
+
|
|
38
|
+
# set up specific options for development environment
|
|
39
|
+
development:
|
|
40
|
+
<<: *defaults
|
|
41
|
+
|
|
42
|
+
# set up specific options for test environment
|
|
43
|
+
test:
|
|
44
|
+
<<: *defaults
|
|
45
|
+
|
|
46
|
+
# set up specific options for production environment
|
|
47
|
+
production:
|
|
48
|
+
<<: *defaults
|
|
49
|
+
|
|
50
|
+
# The following special model.yml fields are supported.
|
|
51
|
+
#
|
|
52
|
+
# For example:
|
|
53
|
+
# attachment_field: [avatar]
|
|
54
|
+
# * arg takes Paperclip field name, or takes [uploaded_data] for Attachment_Fu
|
|
55
|
+
# belongs_to: [account, profile]
|
|
56
|
+
# has_many: [announcements, files, folders, users]
|
|
57
|
+
# has_many_through: [permissions, roles]
|
|
58
|
+
# * has_many :roles, :through => :permissions
|
|
59
|
+
# has_one: [suitcase]
|
|
60
|
+
# polymorphic: [commentable]
|
|
61
|
+
# tree_model: [parent]
|
|
62
|
+
# layout: [default]
|
|
63
|
+
# * default template is the only current theme, with more coming soon
|
|
64
|
+
# ignored_fields: [children_count, ancestors_count, descendants_count, position]
|
|
65
|
+
# * specify fields you don't want generated for your template
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
# if the gem is not installed system wide, we'll just skip the tasks
|
|
2
|
+
begin
|
|
3
|
+
# this will load the latest restfulx gem version
|
|
4
|
+
require 'restfulx/active_record_tasks'
|
|
5
|
+
rescue LoadError
|
|
6
|
+
puts "Could not load active_record_tasks from 'restfulx/active_record_tasks'. " <<
|
|
7
|
+
"If you are loading restfulx gem from vendor/gems, adjust the path to active_record_tasks in " <<
|
|
8
|
+
"lib/tasks/restfulx_tasks.rake accordingly."
|
|
9
|
+
end
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
ActionController::Routing::Routes.draw do |map|
|
|
2
|
+
|
|
3
|
+
# Map application root to default RestfulX controller
|
|
4
|
+
map.root :controller => "flex"
|
|
5
|
+
|
|
6
|
+
# The priority is based upon order of creation: first created -> highest priority.
|
|
7
|
+
|
|
8
|
+
# Sample of regular route:
|
|
9
|
+
# map.connect 'products/:id', :controller => 'catalog', :action => 'view'
|
|
10
|
+
# Keep in mind you can assign values other than :controller and :action
|
|
11
|
+
|
|
12
|
+
# Sample of named route:
|
|
13
|
+
# map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase'
|
|
14
|
+
# This route can be invoked with purchase_url(:id => product.id)
|
|
15
|
+
|
|
16
|
+
# Sample resource route (maps HTTP verbs to controller actions automatically):
|
|
17
|
+
# map.resources :products
|
|
18
|
+
|
|
19
|
+
# Sample resource route with options:
|
|
20
|
+
# map.resources :products, :member => { :short => :get, :toggle => :post }, :collection => { :sold => :get }
|
|
21
|
+
|
|
22
|
+
# Sample resource route with sub-resources:
|
|
23
|
+
# map.resources :products, :has_many => [ :comments, :sales ], :has_one => :seller
|
|
24
|
+
|
|
25
|
+
# Sample resource route with more complex sub-resources
|
|
26
|
+
# map.resources :products do |products|
|
|
27
|
+
# products.resources :comments
|
|
28
|
+
# products.resources :sales, :collection => { :recent => :get }
|
|
29
|
+
# end
|
|
30
|
+
|
|
31
|
+
# Sample resource route within a namespace:
|
|
32
|
+
# map.namespace :admin do |admin|
|
|
33
|
+
# # Directs /admin/products/* to Admin::ProductsController (app/controllers/admin/products_controller.rb)
|
|
34
|
+
# admin.resources :products
|
|
35
|
+
# end
|
|
36
|
+
|
|
37
|
+
# You can have the root of your site routed with map.root -- just remember to delete public/index.html.
|
|
38
|
+
# map.root :controller => "welcome"
|
|
39
|
+
|
|
40
|
+
# See how all your routes lay out with "rake routes"
|
|
41
|
+
|
|
42
|
+
# Install the default routes as the lowest priority.
|
|
43
|
+
# Note: These default routes make all actions in every controller accessible via GET requests. You should
|
|
44
|
+
# consider removing the them or commenting them out if you're using named routes and resources.
|
|
45
|
+
map.connect ':controller/:action/:id'
|
|
46
|
+
map.connect ':controller/:action/:id.:format'
|
|
47
|
+
end
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ActionController::Dispatcher.middleware.use FlashSessionCookieMiddleware, ActionController::Base.session_options[:key]
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/* SWFObject v2.0 <http://code.google.com/p/swfobject/>
|
|
2
|
+
Copyright (c) 2007 Geoff Stearns, Michael Williams, and Bobby van der Sluis
|
|
3
|
+
This software is released under the MIT License <http://www.opensource.org/licenses/mit-license.php>
|
|
4
|
+
*/
|
|
5
|
+
var swfobject=function(){var Z="undefined",P="object",B="Shockwave Flash",h="ShockwaveFlash.ShockwaveFlash",W="application/x-shockwave-flash",K="SWFObjectExprInst",G=window,g=document,N=navigator,f=[],H=[],Q=null,L=null,T=null,S=false,C=false;var a=function(){var l=typeof g.getElementById!=Z&&typeof g.getElementsByTagName!=Z&&typeof g.createElement!=Z&&typeof g.appendChild!=Z&&typeof g.replaceChild!=Z&&typeof g.removeChild!=Z&&typeof g.cloneNode!=Z,t=[0,0,0],n=null;if(typeof N.plugins!=Z&&typeof N.plugins[B]==P){n=N.plugins[B].description;if(n){n=n.replace(/^.*\s+(\S+\s+\S+$)/,"$1");t[0]=parseInt(n.replace(/^(.*)\..*$/,"$1"),10);t[1]=parseInt(n.replace(/^.*\.(.*)\s.*$/,"$1"),10);t[2]=/r/.test(n)?parseInt(n.replace(/^.*r(.*)$/,"$1"),10):0}}else{if(typeof G.ActiveXObject!=Z){var o=null,s=false;try{o=new ActiveXObject(h+".7")}catch(k){try{o=new ActiveXObject(h+".6");t=[6,0,21];o.AllowScriptAccess="always"}catch(k){if(t[0]==6){s=true}}if(!s){try{o=new ActiveXObject(h)}catch(k){}}}if(!s&&o){try{n=o.GetVariable("$version");if(n){n=n.split(" ")[1].split(",");t=[parseInt(n[0],10),parseInt(n[1],10),parseInt(n[2],10)]}}catch(k){}}}}var v=N.userAgent.toLowerCase(),j=N.platform.toLowerCase(),r=/webkit/.test(v)?parseFloat(v.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,i=false,q=j?/win/.test(j):/win/.test(v),m=j?/mac/.test(j):/mac/.test(v);/*@cc_on i=true;@if(@_win32)q=true;@elif(@_mac)m=true;@end@*/return{w3cdom:l,pv:t,webkit:r,ie:i,win:q,mac:m}}();var e=function(){if(!a.w3cdom){return }J(I);if(a.ie&&a.win){try{g.write("<script id=__ie_ondomload defer=true src=//:><\/script>");var i=c("__ie_ondomload");if(i){i.onreadystatechange=function(){if(this.readyState=="complete"){this.parentNode.removeChild(this);V()}}}}catch(j){}}if(a.webkit&&typeof g.readyState!=Z){Q=setInterval(function(){if(/loaded|complete/.test(g.readyState)){V()}},10)}if(typeof g.addEventListener!=Z){g.addEventListener("DOMContentLoaded",V,null)}M(V)}();function V(){if(S){return }if(a.ie&&a.win){var m=Y("span");try{var l=g.getElementsByTagName("body")[0].appendChild(m);l.parentNode.removeChild(l)}catch(n){return }}S=true;if(Q){clearInterval(Q);Q=null}var j=f.length;for(var k=0;k<j;k++){f[k]()}}function J(i){if(S){i()}else{f[f.length]=i}}function M(j){if(typeof G.addEventListener!=Z){G.addEventListener("load",j,false)}else{if(typeof g.addEventListener!=Z){g.addEventListener("load",j,false)}else{if(typeof G.attachEvent!=Z){G.attachEvent("onload",j)}else{if(typeof G.onload=="function"){var i=G.onload;G.onload=function(){i();j()}}else{G.onload=j}}}}}function I(){var l=H.length;for(var j=0;j<l;j++){var m=H[j].id;if(a.pv[0]>0){var k=c(m);if(k){H[j].width=k.getAttribute("width")?k.getAttribute("width"):"0";H[j].height=k.getAttribute("height")?k.getAttribute("height"):"0";if(O(H[j].swfVersion)){if(a.webkit&&a.webkit<312){U(k)}X(m,true)}else{if(H[j].expressInstall&&!C&&O("6.0.65")&&(a.win||a.mac)){D(H[j])}else{d(k)}}}}else{X(m,true)}}}function U(m){var k=m.getElementsByTagName(P)[0];if(k){var p=Y("embed"),r=k.attributes;if(r){var o=r.length;for(var n=0;n<o;n++){if(r[n].nodeName.toLowerCase()=="data"){p.setAttribute("src",r[n].nodeValue)}else{p.setAttribute(r[n].nodeName,r[n].nodeValue)}}}var q=k.childNodes;if(q){var s=q.length;for(var l=0;l<s;l++){if(q[l].nodeType==1&&q[l].nodeName.toLowerCase()=="param"){p.setAttribute(q[l].getAttribute("name"),q[l].getAttribute("value"))}}}m.parentNode.replaceChild(p,m)}}function F(i){if(a.ie&&a.win&&O("8.0.0")){G.attachEvent("onunload",function(){var k=c(i);if(k){for(var j in k){if(typeof k[j]=="function"){k[j]=function(){}}}k.parentNode.removeChild(k)}})}}function D(j){C=true;var o=c(j.id);if(o){if(j.altContentId){var l=c(j.altContentId);if(l){L=l;T=j.altContentId}}else{L=b(o)}if(!(/%$/.test(j.width))&&parseInt(j.width,10)<310){j.width="310"}if(!(/%$/.test(j.height))&&parseInt(j.height,10)<137){j.height="137"}g.title=g.title.slice(0,47)+" - Flash Player Installation";var n=a.ie&&a.win?"ActiveX":"PlugIn",k=g.title,m="MMredirectURL="+G.location+"&MMplayerType="+n+"&MMdoctitle="+k,p=j.id;if(a.ie&&a.win&&o.readyState!=4){var i=Y("div");p+="SWFObjectNew";i.setAttribute("id",p);o.parentNode.insertBefore(i,o);o.style.display="none";G.attachEvent("onload",function(){o.parentNode.removeChild(o)})}R({data:j.expressInstall,id:K,width:j.width,height:j.height},{flashvars:m},p)}}function d(j){if(a.ie&&a.win&&j.readyState!=4){var i=Y("div");j.parentNode.insertBefore(i,j);i.parentNode.replaceChild(b(j),i);j.style.display="none";G.attachEvent("onload",function(){j.parentNode.removeChild(j)})}else{j.parentNode.replaceChild(b(j),j)}}function b(n){var m=Y("div");if(a.win&&a.ie){m.innerHTML=n.innerHTML}else{var k=n.getElementsByTagName(P)[0];if(k){var o=k.childNodes;if(o){var j=o.length;for(var l=0;l<j;l++){if(!(o[l].nodeType==1&&o[l].nodeName.toLowerCase()=="param")&&!(o[l].nodeType==8)){m.appendChild(o[l].cloneNode(true))}}}}}return m}function R(AE,AC,q){var p,t=c(q);if(typeof AE.id==Z){AE.id=q}if(a.ie&&a.win){var AD="";for(var z in AE){if(AE[z]!=Object.prototype[z]){if(z=="data"){AC.movie=AE[z]}else{if(z.toLowerCase()=="styleclass"){AD+=' class="'+AE[z]+'"'}else{if(z!="classid"){AD+=" "+z+'="'+AE[z]+'"'}}}}}var AB="";for(var y in AC){if(AC[y]!=Object.prototype[y]){AB+='<param name="'+y+'" value="'+AC[y]+'" />'}}t.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+AD+">"+AB+"</object>";F(AE.id);p=c(AE.id)}else{if(a.webkit&&a.webkit<312){var AA=Y("embed");AA.setAttribute("type",W);for(var x in AE){if(AE[x]!=Object.prototype[x]){if(x=="data"){AA.setAttribute("src",AE[x])}else{if(x.toLowerCase()=="styleclass"){AA.setAttribute("class",AE[x])}else{if(x!="classid"){AA.setAttribute(x,AE[x])}}}}}for(var w in AC){if(AC[w]!=Object.prototype[w]){if(w!="movie"){AA.setAttribute(w,AC[w])}}}t.parentNode.replaceChild(AA,t);p=AA}else{var s=Y(P);s.setAttribute("type",W);for(var v in AE){if(AE[v]!=Object.prototype[v]){if(v.toLowerCase()=="styleclass"){s.setAttribute("class",AE[v])}else{if(v!="classid"){s.setAttribute(v,AE[v])}}}}for(var u in AC){if(AC[u]!=Object.prototype[u]&&u!="movie"){E(s,u,AC[u])}}t.parentNode.replaceChild(s,t);p=s}}return p}function E(k,i,j){var l=Y("param");l.setAttribute("name",i);l.setAttribute("value",j);k.appendChild(l)}function c(i){return g.getElementById(i)}function Y(i){return g.createElement(i)}function O(k){var j=a.pv,i=k.split(".");i[0]=parseInt(i[0],10);i[1]=parseInt(i[1],10);i[2]=parseInt(i[2],10);return(j[0]>i[0]||(j[0]==i[0]&&j[1]>i[1])||(j[0]==i[0]&&j[1]==i[1]&&j[2]>=i[2]))?true:false}function A(m,j){if(a.ie&&a.mac){return }var l=g.getElementsByTagName("head")[0],k=Y("style");k.setAttribute("type","text/css");k.setAttribute("media","screen");if(!(a.ie&&a.win)&&typeof g.createTextNode!=Z){k.appendChild(g.createTextNode(m+" {"+j+"}"))}l.appendChild(k);if(a.ie&&a.win&&typeof g.styleSheets!=Z&&g.styleSheets.length>0){var i=g.styleSheets[g.styleSheets.length-1];if(typeof i.addRule==P){i.addRule(m,j)}}}function X(k,i){var j=i?"visible":"hidden";if(S){c(k).style.visibility=j}else{A("#"+k,"visibility:"+j)}}return{registerObject:function(l,i,k){if(!a.w3cdom||!l||!i){return }var j={};j.id=l;j.swfVersion=i;j.expressInstall=k?k:false;H[H.length]=j;X(l,false)},getObjectById:function(l){var i=null;if(a.w3cdom&&S){var j=c(l);if(j){var k=j.getElementsByTagName(P)[0];if(!k||(k&&typeof j.SetVariable!=Z)){i=j}else{if(typeof k.SetVariable!=Z){i=k}}}}return i},embedSWF:function(n,u,r,t,j,m,k,p,s){if(!a.w3cdom||!n||!u||!r||!t||!j){return }r+="";t+="";if(O(j)){X(u,false);var q=(typeof s==P)?s:{};q.data=n;q.width=r;q.height=t;var o=(typeof p==P)?p:{};if(typeof k==P){for(var l in k){if(k[l]!=Object.prototype[l]){if(typeof o.flashvars!=Z){o.flashvars+="&"+l+"="+k[l]}else{o.flashvars=l+"="+k[l]}}}}J(function(){R(q,o,u);if(q.id==u){X(u,true)}})}else{if(m&&!C&&O("6.0.65")&&(a.win||a.mac)){X(u,false);J(function(){var i={};i.id=i.altContentId=u;i.width=r;i.height=t;i.expressInstall=m;D(i)})}}},getFlashPlayerVersion:function(){return{major:a.pv[0],minor:a.pv[1],release:a.pv[2]}},hasFlashPlayerVersion:O,createSWF:function(k,j,i){if(a.w3cdom&&S){return R(k,j,i)}else{return undefined}},createCSS:function(j,i){if(a.w3cdom){A(j,i)}},addDomLoadEvent:J,addLoadEvent:M,getQueryParamValue:function(m){var l=g.location.search||g.location.hash;if(m==null){return l}if(l){var k=l.substring(1).split("&");for(var j=0;j<k.length;j++){if(k[j].substring(0,k[j].indexOf("="))==m){return k[j].substring((k[j].indexOf("=")+1))}}}return""},expressInstallCallback:function(){if(C&&L){var i=c(K);if(i){i.parentNode.replaceChild(L,i);if(T){X(T,true);if(a.ie&&a.win){L.style.display="block"}}L=null;T=null;C=false}}}}}();
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
Description:
|
|
2
|
+
Generates/updates the main Flex application controller, typically
|
|
3
|
+
app/flex/<yourappname>/controllers/ApplicationController.as
|
|
4
|
+
|
|
5
|
+
It pulls out all available models and commands from respective
|
|
6
|
+
folders and makes sure they'll be pulled into the Flex application
|
|
7
|
+
at runtime. Doesn't require any arguments or options.
|
|
8
|
+
|
|
9
|
+
Examples:
|
|
10
|
+
`./script/generate rx_controller`
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', '..', 'lib', 'restfulx') if !defined?(RestfulX)
|
|
2
|
+
|
|
3
|
+
class RxControllerGenerator < Rails::Generator::Base
|
|
4
|
+
include RestfulX::Configuration
|
|
5
|
+
|
|
6
|
+
attr_reader :project_name,
|
|
7
|
+
:flex_project_name,
|
|
8
|
+
:base_package,
|
|
9
|
+
:base_folder,
|
|
10
|
+
:command_controller_name,
|
|
11
|
+
:model_names,
|
|
12
|
+
:command_names,
|
|
13
|
+
:flex_root,
|
|
14
|
+
:distributed
|
|
15
|
+
|
|
16
|
+
def initialize(runtime_args, runtime_options = {})
|
|
17
|
+
super
|
|
18
|
+
@project_name, @flex_project_name, @command_controller_name, @base_package, @base_folder,
|
|
19
|
+
@flex_root, @distributed = extract_names
|
|
20
|
+
|
|
21
|
+
@model_names = list_as_files("#{@flex_root}/#{@base_folder}/models")
|
|
22
|
+
@command_names = list_as_files("#{@flex_root}/#{@base_folder}/commands")
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def manifest
|
|
26
|
+
record do |m|
|
|
27
|
+
m.template 'controller.as.erb', File.join("#{@flex_root}/#{@base_folder}/controllers",
|
|
28
|
+
"#{@command_controller_name}.as")
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
package <%= base_package %>.controllers {
|
|
2
|
+
import <%= base_package %>.models.*;
|
|
3
|
+
import <%= base_package %>.commands.*;
|
|
4
|
+
|
|
5
|
+
import mx.core.Application;
|
|
6
|
+
import org.restfulx.Rx;
|
|
7
|
+
import org.restfulx.controllers.RxApplicationController;
|
|
8
|
+
import org.restfulx.utils.RxUtils;
|
|
9
|
+
|
|
10
|
+
public class <%= command_controller_name %> extends RxApplicationController {
|
|
11
|
+
private static var controller:<%= command_controller_name %>;
|
|
12
|
+
|
|
13
|
+
public static var models:Array = [<%= model_names %>]; /* Models */
|
|
14
|
+
|
|
15
|
+
public static var commands:Array = [<%= command_names %>]; /* Commands */
|
|
16
|
+
|
|
17
|
+
public function <%= command_controller_name %>(enforcer:SingletonEnforcer,
|
|
18
|
+
extraServices:Array, defaultServiceId:int = -1) {
|
|
19
|
+
super(commands, models, extraServices, defaultServiceId);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
public static function get instance():<%= command_controller_name %> {
|
|
23
|
+
if (controller == null) initialize();
|
|
24
|
+
return controller;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
public static function initialize(extraServices:Array = null,
|
|
28
|
+
defaultServiceId:int = -1, airDatabaseName:String = null):void {
|
|
29
|
+
if (!RxUtils.isEmpty(airDatabaseName)) Rx.airDatabaseName = airDatabaseName;
|
|
30
|
+
controller = new <%= command_controller_name %>(new SingletonEnforcer,
|
|
31
|
+
extraServices, defaultServiceId);
|
|
32
|
+
Rx.sessionToken = Application.application.parameters.session_token;
|
|
33
|
+
Rx.authenticityToken = Application.application.parameters.authenticity_token;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
class SingletonEnforcer {}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
Description:
|
|
2
|
+
Refreshes main Flex/AIR application file to make sure that
|
|
3
|
+
any of the generated components are included. Warning,
|
|
4
|
+
this will wipe your main application file. Used mostly
|
|
5
|
+
during code generation phase.
|
|
6
|
+
|
|
7
|
+
Examples:
|
|
8
|
+
`./script/generate rx_main_app`
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
require File.join(File.dirname(__FILE__), '..', '..', 'lib', 'restfulx') if !defined?(RestfulX)
|
|
2
|
+
|
|
3
|
+
module Rails
|
|
4
|
+
module Generator
|
|
5
|
+
module Commands
|
|
6
|
+
class Create
|
|
7
|
+
include SchemaToYaml
|
|
8
|
+
end
|
|
9
|
+
end
|
|
10
|
+
end
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
class RxMainAppGenerator < Rails::Generator::Base
|
|
14
|
+
include RestfulX::Configuration
|
|
15
|
+
|
|
16
|
+
attr_reader :project_name,
|
|
17
|
+
:flex_project_name,
|
|
18
|
+
:base_package,
|
|
19
|
+
:base_folder,
|
|
20
|
+
:command_controller_name,
|
|
21
|
+
:model_names,
|
|
22
|
+
:component_names,
|
|
23
|
+
:controller_names,
|
|
24
|
+
:use_air,
|
|
25
|
+
:application_tag,
|
|
26
|
+
:flex_root,
|
|
27
|
+
:distributed
|
|
28
|
+
|
|
29
|
+
def initialize(runtime_args, runtime_options = {})
|
|
30
|
+
super
|
|
31
|
+
@project_name, @flex_project_name, @command_controller_name, @base_package, @base_folder,
|
|
32
|
+
@flex_root, @distributed = extract_names
|
|
33
|
+
|
|
34
|
+
project_file_name = APP_ROOT + '/.project'
|
|
35
|
+
if File.exist?(project_file_name)
|
|
36
|
+
@use_air = true if File.read(project_file_name) =~/com.adobe.flexbuilder.apollo.apollobuilder/m
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
if @use_air
|
|
40
|
+
@application_tag = 'WindowedApplication'
|
|
41
|
+
else
|
|
42
|
+
@application_tag = 'Application'
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
@component_names = []
|
|
46
|
+
if File.exists?("#{flex_root}/#{base_folder}/views/generated")
|
|
47
|
+
@component_names = list_mxml_files("#{flex_root}/#{base_folder}/views/generated")
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def manifest
|
|
52
|
+
record do |m|
|
|
53
|
+
m.template 'mainapp.mxml', File.join("#{flex_root}", "#{flex_project_name}.mxml")
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def banner
|
|
58
|
+
"Usage: #{$0} #{spec.name}"
|
|
59
|
+
end
|
|
60
|
+
end
|