xmvc 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +1 -1
- data/VERSION +1 -1
- data/bin/xmvc +8 -1
- data/lib/xmvc/builder.rb +13 -23
- data/lib/xmvc/cli.rb +10 -3
- data/lib/xmvc/environment.rb +0 -1
- data/lib/xmvc/generators/app.rb +52 -12
- data/lib/xmvc/generators/base.rb +14 -5
- data/lib/xmvc/generators/controller.rb +1 -1
- data/lib/xmvc/generators/model.rb +3 -1
- data/lib/xmvc/generators/templates/app/config/environment.yml +56 -0
- data/lib/xmvc/generators/templates/app/{spec/SpecHelper.js → config/environments/development.yml} +0 -0
- data/lib/xmvc/generators/templates/app/{vendor/screw-unit/spec/spec_helper.js → config/environments/production.yml} +0 -0
- data/lib/xmvc/generators/templates/app/{app → public/app}/App.js +0 -0
- data/lib/xmvc/generators/templates/app/{app → public/app}/controllers/application_controller.js +0 -0
- data/lib/xmvc/generators/templates/app/{app → public/app}/controllers/home_controller.js +0 -0
- data/lib/xmvc/generators/templates/app/{app → public/app}/views/home/index.js +0 -0
- data/lib/xmvc/generators/templates/app/{app → public/app}/views/layout/menu.js +0 -0
- data/lib/xmvc/generators/templates/app/{config → public/config}/application.js +0 -0
- data/lib/xmvc/generators/templates/app/{config → public/config}/boot.js +0 -0
- data/lib/xmvc/generators/templates/app/{config → public/config}/database.js +0 -0
- data/lib/xmvc/generators/templates/app/{config → public/config}/environment.json +0 -0
- data/lib/xmvc/generators/templates/app/{config → public/config}/environments/development.json +0 -0
- data/lib/xmvc/generators/templates/app/{config → public/config}/environments/production.json +0 -0
- data/lib/xmvc/generators/templates/app/{config → public/config}/routes.js +0 -0
- data/lib/xmvc/generators/templates/app/public/{index.html → public/index.html} +0 -0
- data/lib/xmvc/generators/templates/app/public/{stylesheets → public/stylesheets}/extjs-mvc-all.css +0 -0
- data/lib/xmvc/generators/templates/app/public/spec/SpecHelper.js +0 -0
- data/lib/xmvc/generators/templates/app/{spec → public/spec}/index.html +0 -0
- data/lib/xmvc/generators/templates/app/{vendor → public/vendor}/screw-unit/EXAMPLE.html +0 -0
- data/lib/xmvc/generators/templates/app/{vendor → public/vendor}/screw-unit/LICENSE +0 -0
- data/lib/xmvc/generators/templates/app/{vendor → public/vendor}/screw-unit/README.markdown +0 -0
- data/lib/xmvc/generators/templates/app/{vendor → public/vendor}/screw-unit/lib/jquery-1.2.3.js +0 -0
- data/lib/xmvc/generators/templates/app/{vendor → public/vendor}/screw-unit/lib/jquery.fn.js +0 -0
- data/lib/xmvc/generators/templates/app/{vendor → public/vendor}/screw-unit/lib/jquery.print.js +0 -0
- data/lib/xmvc/generators/templates/app/{vendor → public/vendor}/screw-unit/lib/screw.assets.js +0 -0
- data/lib/xmvc/generators/templates/app/{vendor → public/vendor}/screw-unit/lib/screw.behaviors.js +0 -0
- data/lib/xmvc/generators/templates/app/{vendor → public/vendor}/screw-unit/lib/screw.builder.js +0 -0
- data/lib/xmvc/generators/templates/app/{vendor → public/vendor}/screw-unit/lib/screw.css +0 -0
- data/lib/xmvc/generators/templates/app/{vendor → public/vendor}/screw-unit/lib/screw.events.js +0 -0
- data/lib/xmvc/generators/templates/app/{vendor → public/vendor}/screw-unit/lib/screw.matchers.js +0 -0
- data/lib/xmvc/generators/templates/app/{vendor → public/vendor}/screw-unit/lib/screw.server.js +0 -0
- data/lib/xmvc/generators/templates/app/{vendor → public/vendor}/screw-unit/spec/behaviors_spec.js +0 -0
- data/lib/xmvc/generators/templates/app/{vendor → public/vendor}/screw-unit/spec/matchers_spec.js +0 -0
- data/lib/xmvc/generators/templates/app/{vendor → public/vendor}/screw-unit/spec/print_spec.js +0 -0
- data/lib/xmvc/generators/templates/app/public/vendor/screw-unit/spec/spec_helper.js +0 -0
- data/lib/xmvc/generators/templates/app/{vendor → public/vendor}/screw-unit/spec/suite.html +0 -0
- data/lib/xmvc/generators/view.rb +2 -1
- data/lib/xmvc/settings.rb +59 -0
- data/lib/xmvc.rb +35 -3
- data/xmvc.gemspec +39 -38
- metadata +40 -39
- data/lib/xmvc/generators/templates/app/README.rdoc +0 -152
- data/lib/xmvc/generators/templates/app/config/settings.yml +0 -3
data/.document
CHANGED
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.1
|
data/bin/xmvc
CHANGED
@@ -2,11 +2,18 @@
|
|
2
2
|
|
3
3
|
# Check if an older version of extjs-mvc is installed
|
4
4
|
$LOAD_PATH.unshift(File.dirname(__FILE__) + '/../lib')
|
5
|
+
$LOAD_PATH.unshift("/Users/chris/workspace/extjs/extjs-mvc/lib")
|
6
|
+
|
5
7
|
require 'xmvc'
|
6
8
|
require 'xmvc/cli'
|
7
9
|
|
10
|
+
require 'extjs-mvc'
|
11
|
+
require 'extjs-mvc/cli'
|
12
|
+
|
8
13
|
begin
|
9
|
-
Xmvc::CLI.start
|
14
|
+
Xmvc::CLI.start(ARGV, {
|
15
|
+
:host => ExtJS::MVC
|
16
|
+
})
|
10
17
|
rescue Xmvc::Error => e
|
11
18
|
Xmvc.ui.error(e.message)
|
12
19
|
exit e.status_code
|
data/lib/xmvc/builder.rb
CHANGED
@@ -27,17 +27,18 @@ module Xmvc
|
|
27
27
|
# Note that we must pass-in the name of the newly created app @name so that
|
28
28
|
# Jammit appends that to its config_path, otherwise it would create its config file
|
29
29
|
# in the pwd.
|
30
|
-
|
31
30
|
@asset_root = options[:asset_root] || File.expand_path('.')
|
32
31
|
|
33
|
-
|
32
|
+
javascripts = {
|
33
|
+
"application" => application_assets("javascripts", options[:application])
|
34
|
+
}
|
35
|
+
options[:vendors].each do |vendor|
|
36
|
+
javascripts.update(vendor["name"] => vendor_assets("javascripts", vendor))
|
37
|
+
end
|
34
38
|
|
35
39
|
jammit = Jammit::CLI.new([], options)
|
36
40
|
jammit.invoke(:init)
|
37
|
-
jammit.invoke(:config, ["set", "javascripts",
|
38
|
-
"mvc" => mvc_assets,
|
39
|
-
"app" => app_assets
|
40
|
-
}])
|
41
|
+
jammit.invoke(:config, ["set", "javascripts", javascripts])
|
41
42
|
jammit.invoke(:build)
|
42
43
|
|
43
44
|
rescue Jammit::Error => e
|
@@ -45,27 +46,16 @@ module Xmvc
|
|
45
46
|
end
|
46
47
|
end
|
47
48
|
|
48
|
-
def
|
49
|
-
|
49
|
+
def vendor_assets(type, vendor)
|
50
|
+
vendor[type].map {|f| File.join("vendor", vendor["name"], f) }
|
50
51
|
end
|
51
52
|
|
52
|
-
def
|
53
|
-
|
54
|
-
File.join('vendor', 'mvc', f)
|
55
|
-
}
|
53
|
+
def application_assets(type, assets)
|
54
|
+
assets.map {|f| File.join(f)}
|
56
55
|
end
|
57
56
|
|
58
|
-
def
|
59
|
-
[
|
60
|
-
'app/App.js',
|
61
|
-
'config/application.js',
|
62
|
-
'config/routes.js',
|
63
|
-
'vendor/plugins/*/**.js',
|
64
|
-
'overrides/*.js',
|
65
|
-
'app/models/*.js',
|
66
|
-
'app/controllers/*.js',
|
67
|
-
'app/views/*/**.js'
|
68
|
-
]
|
57
|
+
def jammit(options={})
|
58
|
+
Jammit::CLI.new([], options)
|
69
59
|
end
|
70
60
|
end
|
71
61
|
end
|
data/lib/xmvc/cli.rb
CHANGED
@@ -2,6 +2,7 @@ require 'thor'
|
|
2
2
|
|
3
3
|
require 'jammit-core'
|
4
4
|
require 'jammit-core/cli'
|
5
|
+
|
5
6
|
|
6
7
|
module Xmvc
|
7
8
|
class CLI < Thor
|
@@ -9,7 +10,7 @@ module Xmvc
|
|
9
10
|
|
10
11
|
desc "install", "Install a framework"
|
11
12
|
def install(path)
|
12
|
-
Xmvc.ui.confirm('install')
|
13
|
+
Xmvc.ui.confirm('Xmvc install')
|
13
14
|
end
|
14
15
|
|
15
16
|
desc "generate", "Generate model, controller, view or app"
|
@@ -43,16 +44,22 @@ module Xmvc
|
|
43
44
|
end
|
44
45
|
|
45
46
|
def initialize(args=ARGV, config={}, options={})
|
47
|
+
|
46
48
|
# Boot UI
|
47
49
|
Xmvc.ui = UI::Shell.new(shell)
|
48
50
|
|
51
|
+
unless options[:host]
|
52
|
+
raise Xmvc::NoFramework.new("Xmvc is meant to be supplied with a framework extension, eg extjs-mvc, via Xmvc::CLI.start(ARGV, {:framework => Your::Framework})")
|
53
|
+
end
|
54
|
+
|
49
55
|
# Boot environment
|
50
56
|
Xmvc.environment = Xmvc::Environment.new(:development)
|
51
57
|
|
58
|
+
# Set the framework.
|
59
|
+
Xmvc.host = options[:host]
|
60
|
+
|
52
61
|
super
|
53
62
|
end
|
54
|
-
|
55
|
-
private
|
56
63
|
|
57
64
|
end
|
58
65
|
end
|
data/lib/xmvc/environment.rb
CHANGED
data/lib/xmvc/generators/app.rb
CHANGED
@@ -1,7 +1,18 @@
|
|
1
1
|
module Xmvc
|
2
2
|
module Generator
|
3
3
|
class App < Base
|
4
|
-
|
4
|
+
|
5
|
+
FRAMEWORK_ASSETS = [
|
6
|
+
'app/App.js',
|
7
|
+
'config/application.js',
|
8
|
+
'config/routes.js',
|
9
|
+
'vendor/plugins/*/**.js',
|
10
|
+
'overrides/*.js',
|
11
|
+
'app/models/*.js',
|
12
|
+
'app/controllers/*.js',
|
13
|
+
'app/views/*/**.js'
|
14
|
+
]
|
15
|
+
|
5
16
|
def initialize(name, namespace=nil)
|
6
17
|
@file_re ||= Regexp.new("^\.?\/(.*)")
|
7
18
|
@name = name
|
@@ -16,32 +27,54 @@ module Xmvc
|
|
16
27
|
FileUtils.mkdir(@name)
|
17
28
|
FileUtils.chdir(@name)
|
18
29
|
|
30
|
+
# Save a ref to app root, need for Jammit config.
|
31
|
+
app_root = File.expand_path(".")
|
32
|
+
|
33
|
+
# Create the root directory
|
34
|
+
create_root
|
35
|
+
|
36
|
+
# Now walk into the created public folder to write the javascript framework
|
37
|
+
FileUtils.chdir("public")
|
19
38
|
create_app
|
20
39
|
create_config
|
21
40
|
create_lib
|
22
41
|
create_public
|
23
42
|
create_spec
|
24
43
|
create_vendor
|
25
|
-
|
26
|
-
|
44
|
+
install_host
|
45
|
+
|
27
46
|
# Build assets.
|
28
47
|
Xmvc::BuilderManager.dispatch(:setup, {
|
29
|
-
:asset_root => File.expand_path('.')
|
48
|
+
:asset_root => File.expand_path('.'),
|
49
|
+
:app_root => app_root,
|
50
|
+
:vendors => [
|
51
|
+
Xmvc.host.config
|
52
|
+
],
|
53
|
+
:application => FRAMEWORK_ASSETS
|
30
54
|
})
|
31
55
|
|
32
56
|
end
|
33
57
|
|
34
58
|
private
|
35
59
|
|
60
|
+
def create_root
|
61
|
+
FileUtils.mkdir(%w(public))
|
62
|
+
|
63
|
+
# Write config/settings.yml, call-out to Xmvc::Environment isntead.
|
64
|
+
#FileUtils.cp("#{@template}/config/environment.yml", "config")
|
65
|
+
copy_file("config", ".")
|
66
|
+
|
67
|
+
end
|
68
|
+
|
36
69
|
def create_app
|
37
70
|
FileUtils.mkdir(%w(app app/models app/views app/controllers))
|
38
|
-
copy_file("app", ".")
|
71
|
+
copy_file("public/app", ".")
|
39
72
|
show_files("app")
|
40
73
|
end
|
41
74
|
|
42
75
|
def create_config
|
43
76
|
FileUtils.mkdir(%w(config config/environments))
|
44
|
-
copy_file("config", ".")
|
77
|
+
copy_file("public/config", ".")
|
45
78
|
show_files("config")
|
46
79
|
end
|
47
80
|
|
@@ -52,27 +85,34 @@ module Xmvc
|
|
52
85
|
|
53
86
|
def create_public
|
54
87
|
FileUtils.mkdir(%w(public public/stylesheets public/images public/javascripts))
|
55
|
-
copy_file("public", ".")
|
88
|
+
copy_file("public/public", ".")
|
56
89
|
show_files("public")
|
57
90
|
end
|
58
91
|
|
59
92
|
def create_spec
|
60
93
|
FileUtils.mkdir(%w(spec spec/controllers spec/models))
|
61
|
-
copy_file("spec", ".")
|
94
|
+
copy_file("public/spec", ".")
|
62
95
|
show_files("spec")
|
63
96
|
end
|
64
97
|
|
65
98
|
def create_vendor
|
66
99
|
FileUtils.mkdir(%w(vendor vendor/plugins))
|
67
|
-
copy_file("vendor", ".")
|
100
|
+
copy_file("public/vendor", ".")
|
68
101
|
show_files("vendor", false)
|
69
|
-
show_files("vendor/mvc", false)
|
70
102
|
end
|
71
103
|
|
72
|
-
def
|
73
|
-
|
104
|
+
def install_host
|
105
|
+
begin
|
106
|
+
Xmvc.host.install("vendor")
|
107
|
+
Xmvc.ui.confirm(" install vendor/#{Xmvc.host.config['name']}")
|
108
|
+
rescue StandardError => e
|
109
|
+
Xmvc.ui.error('An error occured while installing the host framework')
|
110
|
+
raise Xmvc::HostError.new(e.message)
|
111
|
+
end
|
112
|
+
|
74
113
|
end
|
75
114
|
|
115
|
+
|
76
116
|
def notify(f)
|
77
117
|
m = f.match(@file_re)
|
78
118
|
Xmvc.ui.confirm(" create #{(m) ? m[1] : f}")
|
data/lib/xmvc/generators/base.rb
CHANGED
@@ -9,19 +9,21 @@ module Xmvc
|
|
9
9
|
|
10
10
|
def initialize *args
|
11
11
|
@gsubs ||= {}
|
12
|
-
@gsubs['namespace'] = Xmvc.environment['namespace']
|
12
|
+
@gsubs['namespace'] = "development" #Xmvc.environment['namespace']
|
13
13
|
end
|
14
14
|
|
15
15
|
protected
|
16
16
|
def ensure_directories_present! *args
|
17
17
|
args.each do |a|
|
18
|
-
|
18
|
+
path = public_path(a)
|
19
|
+
Dir.mkdir(path) unless File.exists?(path)
|
19
20
|
end
|
20
21
|
end
|
21
22
|
|
22
23
|
def ensure_no_overwrite! *args
|
23
24
|
args.each do |a|
|
24
|
-
|
25
|
+
path = public_path(a)
|
26
|
+
if File.exists?(path) && !ARGV.include?("--force")
|
25
27
|
raise Xmvc::FileExists.new("File already exists: #{a}")
|
26
28
|
end
|
27
29
|
end
|
@@ -29,7 +31,7 @@ module Xmvc
|
|
29
31
|
|
30
32
|
def template(template_filename, destination_filename)
|
31
33
|
#write the file
|
32
|
-
File.open(destination_filename, 'w') {|f| f.puts(render_template(template_filename))}
|
34
|
+
File.open(public_path(destination_filename), 'w') {|f| f.puts(render_template(template_filename))}
|
33
35
|
|
34
36
|
Xmvc.ui.confirm(" Created #{destination_filename}")
|
35
37
|
end
|
@@ -51,7 +53,11 @@ module Xmvc
|
|
51
53
|
end
|
52
54
|
|
53
55
|
private
|
54
|
-
|
56
|
+
|
57
|
+
def public_path(f)
|
58
|
+
File.join("public", f)
|
59
|
+
end
|
60
|
+
|
55
61
|
##
|
56
62
|
# write a newly generated controller, model or view to environment.json
|
57
63
|
# Unfortunately, we cannot JSON.parse the entire config/environment.json, since it contains comments
|
@@ -59,6 +65,9 @@ module Xmvc
|
|
59
65
|
# Is this Regexp satisfactory?? Could probably be made better.
|
60
66
|
#
|
61
67
|
def to_environment(key, item)
|
68
|
+
Xmvc.ui.warn('Generator::Base#to_environment disabled')
|
69
|
+
return
|
70
|
+
|
62
71
|
re = Regexp.new("\"#{key}\"\s*\:\s*(\\[.*?\\](?!\}))", Regexp::MULTILINE)
|
63
72
|
content = File.read('config/environment.json')
|
64
73
|
m = content.match(re)
|
@@ -23,7 +23,9 @@ module Xmvc
|
|
23
23
|
template "Model.js", @model_filename
|
24
24
|
template "ModelSpec.js", @spec_filename
|
25
25
|
|
26
|
-
to_environment(:models, @gsubs["file_name"])
|
26
|
+
#to_environment(:models, @gsubs["file_name"])
|
27
|
+
Xmvc::Settings.add(:models, @gsubs["file_name"])
|
28
|
+
|
27
29
|
end
|
28
30
|
|
29
31
|
private
|
@@ -0,0 +1,56 @@
|
|
1
|
+
# General settings used by ruby scripts
|
2
|
+
|
3
|
+
namespace: MyApp
|
4
|
+
|
5
|
+
##
|
6
|
+
# Directory paths
|
7
|
+
pluginsDIr: ../vendor/plugins
|
8
|
+
libsDir: ../lib
|
9
|
+
configDir: ../config
|
10
|
+
overridesDir: ../config/overrides
|
11
|
+
appDir: ../app
|
12
|
+
vendor:
|
13
|
+
- extjs-mvc
|
14
|
+
mvcFilename: extjs-mvc-all-min
|
15
|
+
|
16
|
+
# Use config/application for general framework configuration
|
17
|
+
config:
|
18
|
+
- app/App
|
19
|
+
- config/application
|
20
|
+
- config/routes
|
21
|
+
|
22
|
+
##
|
23
|
+
# All stylesheets to be loaded. These are all taken to be relative to the public/stylesheets directory,
|
24
|
+
# and the .css is automatically appended
|
25
|
+
#
|
26
|
+
stylesheets: []
|
27
|
+
|
28
|
+
# Overrides to include. These files should be located in the config/overrides directory
|
29
|
+
overrides: []
|
30
|
+
|
31
|
+
# Plugins to include. Each will load vendor/plugins/SomePlugin/SomePlugin-all.js
|
32
|
+
plugins: []
|
33
|
+
|
34
|
+
# All of the models in this application, found in the app/models folder
|
35
|
+
models: []
|
36
|
+
|
37
|
+
# All of the controllers in this application, found in the app/controllers folder
|
38
|
+
controllers:
|
39
|
+
- application
|
40
|
+
- home
|
41
|
+
|
42
|
+
# All of the views in this application, as an object with the subfolder inside app/views as the key,
|
43
|
+
# and an array of filenames as the value. e.g.:
|
44
|
+
# views:
|
45
|
+
# index:
|
46
|
+
# - index
|
47
|
+
# - edit
|
48
|
+
# - new
|
49
|
+
# - view
|
50
|
+
# will load /app/views/index/index.js and app/views/index/my_view.js
|
51
|
+
views:
|
52
|
+
- layout:
|
53
|
+
- menu
|
54
|
+
- home:
|
55
|
+
- index
|
56
|
+
|
data/lib/xmvc/generators/templates/app/{spec/SpecHelper.js → config/environments/development.yml}
RENAMED
File without changes
|
File without changes
|
File without changes
|
data/lib/xmvc/generators/templates/app/{app → public/app}/controllers/application_controller.js
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/lib/xmvc/generators/templates/app/{config → public/config}/environments/development.json
RENAMED
File without changes
|
data/lib/xmvc/generators/templates/app/{config → public/config}/environments/production.json
RENAMED
File without changes
|
File without changes
|
File without changes
|
data/lib/xmvc/generators/templates/app/public/{stylesheets → public/stylesheets}/extjs-mvc-all.css
RENAMED
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/lib/xmvc/generators/templates/app/{vendor → public/vendor}/screw-unit/lib/jquery-1.2.3.js
RENAMED
File without changes
|
File without changes
|
data/lib/xmvc/generators/templates/app/{vendor → public/vendor}/screw-unit/lib/jquery.print.js
RENAMED
File without changes
|
data/lib/xmvc/generators/templates/app/{vendor → public/vendor}/screw-unit/lib/screw.assets.js
RENAMED
File without changes
|
data/lib/xmvc/generators/templates/app/{vendor → public/vendor}/screw-unit/lib/screw.behaviors.js
RENAMED
File without changes
|
data/lib/xmvc/generators/templates/app/{vendor → public/vendor}/screw-unit/lib/screw.builder.js
RENAMED
File without changes
|
File without changes
|
data/lib/xmvc/generators/templates/app/{vendor → public/vendor}/screw-unit/lib/screw.events.js
RENAMED
File without changes
|
data/lib/xmvc/generators/templates/app/{vendor → public/vendor}/screw-unit/lib/screw.matchers.js
RENAMED
File without changes
|
data/lib/xmvc/generators/templates/app/{vendor → public/vendor}/screw-unit/lib/screw.server.js
RENAMED
File without changes
|
data/lib/xmvc/generators/templates/app/{vendor → public/vendor}/screw-unit/spec/behaviors_spec.js
RENAMED
File without changes
|
data/lib/xmvc/generators/templates/app/{vendor → public/vendor}/screw-unit/spec/matchers_spec.js
RENAMED
File without changes
|
data/lib/xmvc/generators/templates/app/{vendor → public/vendor}/screw-unit/spec/print_spec.js
RENAMED
File without changes
|
File without changes
|
File without changes
|
data/lib/xmvc/generators/view.rb
CHANGED
data/lib/xmvc/settings.rb
CHANGED
@@ -1,3 +1,62 @@
|
|
1
|
+
module Xmvc
|
2
|
+
module Settings
|
3
|
+
|
4
|
+
class << self
|
5
|
+
|
6
|
+
def dispatch(action, *params)
|
7
|
+
|
8
|
+
end
|
9
|
+
|
10
|
+
def load
|
11
|
+
@settings = YAML.load_file('config/environment.yml')
|
12
|
+
end
|
13
|
+
|
14
|
+
##
|
15
|
+
# write a newly generated controller, model or view to environment.json
|
16
|
+
# Unfortunately, we cannot JSON.parse the entire config/environment.json, since it contains comments
|
17
|
+
# and such. Have to RegExp, pick-out the requested key, and JSON.parse the returned chunk.
|
18
|
+
# Is this Regexp satisfactory?? Could probably be made better.
|
19
|
+
#
|
20
|
+
def add (key, item)
|
21
|
+
key = key.to_s
|
22
|
+
@settings[key] = [] unless @settings[key] && @settings[key].kind_of?(Array)
|
23
|
+
|
24
|
+
unless key == "views"
|
25
|
+
@settings[key] << item
|
26
|
+
else
|
27
|
+
if controller = @settings[key].find {|i| i[item[:package]]}
|
28
|
+
controller[item[:package]] << item[:filename]
|
29
|
+
else
|
30
|
+
@settings[key] << {
|
31
|
+
item[:package] => [
|
32
|
+
item[:filename]
|
33
|
+
]
|
34
|
+
}
|
35
|
+
end
|
36
|
+
end
|
37
|
+
save
|
38
|
+
end
|
39
|
+
|
40
|
+
private
|
41
|
+
|
42
|
+
def save
|
43
|
+
File.open('config/environment.yml', "w") {|file|
|
44
|
+
file << @settings.to_yaml
|
45
|
+
}
|
46
|
+
File.open('public/config/environment.json', "w") {|file|
|
47
|
+
file << @settings.to_json
|
48
|
+
}
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
|
55
|
+
##
|
56
|
+
#
|
57
|
+
# ORIGINAL CODE
|
58
|
+
#
|
59
|
+
#
|
1
60
|
module ExtJS
|
2
61
|
module MVC
|
3
62
|
|
data/lib/xmvc.rb
CHANGED
@@ -15,15 +15,16 @@ module Xmvc
|
|
15
15
|
# Do autoloads here
|
16
16
|
#
|
17
17
|
require 'xmvc/settings'
|
18
|
+
require 'xmvc/builder'
|
18
19
|
|
19
20
|
autoload :UI, 'xmvc/ui'
|
20
21
|
autoload :Generator, 'xmvc/generator'
|
21
22
|
autoload :Environment, 'xmvc/environment'
|
22
|
-
autoload :BuilderManager, 'xmvc/builder'
|
23
23
|
autoload :Plugin, 'xmvc/plugin'
|
24
24
|
autoload :Stats, 'xmvc/stats'
|
25
25
|
autoload :Update, 'xmvc/update'
|
26
26
|
autoload :Text, 'xmvc/test'
|
27
|
+
autoload :Settings, 'xmvc/settings'
|
27
28
|
|
28
29
|
class Error < StandardError
|
29
30
|
def self.status_code(code = nil)
|
@@ -41,6 +42,8 @@ module Xmvc
|
|
41
42
|
class AppAlreadyExists < Error; status_code(3) ; end
|
42
43
|
class FileExists < Error; status_code(4) ; end
|
43
44
|
class BuilderError < Error; status_code(5) ; end
|
45
|
+
class NoFramework < Error; status_code(6) ; end
|
46
|
+
class HostError < Error; status_code(10) ; end
|
44
47
|
|
45
48
|
##
|
46
49
|
# Add more error classes here
|
@@ -49,8 +52,17 @@ module Xmvc
|
|
49
52
|
#class GemNotFound < BundlerError; status_code(7) ; end
|
50
53
|
|
51
54
|
class << self
|
55
|
+
##
|
56
|
+
# The Xmvc::UI instance
|
52
57
|
attr_writer :ui
|
53
|
-
|
58
|
+
##
|
59
|
+
# The Xmvc::Environemnt instance
|
60
|
+
#
|
61
|
+
attr_accessor :environment
|
62
|
+
##
|
63
|
+
# An instance of supplied framework plugin, eg ExtJS::MVC::CLI
|
64
|
+
#
|
65
|
+
attr_accessor :host
|
54
66
|
|
55
67
|
def configure
|
56
68
|
@configured ||= begin
|
@@ -62,13 +74,33 @@ module Xmvc
|
|
62
74
|
end
|
63
75
|
end
|
64
76
|
|
77
|
+
def settings
|
78
|
+
@settings ||= Settings.load
|
79
|
+
end
|
80
|
+
|
65
81
|
##
|
66
82
|
# Ensure we're running within a rails app unless generating a new app ($ xmvc generate app foo)
|
67
83
|
#
|
68
84
|
def ensure_in_app
|
69
|
-
|
85
|
+
|
86
|
+
|
87
|
+
if File.exists?("app") && File.exists?("config") && File.exists?("config/environment.json")
|
88
|
+
|
89
|
+
FileUtils.chdir("..")
|
90
|
+
##
|
91
|
+
# For development, ensure we don't execute from installed gem code
|
92
|
+
#
|
93
|
+
$LOAD_PATH.unshift('../lib')
|
94
|
+
#
|
95
|
+
#
|
96
|
+
end
|
97
|
+
|
98
|
+
# Check for existence of arbitrary app files...see if it *looks* like we're in an Xmvc app.
|
99
|
+
unless ARGV.empty? || ARGV.first == "help" || (File.exists?("public") && File.exists?("config") && File.exists?("config/environment.yml"))
|
70
100
|
raise Xmvc::AppNotFound.new("This command must be executed from the root of an xmvc application")
|
71
101
|
end
|
102
|
+
Settings.load
|
103
|
+
|
72
104
|
end
|
73
105
|
|
74
106
|
def ui
|
data/xmvc.gemspec
CHANGED
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{xmvc}
|
8
|
-
s.version = "0.1.
|
8
|
+
s.version = "0.1.1"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Ed Spencer and Chris Scott"]
|
12
|
-
s.date = %q{2010-03-
|
12
|
+
s.date = %q{2010-03-11}
|
13
13
|
s.default_executable = %q{xmvc}
|
14
14
|
s.description = %q{A full-stack, full-stack MVC framework generator geared towards generating towards the Ext JS framework. The actual javascript framework implementation is provided by the Gem extjs-mvc. This gem contains a series of builders and erb-templates for auto-generating javascript model, view and controller class-files.}
|
15
15
|
s.email = %q{christocracy@gmail.com}
|
@@ -49,42 +49,43 @@ Gem::Specification.new do |s|
|
|
49
49
|
"lib/xmvc/generators/templates/ModelSpec.js",
|
50
50
|
"lib/xmvc/generators/templates/View.js",
|
51
51
|
"lib/xmvc/generators/templates/_Action.js",
|
52
|
-
"lib/xmvc/generators/templates/app/
|
53
|
-
"lib/xmvc/generators/templates/app/
|
54
|
-
"lib/xmvc/generators/templates/app/
|
55
|
-
"lib/xmvc/generators/templates/app/app/
|
56
|
-
"lib/xmvc/generators/templates/app/app/
|
57
|
-
"lib/xmvc/generators/templates/app/app/
|
58
|
-
"lib/xmvc/generators/templates/app/
|
59
|
-
"lib/xmvc/generators/templates/app/
|
60
|
-
"lib/xmvc/generators/templates/app/config/
|
61
|
-
"lib/xmvc/generators/templates/app/config/
|
62
|
-
"lib/xmvc/generators/templates/app/config/
|
63
|
-
"lib/xmvc/generators/templates/app/config/
|
64
|
-
"lib/xmvc/generators/templates/app/config/
|
65
|
-
"lib/xmvc/generators/templates/app/config/
|
66
|
-
"lib/xmvc/generators/templates/app/public/
|
67
|
-
"lib/xmvc/generators/templates/app/public/
|
68
|
-
"lib/xmvc/generators/templates/app/
|
69
|
-
"lib/xmvc/generators/templates/app/spec/
|
70
|
-
"lib/xmvc/generators/templates/app/
|
71
|
-
"lib/xmvc/generators/templates/app/vendor/screw-unit/
|
72
|
-
"lib/xmvc/generators/templates/app/vendor/screw-unit/
|
73
|
-
"lib/xmvc/generators/templates/app/vendor/screw-unit/
|
74
|
-
"lib/xmvc/generators/templates/app/vendor/screw-unit/lib/jquery.
|
75
|
-
"lib/xmvc/generators/templates/app/vendor/screw-unit/lib/jquery.
|
76
|
-
"lib/xmvc/generators/templates/app/vendor/screw-unit/lib/
|
77
|
-
"lib/xmvc/generators/templates/app/vendor/screw-unit/lib/screw.
|
78
|
-
"lib/xmvc/generators/templates/app/vendor/screw-unit/lib/screw.
|
79
|
-
"lib/xmvc/generators/templates/app/vendor/screw-unit/lib/screw.
|
80
|
-
"lib/xmvc/generators/templates/app/vendor/screw-unit/lib/screw.
|
81
|
-
"lib/xmvc/generators/templates/app/vendor/screw-unit/lib/screw.
|
82
|
-
"lib/xmvc/generators/templates/app/vendor/screw-unit/lib/screw.
|
83
|
-
"lib/xmvc/generators/templates/app/vendor/screw-unit/
|
84
|
-
"lib/xmvc/generators/templates/app/vendor/screw-unit/spec/
|
85
|
-
"lib/xmvc/generators/templates/app/vendor/screw-unit/spec/
|
86
|
-
"lib/xmvc/generators/templates/app/vendor/screw-unit/spec/
|
87
|
-
"lib/xmvc/generators/templates/app/vendor/screw-unit/spec/
|
52
|
+
"lib/xmvc/generators/templates/app/config/environment.yml",
|
53
|
+
"lib/xmvc/generators/templates/app/config/environments/development.yml",
|
54
|
+
"lib/xmvc/generators/templates/app/config/environments/production.yml",
|
55
|
+
"lib/xmvc/generators/templates/app/public/app/App.js",
|
56
|
+
"lib/xmvc/generators/templates/app/public/app/controllers/application_controller.js",
|
57
|
+
"lib/xmvc/generators/templates/app/public/app/controllers/home_controller.js",
|
58
|
+
"lib/xmvc/generators/templates/app/public/app/views/home/index.js",
|
59
|
+
"lib/xmvc/generators/templates/app/public/app/views/layout/menu.js",
|
60
|
+
"lib/xmvc/generators/templates/app/public/config/application.js",
|
61
|
+
"lib/xmvc/generators/templates/app/public/config/boot.js",
|
62
|
+
"lib/xmvc/generators/templates/app/public/config/database.js",
|
63
|
+
"lib/xmvc/generators/templates/app/public/config/environment.json",
|
64
|
+
"lib/xmvc/generators/templates/app/public/config/environments/development.json",
|
65
|
+
"lib/xmvc/generators/templates/app/public/config/environments/production.json",
|
66
|
+
"lib/xmvc/generators/templates/app/public/config/routes.js",
|
67
|
+
"lib/xmvc/generators/templates/app/public/public/index.html",
|
68
|
+
"lib/xmvc/generators/templates/app/public/public/stylesheets/extjs-mvc-all.css",
|
69
|
+
"lib/xmvc/generators/templates/app/public/spec/SpecHelper.js",
|
70
|
+
"lib/xmvc/generators/templates/app/public/spec/index.html",
|
71
|
+
"lib/xmvc/generators/templates/app/public/vendor/screw-unit/EXAMPLE.html",
|
72
|
+
"lib/xmvc/generators/templates/app/public/vendor/screw-unit/LICENSE",
|
73
|
+
"lib/xmvc/generators/templates/app/public/vendor/screw-unit/README.markdown",
|
74
|
+
"lib/xmvc/generators/templates/app/public/vendor/screw-unit/lib/jquery-1.2.3.js",
|
75
|
+
"lib/xmvc/generators/templates/app/public/vendor/screw-unit/lib/jquery.fn.js",
|
76
|
+
"lib/xmvc/generators/templates/app/public/vendor/screw-unit/lib/jquery.print.js",
|
77
|
+
"lib/xmvc/generators/templates/app/public/vendor/screw-unit/lib/screw.assets.js",
|
78
|
+
"lib/xmvc/generators/templates/app/public/vendor/screw-unit/lib/screw.behaviors.js",
|
79
|
+
"lib/xmvc/generators/templates/app/public/vendor/screw-unit/lib/screw.builder.js",
|
80
|
+
"lib/xmvc/generators/templates/app/public/vendor/screw-unit/lib/screw.css",
|
81
|
+
"lib/xmvc/generators/templates/app/public/vendor/screw-unit/lib/screw.events.js",
|
82
|
+
"lib/xmvc/generators/templates/app/public/vendor/screw-unit/lib/screw.matchers.js",
|
83
|
+
"lib/xmvc/generators/templates/app/public/vendor/screw-unit/lib/screw.server.js",
|
84
|
+
"lib/xmvc/generators/templates/app/public/vendor/screw-unit/spec/behaviors_spec.js",
|
85
|
+
"lib/xmvc/generators/templates/app/public/vendor/screw-unit/spec/matchers_spec.js",
|
86
|
+
"lib/xmvc/generators/templates/app/public/vendor/screw-unit/spec/print_spec.js",
|
87
|
+
"lib/xmvc/generators/templates/app/public/vendor/screw-unit/spec/spec_helper.js",
|
88
|
+
"lib/xmvc/generators/templates/app/public/vendor/screw-unit/spec/suite.html",
|
88
89
|
"lib/xmvc/generators/templates/scaffold/ScaffoldController.js",
|
89
90
|
"lib/xmvc/generators/view.rb",
|
90
91
|
"lib/xmvc/plugin.rb",
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 0
|
7
7
|
- 1
|
8
|
-
-
|
9
|
-
version: 0.1.
|
8
|
+
- 1
|
9
|
+
version: 0.1.1
|
10
10
|
platform: ruby
|
11
11
|
authors:
|
12
12
|
- Ed Spencer and Chris Scott
|
@@ -14,7 +14,7 @@ autorequire:
|
|
14
14
|
bindir: bin
|
15
15
|
cert_chain: []
|
16
16
|
|
17
|
-
date: 2010-03-
|
17
|
+
date: 2010-03-11 00:00:00 -05:00
|
18
18
|
default_executable: xmvc
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -154,42 +154,43 @@ files:
|
|
154
154
|
- lib/xmvc/generators/templates/ModelSpec.js
|
155
155
|
- lib/xmvc/generators/templates/View.js
|
156
156
|
- lib/xmvc/generators/templates/_Action.js
|
157
|
-
- lib/xmvc/generators/templates/app/
|
158
|
-
- lib/xmvc/generators/templates/app/
|
159
|
-
- lib/xmvc/generators/templates/app/
|
160
|
-
- lib/xmvc/generators/templates/app/app/
|
161
|
-
- lib/xmvc/generators/templates/app/app/
|
162
|
-
- lib/xmvc/generators/templates/app/app/
|
163
|
-
- lib/xmvc/generators/templates/app/
|
164
|
-
- lib/xmvc/generators/templates/app/
|
165
|
-
- lib/xmvc/generators/templates/app/config/
|
166
|
-
- lib/xmvc/generators/templates/app/config/
|
167
|
-
- lib/xmvc/generators/templates/app/config/
|
168
|
-
- lib/xmvc/generators/templates/app/config/
|
169
|
-
- lib/xmvc/generators/templates/app/config/
|
170
|
-
- lib/xmvc/generators/templates/app/config/
|
171
|
-
- lib/xmvc/generators/templates/app/public/
|
172
|
-
- lib/xmvc/generators/templates/app/public/
|
173
|
-
- lib/xmvc/generators/templates/app/
|
174
|
-
- lib/xmvc/generators/templates/app/spec/
|
175
|
-
- lib/xmvc/generators/templates/app/
|
176
|
-
- lib/xmvc/generators/templates/app/vendor/screw-unit/
|
177
|
-
- lib/xmvc/generators/templates/app/vendor/screw-unit/
|
178
|
-
- lib/xmvc/generators/templates/app/vendor/screw-unit/
|
179
|
-
- lib/xmvc/generators/templates/app/vendor/screw-unit/lib/jquery.
|
180
|
-
- lib/xmvc/generators/templates/app/vendor/screw-unit/lib/jquery.
|
181
|
-
- lib/xmvc/generators/templates/app/vendor/screw-unit/lib/
|
182
|
-
- lib/xmvc/generators/templates/app/vendor/screw-unit/lib/screw.
|
183
|
-
- lib/xmvc/generators/templates/app/vendor/screw-unit/lib/screw.
|
184
|
-
- lib/xmvc/generators/templates/app/vendor/screw-unit/lib/screw.
|
185
|
-
- lib/xmvc/generators/templates/app/vendor/screw-unit/lib/screw.
|
186
|
-
- lib/xmvc/generators/templates/app/vendor/screw-unit/lib/screw.
|
187
|
-
- lib/xmvc/generators/templates/app/vendor/screw-unit/lib/screw.
|
188
|
-
- lib/xmvc/generators/templates/app/vendor/screw-unit/
|
189
|
-
- lib/xmvc/generators/templates/app/vendor/screw-unit/spec/
|
190
|
-
- lib/xmvc/generators/templates/app/vendor/screw-unit/spec/
|
191
|
-
- lib/xmvc/generators/templates/app/vendor/screw-unit/spec/
|
192
|
-
- lib/xmvc/generators/templates/app/vendor/screw-unit/spec/
|
157
|
+
- lib/xmvc/generators/templates/app/config/environment.yml
|
158
|
+
- lib/xmvc/generators/templates/app/config/environments/development.yml
|
159
|
+
- lib/xmvc/generators/templates/app/config/environments/production.yml
|
160
|
+
- lib/xmvc/generators/templates/app/public/app/App.js
|
161
|
+
- lib/xmvc/generators/templates/app/public/app/controllers/application_controller.js
|
162
|
+
- lib/xmvc/generators/templates/app/public/app/controllers/home_controller.js
|
163
|
+
- lib/xmvc/generators/templates/app/public/app/views/home/index.js
|
164
|
+
- lib/xmvc/generators/templates/app/public/app/views/layout/menu.js
|
165
|
+
- lib/xmvc/generators/templates/app/public/config/application.js
|
166
|
+
- lib/xmvc/generators/templates/app/public/config/boot.js
|
167
|
+
- lib/xmvc/generators/templates/app/public/config/database.js
|
168
|
+
- lib/xmvc/generators/templates/app/public/config/environment.json
|
169
|
+
- lib/xmvc/generators/templates/app/public/config/environments/development.json
|
170
|
+
- lib/xmvc/generators/templates/app/public/config/environments/production.json
|
171
|
+
- lib/xmvc/generators/templates/app/public/config/routes.js
|
172
|
+
- lib/xmvc/generators/templates/app/public/public/index.html
|
173
|
+
- lib/xmvc/generators/templates/app/public/public/stylesheets/extjs-mvc-all.css
|
174
|
+
- lib/xmvc/generators/templates/app/public/spec/SpecHelper.js
|
175
|
+
- lib/xmvc/generators/templates/app/public/spec/index.html
|
176
|
+
- lib/xmvc/generators/templates/app/public/vendor/screw-unit/EXAMPLE.html
|
177
|
+
- lib/xmvc/generators/templates/app/public/vendor/screw-unit/LICENSE
|
178
|
+
- lib/xmvc/generators/templates/app/public/vendor/screw-unit/README.markdown
|
179
|
+
- lib/xmvc/generators/templates/app/public/vendor/screw-unit/lib/jquery-1.2.3.js
|
180
|
+
- lib/xmvc/generators/templates/app/public/vendor/screw-unit/lib/jquery.fn.js
|
181
|
+
- lib/xmvc/generators/templates/app/public/vendor/screw-unit/lib/jquery.print.js
|
182
|
+
- lib/xmvc/generators/templates/app/public/vendor/screw-unit/lib/screw.assets.js
|
183
|
+
- lib/xmvc/generators/templates/app/public/vendor/screw-unit/lib/screw.behaviors.js
|
184
|
+
- lib/xmvc/generators/templates/app/public/vendor/screw-unit/lib/screw.builder.js
|
185
|
+
- lib/xmvc/generators/templates/app/public/vendor/screw-unit/lib/screw.css
|
186
|
+
- lib/xmvc/generators/templates/app/public/vendor/screw-unit/lib/screw.events.js
|
187
|
+
- lib/xmvc/generators/templates/app/public/vendor/screw-unit/lib/screw.matchers.js
|
188
|
+
- lib/xmvc/generators/templates/app/public/vendor/screw-unit/lib/screw.server.js
|
189
|
+
- lib/xmvc/generators/templates/app/public/vendor/screw-unit/spec/behaviors_spec.js
|
190
|
+
- lib/xmvc/generators/templates/app/public/vendor/screw-unit/spec/matchers_spec.js
|
191
|
+
- lib/xmvc/generators/templates/app/public/vendor/screw-unit/spec/print_spec.js
|
192
|
+
- lib/xmvc/generators/templates/app/public/vendor/screw-unit/spec/spec_helper.js
|
193
|
+
- lib/xmvc/generators/templates/app/public/vendor/screw-unit/spec/suite.html
|
193
194
|
- lib/xmvc/generators/templates/scaffold/ScaffoldController.js
|
194
195
|
- lib/xmvc/generators/view.rb
|
195
196
|
- lib/xmvc/plugin.rb
|
@@ -1,152 +0,0 @@
|
|
1
|
-
= ExtJS MVC Base App
|
2
|
-
|
3
|
-
Ext MVC Application structure for any new MVC application. Structure inspired by Ruby on Rails.
|
4
|
-
|
5
|
-
== Installation
|
6
|
-
|
7
|
-
Clone this as the starting point for your apps. Place your cloned directory somewhere apache can serve it, then head to index.html:
|
8
|
-
|
9
|
-
http://localhost/myDirectory/index.html
|
10
|
-
|
11
|
-
You should see a default application set up and ready to go.
|
12
|
-
|
13
|
-
== Prerequisites
|
14
|
-
|
15
|
-
Most prerequisites are installed for you inside the vendor directory:
|
16
|
-
|
17
|
-
* vendor/ext - contains a copy of ExtJS v2.2.1 (debug version, production copy by defaults comes off the cachefly CDN)
|
18
|
-
* vendor/mvc - contains a copy of the latest stable version of Ext MVC (debug and minified versions)
|
19
|
-
* vendor/screw-unit - contains a copy of ScrewUnit, a BDD testing framework for JavaScipt
|
20
|
-
* vendor/yui-compressor - contains a copy of the YUI compressor, which is used in the automatic build process
|
21
|
-
|
22
|
-
Although is is not strictly a prerequisite, you are *strongly* advised to install Ruby and Rubygems as the scripts below will automate a lot of things
|
23
|
-
for you and save you a lot of time. If you're running OSX you probably already have these, if you're on Windows it's a very simple install process.
|
24
|
-
Take a look at http://rubyonrails.org/download for instructions (just the Ruby and RubyGems sections).
|
25
|
-
|
26
|
-
If you don't intend to use the Ruby automation scripts, you can safely delete the script, vendor/mvc/scripts and vendor/yui-compressor folders.
|
27
|
-
|
28
|
-
== Getting Started
|
29
|
-
|
30
|
-
The only thing you need to change is the namespace your application will be using. Choose a meaningful namespace for your application - e.g. for
|
31
|
-
a blog application you might choose BlogApp, or something similar. All of your code will sit under that namespace, like this:
|
32
|
-
|
33
|
-
* BlogApp.models.Post // reference to a Post model constructor
|
34
|
-
* BlogApp.controllers.IndexController // reference to a controller constructor
|
35
|
-
* BlogApp.views.posts.New // reference to a view constructor, usually an Ext.Panel subclass
|
36
|
-
|
37
|
-
It doesn't matter if you don't know what those do yet, the important thing is that you don't pollute the global namespace. The whole of Ext MVC is
|
38
|
-
build around this idea.
|
39
|
-
|
40
|
-
Once you've chosen your namespace, just run the following command:
|
41
|
-
|
42
|
-
ruby script/setup MyAppNamespace
|
43
|
-
|
44
|
-
This will update all files with the default namespace ('MyApp') with the namespace you specify.
|
45
|
-
|
46
|
-
If you can't run the script, you can easily perform the setup yourself - just change the references from the default 'MyApp' namespace to your own
|
47
|
-
namespace in the following files:
|
48
|
-
|
49
|
-
* app/OS.js
|
50
|
-
* app/controllers/IndexController.js
|
51
|
-
* app/views/index/Index.js
|
52
|
-
* config/initialize.js
|
53
|
-
* config/settings.yml
|
54
|
-
|
55
|
-
Just use a simple find/replace all.
|
56
|
-
|
57
|
-
== Build tools
|
58
|
-
|
59
|
-
You need to ensure you have Ruby installed to use the build tools, and also the rake and hpricot gems (sudo gem install rake hpricot).
|
60
|
-
|
61
|
-
Ext MVC will automatically build (concatenate and minify) your javascript and CSS files. Just run the following command from the base directory:
|
62
|
-
|
63
|
-
ruby script/build all
|
64
|
-
|
65
|
-
This will inspect the javascript and css include tags inside index.html and compress them into a single JS file and a single CSS file. It will minify
|
66
|
-
the javascript if the YUI Compressor is installed in vendor/yui-compressor and create the following files:
|
67
|
-
|
68
|
-
* public/application-all.js
|
69
|
-
* public/application-all-min.js
|
70
|
-
* public/stylesheets/application-all.css
|
71
|
-
|
72
|
-
== Generators:
|
73
|
-
|
74
|
-
Ext MVC comes with some built-in generators to automate some aspects of application development. Run the generators
|
75
|
-
described below from within the main directory of your Ext MVC application.
|
76
|
-
|
77
|
-
Be sure that you have updated your config/settings.yml file before running these, otherwise everything will be namespaced
|
78
|
-
to 'MyApp' (see above).
|
79
|
-
|
80
|
-
=== Model
|
81
|
-
|
82
|
-
ruby script/generate model User first_name:string last_name:string balance:int is_admin:boolean
|
83
|
-
|
84
|
-
Will generate the following files:
|
85
|
-
|
86
|
-
in app/models/User.js:
|
87
|
-
/**
|
88
|
-
* @class MyApp.models.MyModel
|
89
|
-
* @extends ExtMVC.Model
|
90
|
-
*/
|
91
|
-
ExtMVC.Model.define("MyApp.models.User", {
|
92
|
-
modelName: 'user',
|
93
|
-
fields: [
|
94
|
-
{name: 'first_name', type: 'string'},
|
95
|
-
{name: 'last_name', type: 'string'},
|
96
|
-
{name: 'balance', type: 'int'},
|
97
|
-
{name: 'is_admin', type: 'boolean'}
|
98
|
-
]
|
99
|
-
});
|
100
|
-
|
101
|
-
in spec/models/User.spec.js:
|
102
|
-
Screw.Unit(function() {
|
103
|
-
describe("The User class", function() {
|
104
|
-
var user;
|
105
|
-
before(function() {
|
106
|
-
user = new MyApp.models.User({
|
107
|
-
//set fields for this model here
|
108
|
-
});
|
109
|
-
});
|
110
|
-
|
111
|
-
//create your unit tests here
|
112
|
-
});
|
113
|
-
});
|
114
|
-
|
115
|
-
It will also add the following line to your index.html file:
|
116
|
-
|
117
|
-
<script type="text/javascript" src="app/models/User.js"></script>
|
118
|
-
|
119
|
-
And the following to your spec/index.html file:
|
120
|
-
|
121
|
-
<script type="text/javascript" src="../app/models/User.js"></script>
|
122
|
-
<script type="text/javascript" src="models/User.spec.js"></script>
|
123
|
-
|
124
|
-
|
125
|
-
== Deployment
|
126
|
-
|
127
|
-
Once you've built your app, upload only the 'public' folder to your web server. Nothing else is required to run the app.
|
128
|
-
|
129
|
-
== Directory Structure:
|
130
|
-
|
131
|
-
* app - a directory to contain your models, views and controllers
|
132
|
-
* app/controllers - contains all of your controllers
|
133
|
-
* app/models - contains all modesl
|
134
|
-
* app/views - contains all view files, usually in subdirectories (e.g. app/views/users/Index.js)
|
135
|
-
* config - contains application configuration files (see below)
|
136
|
-
* lib - contains any library files which are not suited to being plugins
|
137
|
-
* public - the directory you will set as document root on your web server. Place any public-facing assets in here. Note that all javascript and stylesheet files will be concatenated automatically into here when you deploy, so these can exist outside of this folder. Images and other assets will need to be placed here though.
|
138
|
-
* script - contains scripts to automate site build and minification
|
139
|
-
* spec - a directory to place your unit tests or specs
|
140
|
-
* vendor - holds any third-party code
|
141
|
-
* vendor/ext - contains the required version of ExtJS. ExtJS 2.2 comes pre-installed here, with the Ext adapter.
|
142
|
-
* vendor/mvc - contains the required version of Ext MVC. Most recent stable version installed by default. Obtain latest version from http://github.com/extmvc/extmvc/tree
|
143
|
-
* vendor/plugins - contains any MVC-compatible plugins (such as viewport builders, model extensions etc)
|
144
|
-
|
145
|
-
== Important Files:
|
146
|
-
|
147
|
-
* config/routes.js - set up any Ext.History related routing required (see file for help)
|
148
|
-
* config/initialize.js - any app-wide config code, such as setting up location of s.gif, booting your app, etc
|
149
|
-
* config/database.js - define which data adapter your app uses (RESTful adapter, Gears adapter, your own concoction etc)
|
150
|
-
|
151
|
-
* index.html - Development version of the site, including one file at a time and using ext-all-debug
|
152
|
-
* public/index.html - Production version of the site referencing concatenated and minified files
|