volt 0.7.5 → 0.7.6

Sign up to get free protection for your applications and to get access to all the features.
Files changed (34) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/lib/volt/cli/asset_compile.rb +2 -2
  4. data/lib/volt/models/url.rb +2 -0
  5. data/lib/volt/page/bindings/template_binding.rb +42 -50
  6. data/lib/volt/page/bindings/template_binding/grouped_controllers.rb +21 -0
  7. data/lib/volt/page/page.rb +3 -5
  8. data/lib/volt/server/rack/asset_files.rb +1 -1
  9. data/lib/volt/server/rack/component_html_renderer.rb +2 -2
  10. data/lib/volt/server/rack/index_files.rb +3 -3
  11. data/spec/apps/kitchen_sink/app/{home → main}/config/routes.rb +0 -0
  12. data/spec/apps/kitchen_sink/app/main/controllers/main_controller.rb +3 -0
  13. data/spec/apps/kitchen_sink/app/{home/views/index/index.html → main/views/main/main.html} +0 -0
  14. data/spec/page/bindings/content_binding_spec.rb +2 -2
  15. data/spec/page/bindings/template_binding_spec.rb +31 -31
  16. data/spec/server/html_parser/view_parser_spec.rb +37 -37
  17. data/spec/server/rack/asset_files_spec.rb +1 -1
  18. data/spec/templates/targets/binding_document/component_node_spec.rb +1 -1
  19. data/templates/newgem/app/newgem/controllers/main_controller.rb.tt +4 -0
  20. data/templates/newgem/app/newgem/views/{index/index.html → main/main.html} +0 -0
  21. data/templates/project/app/{home → main}/assets/css/.empty_directory +0 -0
  22. data/templates/project/app/{home → main}/assets/js/.empty_directory +0 -0
  23. data/templates/project/app/{home → main}/config/dependencies.rb +0 -0
  24. data/templates/project/app/{home → main}/config/routes.rb +0 -0
  25. data/templates/project/app/main/controllers/main_controller.rb +17 -0
  26. data/templates/project/app/{home → main}/models/.empty_directory +0 -0
  27. data/templates/project/app/{home/views/index → main/views/main}/about.html +0 -0
  28. data/templates/project/app/{home/views/index/home.html → main/views/main/index.html} +0 -0
  29. data/templates/project/app/main/views/main/main.html +29 -0
  30. metadata +19 -18
  31. data/spec/apps/kitchen_sink/app/home/controllers/index_controller.rb +0 -3
  32. data/templates/newgem/app/newgem/controllers/index_controller.rb.tt +0 -11
  33. data/templates/project/app/home/controllers/index_controller.rb +0 -9
  34. data/templates/project/app/home/views/index/index.html +0 -29
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 6cb6fdeeaa6a10b0a3d1c81805a3feda5df1f60d
4
- data.tar.gz: b833be5d63e7db1d7b8f9a1af8afee11d526e8d5
3
+ metadata.gz: d6c8120ac8ce1215c7a6f6b0b8df7c204096d62c
4
+ data.tar.gz: d02edaf4a739538d391a9258f33f71fbba3a8d67
5
5
  SHA512:
6
- metadata.gz: 29913c4b065abdc2960154fbace2edb83a8ea92e6f7955d538541b05227875770d327136d9d2e02e3d6c00642894545d0b917b63f085456dacbd5f1a37f11275
7
- data.tar.gz: 1a73d3935e08f24fc64aa2f7dbca692d4cd27aeda930e9d1045c4e47938fea9ef47badd3ffeebbbea8b4fc004efd6d1a7d5e8dea69bc5a6496c06f0522df023e
6
+ metadata.gz: f2ecb0bfc7ddd045d837ff0144b272d4791a6e60e3e15ff370cbfdcdb5a48f009823f4bdc0f0a53405dfe234b56d2acab41ff3fa2359c3ea79d80c51195d8216
7
+ data.tar.gz: beb777e469522b093ee1453145d9a4256ff661e4503639a2eb95bb835f714e67e02e267ca017ae0b1c7665732b023e64c80b1a2c06bb685fd4aa0e785c35896d
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.5
1
+ 0.7.6
@@ -36,14 +36,14 @@ class CLI
36
36
  def write_component_js
37
37
  component_paths = ComponentPaths.new(Volt.root)
38
38
 
39
- code = ComponentCode.new('home', component_paths).code
39
+ code = ComponentCode.new('main', component_paths).code
40
40
 
41
41
  javascript_code = Opal.compile(code)
42
42
 
43
43
  components_folder = File.join(Volt.root, '/public/components')
44
44
  puts "CF: #{components_folder}"
45
45
  FileUtils.mkdir_p(components_folder)
46
- File.open(File.join(components_folder, '/home.js'), 'w') do |file|
46
+ File.open(File.join(components_folder, '/main.js'), 'w') do |file|
47
47
  file.write(javascript_code)
48
48
  end
49
49
  end
@@ -49,6 +49,8 @@ class URL
49
49
 
50
50
  scroll
51
51
 
52
+ trigger_for_methods!('changed', :path)
53
+
52
54
  return true
53
55
  end
54
56
 
@@ -1,5 +1,6 @@
1
1
  require 'volt/page/bindings/base_binding'
2
2
  require 'volt/page/template_renderer'
3
+ require 'volt/page/bindings/template_binding/grouped_controllers'
3
4
 
4
5
  class TemplateBinding < BaseBinding
5
6
  def initialize(page, target, context, binding_name, binding_in_path, getter)
