luca 0.9.89 → 0.9.91

Sign up to get free protection for your applications and to get access to all the features.
Files changed (186) hide show
  1. data/CHANGELOG +11 -1
  2. data/Gemfile +5 -2
  3. data/Gemfile.lock +84 -56
  4. data/Rakefile +10 -2
  5. data/app/assets/javascripts/luca/components/application.coffee +82 -89
  6. data/app/assets/javascripts/luca/components/collection_view.coffee +9 -5
  7. data/app/assets/javascripts/luca/components/controller.coffee +72 -11
  8. data/app/assets/javascripts/luca/components/fields/base.coffee +61 -8
  9. data/app/assets/javascripts/luca/components/fields/button_field.coffee +53 -7
  10. data/app/assets/javascripts/luca/components/fields/checkbox_array.coffee +12 -7
  11. data/app/assets/javascripts/luca/components/fields/text_field.coffee +1 -1
  12. data/app/assets/javascripts/luca/components/form_view.coffee +2 -2
  13. data/app/assets/javascripts/luca/components/grid_layout_view.coffee +0 -1
  14. data/app/assets/javascripts/luca/components/page.coffee +1 -0
  15. data/app/assets/javascripts/luca/components/table_view.coffee +2 -2
  16. data/app/assets/javascripts/luca/concerns/dom_helpers.coffee +2 -2
  17. data/app/assets/javascripts/luca/containers/card_view.coffee +84 -54
  18. data/app/assets/javascripts/luca/containers/container.coffee +126 -46
  19. data/app/assets/javascripts/luca/containers/modal_view.coffee +9 -9
  20. data/app/assets/javascripts/luca/containers/page_controller.coffee +25 -0
  21. data/app/assets/javascripts/luca/containers/panel_toolbar.coffee +1 -1
  22. data/app/assets/javascripts/luca/containers/viewport.coffee +2 -5
  23. data/app/assets/javascripts/luca/core/collection.coffee +18 -4
  24. data/app/assets/javascripts/luca/core/model.coffee +1 -1
  25. data/app/assets/javascripts/luca/core/panel.coffee +1 -1
  26. data/app/assets/javascripts/luca/core/view.coffee +26 -7
  27. data/app/assets/javascripts/luca/development/code_sync_manager.coffee +51 -4
  28. data/app/assets/javascripts/luca/development/console.coffee +1 -1
  29. data/app/assets/javascripts/luca/framework.coffee +1 -1
  30. data/app/assets/javascripts/luca/index.coffee +1 -0
  31. data/app/assets/javascripts/luca/util/luca.coffee +2 -1
  32. data/app/assets/stylesheets/luca/components/viewport.scss +0 -4
  33. data/bin/luca +14 -0
  34. data/docs/framework.json +1 -1
  35. data/docs/luca-framework-documentation.js +1 -0
  36. data/lib/luca/cli/generate.rb +37 -0
  37. data/lib/luca/cli/server.rb +20 -0
  38. data/lib/luca/cli/sync.rb +40 -0
  39. data/lib/luca/cli/watch.rb +16 -0
  40. data/lib/luca/cli.rb +68 -0
  41. data/lib/luca/collection/endpoint.rb +1 -0
  42. data/lib/luca/component_definition.rb +23 -5
  43. data/lib/luca/luca_application.rb +18 -7
  44. data/lib/luca/rails/version.rb +1 -1
  45. data/lib/luca/server.rb +7 -0
  46. data/lib/luca/stylesheet.rb +2 -3
  47. data/lib/luca/version.rb +3 -0
  48. data/lib/luca/watcher.rb +72 -0
  49. data/lib/luca.rb +8 -1
  50. data/luca.gemspec +14 -7
  51. data/site/.bundle/config +2 -0
  52. data/site/.gitignore +5 -0
  53. data/site/.rvmrc +1 -0
  54. data/site/CHANGELOG.md +41 -0
  55. data/site/DOCS.md +41 -0
  56. data/site/Gemfile +8 -0
  57. data/site/Gemfile.lock +134 -0
  58. data/site/LICENSE.md +19 -0
  59. data/site/config.rb +84 -0
  60. data/site/helpers/site_helpers.rb +20 -0
  61. data/site/html5bp-docs/README.md +38 -0
  62. data/site/html5bp-docs/contribute.md +104 -0
  63. data/site/html5bp-docs/crossdomain.md +21 -0
  64. data/site/html5bp-docs/css.md +135 -0
  65. data/site/html5bp-docs/extend.md +507 -0
  66. data/site/html5bp-docs/faq.md +77 -0
  67. data/site/html5bp-docs/htaccess.md +323 -0
  68. data/site/html5bp-docs/html.md +170 -0
  69. data/site/html5bp-docs/js.md +31 -0
  70. data/site/html5bp-docs/misc.md +25 -0
  71. data/site/html5bp-docs/usage.md +109 -0
  72. data/site/readme.md +47 -0
  73. data/site/source/.htaccess +540 -0
  74. data/site/source/404.html +157 -0
  75. data/site/source/app/assets/javascripts/dependencies.js.coffee +6 -0
  76. data/site/source/app/assets/javascripts/docs/application.coffee +64 -0
  77. data/site/source/app/assets/javascripts/docs/collections/docs_documentation.coffee +17 -0
  78. data/site/source/app/assets/javascripts/docs/collections/github_repositories.coffee +7 -0
  79. data/site/source/app/assets/javascripts/docs/collections/index.coffee +1 -0
  80. data/site/source/app/assets/javascripts/docs/collections/luca_documentation.coffee +17 -0
  81. data/site/source/app/assets/javascripts/docs/collections/public_gists.coffee +4 -0
  82. data/site/source/app/assets/javascripts/docs/config.coffee +5 -0
  83. data/site/source/app/assets/javascripts/docs/index.coffee +12 -0
  84. data/site/source/app/assets/javascripts/docs/lib/router.coffee +3 -0
  85. data/site/source/app/assets/javascripts/docs/lib/util.coffee +0 -0
  86. data/site/source/app/assets/javascripts/docs/models/component.coffee +99 -0
  87. data/site/source/app/assets/javascripts/docs/models/github_repository.coffee +3 -0
  88. data/site/source/app/assets/javascripts/docs/models/index.coffee +1 -0
  89. data/site/source/app/assets/javascripts/docs/templates/component_documentation.jst.ejs +55 -0
  90. data/site/source/app/assets/javascripts/docs/templates/examples_browser/overview.jst.ejs +4 -0
  91. data/site/source/app/assets/javascripts/docs/templates/examples_browser/selector.jst.ejs +11 -0
  92. data/site/source/app/assets/javascripts/docs/templates/github_repository.jst.ejs +4 -0
  93. data/site/source/app/assets/javascripts/docs/templates/layouts/main.jst.ejs +4 -0
  94. data/site/source/app/assets/javascripts/docs/templates/left_navigation.jst.ejs +5 -0
  95. data/site/source/app/assets/javascripts/docs/templates/pages/getting_started.jst.ejs +78 -0
  96. data/site/source/app/assets/javascripts/docs/templates/pages/home.jst.ejs +57 -0
  97. data/site/source/app/assets/javascripts/docs/views/components/code_editor/index.coffee +0 -0
  98. data/site/source/app/assets/javascripts/docs/views/components/code_editor.coffee +45 -0
  99. data/site/source/app/assets/javascripts/docs/views/components/component_documentation.coffee +72 -0
  100. data/site/source/app/assets/javascripts/docs/views/index.coffee +3 -0
  101. data/site/source/app/assets/javascripts/docs/views/pages/browse_source/details.coffee +37 -0
  102. data/site/source/app/assets/javascripts/docs/views/pages/browse_source/list.coffee +31 -0
  103. data/site/source/app/assets/javascripts/docs/views/pages/browse_source.coffee +46 -0
  104. data/site/source/app/assets/javascripts/docs/views/pages/component_editor.coffee +10 -0
  105. data/site/source/app/assets/javascripts/docs/views/pages/examples_browser/docs.coffee +12 -0
  106. data/site/source/app/assets/javascripts/docs/views/pages/examples_browser/source.coffee +13 -0
  107. data/site/source/app/assets/javascripts/docs/views/pages/examples_browser.coffee +102 -0
  108. data/site/source/app/assets/javascripts/docs/views/pages/home.coffee +10 -0
  109. data/site/source/app/assets/javascripts/docs/views/views/api_browser/index.coffee +43 -0
  110. data/site/source/app/assets/javascripts/docs/views/views/collection_view_examples/grid_layout_view_example.coffee +14 -0
  111. data/site/source/app/assets/javascripts/docs/views/views/collection_view_examples/table_view_example.coffee +39 -0
  112. data/site/source/app/assets/javascripts/docs/views/views/form_view_examples/basic_example.coffee +38 -0
  113. data/site/source/app/assets/javascripts/docs/views/views/form_view_examples/complex_layout.coffee +110 -0
  114. data/site/source/app/assets/javascripts/docs/views/views/top_navigation.coffee +6 -0
  115. data/site/source/app/assets/javascripts/docs-docs.js +1 -0
  116. data/site/source/app/assets/javascripts/luca-docs.js +1 -0
  117. data/site/source/app/assets/javascripts/luca-framework-documentation.js +1 -0
  118. data/site/source/app/assets/javascripts/site.js.coffee +4 -0
  119. data/site/source/app/assets/javascripts/vendor/codemirror.js +4786 -0
  120. data/site/source/app/assets/javascripts/vendor/coffeescript.js +346 -0
  121. data/site/source/app/assets/javascripts/vendor/css.js +465 -0
  122. data/site/source/app/assets/javascripts/vendor/htmlmixed.js +84 -0
  123. data/site/source/app/assets/javascripts/vendor/javascript.js +422 -0
  124. data/site/source/app/assets/javascripts/vendor/js-beautify.js +1353 -0
  125. data/site/source/app/assets/javascripts/vendor/modernizr-2.6.1.min.js +4 -0
  126. data/site/source/app/assets/javascripts/vendor/vim.js +2511 -0
  127. data/site/source/app/assets/stylesheets/docs/api-browser.css.scss +5 -0
  128. data/site/source/app/assets/stylesheets/docs/application.css.scss +35 -0
  129. data/site/source/app/assets/stylesheets/docs/browse-source.css.scss +5 -0
  130. data/site/source/app/assets/stylesheets/docs/scrollable-table.css.scss +5 -0
  131. data/site/source/app/assets/stylesheets/site.css.scss +2 -0
  132. data/site/source/app/assets/stylesheets/vendor/codemirror.css +240 -0
  133. data/site/source/app/assets/stylesheets/vendor/prettify-tomorrow-night-bright.css +160 -0
  134. data/site/source/app/assets/stylesheets/vendor/twilight.css +26 -0
  135. data/site/source/crossdomain.xml +15 -0
  136. data/site/source/documentation.html.haml +1 -0
  137. data/site/source/favicon_base.png +0 -0
  138. data/site/source/humans.txt +15 -0
  139. data/site/source/images/background.png +0 -0
  140. data/site/source/images/middleman.png +0 -0
  141. data/site/source/index.html.haml +1 -0
  142. data/site/source/layouts/layout.haml +55 -0
  143. data/site/source/readme.md +63 -0
  144. data/site/source/robots.txt +3 -0
  145. data/spec/javascripts/components/collection_view_spec.coffee +1 -1
  146. data/spec/javascripts/containers/card_view_spec.coffee +58 -5
  147. data/spec/javascripts/core/collection_spec.coffee +1 -1
  148. data/spec/javascripts/core/view_spec.coffee +2 -2
  149. data/vendor/assets/javascripts/backbone-min.js +37 -33
  150. data/vendor/assets/javascripts/backbone-query.min.js +1 -1
  151. data/vendor/assets/javascripts/jquery.js +5 -4
  152. data/vendor/assets/javascripts/luca-dependencies.min.js +8 -6
  153. data/vendor/assets/javascripts/luca-development.min.js +1 -1
  154. data/vendor/assets/javascripts/luca.full.min.js +12 -10
  155. data/vendor/assets/javascripts/luca.min.js +5 -5
  156. data/vendor/assets/javascripts/underscore-min.js +1 -5
  157. data/vendor/assets/javascripts/underscore-string.min.js +1 -1
  158. data/vendor/assets/stylesheets/luca-components.css +0 -2
  159. data/vendor/assets/stylesheets/luca-development.css +1 -1
  160. metadata +215 -39
  161. data/app/assets/javascripts/luca/components/page_controller.coffee +0 -3
  162. data/app/assets/javascripts/luca/core/collection_view.coffee +0 -150
  163. data/site/assets/bootstrap.min.js +0 -7
  164. data/site/assets/dependencies.js +0 -94
  165. data/site/assets/glyphicons-halflings-white.png +0 -0
  166. data/site/assets/glyphicons-halflings.png +0 -0
  167. data/site/assets/luca-ui-bootstrap.css +0 -1331
  168. data/site/assets/luca-ui-bootstrap.js +0 -9
  169. data/site/assets/luca-ui-development-tools.css +0 -234
  170. data/site/assets/luca-ui-development-tools.js +0 -18561
  171. data/site/assets/luca-ui-development-tools.min.js +0 -15
  172. data/site/assets/luca-ui-full.min.js +0 -8
  173. data/site/assets/luca-ui.min.js +0 -4
  174. data/site/assets/sandbox.css +0 -62
  175. data/site/assets/sandbox.js +0 -469
  176. data/site/docs/application.html +0 -41
  177. data/site/docs/caching.html +0 -43
  178. data/site/docs/collection.html +0 -75
  179. data/site/docs/collection_manager.html +0 -71
  180. data/site/docs/containers.html +0 -118
  181. data/site/docs/events.html +0 -153
  182. data/site/docs/view.html +0 -128
  183. data/site/img/glyphicons-halflings-white.png +0 -0
  184. data/site/img/glyphicons-halflings.png +0 -0
  185. data/site/index.html +0 -20
  186. data/site/source-map.js +0 -1
