joosy 1.0.0.RC3 → 1.0.0.RC4
Sign up to get free protection for your applications and to get access to all the features.
- data/app/assets/javascripts/joosy/core/layout.js.coffee +7 -2
- data/app/assets/javascripts/joosy/core/modules/renderer.js.coffee +15 -3
- data/app/assets/javascripts/joosy/core/page.js.coffee +4 -1
- data/app/assets/javascripts/joosy/core/resource/collection.js.coffee +3 -0
- data/app/assets/javascripts/joosy/core/resource/generic.js.coffee +2 -1
- data/lib/joosy/rails/version.rb +1 -1
- data/lib/rails/generators/joosy/layout_generator.rb +0 -2
- data/lib/rails/generators/joosy/page_generator.rb +0 -2
- data/lib/rails/generators/joosy/preloader_generator.rb +0 -2
- data/lib/rails/generators/joosy/resource_generator.rb +0 -1
- data/lib/rails/generators/joosy/templates/app/templates/layouts/application.jst.hamlc +1 -1
- data/lib/rails/generators/joosy/widget_generator.rb +0 -2
- data/spec/javascripts/joosy/core/modules/renderer_spec.js.coffee +7 -13
- data/spec/javascripts/joosy/core/resource/generic_spec.js.coffee +6 -0
- metadata +20 -20
@@ -101,12 +101,17 @@ class Joosy.Layout extends Joosy.Module
|
|
101
101
|
# $.get '/rumbas', (@data) => complete()
|
102
102
|
#
|
103
103
|
@fetch: (callback) ->
|
104
|
-
@::__fetch =
|
104
|
+
@::__fetch = (complete) ->
|
105
|
+
@data = {}
|
106
|
+
callback.call this, =>
|
107
|
+
@dataFetched = true
|
108
|
+
complete()
|
105
109
|
|
106
110
|
#
|
107
|
-
#
|
111
|
+
# Prefetched page data.
|
108
112
|
#
|
109
113
|
data: false
|
114
|
+
dataFetched: false
|
110
115
|
|
111
116
|
#
|
112
117
|
# @param [Hash] params List of route params
|
@@ -85,14 +85,20 @@ Joosy.Modules.Renderer =
|
|
85
85
|
stack.template = template
|
86
86
|
stack.locals = locals
|
87
87
|
|
88
|
-
|
89
|
-
|
88
|
+
# If template was given as a lambda, parameters should
|
89
|
+
# be passed as a context, not as a argument
|
90
|
+
assignContext = false
|
91
|
+
|
92
|
+
isResource = Joosy.Module.hasAncestor locals.constructor, Joosy.Resource.Generic
|
93
|
+
isCollection = Joosy.Module.hasAncestor locals.constructor, Joosy.Resource.Collection
|
90
94
|
|
91
95
|
if Object.isString template
|
92
96
|
if @__renderSection?
|
93
97
|
template = Joosy.Application.templater.resolveTemplate @__renderSection(), template, this
|
94
98
|
|
95
99
|
template = Joosy.Application.templater.buildView template
|
100
|
+
else if Object.isFunction template
|
101
|
+
assignContext = true
|
96
102
|
else if !Object.isFunction template
|
97
103
|
throw new Error "#{Joosy.Module.__className @}> template (maybe @view) does not look like a string or lambda"
|
98
104
|
|
@@ -104,6 +110,8 @@ Joosy.Modules.Renderer =
|
|
104
110
|
@render template, locals, stack
|
105
111
|
renderDynamic: (template, locals={}) =>
|
106
112
|
@renderDynamic template, locals, stack
|
113
|
+
renderInline: (locals={}, template) =>
|
114
|
+
@renderDynamic template, locals, stack
|
107
115
|
|
108
116
|
context = =>
|
109
117
|
data = {}
|
@@ -117,7 +125,11 @@ Joosy.Modules.Renderer =
|
|
117
125
|
Joosy.Module.merge data, renderers
|
118
126
|
data
|
119
127
|
|
120
|
-
result = ->
|
128
|
+
result = ->
|
129
|
+
if assignContext
|
130
|
+
template.call(context())
|
131
|
+
else
|
132
|
+
template(context())
|
121
133
|
|
122
134
|
if dynamic
|
123
135
|
morph = Metamorph result()
|
@@ -52,6 +52,7 @@ class Joosy.Page extends Joosy.Module
|
|
52
52
|
# Prefetched page data.
|
53
53
|
#
|
54
54
|
data: false
|
55
|
+
dataFetched: false
|
55
56
|
|
56
57
|
#
|
57
58
|
# Sets layout for current page
|
@@ -133,7 +134,9 @@ class Joosy.Page extends Joosy.Module
|
|
133
134
|
@fetch: (callback) ->
|
134
135
|
@::__fetch = (complete) ->
|
135
136
|
@data = {}
|
136
|
-
callback.call
|
137
|
+
callback.call this, =>
|
138
|
+
@dataFetched = true
|
139
|
+
complete()
|
137
140
|
|
138
141
|
#
|
139
142
|
# Sets the several separate methods that will fetch data in parallel.
|
@@ -72,7 +72,8 @@ class Joosy.Resource.Generic extends Joosy.Module
|
|
72
72
|
class clone extends this
|
73
73
|
|
74
74
|
if entity instanceof Joosy.Resource.Generic
|
75
|
-
clone.__source
|
75
|
+
clone.__source = entity.memberPath()
|
76
|
+
clone.__source += '/' + @::__entityName.pluralize() if @::__entityName
|
76
77
|
else
|
77
78
|
clone.__source = entity
|
78
79
|
|
data/lib/joosy/rails/version.rb
CHANGED
@@ -8,10 +8,8 @@ module Joosy
|
|
8
8
|
def create_files
|
9
9
|
super
|
10
10
|
|
11
|
-
empty_directory "#{app_path}/layouts"
|
12
11
|
template "app/layouts/template.js.coffee", "#{app_path}/layouts/#{file_name}.js.coffee"
|
13
12
|
|
14
|
-
empty_directory "#{app_path}/templates/layouts"
|
15
13
|
create_file("#{app_path}/templates/layouts/#{file_name}.jst.#{options[:template_kind]}")
|
16
14
|
end
|
17
15
|
|
@@ -8,10 +8,8 @@ module Joosy
|
|
8
8
|
def create_files
|
9
9
|
super
|
10
10
|
|
11
|
-
empty_directory "#{app_path}/pages/#{namespace_path}"
|
12
11
|
template "app/pages/template.js.coffee", "#{app_path}/pages/#{namespace_path}/#{file_name}.js.coffee"
|
13
12
|
|
14
|
-
empty_directory "#{app_path}/templates/pages/#{namespace_path}"
|
15
13
|
create_file "#{app_path}/templates/pages/#{namespace_path}/#{file_name}.jst.#{options[:template_kind]}"
|
16
14
|
end
|
17
15
|
|
@@ -18,10 +18,8 @@ HELP
|
|
18
18
|
|
19
19
|
template "app_preloader.js.coffee.erb", "app/assets/javascripts/#{file_name}_preloader.js.coffee.erb"
|
20
20
|
|
21
|
-
empty_directory "app/controllers"
|
22
21
|
template "app_controller.rb", "app/controllers/#{file_name}_controller.rb"
|
23
22
|
|
24
|
-
empty_directory "app/views/layouts"
|
25
23
|
template "preload.html.#{options[:template_engine]}",
|
26
24
|
"app/views/layouts/#{file_name}.html.#{options[:template_engine]}"
|
27
25
|
|
@@ -1,2 +1,2 @@
|
|
1
|
-
#page{:style => '
|
1
|
+
#page{:style => 'text-align: center'}
|
2
2
|
.content{:id => @yield()}
|
@@ -8,10 +8,8 @@ module Joosy
|
|
8
8
|
def create_files
|
9
9
|
super
|
10
10
|
|
11
|
-
empty_directory "#{app_path}/widgets"
|
12
11
|
template "app/widgets/template.js.coffee", "#{app_path}/widgets/#{file_name}.js.coffee"
|
13
12
|
|
14
|
-
empty_directory "#{app_path}/templates/widgets"
|
15
13
|
create_file "#{app_path}/templates/widgets/#{file_name}.jst.#{options[:template_kind]}"
|
16
14
|
end
|
17
15
|
|
@@ -24,8 +24,7 @@ describe "Joosy.Modules.Renderer", ->
|
|
24
24
|
|
25
25
|
it "updates contents, but only while it is bound to DOM", ->
|
26
26
|
@TestContainer.view (locals) ->
|
27
|
-
template =
|
28
|
-
"#{locals.object.value}"
|
27
|
+
template = -> @object.value
|
29
28
|
|
30
29
|
@renderDynamic(template, locals)
|
31
30
|
|
@@ -57,8 +56,7 @@ describe "Joosy.Modules.Renderer", ->
|
|
57
56
|
data = Joosy.Resource.Generic.build zombie: 'rock'
|
58
57
|
|
59
58
|
@TestContainer.view (locals) ->
|
60
|
-
template =
|
61
|
-
"#{locals.zombie}"
|
59
|
+
template = -> @zombie
|
62
60
|
|
63
61
|
@renderDynamic(template, locals)
|
64
62
|
|
@@ -92,8 +90,7 @@ describe "Joosy.Modules.Renderer", ->
|
|
92
90
|
]
|
93
91
|
|
94
92
|
@TestContainer.view (locals) ->
|
95
|
-
template =
|
96
|
-
"#{locals.data[1] 'zombie'}"
|
93
|
+
template = -> @data[1] 'zombie'
|
97
94
|
|
98
95
|
@renderDynamic(template, locals)
|
99
96
|
|
@@ -118,8 +115,7 @@ describe "Joosy.Modules.Renderer", ->
|
|
118
115
|
|
119
116
|
it "debounces morpher updates", ->
|
120
117
|
@TestContainer.view (locals) ->
|
121
|
-
template =
|
122
|
-
"#{locals.object.value}"
|
118
|
+
template = -> @object.value
|
123
119
|
|
124
120
|
@renderDynamic(template, locals)
|
125
121
|
|
@@ -155,8 +151,7 @@ describe "Joosy.Modules.Renderer", ->
|
|
155
151
|
@TestContainer.helpers "Hoge"
|
156
152
|
|
157
153
|
@TestContainer.view (locals) ->
|
158
|
-
template = (locals) ->
|
159
|
-
"#{locals.multiplier(10)}"
|
154
|
+
template = (locals) -> @multiplier(10)
|
160
155
|
|
161
156
|
@render(template, locals)
|
162
157
|
|
@@ -172,8 +167,7 @@ describe "Joosy.Modules.Renderer", ->
|
|
172
167
|
value * 6
|
173
168
|
|
174
169
|
@TestContainer.view (locals) ->
|
175
|
-
template = (locals) ->
|
176
|
-
"#{locals.globalMultiplier(10)}"
|
170
|
+
template = (locals) -> @globalMultiplier(10)
|
177
171
|
|
178
172
|
@render(template, locals)
|
179
173
|
|
@@ -192,7 +186,7 @@ describe "Joosy.Modules.Renderer", ->
|
|
192
186
|
callback = sinon.spy()
|
193
187
|
|
194
188
|
Box.view (locals) ->
|
195
|
-
template =
|
189
|
+
template = -> @onRefresh -> callback()
|
196
190
|
@render(template, locals)
|
197
191
|
|
198
192
|
box = new Box
|
@@ -45,11 +45,17 @@ describe "Joosy.Resource.Generic", ->
|
|
45
45
|
|
46
46
|
it "handles @at", ->
|
47
47
|
class Fluffy extends Joosy.Resource.Generic
|
48
|
+
@entity 'fluffy'
|
48
49
|
|
49
50
|
clone = Fluffy.at('rumbas!')
|
50
51
|
|
51
52
|
expect(clone.__source).toEqual 'rumbas!'
|
52
53
|
expect(Joosy.Module.hasAncestor clone, Fluffy).toBeTruthy()
|
54
|
+
|
55
|
+
clone = Fluffy.at Test.build(1)
|
56
|
+
|
57
|
+
expect(clone.__source).toEqual '/tests/1/fluffies'
|
58
|
+
expect(Joosy.Module.hasAncestor clone, Fluffy).toBeTruthy()
|
53
59
|
# clone won't be instanceof Fluffy in IE
|
54
60
|
#expect(clone.build({}) instanceof Fluffy).toBeTruthy()
|
55
61
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: joosy
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.0.
|
4
|
+
version: 1.0.0.RC4
|
5
5
|
prerelease: 6
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -12,11 +12,11 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: bin
|
14
14
|
cert_chain: []
|
15
|
-
date: 2012-06-
|
15
|
+
date: 2012-06-19 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: rails
|
19
|
-
requirement: &
|
19
|
+
requirement: &70267714575100 !ruby/object:Gem::Requirement
|
20
20
|
none: false
|
21
21
|
requirements:
|
22
22
|
- - ! '>='
|
@@ -24,10 +24,10 @@ dependencies:
|
|
24
24
|
version: 3.1.0
|
25
25
|
type: :runtime
|
26
26
|
prerelease: false
|
27
|
-
version_requirements: *
|
27
|
+
version_requirements: *70267714575100
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: coffee-rails
|
30
|
-
requirement: &
|
30
|
+
requirement: &70267714574680 !ruby/object:Gem::Requirement
|
31
31
|
none: false
|
32
32
|
requirements:
|
33
33
|
- - ! '>='
|
@@ -35,10 +35,10 @@ dependencies:
|
|
35
35
|
version: '0'
|
36
36
|
type: :runtime
|
37
37
|
prerelease: false
|
38
|
-
version_requirements: *
|
38
|
+
version_requirements: *70267714574680
|
39
39
|
- !ruby/object:Gem::Dependency
|
40
40
|
name: jquery-rails
|
41
|
-
requirement: &
|
41
|
+
requirement: &70267714574220 !ruby/object:Gem::Requirement
|
42
42
|
none: false
|
43
43
|
requirements:
|
44
44
|
- - ! '>='
|
@@ -46,10 +46,10 @@ dependencies:
|
|
46
46
|
version: '0'
|
47
47
|
type: :runtime
|
48
48
|
prerelease: false
|
49
|
-
version_requirements: *
|
49
|
+
version_requirements: *70267714574220
|
50
50
|
- !ruby/object:Gem::Dependency
|
51
51
|
name: haml_coffee_assets
|
52
|
-
requirement: &
|
52
|
+
requirement: &70267714609360 !ruby/object:Gem::Requirement
|
53
53
|
none: false
|
54
54
|
requirements:
|
55
55
|
- - ! '>='
|
@@ -57,10 +57,10 @@ dependencies:
|
|
57
57
|
version: '0'
|
58
58
|
type: :runtime
|
59
59
|
prerelease: false
|
60
|
-
version_requirements: *
|
60
|
+
version_requirements: *70267714609360
|
61
61
|
- !ruby/object:Gem::Dependency
|
62
62
|
name: i18n-js
|
63
|
-
requirement: &
|
63
|
+
requirement: &70267714608940 !ruby/object:Gem::Requirement
|
64
64
|
none: false
|
65
65
|
requirements:
|
66
66
|
- - ! '>='
|
@@ -68,10 +68,10 @@ dependencies:
|
|
68
68
|
version: '0'
|
69
69
|
type: :runtime
|
70
70
|
prerelease: false
|
71
|
-
version_requirements: *
|
71
|
+
version_requirements: *70267714608940
|
72
72
|
- !ruby/object:Gem::Dependency
|
73
73
|
name: guard
|
74
|
-
requirement: &
|
74
|
+
requirement: &70267714608520 !ruby/object:Gem::Requirement
|
75
75
|
none: false
|
76
76
|
requirements:
|
77
77
|
- - ! '>='
|
@@ -79,10 +79,10 @@ dependencies:
|
|
79
79
|
version: '0'
|
80
80
|
type: :development
|
81
81
|
prerelease: false
|
82
|
-
version_requirements: *
|
82
|
+
version_requirements: *70267714608520
|
83
83
|
- !ruby/object:Gem::Dependency
|
84
84
|
name: guard-coffeescript
|
85
|
-
requirement: &
|
85
|
+
requirement: &70267714608100 !ruby/object:Gem::Requirement
|
86
86
|
none: false
|
87
87
|
requirements:
|
88
88
|
- - ! '>='
|
@@ -90,10 +90,10 @@ dependencies:
|
|
90
90
|
version: '0'
|
91
91
|
type: :development
|
92
92
|
prerelease: false
|
93
|
-
version_requirements: *
|
93
|
+
version_requirements: *70267714608100
|
94
94
|
- !ruby/object:Gem::Dependency
|
95
95
|
name: guard-sprockets
|
96
|
-
requirement: &
|
96
|
+
requirement: &70267714607680 !ruby/object:Gem::Requirement
|
97
97
|
none: false
|
98
98
|
requirements:
|
99
99
|
- - ! '>='
|
@@ -101,10 +101,10 @@ dependencies:
|
|
101
101
|
version: '0'
|
102
102
|
type: :development
|
103
103
|
prerelease: false
|
104
|
-
version_requirements: *
|
104
|
+
version_requirements: *70267714607680
|
105
105
|
- !ruby/object:Gem::Dependency
|
106
106
|
name: jasmine
|
107
|
-
requirement: &
|
107
|
+
requirement: &70267714607260 !ruby/object:Gem::Requirement
|
108
108
|
none: false
|
109
109
|
requirements:
|
110
110
|
- - ! '>='
|
@@ -112,7 +112,7 @@ dependencies:
|
|
112
112
|
version: '0'
|
113
113
|
type: :development
|
114
114
|
prerelease: false
|
115
|
-
version_requirements: *
|
115
|
+
version_requirements: *70267714607260
|
116
116
|
description: A gem wrapper to include Joosy via the asset pipeline.
|
117
117
|
email: boris@roundlake.ru
|
118
118
|
executables: []
|