@@ -22,6 +23,12 @@ class TemplateBinding < BaseBinding
22
23
  @arguments = section
23
24
  end
24
25
 
26
+ # Sometimes we want multiple template bindings to share the same controller (usually
27
+ # when displaying a :Title and a :Body), this instance tracks those.
28
+ if @options && (controller_group = @options[:controller_group])
29
+ @grouped_controller = GroupedControllers.new(controller_group)
30
+ end
31
+
25
32
  # Run the initial render
26
33
  update
27
34
 
@@ -58,15 +65,15 @@ class TemplateBinding < BaseBinding
58
65
  # until a file is either found or the component level is reached.
59
66
  #
60
67
  # The defaults are as follows:
61
- # 1. component - home
62
- # 2. controller - index
63
- # 3. view - index
68
+ # 1. component - main
69
+ # 2. controller - main
70
+ # 3. view - main
64
71
  # 4. section - body
65
72
  def path_for_template(lookup_path, force_section=nil)
66
73
  parts = lookup_path.split('/')
67
74
  parts_size = parts.size
68
75
 
69
- default_parts = ['home', 'index', 'index', 'body']
76
+ default_parts = ['main', 'main', 'index', 'body']
70
77
 
71
78
  # When forcing a sub template, we can default the sub template section
72
79
  default_parts[-1] = force_section if force_section
@@ -106,6 +113,14 @@ class TemplateBinding < BaseBinding
106
113
  return nil, nil
107
114
  end
108
115
 
116
+ # Called when the path changes. If we are sharing a controller, clear the cached
117
+ # controller before we queue
118
+ def queue_update
119
+ @grouped_controller.clear if @grouped_controller
120
+
121
+ super
122
+ end
123
+
109
124
  def update
110
125
  full_path, controller_path = path_for_template(@path.cur, @section.cur)
111
126
  # puts "UPDATE: #{@path.inspect} - #{full_path.inspect}"
@@ -128,61 +143,36 @@ class TemplateBinding < BaseBinding
128
143
  def render_template(full_path, controller_path)
129
144
  args = @arguments ? [@arguments] : []
130
145
 
131
- # TODO: at the moment a :body section and a :title will both initialize different
132
- # controllers. Maybe we should have a way to tie them together?
133
- controller_class, action = get_controller(controller_path)
146
+ @controller = nil
134
147
 
135
- if controller_class
136
- # Setup the controller
137
- current_context = controller_class.new(*args)
138
- else
139
- current_context = ModelController.new(*args)
140
- end
141
- @controller = current_context
148
+ # Fetch grouped controllers if we're grouping
149
+ @controller = @grouped_controller.get if @grouped_controller
142
150
 
143
- # Trigger the action
144
- @controller.send(action) if @controller.respond_to?(action)
151
+ # Otherwise, make a new controller
152
+ unless @controller
153
+ controller_class, action = get_controller(controller_path)
145
154
 
146
- @current_template = TemplateRenderer.new(@page, @target, current_context, @binding_name, full_path)
155
+ if controller_class
156
+ # Setup the controller
157
+ @controller = controller_class.new(*args)
158
+ else
159
+ @controller = ModelController.new(*args)
160
+ end
147
161
 
148
- call_ready
149
- end
162
+ # Trigger the action
163
+ @controller.send(action) if @controller.respond_to?(action)
150
164
 
165
+ # Track the grouped controller
166
+ @grouped_controller.set(@controller) if @grouped_controller
167
+ end
151
168
 
169
+ @current_template = TemplateRenderer.new(@page, @target, @controller, @binding_name, full_path)
152
170
 
153
- # # The context for templates can be either a controller, or the original context.
154
- # def render_template(full_path, controller_path)
155
- # # TODO: at the moment a :body section and a :title will both initialize different
156
- # # controllers. Maybe we should have a way to tie them together?
157
- # controller_class, action = get_controller(controller_path)
158
- # if controller_class
159
- # args = []
160
- # puts "MODEL: #{@arguments.inspect}"
161
- # args << SubContext.new(@arguments) if @arguments
162
- #
163
- # # Setup the controller
164
- # current_context = controller_class.new(*args)
165
- # @controller = current_context
166
- #
167
- # # Trigger the action
168
- # @controller.send(action) if @controller.respond_to?(action)
169
- # else
170
- # # Pass the context directly
171
- # current_context = @context
172
- # @controller = nil
173
- # end
174
- #
175
- # @current_template = TemplateRenderer.new(@page, @target, current_context, @binding_name, full_path)
176
- #
177
- # call_ready
178
- # end
171
+ call_ready
172
+ end
179
173
 
180
174
  def call_ready
181
175
  if @controller
182
- if @controller.respond_to?(:section=)
183
- @controller.section = @current_template.section
184
- end
185
-
186
176
  if @controller.respond_to?(:dom_ready)
187
177
  @controller.dom_ready
188
178
  end
@@ -190,6 +180,8 @@ class TemplateBinding < BaseBinding
190
180
  end
191
181
 
192
182
  def remove
183
+ @grouped_controller.clear if @grouped_controller
184
+
193
185
  if @path_changed_listener
194
186
  @path_changed_listener.remove
195
187
  @path_changed_listener = nil
@@ -230,7 +222,7 @@ class TemplateBinding < BaseBinding
230
222
  parts = controller_path[0..-2].map {|v| v.gsub('-', '_').camelize }
231
223
 
232
224
  # Home doesn't get namespaced