@@ -128,6 +128,10 @@
128
128
  # rowFluid: true
129
129
  #
130
130
  # #### Using a layout template with CSS Selectors
131
+ # If you find yourself needing a container view with a complicated
132
+ # visual layout, you can provide your own DOM template as a `@bodyTemplate`
133
+ # and assign each child view in `@components` to its own specific CSS selector.
134
+ #
131
135
  # ...
132
136
  # container.contains
133
137
  # role: "filter"
@@ -153,33 +157,94 @@ container.triggers "before:components",
153
157
  container.replaces "Luca.Container"
154
158
 
155
159
  container.publicConfiguration
160
+ # @components should contain a list of object configurations for child view(s)
161
+ # of this container. The values specified in the configuration object will override the
162
+ # values defined as properties and methods on your view prototypes.
163
+ #
164
+ # There are special properties you can define in your components configuration items
165
+ # that will effect the container:
166
+ #
167
+ # - role: will create a camelized getter for you on the container. e.g. when role is `my_custom_role`,
168
+ # the container will have a method `getMyCustomRole()` that returns that child view.
169
+ #
170
+ # - name: a name for the child view. this allows you to access the component by name using
171
+ # the find() method on the container.
172
+ #
173
+ # - type: a type alias from the component registry. type alias are underscore'd strings
174
+ # matching the component class name. e.g. App.views.MyCustomView type alias is `my_custom_view`
175
+ #
176
+ # - component: a convenience property for setting type, role, and name to be equal.
156
177
  components:[]
