flex_scaffold 0.1.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/CHANGELOG +4 -0
- data/MIT-LICENSE +20 -0
- data/README +169 -0
- data/Rakefile +116 -0
- data/TODO +23 -0
- data/generators/flex_scaffold/USAGE +16 -0
- data/generators/flex_scaffold/flex_scaffold_generator.rb +434 -0
- data/generators/flex_scaffold/templates/_form.rhtml +1 -0
- data/generators/flex_scaffold/templates/_index.rmxml +210 -0
- data/generators/flex_scaffold/templates/_list.rhtml +0 -0
- data/generators/flex_scaffold/templates/_list.rmxml +17 -0
- data/generators/flex_scaffold_resource/USAGE +36 -0
- data/generators/flex_scaffold_resource/flex_scaffold_resource_generator.rb +81 -0
- data/generators/flex_scaffold_resource/templates/controller.rb +101 -0
- data/generators/flex_scaffold_resource/templates/index.rhtml +3 -0
- data/generators/flex_scaffold_resource/templates/layout.rhtml +19 -0
- data/init.rb +29 -0
- data/install.rb +1 -0
- data/lib/action_view_helper.rb +49 -0
- data/lib/actionscript_helper.rb +81 -0
- data/lib/config.rb +49 -0
- data/lib/flex_scaffold_plugin.rb +25 -0
- data/lib/flexobject_view_helper.rb +132 -0
- data/lib/mtag_helper.rb +98 -0
- data/lib/mxml_helper.rb +107 -0
- data/lib/rest_scaffolding.rb +137 -0
- data/lib/validations.rb +180 -0
- data/public/crossdomain.xml +6 -0
- data/public/history.htm +21 -0
- data/public/history.swf +0 -0
- data/public/images/add.gif +0 -0
- data/public/images/arrow_down.gif +0 -0
- data/public/images/arrow_up.gif +0 -0
- data/public/images/create.gif +0 -0
- data/public/images/delete.gif +0 -0
- data/public/images/indicator-small.gif +0 -0
- data/public/images/indicator.gif +0 -0
- data/public/images/read.gif +0 -0
- data/public/images/search.gif +0 -0
- data/public/images/update.gif +0 -0
- data/public/javascripts/flashobject.js +168 -0
- data/public/javascripts/history.js +48 -0
- data/public/playerProductInstall.swf +0 -0
- data/public/stylesheets/default.css +28 -0
- data/tasks/compile_swf.rake +100 -0
- data/tasks/flex_scaffold.rake +38 -0
- data/uninstall.rb +1 -0
- metadata +125 -0
data/CHANGELOG
ADDED
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2007 toddb
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README
ADDED
@@ -0,0 +1,169 @@
|
|
1
|
+
=FlexScaffold
|
2
|
+
|
3
|
+
|
4
|
+
Flex Scaffold should allow you to swap in and out different view layers on your REST controller.
|
5
|
+
For example, to use the model <tt>contact</tt>, use <tt>flex_scaffold: contact</tt>
|
6
|
+
|
7
|
+
class ContactsController < ApplicationController
|
8
|
+
|
9
|
+
layout 'flex_scaffold'
|
10
|
+
flex_scaffold :contact (optional - :size => '800x600')
|
11
|
+
|
12
|
+
# The following line can be used instead of the generated definitions
|
13
|
+
# of index, show, new, edit, update, destroy. There is also the action
|
14
|
+
# schema to look at the data model
|
15
|
+
...
|
16
|
+
end
|
17
|
+
|
18
|
+
Other files that are created:
|
19
|
+
|
20
|
+
/app/flex/contacts/_list.mxml
|
21
|
+
/app/flex/contacts/_contacts.mxml <-- these are compiled to a swf file
|
22
|
+
|
23
|
+
/public/swfs/flex_scaffold/_contacts.swf <-- created via rake flex:app mxml=contacts
|
24
|
+
|
25
|
+
/app/views/layout/flex_scaffold.rhtml <-- templated pages
|
26
|
+
/app/views/flex_scaffold/index.rhtml <-- loads up the swf
|
27
|
+
|
28
|
+
==USAGE
|
29
|
+
|
30
|
+
===Summary
|
31
|
+
|
32
|
+
To generate a scaffold for the model <tt>message</tt> with fields <tt>title</tt> and <tt>body</tt>:
|
33
|
+
|
34
|
+
> ruby script/generate flex_scaffold_resource message title:string body:string
|
35
|
+
> rake db:migrate
|
36
|
+
> ruby script/generate flex_scaffold message
|
37
|
+
> rake flex:app mxml=messages
|
38
|
+
> ruby script/server start
|
39
|
+
|
40
|
+
===1. Install a REST service from flex_scaffold_resource
|
41
|
+
|
42
|
+
Create an Active Resource (REST service)
|
43
|
+
|
44
|
+
> ruby script/generate flex_scaffold_resource message title:string body:string
|
45
|
+
|
46
|
+
This simple command will generate a lot of stuff, in detail:
|
47
|
+
|
48
|
+
* A controller with REST actions and an action for getting the schema
|
49
|
+
* A model named message
|
50
|
+
* A migration named xxx_create_messages
|
51
|
+
* Fixture and unit tests for the model and the controller
|
52
|
+
* A line in your <tt>config/routes.rb</tt> file <tt>map.resources :messages</tt>
|
53
|
+
|
54
|
+
|
55
|
+
Alternatively, you can add scaffolding to any REST resources by adding to any controller:
|
56
|
+
|
57
|
+
flex_scaffold :message
|
58
|
+
|
59
|
+
Note: You can then delete or extend all the other REST actions as they are implicitly scaffolded
|
60
|
+
|
61
|
+
===2. Migrate the database
|
62
|
+
|
63
|
+
> db:migrate
|
64
|
+
|
65
|
+
This updates the database ready for the scaffold to pick up the columns.
|
66
|
+
|
67
|
+
===3. Create the scaffolds
|
68
|
+
|
69
|
+
> ruby script/generate flex_scaffold message
|
70
|
+
|
71
|
+
This will generate:
|
72
|
+
|
73
|
+
* A scaffold view for the controller which loads the swf
|
74
|
+
* A template layout for the controller
|
75
|
+
* Scaffolded mxml files (in <tt>app/flex</tt>)
|
76
|
+
|
77
|
+
===4. Compile the scaffolds
|
78
|
+
|
79
|
+
> rake flex:app mxml=messages
|
80
|
+
|
81
|
+
This will generate:
|
82
|
+
|
83
|
+
* copy assets into the <tt>/app/flex/<model></tt> folder ready for compilation (see below)
|
84
|
+
* compile the swf files based on the configuration in the related controller to <tt>/app/flex/<model></tt>
|
85
|
+
* save the resulting swf in <tt>/public/swfs/flex_scaffold</tt>
|
86
|
+
* ensure that all needed public assets are copied to <tt>/public/</tt> [stylesheets, javascript] (also see Restart server below)
|
87
|
+
|
88
|
+
This +Rake+ task infact copies the necessary assets into the build folder </tt>/app/flex</tt> and then remove when finished. To avoid you compile only. This would involved steps either side for use:
|
89
|
+
|
90
|
+
> rake flex:build:install mxml=contacts [move the assets into the build structure]
|
91
|
+
> rake flex:compile mxml=contacts [repeat this as many times as needed]
|
92
|
+
|
93
|
+
Optionally you may wish to clean up:
|
94
|
+
> rake flex:build:clobber mxml=contacts
|
95
|
+
|
96
|
+
Note: There is currently no way to build multiple scaffolds at one time.
|
97
|
+
|
98
|
+
===5. (Re)Start server?
|
99
|
+
|
100
|
+
Just check this. You should only need to restart the start to init the plugin. This will also copy the correct files to public which is equivalent to the +Rake+ task: <tt>rake flex:public:install</tt>
|
101
|
+
|
102
|
+
|
103
|
+
==General Design Notes:
|
104
|
+
|
105
|
+
Key features:
|
106
|
+
|
107
|
+
* Easily scaffold
|
108
|
+
* Be able to manually compile
|
109
|
+
* Getting model validation generated out to the client (still working out on full validation conversion)
|
110
|
+
|
111
|
+
To do:
|
112
|
+
|
113
|
+
* Be able to cutomise views
|
114
|
+
* Automatic (re)complilation
|
115
|
+
* Perhaps, auto install <tt>flex_sdk2</tt> (this will probably break license - but could have local repository/or checked into a library)
|
116
|
+
|
117
|
+
Long run:
|
118
|
+
|
119
|
+
I suspect that there will need to split out flex_scaffold and ActionView::Helpers::FlexObjectHelper. I would hope
|
120
|
+
that flex have an equivalent set of helpers as javascript.
|
121
|
+
|
122
|
+
===Phase I (complete)
|
123
|
+
* tie in REST (resource) generation for flex_scaffold
|
124
|
+
* scaffold model for flex viewing (flex_scaffold)
|
125
|
+
* generate mxml files for model
|
126
|
+
* compile swf
|
127
|
+
* transfer swf to public folder
|
128
|
+
* load page which points flash file (use JavascriptHelper in openLaszlo)
|
129
|
+
* add CRUD actions on controller
|
130
|
+
* add return schema onto controller
|
131
|
+
|
132
|
+
===Phase II
|
133
|
+
* remove js, styles, etc as generator and put as rake command at startup
|
134
|
+
* add the view layer as the plugin rather than generator
|
135
|
+
* duplicate model validation (at compile time) into client (as well as server)
|
136
|
+
* autocompilation (generator knows whether there were changes)
|
137
|
+
|
138
|
+
===Phase III
|
139
|
+
* configurable scaffold see ajax_scaffold [http://ajaxscaffold.stikipad.com/doc/show/4.0+Design+Docs]
|
140
|
+
|
141
|
+
flex_scaffold :task do
|
142
|
+
table :only => [ :name, :role ]
|
143
|
+
form :except => [ :created_at, :updated_at ]
|
144
|
+
columns do
|
145
|
+
name do
|
146
|
+
sort("name.downcase")
|
147
|
+
is_required
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
|
153
|
+
* template the flex code created in generator using helpers (develop ActiveView::Helpers::FlexHelper)
|
154
|
+
* that is use, rhtml to embed flex within pages (scaffold as a plugin) [unsure whether this will work and/or is desirable]
|
155
|
+
|
156
|
+
===Phase IV
|
157
|
+
* multiple models on a page
|
158
|
+
|
159
|
+
==Credits
|
160
|
+
|
161
|
+
Released under the MIT license (included)
|
162
|
+
|
163
|
+
* toddb --- Flex Scaffold plugin
|
164
|
+
|
165
|
+
The initial code was inspired by (or lifted from)
|
166
|
+
* <tt>flex_engenial_scaffold:</tt> This is the basis for the CRUD look and feel and early code basis
|
167
|
+
* <tt>flexible_rails:</tt> I have used his section from FlexibleRails for using REST services
|
168
|
+
* <tt>ajax_scaffold:</tt> basically reproduced their tables and hook code
|
169
|
+
* <tt>laszlo-plugin:</tt> this separates out the generators well and has a good javascript helper
|
data/Rakefile
ADDED
@@ -0,0 +1,116 @@
|
|
1
|
+
require 'rake'
|
2
|
+
require 'rake/testtask'
|
3
|
+
require 'rake/rdoctask'
|
4
|
+
require 'rake/packagetask'
|
5
|
+
require 'rake/gempackagetask'
|
6
|
+
require 'rake/contrib/rubyforgepublisher'
|
7
|
+
|
8
|
+
PKG_NAME = "flex_scaffold"
|
9
|
+
PKG_VERSION = '0.1.0'
|
10
|
+
RUBYFORGE_PROJECT = 'flexible-rails'
|
11
|
+
RUBYFORGE_USER = ENV['RUBYFORGE_USER']
|
12
|
+
|
13
|
+
desc 'Default: run unit tests.'
|
14
|
+
task :default => :test
|
15
|
+
|
16
|
+
desc 'Test the flex_scaffold plugin.'
|
17
|
+
Rake::TestTask.new(:test) do |t|
|
18
|
+
t.libs << 'lib'
|
19
|
+
t.pattern = 'test/**/*_test.rb'
|
20
|
+
t.verbose = true
|
21
|
+
end
|
22
|
+
|
23
|
+
# Generate packages ------------------------------------------------------------------
|
24
|
+
|
25
|
+
Rake::PackageTask.new(PKG_NAME, PKG_VERSION) do |p|
|
26
|
+
p.need_tar = true
|
27
|
+
p.need_zip = true
|
28
|
+
p.package_files.include("./**/*")
|
29
|
+
p.package_files.exclude 'pkg', 'rdoc'
|
30
|
+
p.package_files.exclude 'notes.txt', '#*'
|
31
|
+
end
|
32
|
+
|
33
|
+
# Tag SVN for releases ------------------------------------------------------------------
|
34
|
+
|
35
|
+
task :tag_svn do
|
36
|
+
url = `svn info`[/^URL:\s*(.*\/)trunk/, 1]
|
37
|
+
tag_message = "-m \"tag release #{PKG_VERSION}\""
|
38
|
+
system("svn cp #{tag_message} #{url}/trunk #{url}/tags/REL-#{PKG_VERSION.gsub(/\./,'_')}")
|
39
|
+
system("svn cp #{tag_message} #{url}/trunk #{url}/rails/plugins/flex_scaffold")
|
40
|
+
end
|
41
|
+
|
42
|
+
# Generate documentation ------------------------------------------------------------------
|
43
|
+
|
44
|
+
desc 'Generate documentation for the flex_scaffold plugin.'
|
45
|
+
Rake::RDocTask.new(:rdoc) do |rdoc|
|
46
|
+
rdoc.rdoc_dir = 'rdoc'
|
47
|
+
rdoc.title = 'Flexible Scaffolding for Rails -- Embedding Flex in Rails through REST'
|
48
|
+
rdoc.main = 'README'
|
49
|
+
rdoc.options << '--line-numbers' << '--inline-source'
|
50
|
+
rdoc.rdoc_files.include('README', 'TODO', 'MIT-LICENSE', 'CHANGELOG')
|
51
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
52
|
+
end
|
53
|
+
|
54
|
+
# Generate GEM ----------------------------------------------------------------------------
|
55
|
+
|
56
|
+
PKG_FILES = FileList[
|
57
|
+
'[a-zA-Z]*',
|
58
|
+
'tasks/**/*',
|
59
|
+
'public/**/*',
|
60
|
+
'generators/**/*',
|
61
|
+
'lib/**/*'
|
62
|
+
] - [ 'test' ]
|
63
|
+
|
64
|
+
spec = Gem::Specification.new do |s|
|
65
|
+
s.name = 'flex_scaffold'
|
66
|
+
s.version = PKG_VERSION
|
67
|
+
s.summary = "Plugin for scaffolding a Flex view within Rails on REST services."
|
68
|
+
s.description = <<-EOF
|
69
|
+
Flexible Rails Scaffolding is a plugin to scaffold REST controllers and a flex view for models. Use generators
|
70
|
+
to create the code and rake to compile. Flexible Rails generates .mxml and .as code so that it can be edited
|
71
|
+
by both Rails and Flex coders.
|
72
|
+
EOF
|
73
|
+
|
74
|
+
s.add_dependency('rake', '>= 0.7.2')
|
75
|
+
s.add_dependency('rails','>= 1.2.0')
|
76
|
+
|
77
|
+
s.rdoc_options << '--exclude' << '.'
|
78
|
+
s.has_rdoc = false
|
79
|
+
|
80
|
+
s.files = PKG_FILES.to_a.delete_if {|f| f.include?('.svn')}
|
81
|
+
s.require_path = 'lib'
|
82
|
+
|
83
|
+
s.author = "toddb"
|
84
|
+
s.email = "todd@8wireunlimited.com"
|
85
|
+
s.homepage = "http://flexible-rails.rubyforge.org"
|
86
|
+
s.rubyforge_project = "flexible-rails"
|
87
|
+
end
|
88
|
+
|
89
|
+
Rake::GemPackageTask.new(spec) do |pkg|
|
90
|
+
pkg.gem_spec = spec
|
91
|
+
end
|
92
|
+
|
93
|
+
|
94
|
+
# Publishing -------------------------------------------------------
|
95
|
+
#desc "Publish the API documentation"
|
96
|
+
#task :pgem => [:gem] do
|
97
|
+
# Rake::SshFilePublisher.new("davidhh@wrath.rubyonrails.org", "public_html/gems/gems", "pkg", "#{PKG_FILE_NAME}.gem").upload
|
98
|
+
# `ssh davidhh@wrath.rubyonrails.org './gemupdate.sh'`
|
99
|
+
#end
|
100
|
+
|
101
|
+
desc "Publish the API documentation"
|
102
|
+
task :publish_rdoc => [:rdoc] do
|
103
|
+
program = (RUBY_PLATFORM =~ /mswin32/) ? "winscp3" : "scp"
|
104
|
+
system("#{program} -r rdoc/* #{RUBYFORGE_USER}@rubyforge.org:/var/www/gforge-projects/#{RUBYFORGE_PROJECT}")
|
105
|
+
end
|
106
|
+
|
107
|
+
desc "Publish the release files to RubyForge."
|
108
|
+
task :release => [ :package ] do
|
109
|
+
require 'rubyforge'
|
110
|
+
|
111
|
+
packages = %w( gem tgz zip ).collect{ |ext| "pkg/#{PKG_NAME}-#{PKG_VERSION}.#{ext}" }
|
112
|
+
|
113
|
+
rubyforge = RubyForge.new
|
114
|
+
rubyforge.login
|
115
|
+
rubyforge.add_release(RUBYFORGE_PROJECT, PKG_NAME, "REL #{PKG_VERSION}", *packages)
|
116
|
+
end
|
data/TODO
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
= Flexible Rails -- To Do List
|
2
|
+
|
3
|
+
== Fixes
|
4
|
+
* Sizing on pages at 100% height is dodgy because it needs it is based on the parent element - if this is body it is not implicitly sized (see http://www.webmasterworld.com/forum83/200.htm)
|
5
|
+
* Update is slightly broken
|
6
|
+
|
7
|
+
== Better understanding
|
8
|
+
* Flex use of CSS (personally I'm finding it limited) for themes
|
9
|
+
|
10
|
+
== New features
|
11
|
+
* Warn when needs recompilation
|
12
|
+
* Automatic recompilation
|
13
|
+
* themes
|
14
|
+
* Ensure app/flex/ can be used in conjunction with FlexBuilder
|
15
|
+
|
16
|
+
==Refactoring
|
17
|
+
* The generator code is ugly
|
18
|
+
* Separate out the functions in the mxml code
|
19
|
+
|
20
|
+
==Limitations
|
21
|
+
* Extend validation conversions
|
22
|
+
* No test suite
|
23
|
+
* Remove the hooks into the validation on the ActiveRecord (see lib\validations.rb)
|
@@ -0,0 +1,16 @@
|
|
1
|
+
Description:
|
2
|
+
The flex_scaffold generator creates a Flex application mxml source file and
|
3
|
+
a view that displays it. The model and controller must alrady exist: user script/generate
|
4
|
+
flex_scaffold_resource.
|
5
|
+
|
6
|
+
The generator takes a model name (singular) as its first argument.
|
7
|
+
|
8
|
+
Example:
|
9
|
+
./script/generate flex_scaffold contact
|
10
|
+
|
11
|
+
This will create:
|
12
|
+
app/flex/contacts/contacts.mxml
|
13
|
+
app/flex/contacts/_list.mxml
|
14
|
+
app/views/contacts/index.rhtml
|
15
|
+
app/views/layouts/contacts.rhtml
|
16
|
+
|