233
- if parts.first == 'Home'
225
+ if parts.first == 'Main'
234
226
  parts.shift
235
227
  end
236
228
 
@@ -0,0 +1,21 @@
1
+ # Some template bindings share the controller with other template bindings based
2
+ # on a name. This class stores those and provides helper methods to clear/set/get.
3
+ class GroupedControllers
4
+ @@controllers = {}
5
+
6
+ def initialize(name)
7
+ @name = name
8
+ end
9
+
10
+ def get
11
+ @@controllers[@name]
12
+ end
13
+
14
+ def set(controller)
15
+ @@controllers[@name] = controller
16
+ end
17
+
18
+ def clear
19
+ @@controllers.delete(@name)
20
+ end
21
+ end
@@ -43,8 +43,6 @@ class Page
43
43
  attr_reader :url, :params, :page, :templates, :routes, :draw_cycle, :events
44
44
 
45
45
  def initialize
46
- # debugger
47
- puts "------ Page Loaded -------"
48
46
  @model_classes = {}
49
47
 
50
48
  # Run the code to setup the page
@@ -163,10 +161,10 @@ class Page
163
161
  # Do the initial url params parse
164
162
  @url_tracker.url_updated(true)
165
163
 
166
- main_controller = IndexController.new
164
+ main_controller = MainController.new
167
165
 
168
166
  # Setup main page template
169
- TemplateRenderer.new(self, DomTarget.new, main_controller, 'CONTENT', 'home/index/index/body')
167
+ TemplateRenderer.new(self, DomTarget.new, main_controller, 'CONTENT', 'main/main/main/body')
170
168
 
171
169
  # Setup title listener template
172
170
  title_target = AttributeTarget.new
@@ -175,7 +173,7 @@ class Page
175
173
  # puts "SET TITLE: #{title.inspect}: #{title_target.inspect}"
176
174
  `document.title = title;`
177
175
  end
178
- TemplateRenderer.new(self, title_target, main_controller, "main", "home/index/index/title")
176
+ TemplateRenderer.new(self, title_target, main_controller, "main", "main/main/main/title")
179
177
 
180
178
  # TODO: this dom ready should really happen in the template renderer
181
179
  main_controller.dom_ready if main_controller.respond_to?(:dom_ready)
@@ -83,7 +83,7 @@ class AssetFiles
83
83
  else
84
84
  opal_js_files << '/assets/volt/page/page.js'
85
85
  end
86
- opal_js_files << '/components/home.js'
86
+ opal_js_files << '/components/main.js'
87
87
 
88
88
  javascript_files += opal_js_files
89
89
 
@@ -10,8 +10,8 @@ class ComponentHtmlRenderer
10
10
  req = Rack::Request.new(env)
11
11
  path = req.path
12
12
 
13
- # For now just assume home
14
- component_name = 'home'
13
+ # For now just assume main
14
+ component_name = 'main'
15
15
 
16
16
  page = Page.new
17
17
 
@@ -10,7 +10,7 @@ class IndexFiles
10
10
 
11
11
  @@router ||= Routes.new.define do
12
12
  # Find the route file
13
- home_path = component_paths.component_path('home')
13
+ home_path = component_paths.component_path('main')
14
14
  route_file = File.read("#{home_path}/config/routes.rb")
15
15
  eval(route_file)
16
16
  end
@@ -41,11 +41,11 @@ class IndexFiles
41
41
 
42
42
  def javascript_files
43
43
  # TODO: Cache somehow, this is being loaded every time
44
- AssetFiles.new('home', @component_paths).javascript_files(@opal_files)
44
+ AssetFiles.new('main', @component_paths).javascript_files(@opal_files)
45
45
  end
46
46
 
47
47
  def css_files
48
- AssetFiles.new('home', @component_paths).css_files
48
+ AssetFiles.new('main', @component_paths).css_files
49
49
  end
50
50
 
51
51
 
@@ -0,0 +1,3 @@
1
+ class MainController < ModelController
2
+ model :page
3
+ end
@@ -19,7 +19,7 @@ describe ContentBinding do
19
19
  binding = lambda {|page, target, context, id| ContentBinding.new(page, target, context, id, Proc.new { self[:name] }) }
20
20
 