157
178
 
158
- container.privateConfiguration
159
- emptyContainerElements: false
160
- className: 'luca-ui-container'
161
- componentTag: 'div'
162
- componentClass: 'luca-ui-panel'
163
- isContainer: true
164
- rendered: false
179
+ # The `@defaults` property is an object of configuration parameters which will be set
180
+ # on each child component. Values explicitly defines in the components config will
181
+ # take precedence over the default.
182
+ defaults: {}
183
+
184
+ # The `@extensions` property is useful when you are subclassing a container view
185
+ # which already defines an array of components, and you want to specifically override
186
+ # properties and settings on the children. The `@extensions` property expects either:
187
+ #
188
+ # An object whose keys match the names of the `@role` property defined on the child components.
189
+ # The value should be an object which will override any values defined on the parent class.
190
+ #
191
+ # or:
192
+ #
193
+ # An array of objects in the same array position / index as the target child view you wish to extend.
194
+ extensions: {}
165
195
 
166
196
  # @componentEvents provides declarative syntax for responding to events on
167
197
  # the components in this container. the format of the syntax is very similar
168
198
  # to the other event binding helpers:
169
199
  #
170
- # component_accessor component:trigger
171
- #
172
- # where component_accessor is either the name of the role, or a method on the container
173
- # which will find the component in question.
174
- #
175
- # myContainer = new Luca.Container
176
- # componentEvents:
177
- # "name component:trigger" : "handler"
178
- # "role component:trigger" : "handler"
179
- # "getter component:trigger" : "handler"
200
+ # `component_accessor component:trigger`
180
201
  #
