tidyflash 0.1
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/Manifest +40 -0
- data/README +4 -0
- data/Rakefile +15 -0
- data/bin/test_project.axml +19 -0
- data/bin/tidyflash +33 -0
- data/lib/script/bwlimit.rb +305 -0
- data/lib/script/generate +124 -0
- data/lib/script/server +4 -0
- data/lib/script/server.rb +20 -0
- data/lib/tasks/assets.rb +133 -0
- data/lib/tasks/demo_config.rb +27 -0
- data/lib/tasks/deploy.rb +21 -0
- data/lib/tidy/axml.rb +31 -0
- data/lib/tidy/compile.rb +97 -0
- data/lib/tidy/generate.rb +20 -0
- data/lib/tidy/template.rb +84 -0
- data/lib/tidy/template_binding.rb +26 -0
- data/lib/tidy/templates/air.axml.erb +19 -0
- data/lib/tidy/templates/demo_config.as.erb +7 -0
- data/lib/tidy_project.rb +26 -0
- data/templates/project/project.rb +17 -0
- data/templates/project/rakefile.rb +29 -0
- data/templates/project/script/fcsh/rakefile.rb +3 -0
- data/templates/project/src/app/helpers/Colours.as +1 -0
- data/templates/project/src/app/helpers/Debug.as +17 -0
- data/templates/project/src/app/helpers/Typography.as +1 -0
- data/templates/project/src/app/models/App.as +21 -0
- data/templates/project/src/app/models/FlashVars.as +1 -0
- data/templates/project/src/app/views/MainView.as +16 -0
- data/templates/project/src/app/views/PreloaderView.as +36 -0
- data/templates/scaffold/bin/xml/__model.xml +0 -0
- data/templates/scaffold/scaffold.rb +41 -0
- data/templates/scaffold/src/models/__Model.as +11 -0
- data/templates/scaffold/src/views/__model/__ModelDetailView.as +0 -0
- data/templates/scaffold/src/views/__model/__ModelListItemView.as +0 -0
- data/templates/scaffold/src/views/__model/__ModelListView.as +0 -0
- data/templates/swfobject/bin/index.html +16 -0
- data/templates/swfobject/bin/js/swfobject.js +5 -0
- data/templates/swfobject/swfobject.rb +12 -0
- data/test/test_tidy_project.rb +67 -0
- data/tidyflash.gemspec +32 -0
- metadata +125 -0
@@ -0,0 +1,27 @@
|
|
1
|
+
require 'erb'
|
2
|
+
class Fixnum; def class; "Number"; end;end
|
3
|
+
class Float; def class; "Number"; end; end
|
4
|
+
class TrueClass; def class; "Boolean"; end ;end
|
5
|
+
class FalseClass; def class; "Boolean"; end ;end
|
6
|
+
|
7
|
+
class String
|
8
|
+
def to_actionscript
|
9
|
+
self
|
10
|
+
self.gsub!(/\:/,"")
|
11
|
+
self.gsub!("\=\>",":")
|
12
|
+
self
|
13
|
+
end
|
14
|
+
end
|
15
|
+
class DemoConfig
|
16
|
+
def initialize(options)
|
17
|
+
template = File.read( 'lib/tasks/templates/demo_config.as.erb' )
|
18
|
+
@vars = options[:vars]
|
19
|
+
@class = options[:class]
|
20
|
+
@package = ""
|
21
|
+
as_class = ERB.new(template)
|
22
|
+
`mkdir -p #{File.dirname(options[:output])}`
|
23
|
+
File.open(options[:output],'w') do |f|
|
24
|
+
f << as_class.result(binding)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
data/lib/tasks/deploy.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
namespace :deploy do
|
2
|
+
desc "zip into ~/Public/ folder with current revision number"
|
3
|
+
task "zip" do
|
4
|
+
v = `bzr revno`.strip
|
5
|
+
cmd = "bzr export ~/Public/fubuntu-r#{v}.zip bin --root=Fubuntu-r#{v}"
|
6
|
+
puts cmd
|
7
|
+
puts exec cmd
|
8
|
+
end
|
9
|
+
|
10
|
+
desc "package air app"
|
11
|
+
task :package do
|
12
|
+
Dir.chdir("bin") do
|
13
|
+
puts "adt -certificate -cn SelfSigned 1024-RSA air_cert.pfx password"
|
14
|
+
command = "adt -package -storetype pkcs12 -keystore ../config/air_cert.pfx Fubuntu.air air.axml Fubuntu-air.swf apps/ gadgets/ icons/ platforms/ system/"
|
15
|
+
puts command
|
16
|
+
puts `#{command}`
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
|
21
|
+
end
|
data/lib/tidy/axml.rb
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require 'erb'
|
2
|
+
module Tidy
|
3
|
+
class Axml
|
4
|
+
def initialize(args)
|
5
|
+
|
6
|
+
|
7
|
+
@main = args[:main]
|
8
|
+
@output = args[:output]
|
9
|
+
@id = args[:id] || @output
|
10
|
+
@version = (args[:version] || "1").to_s.strip
|
11
|
+
@app_name = args[:app_name] || @output.to_s.gsub("_","")
|
12
|
+
@filename = @output
|
13
|
+
@content = "#{@output}.swf"
|
14
|
+
@width = args[:width] || 1200
|
15
|
+
@height = args[:height] || 900
|
16
|
+
source = File.read( "#{File.expand_path(File.dirname(__FILE__))}/templates/air.axml.erb" )
|
17
|
+
|
18
|
+
axml_file = "bin/#{@output}.axml"
|
19
|
+
|
20
|
+
puts "Air template with main:#{@main}, @output:#{@output}, id:#{@id}, @version:#{@version}, @app_name:#{@app_name}, filename:#{@filename}"
|
21
|
+
|
22
|
+
template = ERB.new(source)
|
23
|
+
|
24
|
+
File.open(axml_file,'w') do |f|
|
25
|
+
f << template.result(binding)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
|
30
|
+
end
|
31
|
+
end
|
data/lib/tidy/compile.rb
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
class Hash
|
2
|
+
def to_flex_arguments
|
3
|
+
map{ |key, value|
|
4
|
+
key = key.to_s.gsub("_","-")
|
5
|
+
if (value.class == Array)
|
6
|
+
value.map{|v| "-#{key}=#{v}" }.join(" ")
|
7
|
+
else
|
8
|
+
"-#{key}=#{value}"
|
9
|
+
end
|
10
|
+
}.join(" ")
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
require 'sprout/user'
|
15
|
+
require 'sprout/fcsh_socket'
|
16
|
+
require "#{File.expand_path(File.dirname(__FILE__))}/axml"
|
17
|
+
|
18
|
+
module Tidy
|
19
|
+
class Compile
|
20
|
+
WIDTH, HEIGHT = 1200, 900
|
21
|
+
DEFAULTS = {
|
22
|
+
:default_background_color=>"#000000",
|
23
|
+
:default_frame_rate=> 60,
|
24
|
+
#:incremental=>true,
|
25
|
+
:use_network=>false,
|
26
|
+
:verbose_stacktraces=>true
|
27
|
+
#:warnings=>true
|
28
|
+
}
|
29
|
+
def self.swf_url(args)
|
30
|
+
"bin/#{args[:output]}.swf"
|
31
|
+
end
|
32
|
+
#
|
33
|
+
# args can include:
|
34
|
+
# :width, :height, :output, etc...
|
35
|
+
# and underscore_versions of the compiler arguments
|
36
|
+
def self.air(args)
|
37
|
+
build args, "mxmlc +configname=air " + parse_options(args.merge(:options=>{:define=>["CONFIG::air,true","CONFIG::swf,false"]}))
|
38
|
+
Axml.new( args )
|
39
|
+
unless args[:do_not_launch]
|
40
|
+
File.delete File.expand_path("~/mm.cfg") if File.exists? File.expand_path("~/mm.cfg")
|
41
|
+
puts `adl bin/#{args[:output]}.axml`
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
|
46
|
+
#
|
47
|
+
# TODO: make adl launch an air file with a webkit instance and the swf inside it
|
48
|
+
#
|
49
|
+
def self.swf(args)
|
50
|
+
|
51
|
+
end
|
52
|
+
# usage: DemoConfig.new(:vars=>{:varName=>'value', :anotherVar=>2.4}, :output=>'variation')
|
53
|
+
def self.demo(args)
|
54
|
+
DemoConfig.new(:vars=>args[:vars] || {},
|
55
|
+
:class=>'DemoConfig',
|
56
|
+
:output=>"demos/#{args[:output]}/DemoConfig.as")
|
57
|
+
air(args.merge(:paths=>["demos/#{args[:output]}"]))
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.build(args,command)
|
61
|
+
#puts "cd #{FileUtils.pwd} && #{command}"
|
62
|
+
command_result = command
|
63
|
+
filtered_result = command_result.to_a.map{|l| l unless l.match(/^Reason|^Recompile/)}.compact
|
64
|
+
puts filtered_result
|
65
|
+
|
66
|
+
unless File.exists?(swf_url args)
|
67
|
+
puts "Building for first time"
|
68
|
+
require 'open3'
|
69
|
+
stdin, stdout, stderr = Open3.popen3(command)
|
70
|
+
puts "#{stdout.read}\n#{stderr.read}"
|
71
|
+
return
|
72
|
+
end
|
73
|
+
begin
|
74
|
+
result = Sprout::FCSHSocket.execute command
|
75
|
+
rescue
|
76
|
+
#if (result =~ /Connection refused/)
|
77
|
+
puts "*******************"
|
78
|
+
puts "* Starting FCSH *"
|
79
|
+
puts "*******************"
|
80
|
+
Dir.chdir("script/fcsh") do
|
81
|
+
require 'open3'
|
82
|
+
stdin, stdout, stderr = Open3.popen3("rake fcsh:start")
|
83
|
+
puts "#{stdout.read}\n#{stderr.read}"
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
DEFAULT_PATHS = %w[src assets ~/.tidy/tidy-as3]
|
88
|
+
def self.parse_options(args)
|
89
|
+
options = args[:options] ? DEFAULTS.merge(args[:options]) : DEFAULTS
|
90
|
+
paths = DEFAULT_PATHS
|
91
|
+
paths = args[:paths].concat(DEFAULT_PATHS) unless args[:paths].nil?
|
92
|
+
paths = paths.map{|path| "-source-path+=#{File.expand_path path}" }.join(" ")
|
93
|
+
"#{options.to_flex_arguments} -default-size #{args[:width]||WIDTH} #{args[:height]||HEIGHT} #{paths} -o=#{File.expand_path swf_url(args)} #{File.expand_path args[:main]}"
|
94
|
+
end
|
95
|
+
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'rubygems'
|
3
|
+
require 'active_support'
|
4
|
+
require 'tidy/template'
|
5
|
+
#LANGUAGE = 'as3' #TODO: un-hard-code
|
6
|
+
#SCRIPT_PATH = File.join("script", LANGUAGE)
|
7
|
+
#def available_templates
|
8
|
+
# Dir.entries(SCRIPT_PATH).collect{|e| e unless e[0]==46}.compact
|
9
|
+
#end
|
10
|
+
|
11
|
+
module Tidy
|
12
|
+
require 'erb'
|
13
|
+
require 'fileutils'
|
14
|
+
class Generate
|
15
|
+
def initialize(options={:template_id=>nil})
|
16
|
+
Template.new(options)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
@@ -0,0 +1,84 @@
|
|
1
|
+
require 'tidy/template_binding'
|
2
|
+
module Tidy
|
3
|
+
class Template
|
4
|
+
attr_reader :args
|
5
|
+
def initialize(params)
|
6
|
+
@template_id = params[:template_id]
|
7
|
+
@force = params[:force]
|
8
|
+
@args = params[:args].collect{|arg| arg unless arg.match("--")}
|
9
|
+
|
10
|
+
create_template_binding
|
11
|
+
copy_files if @template_binding.valid?
|
12
|
+
|
13
|
+
end
|
14
|
+
def create_template_binding
|
15
|
+
require template_class
|
16
|
+
# the get_template_binding method is placed
|
17
|
+
# in the included template class
|
18
|
+
@template_binding = get_template_binding(self)
|
19
|
+
@template_binding.init!
|
20
|
+
end
|
21
|
+
|
22
|
+
def template_path
|
23
|
+
File.join(File.expand_path(File.dirname(__FILE__)),'../../templates',@template_id)
|
24
|
+
end
|
25
|
+
|
26
|
+
def template_class
|
27
|
+
File.join(template_path,"#{@template_id}.rb")
|
28
|
+
end
|
29
|
+
|
30
|
+
def copy_files
|
31
|
+
pattern = File.join(template_path,"**/*")
|
32
|
+
files = Dir.glob(pattern)
|
33
|
+
files.each do |filename|
|
34
|
+
copy_file(filename) unless filename == template_class
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
def copy_file(filename)
|
39
|
+
if File.directory?(filename)
|
40
|
+
|
41
|
+
make_dirs(get_destination filename)
|
42
|
+
return
|
43
|
+
end
|
44
|
+
contents = IO.read(filename)
|
45
|
+
destination = get_destination(filename)
|
46
|
+
make_dirs(File.split(destination)[0])
|
47
|
+
|
48
|
+
result = File.extname(filename) == ".erb" ? contents : ERB.new(contents,0,"%").result(@template_binding.get_binding)
|
49
|
+
force = @force unless @force.nil?
|
50
|
+
if File.exists?(destination)
|
51
|
+
if(force.nil?)
|
52
|
+
puts "overwrite #{destination}? (yN)"
|
53
|
+
force = $stdin.gets.chomp.downcase == "y"
|
54
|
+
end
|
55
|
+
unless force
|
56
|
+
puts "skipping #{destination}"
|
57
|
+
else
|
58
|
+
File.delete(destination)
|
59
|
+
write_result(result,destination)
|
60
|
+
end
|
61
|
+
else
|
62
|
+
write_result(result,destination)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def write_result result,destination
|
67
|
+
File.open(destination,'a') do |file|
|
68
|
+
file << result
|
69
|
+
end
|
70
|
+
puts("created " + destination)
|
71
|
+
end
|
72
|
+
|
73
|
+
def make_dirs(dir)
|
74
|
+
FileUtils.mkdir_p(dir) unless File.exists? dir
|
75
|
+
end
|
76
|
+
|
77
|
+
def get_destination(file)
|
78
|
+
@template_binding.get_destination file.gsub(template_path,".")
|
79
|
+
end
|
80
|
+
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
module Tidy
|
2
|
+
class TemplateBinding
|
3
|
+
def initialize(template)
|
4
|
+
@template = template
|
5
|
+
@is_valid = true
|
6
|
+
end
|
7
|
+
def init!
|
8
|
+
#override this method to do extra curricular template activities
|
9
|
+
end
|
10
|
+
def valid?
|
11
|
+
@is_valid
|
12
|
+
end
|
13
|
+
def get_binding
|
14
|
+
return binding
|
15
|
+
end
|
16
|
+
def get_destination path
|
17
|
+
path
|
18
|
+
end
|
19
|
+
#COMMON stuff for templates
|
20
|
+
def credit
|
21
|
+
"Generated with Tidy Flash"
|
22
|
+
end
|
23
|
+
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<application xmlns="http://ns.adobe.com/air/application/1.5">
|
3
|
+
<id><%=@app_name.gsub(" ", "")%></id>
|
4
|
+
<version><%=@version.chomp%></version>
|
5
|
+
<filename><%=@app_name%></filename>
|
6
|
+
<initialWindow>
|
7
|
+
<content><%=@content%></content>
|
8
|
+
<visible>true</visible>
|
9
|
+
<x>400</x>
|
10
|
+
<y>50</y>
|
11
|
+
<width><%=@width%></width>
|
12
|
+
<height><%=@height + 23%></height>
|
13
|
+
</initialWindow>
|
14
|
+
<!--
|
15
|
+
<icon>
|
16
|
+
<image128x128>icons/128x128/fubuntu_logo_128x128.png</image128x128>
|
17
|
+
</icon>
|
18
|
+
-->
|
19
|
+
</application>
|
data/lib/tidy_project.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
require 'open3'
|
3
|
+
$:.unshift(File.expand_path('..', __FILE__))
|
4
|
+
require 'tidy/generate'
|
5
|
+
class TidyProject
|
6
|
+
|
7
|
+
|
8
|
+
def initialize(project_name)
|
9
|
+
@project_dir = project_name
|
10
|
+
raise "Project already exists" if File.exists? project_name
|
11
|
+
FileUtils.mkdir_p(project_name)
|
12
|
+
Dir.chdir(@project_dir) do
|
13
|
+
Tidy::Generate.new(:template_id=>'project', :args=>[project_name])
|
14
|
+
end
|
15
|
+
unless File.exists?(File.expand_path("~/.tidy/tidy-as3"))
|
16
|
+
puts "You don't have the tidy as3 libs installed. Attempting to pull them from github..."
|
17
|
+
command = "git clone git@github.com:michaelforrest/tidy-as3.git ~/.tidy/tidy-as3"
|
18
|
+
puts command
|
19
|
+
stdin, stdout, stderr = Open3.popen3(command)
|
20
|
+
puts "#{stdout.read}\n#{stderr.read}"
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
|
26
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
|
2
|
+
def get_template_binding(template)
|
3
|
+
Project.new(template)
|
4
|
+
end
|
5
|
+
|
6
|
+
class Project < Tidy::TemplateBinding
|
7
|
+
def initialize(params)
|
8
|
+
super(params)
|
9
|
+
@project_name = params.args[0]
|
10
|
+
end
|
11
|
+
def init!
|
12
|
+
FileUtils.mkdir_p "bin"
|
13
|
+
FileUtils.mkdir_p "assets"
|
14
|
+
#puts "Getting Tidy libraries"
|
15
|
+
#puts `svn co http://lbi-useful-actionscript-3.googlecode.com/svn/trunk/LBiUseful/project/src lib/lbi`
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'tidy/compile'
|
2
|
+
|
3
|
+
#desc 'compile and run air app (needs a couple of extra files manually created so far)'
|
4
|
+
#task :air do |t|
|
5
|
+
# Compile.air :main=>"src/Fubuntu.as", :output=>"Fubuntu-air"
|
6
|
+
#end
|
7
|
+
|
8
|
+
desc 'Compile and run the test harness'
|
9
|
+
task :test do |t|
|
10
|
+
Compile.air :main=>"src/FubuntuRunner.as", :output=>"Fubuntu-test", :paths=>['test','lib/asunit3']
|
11
|
+
end
|
12
|
+
|
13
|
+
desc 'Compile and run app'
|
14
|
+
task :app do
|
15
|
+
Tidy::Compile.air(:main=>'src/app/views/MainView.as',
|
16
|
+
:output=>"<%= @project_name.underscore %>",
|
17
|
+
:version=> "0.1")
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
#desc "regression tester"
|
22
|
+
#regress :regress do |t|
|
23
|
+
# t.input = "features/RegressionTestView.as"
|
24
|
+
#end
|
25
|
+
|
26
|
+
|
27
|
+
# set up the default rake task
|
28
|
+
task :default => :app
|
29
|
+
|
@@ -0,0 +1 @@
|
|
1
|
+
package app.helpers{
|
@@ -0,0 +1,17 @@
|
|
1
|
+
package app.helpers {
|
2
|
+
import flash.display.Stage;
|
3
|
+
|
4
|
+
/**
|
5
|
+
* @author michaelforrest
|
6
|
+
*/
|
7
|
+
public class Debug {
|
8
|
+
private static var show_invisible_fills : Boolean = false;
|
9
|
+
|
10
|
+
public static function init(stage : Stage) : void {
|
11
|
+
new Debug();
|
12
|
+
}
|
13
|
+
public static function showInvisibleFills() : Boolean {
|
14
|
+
return show_invisible_fills;
|
15
|
+
}
|
16
|
+
}
|
17
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
package app.helpers {
|
@@ -0,0 +1,21 @@
|
|
1
|
+
package app.models {
|
2
|
+
import flash.events.Event;
|
3
|
+
|
4
|
+
import tidy.mvc.model.EventMapper;
|
5
|
+
/**
|
6
|
+
* <%= credit %>
|
7
|
+
*/
|
8
|
+
public class App extends EventMapper {
|
9
|
+
|
10
|
+
public static var READY : String = "ready";
|
11
|
+
public function dispatchReady() : void {dispatchEvent(new Event(READY));}
|
12
|
+
|
13
|
+
private static var instance : App;
|
14
|
+
public static function getInstance() : App {
|
15
|
+
if(!instance) instance = new App();
|
16
|
+
return instance;
|
17
|
+
}
|
18
|
+
public function App() {
|
19
|
+
}
|
20
|
+
}
|
21
|
+
}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
package app.views {
|
2
|
+
import tidy.mvc.view.ViewBase;
|
3
|
+
/**
|
4
|
+
* Main Entry Point Class
|
5
|
+
* <%= credit %>
|
6
|
+
*/
|
7
|
+
[Frame(factoryClass="app.views.PreloaderView")]
|
8
|
+
public class MainView extends ViewBase {
|
9
|
+
|
10
|
+
public function MainView() {
|
11
|
+
super({paddingLeft:20, paddingTop:20, columnWidth:600 });
|
12
|
+
trace("Hello from this src/app/views/MainView")
|
13
|
+
append(text("It worked! Edit this view in src/app/views/MainView"));
|
14
|
+
}
|
15
|
+
}
|
16
|
+
}
|
@@ -0,0 +1,36 @@
|
|
1
|
+
package app.views{
|
2
|
+
import flash.display.MovieClip;
|
3
|
+
import flash.display.DisplayObject;
|
4
|
+
import flash.events.Event;
|
5
|
+
import flash.utils.getDefinitionByName;
|
6
|
+
public class PreloaderView extends MovieClip{
|
7
|
+
|
8
|
+
public function PreloaderView() {
|
9
|
+
stop();
|
10
|
+
addEventListener(Event.ENTER_FRAME, onEnterFrame);
|
11
|
+
}
|
12
|
+
private function onEnterFrame(event : Event) : void {
|
13
|
+
showProgress();
|
14
|
+
if(framesLoaded == totalFrames) {
|
15
|
+
removeEventListener(Event.ENTER_FRAME, onEnterFrame);
|
16
|
+
nextFrame();
|
17
|
+
init();
|
18
|
+
}
|
19
|
+
}
|
20
|
+
|
21
|
+
// customise this method to make your loader nicer.
|
22
|
+
private function showProgress() : void{
|
23
|
+
var percent : Number = root.loaderInfo.bytesLoaded / root.loaderInfo.bytesTotal;
|
24
|
+
graphics.clear();
|
25
|
+
graphics.beginFill(0xCCCCCC);
|
26
|
+
graphics.drawRect(0,0,stage.stageWidth * percent, stage.stageHeight);
|
27
|
+
}
|
28
|
+
private function init() : void {
|
29
|
+
var mainClass : Class = Class(getDefinitionByName("app.views.MainView"));
|
30
|
+
if(mainClass) {
|
31
|
+
var app : Object = new mainClass();
|
32
|
+
addChild(app as DisplayObject);
|
33
|
+
}
|
34
|
+
}
|
35
|
+
}
|
36
|
+
}
|
File without changes
|
@@ -0,0 +1,41 @@
|
|
1
|
+
def get_template_binding(template)
|
2
|
+
Scaffold.new(template)
|
3
|
+
end
|
4
|
+
|
5
|
+
class Scaffold < LBi::TemplateBinding
|
6
|
+
def initialize(template)
|
7
|
+
super(template)
|
8
|
+
@model = template.args.shift.classify
|
9
|
+
if @model.nil?
|
10
|
+
puts <<-MSG
|
11
|
+
Please provide a name for your model. For example:
|
12
|
+
$ ruby script/lbi/generate scaffold Page
|
13
|
+
MSG
|
14
|
+
@is_valid = false
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def model_name
|
19
|
+
@model.classify
|
20
|
+
end
|
21
|
+
def instance_name
|
22
|
+
@model.underscore
|
23
|
+
end
|
24
|
+
|
25
|
+
def collection_name
|
26
|
+
@model.tableize
|
27
|
+
end
|
28
|
+
|
29
|
+
def package_name
|
30
|
+
@model.downcase
|
31
|
+
end
|
32
|
+
def path_to_collection
|
33
|
+
"#{collection_name}.#{instance_name}"
|
34
|
+
end
|
35
|
+
|
36
|
+
def get_destination path
|
37
|
+
path.gsub!("__model", package_name)
|
38
|
+
path.gsub!("__Model", @model)
|
39
|
+
path
|
40
|
+
end
|
41
|
+
end
|
File without changes
|
File without changes
|
File without changes
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
|
2
|
+
"http://www.w3.org/TR/html4/strict.dtd">
|
3
|
+
<html>
|
4
|
+
<head>
|
5
|
+
<title><%=@swf_name.humanize%> | Tidy Flash Page</title>
|
6
|
+
<script src="js/swfobject.js" type="text/javascript" charset="utf-8"></script>
|
7
|
+
</head>
|
8
|
+
<body>
|
9
|
+
<div style="width:800px;height:600px">
|
10
|
+
<div id="<%=@swf_name%>">You need Flash 10 to view this!</div>
|
11
|
+
</div>
|
12
|
+
<script type="text/javascript" charset="utf-8">
|
13
|
+
swfobject.embedSWF('<%=@swf_name%>.swf', '<%=@swf_name%>', "100%", "100%", '10');
|
14
|
+
</script>
|
15
|
+
</body>
|
16
|
+
</html>
|
@@ -0,0 +1,5 @@
|
|
1
|
+
/* SWFObject v2.1 <http://code.google.com/p/swfobject/>
|
2
|
+
Copyright (c) 2007-2008 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 b="undefined",Q="object",n="Shockwave Flash",p="ShockwaveFlash.ShockwaveFlash",P="application/x-shockwave-flash",m="SWFObjectExprInst",j=window,K=document,T=navigator,o=[],N=[],i=[],d=[],J,Z=null,M=null,l=null,e=false,A=false;var h=function(){var v=typeof K.getElementById!=b&&typeof K.getElementsByTagName!=b&&typeof K.createElement!=b,AC=[0,0,0],x=null;if(typeof T.plugins!=b&&typeof T.plugins[n]==Q){x=T.plugins[n].description;if(x&&!(typeof T.mimeTypes!=b&&T.mimeTypes[P]&&!T.mimeTypes[P].enabledPlugin)){x=x.replace(/^.*\s+(\S+\s+\S+$)/,"$1");AC[0]=parseInt(x.replace(/^(.*)\..*$/,"$1"),10);AC[1]=parseInt(x.replace(/^.*\.(.*)\s.*$/,"$1"),10);AC[2]=/r/.test(x)?parseInt(x.replace(/^.*r(.*)$/,"$1"),10):0}}else{if(typeof j.ActiveXObject!=b){var y=null,AB=false;try{y=new ActiveXObject(p+".7")}catch(t){try{y=new ActiveXObject(p+".6");AC=[6,0,21];y.AllowScriptAccess="always"}catch(t){if(AC[0]==6){AB=true}}if(!AB){try{y=new ActiveXObject(p)}catch(t){}}}if(!AB&&y){try{x=y.GetVariable("$version");if(x){x=x.split(" ")[1].split(",");AC=[parseInt(x[0],10),parseInt(x[1],10),parseInt(x[2],10)]}}catch(t){}}}}var AD=T.userAgent.toLowerCase(),r=T.platform.toLowerCase(),AA=/webkit/.test(AD)?parseFloat(AD.replace(/^.*webkit\/(\d+(\.\d+)?).*$/,"$1")):false,q=false,z=r?/win/.test(r):/win/.test(AD),w=r?/mac/.test(r):/mac/.test(AD);/*@cc_on q=true;@if(@_win32)z=true;@elif(@_mac)w=true;@end@*/return{w3cdom:v,pv:AC,webkit:AA,ie:q,win:z,mac:w}}();var L=function(){if(!h.w3cdom){return }f(H);if(h.ie&&h.win){try{K.write("<script id=__ie_ondomload defer=true src=//:><\/script>");J=C("__ie_ondomload");if(J){I(J,"onreadystatechange",S)}}catch(q){}}if(h.webkit&&typeof K.readyState!=b){Z=setInterval(function(){if(/loaded|complete/.test(K.readyState)){E()}},10)}if(typeof K.addEventListener!=b){K.addEventListener("DOMContentLoaded",E,null)}R(E)}();function S(){if(J.readyState=="complete"){J.parentNode.removeChild(J);E()}}function E(){if(e){return }if(h.ie&&h.win){var v=a("span");try{var u=K.getElementsByTagName("body")[0].appendChild(v);u.parentNode.removeChild(u)}catch(w){return }}e=true;if(Z){clearInterval(Z);Z=null}var q=o.length;for(var r=0;r<q;r++){o[r]()}}function f(q){if(e){q()}else{o[o.length]=q}}function R(r){if(typeof j.addEventListener!=b){j.addEventListener("load",r,false)}else{if(typeof K.addEventListener!=b){K.addEventListener("load",r,false)}else{if(typeof j.attachEvent!=b){I(j,"onload",r)}else{if(typeof j.onload=="function"){var q=j.onload;j.onload=function(){q();r()}}else{j.onload=r}}}}}function H(){var t=N.length;for(var q=0;q<t;q++){var u=N[q].id;if(h.pv[0]>0){var r=C(u);if(r){N[q].width=r.getAttribute("width")?r.getAttribute("width"):"0";N[q].height=r.getAttribute("height")?r.getAttribute("height"):"0";if(c(N[q].swfVersion)){if(h.webkit&&h.webkit<312){Y(r)}W(u,true)}else{if(N[q].expressInstall&&!A&&c("6.0.65")&&(h.win||h.mac)){k(N[q])}else{O(r)}}}}else{W(u,true)}}}function Y(t){var q=t.getElementsByTagName(Q)[0];if(q){var w=a("embed"),y=q.attributes;if(y){var v=y.length;for(var u=0;u<v;u++){if(y[u].nodeName=="DATA"){w.setAttribute("src",y[u].nodeValue)}else{w.setAttribute(y[u].nodeName,y[u].nodeValue)}}}var x=q.childNodes;if(x){var z=x.length;for(var r=0;r<z;r++){if(x[r].nodeType==1&&x[r].nodeName=="PARAM"){w.setAttribute(x[r].getAttribute("name"),x[r].getAttribute("value"))}}}t.parentNode.replaceChild(w,t)}}function k(w){A=true;var u=C(w.id);if(u){if(w.altContentId){var y=C(w.altContentId);if(y){M=y;l=w.altContentId}}else{M=G(u)}if(!(/%$/.test(w.width))&&parseInt(w.width,10)<310){w.width="310"}if(!(/%$/.test(w.height))&&parseInt(w.height,10)<137){w.height="137"}K.title=K.title.slice(0,47)+" - Flash Player Installation";var z=h.ie&&h.win?"ActiveX":"PlugIn",q=K.title,r="MMredirectURL="+j.location+"&MMplayerType="+z+"&MMdoctitle="+q,x=w.id;if(h.ie&&h.win&&u.readyState!=4){var t=a("div");x+="SWFObjectNew";t.setAttribute("id",x);u.parentNode.insertBefore(t,u);u.style.display="none";var v=function(){u.parentNode.removeChild(u)};I(j,"onload",v)}U({data:w.expressInstall,id:m,width:w.width,height:w.height},{flashvars:r},x)}}function O(t){if(h.ie&&h.win&&t.readyState!=4){var r=a("div");t.parentNode.insertBefore(r,t);r.parentNode.replaceChild(G(t),r);t.style.display="none";var q=function(){t.parentNode.removeChild(t)};I(j,"onload",q)}else{t.parentNode.replaceChild(G(t),t)}}function G(v){var u=a("div");if(h.win&&h.ie){u.innerHTML=v.innerHTML}else{var r=v.getElementsByTagName(Q)[0];if(r){var w=r.childNodes;if(w){var q=w.length;for(var t=0;t<q;t++){if(!(w[t].nodeType==1&&w[t].nodeName=="PARAM")&&!(w[t].nodeType==8)){u.appendChild(w[t].cloneNode(true))}}}}}return u}function U(AG,AE,t){var q,v=C(t);if(v){if(typeof AG.id==b){AG.id=t}if(h.ie&&h.win){var AF="";for(var AB in AG){if(AG[AB]!=Object.prototype[AB]){if(AB.toLowerCase()=="data"){AE.movie=AG[AB]}else{if(AB.toLowerCase()=="styleclass"){AF+=' class="'+AG[AB]+'"'}else{if(AB.toLowerCase()!="classid"){AF+=" "+AB+'="'+AG[AB]+'"'}}}}}var AD="";for(var AA in AE){if(AE[AA]!=Object.prototype[AA]){AD+='<param name="'+AA+'" value="'+AE[AA]+'" />'}}v.outerHTML='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"'+AF+">"+AD+"</object>";i[i.length]=AG.id;q=C(AG.id)}else{if(h.webkit&&h.webkit<312){var AC=a("embed");AC.setAttribute("type",P);for(var z in AG){if(AG[z]!=Object.prototype[z]){if(z.toLowerCase()=="data"){AC.setAttribute("src",AG[z])}else{if(z.toLowerCase()=="styleclass"){AC.setAttribute("class",AG[z])}else{if(z.toLowerCase()!="classid"){AC.setAttribute(z,AG[z])}}}}}for(var y in AE){if(AE[y]!=Object.prototype[y]){if(y.toLowerCase()!="movie"){AC.setAttribute(y,AE[y])}}}v.parentNode.replaceChild(AC,v);q=AC}else{var u=a(Q);u.setAttribute("type",P);for(var x in AG){if(AG[x]!=Object.prototype[x]){if(x.toLowerCase()=="styleclass"){u.setAttribute("class",AG[x])}else{if(x.toLowerCase()!="classid"){u.setAttribute(x,AG[x])}}}}for(var w in AE){if(AE[w]!=Object.prototype[w]&&w.toLowerCase()!="movie"){F(u,w,AE[w])}}v.parentNode.replaceChild(u,v);q=u}}}return q}function F(t,q,r){var u=a("param");u.setAttribute("name",q);u.setAttribute("value",r);t.appendChild(u)}function X(r){var q=C(r);if(q&&(q.nodeName=="OBJECT"||q.nodeName=="EMBED")){if(h.ie&&h.win){if(q.readyState==4){B(r)}else{j.attachEvent("onload",function(){B(r)})}}else{q.parentNode.removeChild(q)}}}function B(t){var r=C(t);if(r){for(var q in r){if(typeof r[q]=="function"){r[q]=null}}r.parentNode.removeChild(r)}}function C(t){var q=null;try{q=K.getElementById(t)}catch(r){}return q}function a(q){return K.createElement(q)}function I(t,q,r){t.attachEvent(q,r);d[d.length]=[t,q,r]}function c(t){var r=h.pv,q=t.split(".");q[0]=parseInt(q[0],10);q[1]=parseInt(q[1],10)||0;q[2]=parseInt(q[2],10)||0;return(r[0]>q[0]||(r[0]==q[0]&&r[1]>q[1])||(r[0]==q[0]&&r[1]==q[1]&&r[2]>=q[2]))?true:false}function V(v,r){if(h.ie&&h.mac){return }var u=K.getElementsByTagName("head")[0],t=a("style");t.setAttribute("type","text/css");t.setAttribute("media","screen");if(!(h.ie&&h.win)&&typeof K.createTextNode!=b){t.appendChild(K.createTextNode(v+" {"+r+"}"))}u.appendChild(t);if(h.ie&&h.win&&typeof K.styleSheets!=b&&K.styleSheets.length>0){var q=K.styleSheets[K.styleSheets.length-1];if(typeof q.addRule==Q){q.addRule(v,r)}}}function W(t,q){var r=q?"visible":"hidden";if(e&&C(t)){C(t).style.visibility=r}else{V("#"+t,"visibility:"+r)}}function g(s){var r=/[\\\"<>\.;]/;var q=r.exec(s)!=null;return q?encodeURIComponent(s):s}var D=function(){if(h.ie&&h.win){window.attachEvent("onunload",function(){var w=d.length;for(var v=0;v<w;v++){d[v][0].detachEvent(d[v][1],d[v][2])}var t=i.length;for(var u=0;u<t;u++){X(i[u])}for(var r in h){h[r]=null}h=null;for(var q in swfobject){swfobject[q]=null}swfobject=null})}}();return{registerObject:function(u,q,t){if(!h.w3cdom||!u||!q){return }var r={};r.id=u;r.swfVersion=q;r.expressInstall=t?t:false;N[N.length]=r;W(u,false)},getObjectById:function(v){var q=null;if(h.w3cdom){var t=C(v);if(t){var u=t.getElementsByTagName(Q)[0];if(!u||(u&&typeof t.SetVariable!=b)){q=t}else{if(typeof u.SetVariable!=b){q=u}}}}return q},embedSWF:function(x,AE,AB,AD,q,w,r,z,AC){if(!h.w3cdom||!x||!AE||!AB||!AD||!q){return }AB+="";AD+="";if(c(q)){W(AE,false);var AA={};if(AC&&typeof AC===Q){for(var v in AC){if(AC[v]!=Object.prototype[v]){AA[v]=AC[v]}}}AA.data=x;AA.width=AB;AA.height=AD;var y={};if(z&&typeof z===Q){for(var u in z){if(z[u]!=Object.prototype[u]){y[u]=z[u]}}}if(r&&typeof r===Q){for(var t in r){if(r[t]!=Object.prototype[t]){if(typeof y.flashvars!=b){y.flashvars+="&"+t+"="+r[t]}else{y.flashvars=t+"="+r[t]}}}}f(function(){U(AA,y,AE);if(AA.id==AE){W(AE,true)}})}else{if(w&&!A&&c("6.0.65")&&(h.win||h.mac)){A=true;W(AE,false);f(function(){var AF={};AF.id=AF.altContentId=AE;AF.width=AB;AF.height=AD;AF.expressInstall=w;k(AF)})}}},getFlashPlayerVersion:function(){return{major:h.pv[0],minor:h.pv[1],release:h.pv[2]}},hasFlashPlayerVersion:c,createSWF:function(t,r,q){if(h.w3cdom){return U(t,r,q)}else{return undefined}},removeSWF:function(q){if(h.w3cdom){X(q)}},createCSS:function(r,q){if(h.w3cdom){V(r,q)}},addDomLoadEvent:f,addLoadEvent:R,getQueryParamValue:function(v){var u=K.location.search||K.location.hash;if(v==null){return g(u)}if(u){var t=u.substring(1).split("&");for(var r=0;r<t.length;r++){if(t[r].substring(0,t[r].indexOf("="))==v){return g(t[r].substring((t[r].indexOf("=")+1)))}}}return""},expressInstallCallback:function(){if(A&&M){var q=C(m);if(q){q.parentNode.replaceChild(M,q);if(l){W(l,true);if(h.ie&&h.win){M.style.display="block"}}M=null;l=null;A=false}}}}}();
|