21
21
  templates = {
22
- 'home/index' => {
22
+ 'main/main' => {
23
23
  'html' => 'hello <!-- $1 --><!-- $/1 -->',
24
24
  'bindings' => {1 => [binding]}
25
25
  }
@@ -30,7 +30,7 @@ describe ContentBinding do
30
30
 
31
31
  dom = AttributeTarget.new(0)
32
32
 
33
- TemplateRenderer.new(page, dom, context, 'main', 'home/index')
33
+ TemplateRenderer.new(page, dom, context, 'main', 'main/main')
34
34
 
35
35
  expect(dom.to_html).to eq('hello jimmy')
36
36
  end
@@ -16,7 +16,7 @@ describe TemplateBinding do
16
16
  # TODO: We should decouple things so we don't need to allocate
17
17
  @template_binding = TemplateBinding.allocate
18
18
  @template_binding.instance_variable_set('@page', @page)
19
- @template_binding.setup_path('home/index/index')
19
+ @template_binding.setup_path('main/main/main')
20
20
  end
21
21
 
22
22
  def set_template(templates)
@@ -29,33 +29,33 @@ describe TemplateBinding do
29
29
 
30
30
  it "should lookup nested controller action" do
31
31
  @templates = {
32
- 'home/index/blog/nav' => '',
33
- 'home/comments/new/body' => '',
32
+ 'main/main/blog/nav' => '',
33
+ 'main/comments/new/body' => '',
34
34
  }
35
35
 
36
36
  result = @template_binding.path_for_template('comments/new').last
37
- expect(result).to eq(['home', 'comments_controller', 'new'])
37
+ expect(result).to eq(['main', 'comments_controller', 'new'])
38
38
  end
39
39
 
40
40
  it "it should not look in the local component/controller for a specified controller/action" do
41
41
  @templates = {
42
- 'home/comments/new/body' => ''
42
+ 'main/comments/new/body' => ''
43
43
  }
44
44
 
45
45
  path, result = @template_binding.path_for_template('comments/new')
46
- expect(path).to eq('home/comments/new/body')
47
- expect(result).to eq(['home', 'comments_controller', 'new'])
46
+ expect(path).to eq('main/comments/new/body')
47
+ expect(result).to eq(['main', 'comments_controller', 'new'])
48
48
  end
49
49
 
50
50
 
51
51
  it "should handle a tripple lookup" do
52
52
  @templates = {
53
- 'home/comments/new/errors' => '',
53
+ 'main/comments/new/errors' => '',
54
54
  'comments/new/errors/body' => ''
55
55
  }
56
56
 
57
57
  path, result = @template_binding.path_for_template('comments/new/errors')
58
- expect(path).to eq('home/comments/new/errors')
58
+ expect(path).to eq('main/comments/new/errors')
59
59
  expect(result).to eq(nil)
60
60
  end
61
61
 
@@ -72,75 +72,75 @@ describe TemplateBinding do
72
72
 
73
73
  it "should find a matching component" do
74
74
  @templates = {
75
- 'comments/new/index/body' => ''
75
+ 'comments/new/main/body' => ''
76
76
  }
77
77
 
78
78
  path, result = @template_binding.path_for_template('comments/new')
79
- expect(path).to eq('comments/new/index/body')
80
- expect(result).to eq(['comments', 'new_controller', 'index'])
79
+ expect(path).to eq('comments/new/main/body')
80
+ expect(result).to eq(['comments', 'new_controller', 'main'])
81
81
  end
82
82
 
83
83
  it "should lookup sub-templates within its own file" do
84
84
  @templates = {
85
- 'home/index/blog/nav' => '',
86
- 'home/index/index/nav' => '',
85
+ 'main/main/blog/nav' => '',
86
+ 'main/main/main/nav' => '',
87
87
  }
88
88
 
89
- expect(@template_binding.path_for_template('nav').first).to eq('home/index/index/nav')
89
+ expect(@template_binding.path_for_template('nav').first).to eq('main/main/main/nav')
90
90
  end
91
91
 
92
92
  it "should lookup sub-templates within another local view" do
93
93
  @templates = {
94
- 'home/index/blog/nav' => '',
95
- 'home/index/index/nav' => '',
94
+ 'main/main/blog/nav' => '',
95
+ 'main/main/main/nav' => '',
96
96
  }
97
97
 
98
- expect(@template_binding.path_for_template('blog/nav').first).to eq('home/index/blog/nav')
98
+ expect(@template_binding.path_for_template('blog/nav').first).to eq('main/main/blog/nav')
99
99
  end
100
100
 
101
101
  it "should lookup in another view" do
102
102
  @templates = {
103
- 'home/index/nav/body' => '',
103
+ 'main/main/nav/body' => '',
104
104
  }
105
105
 
106
- expect(@template_binding.path_for_template('nav').first).to eq('home/index/nav/body')
106
+ expect(@template_binding.path_for_template('nav').first).to eq('main/main/nav/body')
107
107
  end
108
108
 
109
109
  it "should lookup in a controller" do
110
110
  @templates = {
111
- 'home/nav/index/body' => ''
111
+ 'main/nav/main/body' => ''
112
112
  }
113
113
 
114
- expect(@template_binding.path_for_template('nav').first).to eq('home/nav/index/body')
114
+ expect(@template_binding.path_for_template('nav').first).to eq('main/nav/main/body')
115
115
  end
116
116
 
117
117
  it "should lookup in a controller/view" do
118
118
  @templates = {
119
- 'home/blog/nav/body' => ''
119
+ 'main/blog/nav/body' => ''
120
120
  }
121
121
 
122
- expect(@template_binding.path_for_template('blog/nav').first).to eq('home/blog/nav/body')
122
+ expect(@template_binding.path_for_template('blog/nav').first).to eq('main/blog/nav/body')
123
123
  end
124
124
 
125
125
  it "should lookup in a controller" do
126
126
  @templates = {
127
- 'home/nav/index/body' => ''
127
+ 'main/nav/main/body' => ''
128
128
  }
129
129
 
130
- expect(@template_binding.path_for_template('nav').first).to eq('home/nav/index/body')
130
+ expect(@template_binding.path_for_template('nav').first).to eq('main/nav/main/body')
131
131
  end
132
132
 
133
133
  it "should lookup in a component" do
134
134
  @templates = {
135
- 'nav/index/index/body' => ''
135
+ 'nav/main/main/body' => ''
136
136
  }
137
137
 
138
- expect(@template_binding.path_for_template('nav').first).to eq('nav/index/index/body')
138
+ expect(@template_binding.path_for_template('nav').first).to eq('nav/main/main/body')
139
139
  end
140
140
 
141
141
  it "should lookup in a component/controller/view" do
142
142
  @templates = {
143
- 'nav/index/index/body' => '',
143
+ 'nav/main/main/body' => '',
144
144
  'auth/login/new/body' => ''
145
145
  }
146
146
 
@@ -149,10 +149,10 @@ describe TemplateBinding do
149
149
 
150
150
  it "should let you force a sub template" do
151
151
  @templates = {
152
- 'nav/index/index/title' => '',
152
+ 'nav/main/main/title' => '',
153
153
  'auth/login/new/title' => ''
154
154
  }
155
155
 
156
- expect(@template_binding.path_for_template('nav', 'title').first).to eq('nav/index/index/title')
156
+ expect(@template_binding.path_for_template('nav', 'title').first).to eq('nav/main/main/title')
157
157
  end
158
158
  end
@@ -7,10 +7,10 @@ describe ViewParser do
7
7
  it "should parse content bindings" do
8
8
  html = "<p>Some {content} binding, {name}</p>"
9
9
 
10
- view = ViewParser.new(html, "home/index/index")
10
+ view = ViewParser.new(html, "main/main/main")
11
11
 
12
12
  expect(view.templates).to eq({
13
- 'home/index/index/body' => {
13
+ 'main/main/main/body' => {
14
14
  'html' => '<p>Some <!-- $0 --><!-- $/0 --> binding, <!-- $1 --><!-- $/1 --></p>',
15
15
  'bindings' => {
16
16
  0 => ["lambda { |__p, __t, __c, __id| ContentBinding.new(__p, __t, __c, __id, Proc.new { content }) }"],
@@ -34,23 +34,23 @@ describe ViewParser do
34
34
  </p>
35
35
  END
36
36
 
37
- view = ViewParser.new(html, "home/index/index")
37
+ view = ViewParser.new(html, "main/main/main")
38
38
 
39
39
  expect(view.templates).to eq( {
40
- "home/index/index/body/__ifg0/__if0" => {
40
+ "main/main/main/body/__ifg0/__if0" => {
41
41
  "html" => "\n text\n "
42
42
  },
43
- "home/index/index/body/__ifg0/__if1" => {
43
+ "main/main/main/body/__ifg0/__if1" => {
44
44
  "html" => "\n <button>Button</button>\n "
45
45
  },
46
- "home/index/index/body/__ifg0/__if2" => {
46
+ "main/main/main/body/__ifg0/__if2" => {
47
47
  "html" => "\n <a href=\"\">link</a>\n "
48
48
  },
49
- "home/index/index/body" => {
49
+ "main/main/main/body" => {
50
50
  "html" => " <p>\n Some\n <!-- $0 --><!-- $/0 -->\n </p>\n",
51
51
  "bindings" => {
52
52
  0 => [
53
- "lambda { |__p, __t, __c, __id| IfBinding.new(__p, __t, __c, __id, [[Proc.new { showing == :text }, \"home/index/index/body/__ifg0/__if0\"], [Proc.new { showing == :button }, \"home/index/index/body/__ifg0/__if1\"], [nil, \"home/index/index/body/__ifg0/__if2\"]]) }"
53
+ "lambda { |__p, __t, __c, __id| IfBinding.new(__p, __t, __c, __id, [[Proc.new { showing == :text }, \"main/main/main/body/__ifg0/__if0\"], [Proc.new { showing == :button }, \"main/main/main/body/__ifg0/__if1\"], [nil, \"main/main/main/body/__ifg0/__if2\"]]) }"
54
54
  ]
55
55
  }
56
56
  }
@@ -73,28 +73,28 @@ describe ViewParser do
73
73
  </p>
74
74
  END
75
75
 
76
- view = ViewParser.new(html, "home/index/index")
76
+ view = ViewParser.new(html, "main/main/main")
77
77
 
78
78
  expect(view.templates).to eq( {
79
- "home/index/index/body/__ifg0/__if0/__ifg0/__if0" => {
79
+ "main/main/main/body/__ifg0/__if0/__ifg0/__if0" => {
80
80
  "html"=>"\n sub item text\n "
81
81
  },
82
- "home/index/index/body/__ifg0/__if0" => {
82
+ "main/main/main/body/__ifg0/__if0" => {
83
83
  "html" => "\n <!-- $0 --><!-- $/0 -->\n ",
84
84
  "bindings" => {
85
85
  0 => [
86
- "lambda { |__p, __t, __c, __id| IfBinding.new(__p, __t, __c, __id, [[Proc.new { sub_item }, \"home/index/index/body/__ifg0/__if0/__ifg0/__if0\"]]) }"
86
+ "lambda { |__p, __t, __c, __id| IfBinding.new(__p, __t, __c, __id, [[Proc.new { sub_item }, \"main/main/main/body/__ifg0/__if0/__ifg0/__if0\"]]) }"
87
87
  ]
88
88
  }
89
89
  },
90
- "home/index/index/body/__ifg0/__if1" => {
90
+ "main/main/main/body/__ifg0/__if1" => {
91
91
  "html" => "\n other\n "
92
92
  },
93
- "home/index/index/body" => {
93
+ "main/main/main/body" => {
94
94
  "html" => " <p>\n Some\n <!-- $0 --><!-- $/0 -->\n </p>\n",
95
95
  "bindings" => {
96
96
  0 => [
97
- "lambda { |__p, __t, __c, __id| IfBinding.new(__p, __t, __c, __id, [[Proc.new { showing == :text }, \"home/index/index/body/__ifg0/__if0\"], [nil, \"home/index/index/body/__ifg0/__if1\"]]) }"
97
+ "lambda { |__p, __t, __c, __id| IfBinding.new(__p, __t, __c, __id, [[Proc.new { showing == :text }, \"main/main/main/body/__ifg0/__if0\"], [nil, \"main/main/main/body/__ifg0/__if1\"]]) }"
98
98
  ]
99
99
  }
100
100
  }
@@ -111,10 +111,10 @@ describe ViewParser do
111
111
  </div>
112
112
  END
113
113
 
114
- view = ViewParser.new(html, "home/index/index")
114
+ view = ViewParser.new(html, "main/main/main")
115
115
 
116
116
  expect(view.templates).to eq({
117
- "home/index/index/body/__template/0" => {
117
+ "main/main/main/body/__template/0" => {
118
118
  "html" => "\n <p><!-- $0 --><!-- $/0 --></p>\n ",
119
119
  "bindings" => {
120
120
  0 => [
@@ -122,11 +122,11 @@ describe ViewParser do
122
122
  ]
123
123
  }
124
124
  },
125
- "home/index/index/body" => {
125
+ "main/main/main/body" => {
126
126
  "html" => " <div class=\"main\">\n <!-- $0 --><!-- $/0 -->\n </div>\n",
127
127
  "bindings" => {
128
128
  0 => [
129
- "lambda { |__p, __t, __c, __id| EachBinding.new(__p, __t, __c, __id, Proc.new { _items }, \"item\", \"home/index/index/body/__template/0\") }"
129
+ "lambda { |__p, __t, __c, __id| EachBinding.new(__p, __t, __c, __id, Proc.new { _items }, \"item\", \"main/main/main/body/__template/0\") }"
130
130
  ]
131
131
  }
132
132
  }
@@ -141,10 +141,10 @@ describe ViewParser do
141
141
  </div>
142
142
  END
143
143
 
144
- view = ViewParser.new(html, "home/index/index")
144
+ view = ViewParser.new(html, "main/main/main")
145
145
 
146
146
  expect(view.templates).to eq({
147
- "home/index/index/body" => {
147
+ "main/main/main/body" => {
148
148
  "html" => " <div id=\"id0\">\n </div>\n",
149
149
  "bindings" => {
150
150
  "id0" => [
@@ -161,10 +161,10 @@ describe ViewParser do
161
161
  </div>
162
162
  END
163
163
 
164
- view = ViewParser.new(html, "home/index/index")
164
+ view = ViewParser.new(html, "main/main/main")
165
165
 
166
166
  expect(view.templates).to eq({
167
- "home/index/index/body/_rv1" => {
167
+ "main/main/main/body/_rv1" => {
168
168
  "html" => "start <!-- $0 --><!-- $/0 --> <!-- $1 --><!-- $/1 --> string",
169
169
  "bindings" => {
170
170
  0 => [
@@ -175,11 +175,11 @@ describe ViewParser do
175
175
  ]
176
176
  }
177
177
  },
178
- "home/index/index/body" => {
178
+ "main/main/main/body" => {
179
179
  "html" => " <div id=\"id0\">\n </div>\n",
180
180
  "bindings" => {
181
181
  "id0" => [
182
- "lambda { |__p, __t, __c, __id| AttributeBinding.new(__p, __t, __c, __id, \"class\", Proc.new { ReactiveTemplate.new(__p, __c, \"home/index/index/body/_rv1\") }) }"
182
+ "lambda { |__p, __t, __c, __id| AttributeBinding.new(__p, __t, __c, __id, \"class\", Proc.new { ReactiveTemplate.new(__p, __c, \"main/main/main/body/_rv1\") }) }"
183
183
  ]
184
184
  }
185
185
  }
@@ -191,14 +191,14 @@ describe ViewParser do
191
191
  {#template "/home/temp/path"}
192
192
  END
193
193
 
194
- view = ViewParser.new(html, "home/index/index")
194
+ view = ViewParser.new(html, "main/main/main")
195
195
 
196
196
  expect(view.templates).to eq({
197
- "home/index/index/body" => {
197
+ "main/main/main/body" => {
198
198
  "html" => " <!-- $0 --><!-- $/0 -->\n",
199
199
  "bindings" => {
200
200
  0 => [
201
- "lambda { |__p, __t, __c, __id| TemplateBinding.new(__p, __t, __c, __id, \"home/index/index/body\", Proc.new { [\"/home/temp/path\"] }) }"
201
+ "lambda { |__p, __t, __c, __id| TemplateBinding.new(__p, __t, __c, __id, \"main/main/main/body\", Proc.new { [\"/home/temp/path\"] }) }"
202
202
  ]
203
203
  }
204
204
  }
@@ -211,7 +211,7 @@ describe ViewParser do
211
211
  <a href="/{link_name}">Link</a>
212
212
  END
213
213
 
214
- view = ViewParser.new(html, "home/index/index/body")
214
+ view = ViewParser.new(html, "main/main/main/body")
215
215
 
216
216
  # puts view.templates.inspect
217
217
  end
@@ -220,7 +220,7 @@ describe ViewParser do
220
220
  <a href="{link_name}">Link</a>
221
221
  END
222
222
 
223
- view = ViewParser.new(html, "home/index/index/body")
223
+ view = ViewParser.new(html, "main/main/main/body")
224
224
 
225
225
  # puts view.templates.inspect
226
226
  end
@@ -238,13 +238,13 @@ describe ViewParser do
238
238
  <p>This text goes in the body</p>
239
239
  END
240
240
 
241
- view = ViewParser.new(html, "home/index/index")
241
+ view = ViewParser.new(html, "main/main/main")
242
242
 
243
243
  expect(view.templates).to eq( {
244
- "home/index/index/title" => {
244
+ "main/main/main/title" => {
245
245
  "html" => "\n This text goes in the title\n\n "
246
246
  },
247
- "home/index/index/body" => {
247
+ "main/main/main/body" => {
248
248
  "html" => "\n <p>This text goes in the body</p>\n"
249
249
  }
250
250
  })
@@ -257,10 +257,10 @@ describe ViewParser do
257
257
  <textarea name="cool">some text in a textarea</textarea>
258
258
  END
259
259
 
260
- view = ViewParser.new(html, "home/index/index")
260
+ view = ViewParser.new(html, "main/main/main")
261
261
 
262
262
  expect(view.templates).to eq({
263
- "home/index/index/body" => {
263
+ "main/main/main/body" => {
264
264
  "html" => " <textarea name=\"cool\">some text in a textarea</textarea>\n"
265
265
  }
266
266
  })
@@ -271,10 +271,10 @@ describe ViewParser do
271
271
  <textarea name="cool">{awesome}</textarea>
272
272
  END
273
273
 
274
- view = ViewParser.new(html, "home/index/index")
274
+ view = ViewParser.new(html, "main/main/main")
275
275
 
276
276
  expect(view.templates).to eq({
277
- "home/index/index/body" => {
277
+ "main/main/main/body" => {
278
278
  "html" => " <textarea name=\"cool\" id=\"id1\"></textarea>\n",
279
279
  "bindings" => {
280
280
  "id1" => [
@@ -19,7 +19,7 @@ if RUBY_PLATFORM != 'opal'
19
19
  it "should list all JS files" do
20
20
  main = AssetFiles.new("main", @component_paths)
21
21
 
22
- expect(main.javascript_files(nil)).to eq(["/assets/js/jquery-2.0.3.js", "/assets/js/sockjs-0.3.4.min.js", "/assets/js/vertxbus.js", "/assets/js/bootstrap.js", "/assets/js/test2.js", "/assets/js/test3.js", "/assets/js/test1.js", "/assets/volt/page/page.js", "/components/home.js"])
22
+ expect(main.javascript_files(nil)).to eq(["/assets/js/jquery-2.0.3.js", "/assets/js/sockjs-0.3.4.min.js", "/assets/js/vertxbus.js", "/assets/js/bootstrap.js", "/assets/js/test2.js", "/assets/js/test3.js", "/assets/js/test1.js", "/assets/volt/page/page.js", "/components/main.js"])
23
23
  end
24
24
  end
25
25
  end
@@ -23,7 +23,7 @@ describe ComponentNode do
23
23
  #
24
24
  # page = Page.new
25
25
  #
26
- # template = ViewParser.new(view, 'home/index/index/title')
26
+ # template = ViewParser.new(view, main/main/main/index/index/title')
27
27
  #
28
28
  # page.add_template
29
29
  # end
@@ -0,0 +1,4 @@
1
+ module <%=config[:name].gsub(/^volt[-]/, '').gsub('-', '_').split("_").map {|s| s.capitalize }.join("") %>
2
+ class MainController < ModelController
3
+ end
4
+ end
@@ -0,0 +1,17 @@
1
+ class MainController < ModelController
2
+ def index
3
+ # Add code for when the index view is loaded
4
+ end
5
+
6
+ def about
7
+ # Add code for when the about view is loaded
8
+ end
9
+
10
+ private
11
+ # the main template contains a #template binding that shows another
12
+ # template. This is the path to that template. It may change based
13
+ # on the params._controller and params._action values.
14
+ def main_path
15
+ params._controller.or('main') + "/" + params._action.or('index')
16
+ end
17
+ end
@@ -0,0 +1,29 @@
1
+ <:Title>
2
+ {#template main_path, "title", {controller_group: 'main'}}
3
+
4
+ <:Body>
5
+ <div class="container">
6
+ <div class="header">
7
+ <ul class="nav nav-pills pull-right">
8
+ <:nav href="/" text="Home" />
9
+ <:nav href="/blog" text="Blog" />
10
+ <:nav href="/about" text="About" />
11
+ </ul>
12
+ <h3 class="text-muted">Project name</h3>
13
+ </div>
14
+
15
+ <:volt:notices />
16
+
17
+ {#template main_path, 'body', {controller_group: 'main'}}
18
+
19
+ <div class="footer">
20
+ <p>&copy; Company 2014</p>
21
+ </div>
22
+
23
+ </div>
24
+
25
+ <:Nav>
26
+ <li class="{#if url.path.split('/')[1] == @href.split('/')[1]}active{/}">
27
+ <a href="{@href}">{@text}</a>
28
+ </li>
29
+
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: volt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.5
4
+ version: 0.7.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ryan Stout
@@ -408,6 +408,7 @@ files:
408
408
  - lib/volt/page/bindings/event_binding.rb
409
409
  - lib/volt/page/bindings/if_binding.rb
410
410
  - lib/volt/page/bindings/template_binding.rb
411
+ - lib/volt/page/bindings/template_binding/grouped_controllers.rb
411
412
  - lib/volt/page/channel.rb
412
413
  - lib/volt/page/channel_stub.rb
413
414
  - lib/volt/page/document.rb
@@ -478,9 +479,9 @@ files:
478
479
  - spec/apps/file_loading/app/slideshow/assets/js/test3.js
479
480
  - spec/apps/kitchen_sink/.gitignore
480
481
  - spec/apps/kitchen_sink/Gemfile
481
- - spec/apps/kitchen_sink/app/home/config/routes.rb
482
- - spec/apps/kitchen_sink/app/home/controllers/index_controller.rb
483
- - spec/apps/kitchen_sink/app/home/views/index/index.html
482
+ - spec/apps/kitchen_sink/app/main/config/routes.rb
483
+ - spec/apps/kitchen_sink/app/main/controllers/main_controller.rb
484
+ - spec/apps/kitchen_sink/app/main/views/main/main.html
484
485
  - spec/apps/kitchen_sink/config.ru
485
486
  - spec/apps/kitchen_sink/public/index.html
486
487
  - spec/extra_core/inflector_spec.rb
@@ -526,8 +527,8 @@ files:
526
527
  - templates/newgem/app/newgem/assets/js/.empty_directory
527
528
  - templates/newgem/app/newgem/config/dependencies.rb
528
529
  - templates/newgem/app/newgem/config/routes.rb
529
- - templates/newgem/app/newgem/controllers/index_controller.rb.tt
530
- - templates/newgem/app/newgem/views/index/index.html
530
+ - templates/newgem/app/newgem/controllers/main_controller.rb.tt
531
+ - templates/newgem/app/newgem/views/main/main.html
531
532
  - templates/newgem/bin/newgem.tt
532
533
  - templates/newgem/gitignore.tt
533
534
  - templates/newgem/lib/newgem.rb.tt
@@ -542,15 +543,15 @@ files:
542
543
  - templates/project/Gemfile.tt
543
544
  - templates/project/README.md.tt
544
545
  - templates/project/app/.empty_directory
545
- - templates/project/app/home/assets/css/.empty_directory
546
- - templates/project/app/home/assets/js/.empty_directory
547
- - templates/project/app/home/config/dependencies.rb
548
- - templates/project/app/home/config/routes.rb
549
- - templates/project/app/home/controllers/index_controller.rb
550
- - templates/project/app/home/models/.empty_directory
551
- - templates/project/app/home/views/index/about.html
552
- - templates/project/app/home/views/index/home.html
553
- - templates/project/app/home/views/index/index.html
546
+ - templates/project/app/main/assets/css/.empty_directory
547
+ - templates/project/app/main/assets/js/.empty_directory
548
+ - templates/project/app/main/config/dependencies.rb
549
+ - templates/project/app/main/config/routes.rb
550
+ - templates/project/app/main/controllers/main_controller.rb
551
+ - templates/project/app/main/models/.empty_directory
552
+ - templates/project/app/main/views/main/about.html
553
+ - templates/project/app/main/views/main/index.html
554
+ - templates/project/app/main/views/main/main.html
554
555
  - templates/project/config.ru
555
556
  - templates/project/public/index.html
556
557
  - templates/project/spec/spec_helper.rb
@@ -589,9 +590,9 @@ test_files:
589
590
  - spec/apps/file_loading/app/slideshow/assets/js/test3.js
590
591
  - spec/apps/kitchen_sink/.gitignore
591
592
  - spec/apps/kitchen_sink/Gemfile
592
- - spec/apps/kitchen_sink/app/home/config/routes.rb
593
- - spec/apps/kitchen_sink/app/home/controllers/index_controller.rb
594
- - spec/apps/kitchen_sink/app/home/views/index/index.html
593
+ - spec/apps/kitchen_sink/app/main/config/routes.rb
594
+ - spec/apps/kitchen_sink/app/main/controllers/main_controller.rb
595
+ - spec/apps/kitchen_sink/app/main/views/main/main.html
595
596
  - spec/apps/kitchen_sink/config.ru
596
597
  - spec/apps/kitchen_sink/public/index.html
597
598
  - spec/extra_core/inflector_spec.rb
@@ -1,3 +0,0 @@
1
- class IndexController < ModelController
2
- model :page
3
- end
@@ -1,11 +0,0 @@
1
- module <%=config[:name].gsub(/^volt[-]/, '').gsub('-', '_').split("_").map {|s| s.capitalize }.join("") %>
2
- class IndexController < ModelController
3
- model :page
4
-
5
- attr_accessor :data
6
-
7
- def initialize(data)
8
- @data = data
9
- end
10
- end
11
- end
@@ -1,9 +0,0 @@
1
- class IndexController < ModelController
2
- def index
3
- # Add code for when the main page is loaded
4
- end
5
-
6
- def home
7
- # Add code for when the home view is loaded
8
- end
9
- end
@@ -1,29 +0,0 @@
1
- <:Title>
2
- {#template params._controller.or('index') + '/' + params._action.or('home'), "title"}
3
-
4
- <:Body>
5
- <div class="container">
6
- <div class="header">
7
- <ul class="nav nav-pills pull-right">
8
- <:nav action="" text="Home" />
9
- <:nav action="about" text="About" />
10
- </ul>
11
- <h3 class="text-muted">Project name</h3>
12
- </div>
13
-
14
- <:volt:notices />
15
-
16
- {#template params._controller.or('index') + '/' + params._action.or('home')}
17
-
18
- <div class="footer">
19
- <p>&copy; Company 2014</p>
20
- </div>
21
-
22
- </div>
23
-
24
-
25
- <:Nav>
26
- <li class="{#if params._action.or('') == @action}active{/}">
27
- <a href="/{@action}">{@text}</a>
28
- </li>
29
-