202
+ # where component_accessor is either the name of the component, or a the role
203
+ # property on the component, component:trigger is the event that component fires.
204
+ # handler is a method on the container which will respond to the child component event.
205
+ # <pre>
206
+ # myContainer = new Luca.Container
207
+ # componentEvents:
208
+ # "name component:trigger" : "handler"
209
+ # "role component:trigger" : "handler"
210
+ # "getter component:trigger" : "handler"
211
+ # components:[
212
+ # name: "name"
213
+ # ]
214
+ # </pre>
181
215
  componentEvents: {}
182
216
 
217
+ container.privateConfiguration
218
+ className: 'luca-ui-container'
219
+
220
+ # This is a convenience attribute for identifying
221
+ # views which are luca containers
222
+ isContainer: true
223
+
224
+ # if set to true, we will generate DOM elements
225
+ # to wrap each of our components in. This should
226
+ # generally be avoided IMO as it pollutes the DOM,
227
+ # but is currently necessary for some container implementations
228
+ generateComponentElements: false
229
+
230
+ # if set to true, the DOM elements which wrap
231
+ # our components will be emptied prior to rendering
232
+ # the component inside this container.
233
+ emptyContainerElements: false
234
+
235
+ # if @generateComponentElements is true, which tag should this
236
+ # container wrap our components in?
237
+ componentTag: 'div'
238
+
239
+ # if @generateComponentElements is true, which class should we
240
+ # apply to the container elements which wrap our components?
241
+ componentClass: 'luca-ui-panel'
242
+
243
+ rendered: false
244
+
245
+
246
+
247
+ container.privateMethods
183
248
  initialize: (@options={})->
184
249
  _.extend @, @options
185
250
 
@@ -199,6 +264,7 @@ container.privateConfiguration
199
264
 
200
265
  Luca.View::initialize.apply @, arguments
201
266
 
267
+ # Removing a container will call remove on all of the nested components as well.
202
268
  remove: ()->
203
269
  Luca.View::remove.apply(@, arguments)
204
270
  @eachComponent (component)->
@@ -344,8 +410,7 @@ container.privateConfiguration
344
410
 
345
411
  map
346
412
 
347
- # Trigger the Rendering Pipeline process on all of the nested
348
- # components
413
+ # Trigger the Rendering Pipeline process on all of the nested components
349
414
  renderComponents: (@debugMode="")->
350
415
  @debug "container render components"
351
416
 
@@ -383,8 +448,6 @@ container.privateConfiguration
383
448
 
384
449
  throw e unless Luca.silenceRenderErrors? is true
385
450
 
386
- #### Container Activation
387
- #
388
451
  # When a container is first activated is a good time to perform
389
452
  # operations which are not needed unless that component becomes
390
453
  # visible. This first activation event should be relayed to all
@@ -401,27 +464,6 @@ container.privateConfiguration
401
464
  component?.trigger?.call component, "first:activation", component, activator
402
465
  component.previously_activated = true
403
466
 
404
- #### Underscore Methods For Working with Components
405
- _: ()-> _( @components )
406
-
407
- pluck: (attribute)->
408
- @_().pluck(attribute)
409
-
410
- invoke: (method)->
411
- @_().invoke(method)
412
-
413
- select: (fn)->
414
- @_().select(fn)
415
-
416
- detect: (fn)->
417
- @_().detect(attribute)
418
-
419
- reject: (fn)->
420
- @_().reject(fn)
421
-
422
- map: (fn)->
423
- @_().map(fn)
424
-
425
467
  registerComponentEvents: (eventList, direction="on")->
426
468
  container = @
427
469
 
@@ -443,13 +485,41 @@ container.privateConfiguration
443
485
 
444
486
  component[direction](eventId, @[handler], container)
445
487
 
488
+ container.publicMethods
489
+ # Returns an underscore.js object that wraps the components array
490
+ _: ()-> _( @components )
446
491
 
492
+ # Return the value of attribute of each component
493
+ pluck: (attribute)->
494
+ @_().pluck(attribute)
495
+
496
+ # Invoke the passed method name on each component
497
+ invoke: (method)->
498
+ @_().invoke(method)
499
+
500
+ # Select any component for which the passed iterator returns true
501
+ select: (iterator)->
502
+ @_().select(iterator)
503
+
504
+ # Find the first matching component for which the passed iterator returns true
505
+ detect: (iterator)->
506
+ @_().detect(iterator)
507
+
508
+ # Return a list of components without the components for which the passed iterator returns true
509
+ reject: (iterator)->
510
+ @_().reject(iterator)
511
+
512
+ # Run the passed iterator over each component and return the result in an array
513
+ map: (fn)->
514
+ @_().map(fn)
515
+
516
+ # Returns a list of nested components which are also containers
447
517
  subContainers: ()->
448
518
  @select (component)->
449
519
  component.isContainer is true
450
520
 
451
521
  roles: ()->
452
- _( @allChildren() ).pluck('role')
522
+ _( @allChildren() ).chain().pluck('role').compact().value()
453
523
 
454
524
  allChildren: ()->
455
525
  children = @components
@@ -459,6 +529,11 @@ container.privateConfiguration
459
529
 
460
530
  _([children,grandchildren]).chain().compact().flatten().value()
461
531
 
532
+ # Find a direct component on this card by its name.
533
+ find: (name)->
534
+ _( @components ).detect (c)->
535
+ c.name is name
536
+
462
537
  findComponentForEventBinding: (nameRoleOrGetter, deep=true)->
463
538
  @findComponentByName(nameRoleOrGetter, deep) || @findComponentByGetter( nameRoleOrGetter, deep ) || @findComponentByRole( nameRoleOrGetter, deep )
464
539
 
@@ -506,10 +581,17 @@ container.privateConfiguration
506
581
  fn.call component, component, index
507
582
  component?.eachComponent?.apply component, [fn,deep] if deep
508
583
 
509
- indexOf: (name)->
584
+ indexOfComponentName: (name)->
510
585
  names = _( @components ).pluck('name')
511
586
  _( names ).indexOf(name)
512
587
 
588
+ indexOf: (nameOrComponent)->
589
+ if _.isString(nameOrComponent)
590
+ return @indexOfComponentName(nameOrComponent)
591
+
592
+ if _.isObject(nameOrComponent)
593
+ _( @components ).indexOf( nameOrComponent )
594
+
513
595
  activeComponent: ()->
514
596
  return @ unless @activeItem
515
597
  return @components[ @activeItem ]
@@ -617,8 +699,6 @@ doComponents = ()->
617
699
  validateContainerConfiguration = ()->
618
700
  true
619
701
 
620
- # Private Helpers
621
- #
622
702
  # indexComponent( component ).at( index ).in( componentsInternalIndexMap )
623
703
  indexComponent = (component)->
624
704
  at: (index)->
@@ -1,13 +1,13 @@
1
- _.def("Luca.ModalView").extends("Luca.Container").with
1
+ view = Luca.register "Luca.containers.ModalView"
2
+ view.extends "Luca.Container"
2
3
 
4
+ view.publicConfiguration
3
5
  closeOnEscape: true
4
-
5
6
  showOnInitialize: false
6
-
7
7
  backdrop: false
8
+ className: "modal"
8
9
 
9
- className: "luca-ui-container modal"
10
-
10
+ view.publicMethods
11
11
  container: ()->
12
12
  $('body')
13
13
 
@@ -27,10 +27,10 @@ _.def("Luca.ModalView").extends("Luca.Container").with
27
27
  $('body').append( @$el )
28
28
 
29
29
  @$el.modal
30
- backdrop: @backdrop is true
31
- keyboard: @closeOnEscape is true
32
- show: @showOnInitialize is true
30
+ backdrop: !!(@backdrop is true)
31
+ keyboard: !!(@closeOnEscape is true)
32
+ show: !!(@showOnInitialize is true)
33
33
 
34
34
  @
35
35
 
36
- _.def("Luca.containers.ModalView").extends("Luca.ModalView").with()
36
+ view.register()
@@ -0,0 +1,25 @@
1
+ # The PageController container is a special type of container whose components or pages
2
+ # will always monopolize the entire element's display and where only one page or component
3
+ # will be visible at a time. The PageController is typically going to be at the very root
4
+ # of every application, and will be directly integrated with the application's router.
5
+ # A typical application hierarchy will be an abstract `Viewport` with a single top level
6
+ # `PageController` named 'main_controller'.
7
+ #
8
+ # - Viewport / Application
9
+ # - Router. ( maps urls to named pages on the controller )
10
+ # - Main Page Controller
11
+ # - Pages
12
+ # - Named views / containers
13
+ view = Luca.register "Luca.containers.PageController"
14
+ view.extends "Luca.Container"
15
+
16
+ view.privateMethods
17
+ initialize: (@options={})->
18
+ @components ||= @pages || @options.pages
19
+ for component in @components
20
+ component.components ||= component.pages
21
+
22
+ Luca.Container::initialize.apply(@, arguments)
23
+
24
+ view.register()
25
+
@@ -75,7 +75,7 @@ panelToolbar.defines
75
75
  @
76
76
 
77
77
 
78
- make = Backbone.View::make
78
+ make = Luca.View::make
79
79
 
80
80
  buildButton = (config, wrap=true)->
81
81
  if config.ctype? or config.type?
@@ -39,10 +39,7 @@ viewport.defines
39
39
  @$el.removeClass('fullscreen-enabled')
40
40
 
41
41
  beforeRender: ()->
42
- Luca.containers.CardView::beforeRender?.apply(@, arguments)
43
-
44
- #if Luca.config.enableBoostrap and @topNav and @fullscreen
45
- # $('body').css('padding','40px')
42
+ Luca.Container::beforeRender?.apply(@, arguments)
46
43
 
47
44
  @renderTopNavigation() if @topNav?
48
45
  @renderBottomNavigation() if @bottomNav?
@@ -54,7 +51,7 @@ viewport.defines
54
51
  @$el.width()
55
52
 
56
53
  afterRender: ()->
57
- Luca.containers.CardView::after?.apply(@, arguments)
54
+ Luca.Container::afterRender?.apply(@, arguments)
58
55
 
59
56
  if Luca.config.enableBoostrap is true and @containerClassName
60
57
  @$el.children().wrap('<div class="#{ containerClassName }" />')
@@ -1,4 +1,4 @@
1
- collection = Luca.define 'Luca.Collection'
1
+ collection = Luca.register 'Luca.Collection'
2
2
  collection.extends 'Backbone.QueryCollection'
3
3
  collection.includes 'Luca.Events'
4
4
 
@@ -6,13 +6,13 @@ collection.triggers "after:initialize",
6
6
  "before:fetch",
7
7
  "after:response"
8
8
 
9
- collection.defines
9
+ collection.publicConfiguration
10
10
  model: Luca.Model
11
11
  # cachedMethods refers to a list of methods on the collection
12
12
  # whose value gets cached once it is ran. the collection then
13
13
  # binds to change, add, remove, and reset events and then expires
14
14
  # the cached value once these events are fired.
15
-
15
+ #
16
16
  # cachedMethods expects an array of strings representing the method name
17
17
  # or objects containing @method and @resetEvents properties. by default
18
18
  # @resetEvents are 'add','remove',reset' and 'change'.
@@ -22,6 +22,17 @@ collection.defines
22
22
  # and return the filtered results that way, then set this to true
23
23
  remoteFilter: false
24
24
 
25
+ # setting a cache key to a string, or to a function which returns
26
+ # a string, will determine where the collections' models are pulled
27
+ # from if they are available on page load. also known as "bootstrapping"
28
+ # your collections with data. The cache key will look in whatever object
29
+ # is set in Luca.config.modelBootstrap for its models.
30
+ cache_key: undefined
31
+
32
+ # Which CollectionManager should we register with? Expects either a string
33
+ # which will get resolved into a global variable, or a
34
+ manager: undefined
35
+
25
36
  initialize: (models=[], @options)->
26
37
  _.extend @, @options
27
38
  @_reset()
@@ -44,7 +55,7 @@ collection.defines
44
55
  @name ||= @registerAs
45
56
  @manager ||= @registerWith
46
57
 
47
- @manager = if _.isFunction(@manager) then @manager() else @manager
58
+ @manager = Luca.util.read(@manager) if @manager?
48
59
 
49
60
  # if they specify a
50
61
  if @name and not @manager
@@ -346,6 +357,9 @@ collection.defines
346
357
  else
347
358
  @models
348
359
 
360
+ collection.register()
361
+
362
+
349
363
  # Global Collection Observer
350
364
  _.extend Luca.Collection.prototype,
351
365
  trigger: ()->
@@ -1,4 +1,4 @@
1
- model = Luca.define 'Luca.Model'
1
+ model = Luca.register 'Luca.Model'
2
2
 
3
3
  model.extends 'Backbone.Model'
4
4
 
@@ -54,7 +54,7 @@ panel.publicMethods
54
54
  @$bodyEl().empty()
55
55
 
56
56
  $html: (content)->
57
- @$bodyEl().html( content )
57
+ if content? then @$bodyEl().html( content ) else @$bodyEl().html()
58
58
 
59
59
  $append: (content)->
60
60
  @$bodyEl().append(content)
@@ -136,11 +136,11 @@ view.publicConfiguration
136
136
  #
137
137
  autoBindEventHandlers: false
138
138
 
139
- # Supplying configuration to `@_events` will ensure that this configuration
139
+ # Supplying configuration to `@_inheritEvents` will ensure that this configuration
140
140
  # is present on views which extend from this view. In normal Backbone behavior
141
141
  # the `@events` property can be overridden by views which extend, and this isn't
142
142
  # always what you want from your component.
143
- _events: undefined
143
+ _inheritEvents: undefined
144
144
 
145
145
 
146
146
 
@@ -174,14 +174,14 @@ view.publicMethods
174
174
 
175
175
  Luca.concern.setup.call(@)
176
176
 
177
- @delegateEvents()
177
+ @delegateEvents() unless _.isEmpty(@events)
178
178
 
179
179
  @trigger "after:initialize", @
180
180
 
181
181
  _.bindAll(@, @bindMethods...) if @bindMethods?.legth > 0
182
182
 
183
- unless _.isEmpty(@_events)
184
- for eventId, handler of @_events
183
+ unless _.isEmpty(@_inheritEvents)
184
+ for eventId, handler of @_inheritEvents
185
185
  @registerEvent(eventId, handler)
186
186
 
187
187
 
@@ -198,7 +198,17 @@ view.publicMethods
198
198
 
199
199
  Backbone.View::trigger.apply @, arguments
200
200
 
201
-
201
+ # Backbone.View.prototype.make is removed in 0.9.10.
202
+ # As we happen to rely on this little utility heavily,
203
+ # we add it to Luca.View
204
+ make: (tagName, attributes, content)->
205
+ el = document.createElement(tagName);
206
+ if (attributes)
207
+ Backbone.$(el).attr(attributes)
208
+ if (content != null)
209
+ Backbone.$(el).html(content)
210
+
211
+ el
202
212
 
203
213
  registerEvent: (selector, handler)->
204
214
  @events ||= {}
@@ -206,7 +216,8 @@ view.publicMethods
206
216
  if _.isObject(selector)
207
217
  @events = _.extend(@events, selector)
208
218
  else
209
- @events[selector] = handler
219
+ if _.isFunction(handler) || (_.isString(handler) && @[handler]?)
220
+ @events[selector] = handler
210
221
 
211
222
  @delegateEvents()
212
223
 
@@ -240,6 +251,14 @@ view.privateMethods
240
251
  # - first:activation : firstActivation()
241
252
  setupHooks: Luca.util.setupHooks
242
253
 
254
+ # In order to support some Luca apps which rely
255
+ # on Backbone.View.make.
256
+ view.afterDefinition ()->
257
+ if not Backbone.View::make?
258
+ Backbone.View::make = ()->
259
+ console.log "Backbone.View::make has been removed from backbone. You should use Luca.View::make instead."
260
+ Luca.View::make
261
+
243
262
  view.register()
244
263
 
245
264
  Luca.View._originalExtend = Backbone.View.extend
@@ -1,15 +1,59 @@
1
+ # The `Luca.CodeSyncManager` works along with the Guard adapter that ships with
2
+ # the ruby gem. This is still an experimental option at this point, but I use
3
+ # it regularly on all of my Luca projects and it allows me to develop my applications
4
+ # directly from my editor and rarely have the need to refresth the browser to work with
5
+ # javascript and css changes.
6
+ #
7
+ # #### Similar to LiveReload
8
+ # It is similar to projects like LiveReload, except that it knows a lot about the luca
9
+ # framework and application conventions and uses this knowledge to optimize live reloading
10
+ # behavior, avoiding the need to do full browser reloads. This typically doesn't work well
11
+ # with state heavy applications, since the browser reloading doesn't always construct application
12
+ # state exactly as you need it when you're making your css changes etc.
13
+ #
14
+ # #### 1) Add an entry to your Guardfile:
15
+ # guard 'luca' do
16
+ # watch(%r{^app/assets/stylesheets/(.+)}) do |match|
17
+ # path = match.last
18
+ # end
19
+
20
+ # watch(%r{^app/assets/javascripts/(.+)}) do |match|
21
+ # path = match.last
22
+ # end
23
+ # end
24
+ #
25
+ # #### 2) Add the `CodeSyncManager` to your development mode application.
26
+ # **Note:** This expect
27
+ # you to have a `Luca.SocketManager` capable backend such as faye or socket.io running. It
28
+ # handles the same configuration options as the `Luca.SocketManager` as well.
29
+ #
30
+ # app = Luca()
31
+ # app.codeSyncManager = new Luca.CodeSyncManager
32
+ # host: "//localhost:9292/faye"
33
+ # channel: "/changes"
34
+ # app.codeSyncManager.trigger("ready")
35
+ #
36
+ # #### 3) Run guard.
37
+ # Edit your files, watch your changes appear.
38
+ #
39
+ # ### Using the Syncpad
40
+ #
41
+ # The syncpad is a special naming convention for development scratch paper in your editor. A file
42
+ # named syncpad.coffee, syncpad.css.scss, syncpad.jst.ejs.haml, etc will be evaluated live when you change
43
+ # them in your editor. I personally use this to experiment with code / css and get immediate results without
44
+ # needing to refresh the browser.
1
45
  codeManager = Luca.register "Luca.CodeSyncManager"
2
46
  codeManager.extends "Luca.SocketManager"
3
47
 
4
48
  codeManager.publicConfiguration
5
- host: Luca.config.codeSyncHost || "http://localhost:9292/faye"
49
+ host: Luca.config.codeSyncHost || "//localhost:9292/faye"
6
50
  namespace: "luca"
7
- channel: Luca.config.codeSyncChannel || "/changes"
51
+ channel: Luca.config.codeSyncChannel || "/luca-code-sync"
8
52
 
9
53
  codeManager.classMethods
10
54
  setup: (options={})->
11
55
  @codeSyncManager = new Luca.CodeSyncManager(options)
12
- @codeSyncManager.trigger("ready")
56
+ @codeSyncManager.trigger "ready"
13
57
 
14
58
  codeManager.privateMethods
15
59
  initialize: (@attributes={})->
@@ -19,6 +63,9 @@ codeManager.privateMethods
19
63
  Luca.SocketManager::initialize.call(@, @attributes)
20
64
  @bindToChannel()
21
65
 
66
+ start: ()->
67
+ @trigger "ready"
68
+
22
69
  bindToChannel: ()->
23
70
  if @client?
24
71
  @client.subscribe @channel, ()=>
@@ -123,4 +170,4 @@ codeManager.privateMethods
123
170
  $('head').append( link )
124
171
 
125
172
  codeManager.defines
126
- make: Backbone.View::make
173
+ make: Luca.View::make
@@ -186,7 +186,7 @@ Luca.util.inspectComponent = (component)->
186
186
 
187
187
  Luca.util.launchers.developmentConsole = (name="luca-development-console")->
188
188
  @_lucaDevConsole = Luca name, ()=>
189
- @$el.append Backbone.View::make("div", id: "#{ name }-wrapper", class: "modal fade large")
189
+ @$el.append Luca.View::make("div", id: "#{ name }-wrapper", class: "modal fade large")
190
190
 
191
191
  dconsole = new Luca.tools.DevelopmentConsole
192
192
  name: name
@@ -22,7 +22,7 @@ lucaUtilityHelper = (payload, args...)->
22
22
 
23
23
  (window || global).Luca = ()-> lucaUtilityHelper.apply(@, arguments)
24
24
 
25
- Luca.VERSION = '0.9.9'
25
+ Luca.VERSION = '0.9.91'
26
26
 
27
27
  _.extend Luca,
28
28
  core: {}
@@ -1,3 +1,4 @@
1
+ #= require_self
1
2
  #= require_tree ./templates
2
3
  #= require ./framework
3
4
  #= require ./config
@@ -112,7 +112,8 @@ Luca.util.loadScript = (url, callback) ->
112
112
  script.src = url
113
113
  document.body.appendChild(script)
114
114
 
115
- Luca.util.make = Backbone.View::make
115
+ Luca.util.make = (tagName="div", attributes={}, contents="")->
116
+ Luca.View::make.apply(@, arguments)
116
117
 
117
118
  Luca.util.list = (list,options={},ordered)->
118
119
  container = if ordered then "ol" else "ul"
@@ -3,10 +3,6 @@ html.luca-ui-fullscreen, body.luca-ui-fullscreen {
3
3
  }
4
4
 
5
5
  .luca-ui-fullscreen {
6
- .fluid-viewport-wrapper {
7
- padding-top:40px;
8
- }
9
-
10
6
  .luca-viewport, .luca-ui-viewport, .fullscreen-container {
11
7
  min-height: 100%;
12
8
  height: auto !important;
data/bin/luca ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
4
+
5
+ require 'rubygems'
6
+ require 'faye'
7
+ require 'sass'
8
+ require 'coffee-script'
9
+ require 'redcarpet'
10
+ require 'listen'
11
+ require 'luca'
12
+ require 'luca/cli'
13
+
14
+ Luca::Cli::Base.start