luca 0.9.8 → 0.9.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (310) hide show
  1. data/CHANGELOG +49 -0
  2. data/Gemfile +8 -1
  3. data/Gemfile.lock +97 -53
  4. data/Guardfile +3 -25
  5. data/README.md +5 -16
  6. data/ROADMAP +15 -9
  7. data/Rakefile +24 -75
  8. data/app.rb +10 -42
  9. data/app/assets/javascripts/luca/basic.coffee +1 -1
  10. data/app/assets/javascripts/luca/components/application.coffee +187 -104
  11. data/app/assets/javascripts/luca/components/collection_view.coffee +115 -51
  12. data/app/assets/javascripts/luca/components/controller.coffee +87 -10
  13. data/app/assets/javascripts/luca/components/fields/base.coffee +74 -13
  14. data/app/assets/javascripts/luca/components/fields/button_field.coffee +60 -13
  15. data/app/assets/javascripts/luca/components/fields/checkbox_array.coffee +12 -7
  16. data/app/assets/javascripts/luca/components/fields/select_field.coffee +82 -23
  17. data/app/assets/javascripts/luca/components/fields/text_area_field.coffee +25 -10
  18. data/app/assets/javascripts/luca/components/fields/text_field.coffee +9 -3
  19. data/app/assets/javascripts/luca/components/form_view.coffee +105 -33
  20. data/app/assets/javascripts/luca/components/grid_layout_view.coffee +42 -0
  21. data/app/assets/javascripts/luca/components/index.coffee +6 -0
  22. data/app/assets/javascripts/luca/components/nav_bar.coffee +60 -6
  23. data/app/assets/javascripts/luca/components/page.coffee +70 -0
  24. data/app/assets/javascripts/luca/components/simple_collection_view.coffee +10 -0
  25. data/app/assets/javascripts/luca/components/table_view.coffee +7 -3
  26. data/app/assets/javascripts/luca/components/table_view_scrollable.coffee +23 -0
  27. data/app/assets/javascripts/luca/concerns/collection_event_bindings.coffee +4 -1
  28. data/app/assets/javascripts/luca/concerns/development_tool_helpers.coffee +23 -14
  29. data/app/assets/javascripts/luca/concerns/dom_helpers.coffee +2 -2
  30. data/app/assets/javascripts/luca/concerns/filterable.coffee +8 -11
  31. data/app/assets/javascripts/luca/concerns/form_model_bindings.coffee +20 -0
  32. data/app/assets/javascripts/luca/concerns/modal_view.coffee +40 -15
  33. data/app/assets/javascripts/luca/concerns/query_collection_bindings.coffee +7 -1
  34. data/app/assets/javascripts/luca/concerns/state_model.coffee +40 -26
  35. data/app/assets/javascripts/luca/concerns/templating.coffee +3 -1
  36. data/app/assets/javascripts/luca/config.coffee +5 -0
  37. data/app/assets/javascripts/luca/containers/card_view.coffee +87 -52
  38. data/app/assets/javascripts/luca/containers/container.coffee +305 -108
  39. data/app/assets/javascripts/luca/containers/modal_view.coffee +9 -9
  40. data/app/assets/javascripts/luca/containers/page_controller.coffee +25 -0
  41. data/app/assets/javascripts/luca/containers/panel_toolbar.coffee +5 -6
  42. data/app/assets/javascripts/luca/containers/tab_view.coffee +19 -10
  43. data/app/assets/javascripts/luca/containers/viewport.coffee +12 -16
  44. data/app/assets/javascripts/luca/core/collection.coffee +19 -5
  45. data/app/assets/javascripts/luca/core/events.coffee +5 -5
  46. data/app/assets/javascripts/luca/core/model.coffee +1 -1
  47. data/app/assets/javascripts/luca/core/panel.coffee +18 -6
  48. data/app/assets/javascripts/luca/core/registry/component_definition.coffee +2 -1
  49. data/app/assets/javascripts/luca/core/registry/meta_data.coffee +2 -0
  50. data/app/assets/javascripts/luca/core/registry/registry.coffee +14 -11
  51. data/app/assets/javascripts/luca/core/templates.coffee +5 -1
  52. data/app/assets/javascripts/luca/core/view.coffee +200 -47
  53. data/app/assets/javascripts/luca/dependencies.coffee +2 -0
  54. data/app/assets/javascripts/luca/development/code_sync_manager.coffee +173 -0
  55. data/app/assets/javascripts/luca/development/component.coffee +76 -0
  56. data/app/assets/javascripts/luca/development/components.coffee +57 -0
  57. data/app/assets/javascripts/luca/development/console.coffee +1 -1
  58. data/app/assets/javascripts/luca/development/index.coffee +4 -1
  59. data/app/assets/javascripts/luca/framework.coffee +7 -3
  60. data/app/assets/javascripts/luca/index.coffee +2 -1
  61. data/app/assets/javascripts/luca/managers/collection_manager.coffee +2 -3
  62. data/app/assets/javascripts/luca/managers/index.coffee +1 -1
  63. data/app/assets/javascripts/luca/managers/socket_manager.coffee +31 -8
  64. data/app/assets/javascripts/luca/templates/components/nav_bar.jst.ejs +16 -1
  65. data/app/assets/javascripts/luca/templates/containers/tab_view.jst.ejs +1 -1
  66. data/app/assets/javascripts/luca/util/index.coffee +1 -0
  67. data/app/assets/javascripts/luca/util/keybindings.coffee +24 -0
  68. data/app/assets/javascripts/luca/util/logging.coffee +15 -0
  69. data/app/assets/javascripts/luca/util/luca.coffee +9 -1
  70. data/app/assets/stylesheets/luca/components/table_view.scss +85 -0
  71. data/app/assets/stylesheets/luca/components/viewport.scss +0 -4
  72. data/app/assets/stylesheets/luca/containers/container.scss +8 -0
  73. data/app/assets/stylesheets/luca/index.css +2 -2
  74. data/bin/luca +14 -0
  75. data/config.ru +1 -2
  76. data/docs/framework.json +1 -0
  77. data/docs/luca-framework-documentation.js +1 -0
  78. data/docs/{application.md → old/application.md} +0 -0
  79. data/docs/{collection.md → old/collection.md} +0 -0
  80. data/docs/{collection_manager.md → old/collection_manager.md} +0 -0
  81. data/docs/{container_philosophy.md → old/container_philosophy.md} +0 -0
  82. data/docs/{event_binding_helpers.md → old/event_binding_helpers.md} +0 -0
  83. data/docs/{method_caching_and_computed_properties.md → old/method_caching_and_computed_properties.md} +0 -0
  84. data/docs/{view.md → old/view.md} +0 -0
  85. data/lib/generators/luca/application/templates/javascripts/dependencies.coffee +2 -5
  86. data/lib/guard/luca.rb +84 -0
  87. data/lib/luca.rb +25 -1
  88. data/lib/luca/asset_compiler.rb +117 -0
  89. data/lib/luca/cli.rb +68 -0
  90. data/lib/luca/cli/generate.rb +37 -0
  91. data/lib/luca/cli/server.rb +20 -0
  92. data/lib/luca/cli/sync.rb +40 -0
  93. data/lib/luca/cli/watch.rb +16 -0
  94. data/lib/luca/collection.rb +64 -0
  95. data/lib/luca/collection/endpoint.rb +38 -0
  96. data/lib/luca/collection/file_backend.rb +121 -0
  97. data/lib/luca/collection/redis_backend.rb +153 -0
  98. data/lib/luca/compiled_asset.rb +61 -0
  99. data/lib/luca/component_definition.rb +356 -0
  100. data/lib/luca/luca_application.rb +258 -0
  101. data/lib/luca/project.rb +73 -0
  102. data/lib/luca/project_harness.rb +96 -0
  103. data/lib/luca/rails.rb +5 -3
  104. data/lib/luca/rails/engine.rb +8 -0
  105. data/lib/luca/rails/version.rb +1 -2
  106. data/lib/luca/server.rb +7 -0
  107. data/lib/luca/stylesheet.rb +35 -0
  108. data/lib/luca/template.rb +2 -0
  109. data/lib/luca/template_asset.rb +64 -0
  110. data/lib/luca/version.rb +3 -0
  111. data/lib/luca/watcher.rb +72 -0
  112. data/lib/railties/luca/tasks.rake +7 -0
  113. data/site/.bundle/config +2 -0
  114. data/site/.gitignore +5 -0
  115. data/site/.rvmrc +1 -0
  116. data/site/CHANGELOG.md +41 -0
  117. data/site/DOCS.md +41 -0
  118. data/site/Gemfile +8 -0
  119. data/site/Gemfile.lock +134 -0
  120. data/site/LICENSE.md +19 -0
  121. data/site/config.rb +84 -0
  122. data/site/helpers/site_helpers.rb +20 -0
  123. data/site/html5bp-docs/README.md +38 -0
  124. data/site/html5bp-docs/contribute.md +104 -0
  125. data/site/html5bp-docs/crossdomain.md +21 -0
  126. data/site/html5bp-docs/css.md +135 -0
  127. data/site/html5bp-docs/extend.md +507 -0
  128. data/site/html5bp-docs/faq.md +77 -0
  129. data/site/html5bp-docs/htaccess.md +323 -0
  130. data/site/html5bp-docs/html.md +170 -0
  131. data/site/html5bp-docs/js.md +31 -0
  132. data/site/html5bp-docs/misc.md +25 -0
  133. data/site/html5bp-docs/usage.md +109 -0
  134. data/site/readme.md +47 -0
  135. data/site/source/.htaccess +540 -0
  136. data/site/source/404.html +157 -0
  137. data/site/source/app/assets/javascripts/dependencies.js.coffee +6 -0
  138. data/site/source/app/assets/javascripts/docs-docs.js +1 -0
  139. data/site/source/app/assets/javascripts/docs/application.coffee +64 -0
  140. data/site/source/app/assets/javascripts/docs/collections/docs_documentation.coffee +17 -0
  141. data/site/source/app/assets/javascripts/docs/collections/github_repositories.coffee +7 -0
  142. data/site/source/app/assets/javascripts/docs/collections/index.coffee +1 -0
  143. data/site/source/app/assets/javascripts/docs/collections/luca_documentation.coffee +17 -0
  144. data/site/source/app/assets/javascripts/docs/collections/public_gists.coffee +4 -0
  145. data/site/source/app/assets/javascripts/docs/config.coffee +5 -0
  146. data/site/source/app/assets/javascripts/docs/index.coffee +12 -0
  147. data/site/source/app/assets/javascripts/docs/lib/router.coffee +3 -0
  148. data/{spec/components/application_spec.coffee → site/source/app/assets/javascripts/docs/lib/util.coffee} +0 -0
  149. data/site/source/app/assets/javascripts/docs/models/component.coffee +99 -0
  150. data/site/source/app/assets/javascripts/docs/models/github_repository.coffee +3 -0
  151. data/site/source/app/assets/javascripts/docs/models/index.coffee +1 -0
  152. data/site/source/app/assets/javascripts/docs/templates/component_documentation.jst.ejs +55 -0
  153. data/site/source/app/assets/javascripts/docs/templates/examples_browser/overview.jst.ejs +4 -0
  154. data/site/source/app/assets/javascripts/docs/templates/examples_browser/selector.jst.ejs +11 -0
  155. data/site/source/app/assets/javascripts/docs/templates/github_repository.jst.ejs +4 -0
  156. data/site/source/app/assets/javascripts/docs/templates/layouts/main.jst.ejs +4 -0
  157. data/site/source/app/assets/javascripts/docs/templates/left_navigation.jst.ejs +5 -0
  158. data/site/source/app/assets/javascripts/docs/templates/pages/getting_started.jst.ejs +78 -0
  159. data/site/source/app/assets/javascripts/docs/templates/pages/home.jst.ejs +57 -0
  160. data/site/source/app/assets/javascripts/docs/views/components/code_editor.coffee +45 -0
  161. data/{spec/components/collection_loader_view_spec.coffee → site/source/app/assets/javascripts/docs/views/components/code_editor/index.coffee} +0 -0
  162. data/site/source/app/assets/javascripts/docs/views/components/component_documentation.coffee +72 -0
  163. data/site/source/app/assets/javascripts/docs/views/index.coffee +3 -0
  164. data/site/source/app/assets/javascripts/docs/views/pages/browse_source.coffee +46 -0
  165. data/site/source/app/assets/javascripts/docs/views/pages/browse_source/details.coffee +37 -0
  166. data/site/source/app/assets/javascripts/docs/views/pages/browse_source/list.coffee +31 -0
  167. data/site/source/app/assets/javascripts/docs/views/pages/component_editor.coffee +10 -0
  168. data/site/source/app/assets/javascripts/docs/views/pages/examples_browser.coffee +102 -0
  169. data/site/source/app/assets/javascripts/docs/views/pages/examples_browser/docs.coffee +12 -0
  170. data/site/source/app/assets/javascripts/docs/views/pages/examples_browser/source.coffee +13 -0
  171. data/site/source/app/assets/javascripts/docs/views/pages/home.coffee +10 -0
  172. data/site/source/app/assets/javascripts/docs/views/views/api_browser/index.coffee +43 -0
  173. data/site/source/app/assets/javascripts/docs/views/views/collection_view_examples/grid_layout_view_example.coffee +14 -0
  174. data/site/source/app/assets/javascripts/docs/views/views/collection_view_examples/table_view_example.coffee +39 -0
  175. data/site/source/app/assets/javascripts/docs/views/views/form_view_examples/basic_example.coffee +38 -0
  176. data/site/source/app/assets/javascripts/docs/views/views/form_view_examples/complex_layout.coffee +110 -0
  177. data/site/source/app/assets/javascripts/docs/views/views/top_navigation.coffee +6 -0
  178. data/site/source/app/assets/javascripts/luca-docs.js +1 -0
  179. data/site/source/app/assets/javascripts/luca-framework-documentation.js +1 -0
  180. data/site/source/app/assets/javascripts/site.js.coffee +4 -0
  181. data/site/source/app/assets/javascripts/vendor/codemirror.js +4786 -0
  182. data/site/source/app/assets/javascripts/vendor/coffeescript.js +346 -0
  183. data/site/source/app/assets/javascripts/vendor/css.js +465 -0
  184. data/site/source/app/assets/javascripts/vendor/htmlmixed.js +84 -0
  185. data/site/source/app/assets/javascripts/vendor/javascript.js +422 -0
  186. data/site/source/app/assets/javascripts/vendor/js-beautify.js +1353 -0
  187. data/site/source/app/assets/javascripts/vendor/modernizr-2.6.1.min.js +4 -0
  188. data/site/source/app/assets/javascripts/vendor/vim.js +2511 -0
  189. data/site/source/app/assets/stylesheets/docs/api-browser.css.scss +5 -0
  190. data/site/source/app/assets/stylesheets/docs/application.css.scss +35 -0
  191. data/site/source/app/assets/stylesheets/docs/browse-source.css.scss +5 -0
  192. data/site/source/app/assets/stylesheets/docs/scrollable-table.css.scss +5 -0
  193. data/site/source/app/assets/stylesheets/site.css.scss +2 -0
  194. data/site/source/app/assets/stylesheets/vendor/codemirror.css +240 -0
  195. data/site/source/app/assets/stylesheets/vendor/prettify-tomorrow-night-bright.css +160 -0
  196. data/site/source/app/assets/stylesheets/vendor/twilight.css +26 -0
  197. data/site/source/crossdomain.xml +15 -0
  198. data/site/source/documentation.html.haml +1 -0
  199. data/site/source/favicon_base.png +0 -0
  200. data/site/source/humans.txt +15 -0
  201. data/site/source/images/background.png +0 -0
  202. data/site/source/images/middleman.png +0 -0
  203. data/site/source/index.html.haml +1 -0
  204. data/site/source/layouts/layout.haml +55 -0
  205. data/site/source/readme.md +63 -0
  206. data/site/source/robots.txt +3 -0
  207. data/spec/{components/grid_view_spec.coffee → javascripts/components/application_spec.coffee} +0 -0
  208. data/spec/{components/pagination_control_spec.coffee → javascripts/components/collection_loader_view_spec.coffee} +0 -0
  209. data/spec/{components → javascripts/components}/collection_view_spec.coffee +1 -1
  210. data/spec/{components → javascripts/components}/controller_spec.coffee +0 -0
  211. data/spec/{components → javascripts/components}/fields/checkbox_array_spec.coffee +0 -0
  212. data/spec/javascripts/components/form_view_spec.coffee +162 -0
  213. data/spec/{components/record_manager_spec.coffee → javascripts/components/grid_view_spec.coffee} +0 -0
  214. data/spec/{components → javascripts/components}/multi_collection_view_spec.coffee +0 -0
  215. data/spec/{components/template_spec.coffee → javascripts/components/pagination_control_spec.coffee} +0 -0
  216. data/spec/{concerns/paginatable_spec.coffee → javascripts/components/record_manager_spec.coffee} +0 -0
  217. data/spec/{components → javascripts/components}/table_view_spec.coffee +0 -0
  218. data/spec/{containers/modal_view_spec.coffee → javascripts/components/template_spec.coffee} +0 -0
  219. data/spec/{concerns → javascripts/concerns}/collection_event_bindings_spec.coffee +0 -0
  220. data/spec/{concerns → javascripts/concerns}/dom_helpers_spec.coffee +0 -0
  221. data/spec/{concerns → javascripts/concerns}/filterable_spec.coffee +0 -0
  222. data/spec/{concerns → javascripts/concerns}/model_presenter_spec.coffee +0 -0
  223. data/spec/{containers/panel_view_spec.coffee → javascripts/concerns/paginatable_spec.coffee} +0 -0
  224. data/spec/{concerns → javascripts/concerns}/state_model_spec.coffee +5 -0
  225. data/spec/javascripts/containers/card_view_spec.coffee +108 -0
  226. data/spec/{containers/tab_view_spec.coffee → javascripts/containers/modal_view_spec.coffee} +0 -0
  227. data/spec/{containers/viewport_spec.coffee → javascripts/containers/panel_view_spec.coffee} +0 -0
  228. data/spec/{core/observer_spec.coffee → javascripts/containers/tab_view_spec.coffee} +0 -0
  229. data/spec/{managers/socket_manager_spec.coffee → javascripts/containers/viewport_spec.coffee} +0 -0
  230. data/spec/{core → javascripts/core}/collection_spec.coffee +1 -1
  231. data/spec/{core → javascripts/core}/concerns_spec.coffee +0 -0
  232. data/spec/{core → javascripts/core}/container_spec.coffee +0 -0
  233. data/spec/{core → javascripts/core}/define_spec.coffee +0 -0
  234. data/spec/{core → javascripts/core}/events_spec.coffee +0 -0
  235. data/spec/{core → javascripts/core}/field_spec.coffee +0 -0
  236. data/spec/{core → javascripts/core}/framework_spec.coffee +0 -0
  237. data/spec/{core → javascripts/core}/model_spec.coffee +0 -0
  238. data/spec/javascripts/core/observer_spec.coffee +0 -0
  239. data/spec/{core → javascripts/core}/util_spec.coffee +0 -0
  240. data/spec/{core → javascripts/core}/view_spec.coffee +51 -39
  241. data/spec/{dependencies → javascripts/dependencies}/index.coffee +0 -0
  242. data/spec/{dependencies → javascripts/dependencies}/jasmine-html.js +0 -0
  243. data/spec/{dependencies → javascripts/dependencies}/jasmine.js +0 -0
  244. data/spec/{dependencies → javascripts/dependencies}/sinon.js +0 -0
  245. data/spec/{helper.coffee → javascripts/helper.coffee} +0 -0
  246. data/spec/{managers → javascripts/managers}/collection_manager_spec.coffee +0 -0
  247. data/spec/javascripts/managers/socket_manager_spec.coffee +0 -0
  248. data/spec/lib/component_definition_spec.rb +63 -0
  249. data/spec/lib/input_compiler_spec.rb +9 -0
  250. data/spec/lib/luca_application_spec.rb +30 -0
  251. data/spec/support/fixtures/application.coffee +45 -0
  252. data/spec/support/fixtures/component.coffee +34 -0
  253. data/tutorials/component-definitions.md +0 -0
  254. data/tutorials/component-definitions/01_intro.md +0 -0
  255. data/tutorials/component-driven-design.md +140 -0
  256. data/tutorials/structure-of-a-project.md +63 -0
  257. data/vendor/assets/javascripts/backbone-min.js +37 -33
  258. data/vendor/assets/javascripts/backbone-query.min.js +1 -1
  259. data/vendor/assets/javascripts/hogan.js +707 -0
  260. data/vendor/assets/javascripts/jquery.js +5 -4
  261. data/vendor/assets/javascripts/keymaster.min.js +4 -0
  262. data/vendor/assets/javascripts/luca-dependencies.min.js +8 -0
  263. data/vendor/assets/javascripts/luca-development.min.js +1 -0
  264. data/vendor/assets/javascripts/luca-spec.js +6 -6
  265. data/vendor/assets/javascripts/luca-ui.js +7386 -0
  266. data/vendor/assets/javascripts/luca-ui.min.js +5 -0
  267. data/vendor/assets/javascripts/luca.full.min.js +12 -0
  268. data/vendor/assets/javascripts/luca.min.js +5 -0
  269. data/vendor/assets/javascripts/underscore-min.js +1 -5
  270. data/vendor/assets/javascripts/underscore-string.min.js +1 -1
  271. data/vendor/assets/stylesheets/luca-components.css +202 -0
  272. data/vendor/assets/stylesheets/luca-development.css +23 -0
  273. data/vendor/assets/stylesheets/luca-ui.css +198 -0
  274. metadata +324 -94
  275. data/app/assets/javascripts/luca/components/base_toolbar.coffee +0 -17
  276. data/app/assets/javascripts/luca/components/form_button_toolbar.coffee +0 -28
  277. data/app/assets/javascripts/luca/components/grid_view.coffee +0 -269
  278. data/app/assets/javascripts/luca/components/page_controller.coffee +0 -7
  279. data/app/assets/javascripts/luca/components/template.coffee +0 -5
  280. data/app/assets/javascripts/luca/components/toolbar_dialog.coffee +0 -25
  281. data/lib/luca/code_browser.rb +0 -55
  282. data/lib/luca/command_line.rb +0 -69
  283. data/lib/luca/component_documentation.rb +0 -72
  284. data/site/assets/bootstrap.min.js +0 -7
  285. data/site/assets/dependencies.js +0 -94
  286. data/site/assets/glyphicons-halflings-white.png +0 -0
  287. data/site/assets/glyphicons-halflings.png +0 -0
  288. data/site/assets/luca-ui-bootstrap.css +0 -1331
  289. data/site/assets/luca-ui-bootstrap.js +0 -9
  290. data/site/assets/luca-ui-development-tools.css +0 -234
  291. data/site/assets/luca-ui-development-tools.js +0 -18561
  292. data/site/assets/luca-ui-development-tools.min.js +0 -15
  293. data/site/assets/luca-ui-full.min.js +0 -8
  294. data/site/assets/luca-ui.min.js +0 -4
  295. data/site/assets/sandbox.css +0 -62
  296. data/site/assets/sandbox.js +0 -469
  297. data/site/docs/application.html +0 -41
  298. data/site/docs/caching.html +0 -43
  299. data/site/docs/collection.html +0 -75
  300. data/site/docs/collection_manager.html +0 -71
  301. data/site/docs/containers.html +0 -118
  302. data/site/docs/events.html +0 -153
  303. data/site/docs/view.html +0 -128
  304. data/site/img/glyphicons-halflings-white.png +0 -0
  305. data/site/img/glyphicons-halflings.png +0 -0
  306. data/site/index.html +0 -20
  307. data/site/source-map.js +0 -1
  308. data/spec/components/form_view_spec.coffee +0 -84
  309. data/spec/containers/card_view_spec.coffee +0 -50
  310. data/spec/luca-spec.coffee +0 -9
data/app.rb CHANGED
@@ -1,7 +1,10 @@
1
-
1
+ $LOAD_PATH.unshift( File.join(File.dirname(__FILE__),'lib') )
2
2
  require 'rubygems'
3
3
  require 'bundler'
4
- Bundler.require
4
+ require 'luca'
5
+ require 'redcarpet'
6
+ require 'active_support/core_ext'
7
+ Bundler.require(:default, :development)
5
8
 
6
9
  require 'faker'
7
10
 
@@ -11,9 +14,6 @@ module AssetHelpers
11
14
  end
12
15
  end
13
16
 
14
- require "#{ File.expand_path('../', __FILE__) }/lib/luca/template.rb"
15
- require "#{ File.expand_path('../', __FILE__) }/lib/luca/code_browser.rb"
16
-
17
17
  module Luca
18
18
  class Template
19
19
  def self.namespace
@@ -31,6 +31,10 @@ class App < Sinatra::Base
31
31
  sprockets.register_engine '.luca', Luca::Template
32
32
 
33
33
  configure do
34
+ HoganAssets::Config.configure do |config|
35
+ config.template_namespace = 'JST'
36
+ end
37
+
34
38
  sprockets.append_path(File.join(root, 'app', 'assets', 'stylesheets'))
35
39
  sprockets.append_path(File.join(root, 'app', 'assets', 'javascripts'))
36
40
  sprockets.append_path(File.join(root, 'vendor', 'assets', 'javascripts'))
@@ -40,6 +44,7 @@ class App < Sinatra::Base
40
44
  sprockets.context_class.instance_eval do
41
45
  include AssetHelpers
42
46
  end
47
+
43
48
  end
44
49
 
45
50
  helpers do
@@ -54,41 +59,4 @@ class App < Sinatra::Base
54
59
  erb :jasmine
55
60
  end
56
61
 
57
- Luca::CodeBrowser.look_for_source_in( File.join(File.expand_path('../', __FILE__),'src') )
58
-
59
- get "/luca/source-map.js" do
60
- source_map = {}
61
-
62
- files = (["src/**/*.coffee","assets/javascripts/sandbox/**/*.coffee"]).map do |location|
63
- Dir.glob("#{ App.root }/#{ location }")
64
- end
65
-
66
- files.flatten.each do |file|
67
- definitions = IO.read(file).lines.to_a.grep /_\.def/
68
-
69
- definitions.each do |definition|
70
- component = definition.match(/_\.def\(['"](.+)['"]\)\./)
71
-
72
- if component and component[1]
73
- componentId = component[1].gsub(/['"].*$/,'')
74
- if componentId
75
- source_map[ componentId ] = {className:componentId,file:file,source:IO.read(file)}
76
- end
77
- end
78
- end
79
- end
80
-
81
- JSON.generate source_map.values
82
- end
83
-
84
- get "/components" do
85
- if params[:component]
86
- component = params[:component]
87
- source = Luca::CodeBrowser.get_source_for( component )
88
- {className:component, source:source}.to_json
89
- else
90
- Luca::CodeBrowser.map_source
91
- end
92
- end
93
-
94
62
  end
@@ -4,5 +4,5 @@
4
4
  #= require ./util
5
5
  #= require ./managers
6
6
  #= require ./core
7
- #= require ./containers
7
+ #= require ./containers/container
8
8
  #= require ./framework
@@ -1,14 +1,72 @@
1
- # Luca.Application
1
+ # The `Luca.Application` is the main entry point into your Application.
2
+ # It acts as a global state machine, page controller, and router, in addition
3
+ # to providing access to other singletons such as the CollectionManager, and SocketManager.
4
+ #
5
+ # The structure of a common `Luca.Application` is that it contains one or many `Pages` which
6
+ # themselves are made up of the components of your application. One `Page` is visible at a time
7
+ # and which page is displayed is managed by an instance of the `Luca.components.Controller` class.
2
8
  #
3
- # The Application class is the global state tracking mechanism
4
- # for your single page application, as well as the entry point.
9
+ # ### Example Configuration
10
+ # application = Luca.register "App.Application"
11
+ # application.extends "Luca.Application"
12
+ #
13
+ # application.defines
14
+ # name: "MyApplication"
15
+ # routes:
16
+ # "" : "home"
17
+ # "standard/backbone/style/:route" : "name_of_page#name_of_method"
18
+ #
19
+ # components:[
20
+ # name: "home"
21
+ # ,
22
+ # type: "your_view"
23
+ # name: "name_of_page"
24
+ # name_of_method: (routeParam)->
25
+ # @doSomethignToSetupYourPageWithThePassed(routeParam)
26
+ # ]
27
+ #
28
+ # App.onReady ()->
29
+ # window.MyApp = new App.Application();
30
+ # window.MyApp.boot()
31
+ #
32
+ # #### @routes and pages
33
+ #
34
+ # In the above example, our application contains two pages, one with the name 'home'
35
+ # and one with the name 'name_of_page'. It also specifies a `@routes` property which
36
+ # is identical to the configuration you would see in a standard `Backbone.Router`.
37
+ #
38
+ # Whenever the route matches 'standard/backbone/style/route' the `App.Application` instance
39
+ # will send an instruction to the `Luca.components.Controller` to `activate` the page whose name
40
+ # is passed in the `@routes` config.
41
+ #
42
+ # If that page defines a method called `@routeHandler` it will be called with the parameters
43
+ # from the route. In the `@routes` config you can specify your own route handler method
44
+ # by using the rails style `page_name#action` and it will call the `@action` method instead
45
+ # on the view named `page_name`.
46
+ #
47
+ # The `App.Application` instance, also accessible by `window.MyApp`, or through the helper `App()`
48
+ # or `Luca.getApplication()` maintains the state of which page is active. You can access this
49
+ # in your code by calling `App().activePage()`.
50
+ #
51
+ # #### Controllers
52
+ #
53
+ # The `Luca.components.Controller` is a special type of component which contains
54
+ # other views, or `Pages` which only one will be visible at any given time. It expects
55
+ # that each page will have its own unique `@name` property. A `Luca.components.Controller` can
56
+ # contain other controllers, providing you with a way of structuring your application layout
57
+ # in an organized, hierarchal fashion.
58
+ #
59
+ # By default, any `Luca.Application` will have one `Luca.components.Controller` automatically
60
+ # created named 'main_controller' which is accessible by `MyApp.getMainController()`. Any
61
+ # components you define on the `Luca.Application` instance will be wrapped by the main controller
62
+ # automatically unless you specify `@useController = false` in your Application component definition.
5
63
  application = Luca.register "Luca.Application"
6
64
  application.extends "Luca.containers.Viewport"
7
65
 
8
66
  application.triggers "controller:change",
9
67
  "action:change"
10
68
 
11
- application.publicInterface
69
+ application.publicConfiguration
12
70
  name: "MyApp"
13
71
 
14
72
  # The Application uses a Backbone.Model as a state machine, which
@@ -16,7 +74,7 @@ application.publicInterface
16
74
  # most importantly to bind to change events of certain attributes.
17
75
  #
18
76
  # the @defaultState property will be the default attributes
19
- defaultState: {}
77
+ stateful: {}
20
78
 
21
79
  # if autoBoot is set to true, the application will
22
80
  # attempt to boot on document ready.
@@ -28,6 +86,18 @@ application.publicInterface
28
86
  # listen for on this component before you start history
29
87
  autoStartHistory: "before:render"
30
88
 
89
+ # use Backbone.history push state?
90
+ pushState: false
91
+
92
+ # If the server renders the entire page
93
+ # first, then we should start history silently.
94
+ startHistorySilently: false
95
+
96
+ # In cases where we use pushState, we need to tell
97
+ # the application what the actual root url of our app
98
+ # is, since everything after would otherwise be a hashbang
99
+ rootUrl: undefined
100
+
31
101
  # we will create a collection manager singleton
32
102
  # by default unless otherwise specified.
33
103
  useCollectionManager: true
@@ -41,7 +111,6 @@ application.publicInterface
41
111
  # just pass a reference to the class you would like to use.
42
112
  collectionManagerClass: "Luca.CollectionManager"
43
113
 
44
-
45
114
  # Luca plugin apps are apps which mount onto existing
46
115
  # luca apps, and will not have the behavior of a main
47
116
  # app which acts as a singleton
@@ -53,49 +122,42 @@ application.publicInterface
53
122
  # with several 'pages' so to speak
54
123
  useController: true
55
124
 
56
- # Key Handler
125
+ # If your Application does not behave as a Viewport that monopolizes
126
+ # its entire element, but instead you wish to render the application
127
+ # controller to a specific element, you can specify the css selector of that element.
128
+ mainControllerContainer: undefined
129
+
130
+ # keyEvents understands the following modifiers:
131
+ # - `⇧`, `shift`, `option`, `⌥`, `alt`, `ctrl`, `control`, `command`, and `⌘`.
132
+ # The following special keys can be used for shortcuts:
133
+ # `backspace`, `tab`, `clear`, `enter`, `return`, `esc`, `escape`, `space`,
134
+ # `up`, `down`, `left`, `right`, `home`, `end`, `pageup`, `pagedown`, `del`, `delete`
135
+ # and `f1` through `f19`.
57
136
  #
58
- # One responsibility of the application, since it is a viewport which monopolizes the entire screen
59
- # is to relay keypress events from the document, to whatever views are interested in responding to them.
60
- #
61
- # This functionality is disabled by default.
62
- useKeyHandler: false
63
-
64
- # You can configure key events by specifying them by their name, as it exists in Luca.keyMap. For example:
137
+ # **Note**: This requires the keymaster.js library to be loaded. This library is included
138
+ # with the bundled dependencies that ship with Luca.
65
139
  #
140
+ # Example:
141
+ # application.configuration
142
+ # keyEvents:
143
+ # '⌘+r, ctrl+r': "keyHandlerFunction"
144
+ # keyHandlerFunction: -> alert 'something + r was pressed'
66
145
  keyEvents: {}
67
146
 
68
- # keyEvents
69
- # keyup: keyUpHandler
70
- # enter: enterHandler
71
- # meta:
72
- # up: metaUpHandler
73
- # control:
74
- # forwardslash: controlSlashHandler
75
- # keyup: controlUpHandler
76
- # control_meta:
77
- # keydown: metaControlKeyDownHandler
78
- #
79
- #
80
-
81
- # applications have one component, the controller.
82
- # any components defined on the application class directly
83
- # will get wrapped by the main controller unless you
84
- # set useController = false
85
- components:[
86
- type: 'template'
87
- name: 'welcome'
88
- template: 'sample/welcome'
89
- templateContainer: "Luca.templates"
90
- ]
91
-
92
- # DOCUMENT
147
+ # create getter methods for the various roles in the application's components on the application itself.
93
148
  createRoleBasedGetters: false
149
+
150
+ # create an instance of Luca.SocketManager which is a Backbone.Events style abstraction that
151
+ # sits on top of services like faye, or socket.io
94
152
  useSocketManager: false
95
153
  socketManagerOptions: {}
96
154
 
97
- # Don't create getters on this component
98
- # for the nested components
155
+ application.publicMethods
156
+ # Creating your Application and all of its components and pages is
157
+ # generally as simple as creating an instance of your Application class:
158
+ # Luca.onReady ()->
159
+ # window.MyApp = new Luca.Application()
160
+ # window.MyApp.boot()
99
161
  initialize: (@options={})->
100
162
  app = @
101
163
  appName = @name
@@ -123,6 +185,7 @@ application.publicInterface
123
185
  # to a given page, or component, by its name. The controller integrates
124
186
  # with the state machine of the application
125
187
  @setupMainController() if @useController is true
188
+
126
189
  # we will render when all of the various components
127
190
  # which handle our data dependencies determine that
128
191
  # we are ready
@@ -140,10 +203,8 @@ application.publicInterface
140
203
  # keyEvents:
141
204
  # meta:
142
205
  # forwardslash: "altSlashHandler"
143
- if @useKeyRouter is true
144
- console.log "The useKeyRouter property is being deprecated. switch to useKeyHandler instead"
145
-
146
- @setupKeyHandler() if (@useKeyHandler is true or @useKeyRouter is true) and @keyEvents?
206
+ if (@useKeyHandler is true or @useKeyRouter is true) and @keyEvents?
207
+ @setupKeyHandler()
147
208
 
148
209
  # if the application is a plugin designed to modify the behavior
149
210
  # of another app, then don't claim ownership. otherwise the most common
@@ -164,11 +225,9 @@ application.publicInterface
164
225
  Luca.trigger "application:available", @
165
226
 
166
227
  # @activeView() returns a reference to the instance of the view
167
- # which is currently monopolizing the viewport.
168
- #
169
- # this will be whicever component is active on the controllers
170
- # nested within the main controller, if there are any, or the view
171
- # itself which is active on the main controller.
228
+ # which is currently monopolizing the viewport. In an application
229
+ # which uses a controller hierarchy, it will be the last controller
230
+ # has activated one of its pages.
172
231
  activeView: ()->
173
232
  if active = @activeSubSection()
174
233
  @view( active )
@@ -186,7 +245,8 @@ application.publicInterface
186
245
  @get("active_sub_section")
187
246
 
188
247
  activePages: ()->
189
- @$('.luca-ui-controller').map (index,element)=> $(element).data('active-section')
248
+ console.log "This method will be getting removed in Luca 1.0"
249
+ @$('.luca-controller').map (index,element)=> $(element).data('active-section')
190
250
 
191
251
  # boot should trigger the ready event, which will call the initial call
192
252
  # to render() your application, which will have a cascading effect on every
@@ -199,7 +259,6 @@ application.publicInterface
199
259
  boot: ()->
200
260
  @trigger "ready"
201
261
  for service in [@collectionManager, @socket, @router]
202
- console.log "Trigggering Ready On", service
203
262
  service?.trigger("ready")
204
263
 
205
264
  # delegate to the collection manager's get or create function.
@@ -207,47 +266,31 @@ application.publicInterface
207
266
  collection: ()->
208
267
  @collectionManager.getOrCreate.apply(@collectionManager, arguments)
209
268
 
269
+ # Get an attribute from our internal state machine
210
270
  get: (attribute)->
211
271
  @state.get(attribute)
212
272
 
273
+ # Set an attribute on our internal state machine
213
274
  set: (attribute, value, options)->
214
275
  @state.set.apply(@state, arguments)
215
276
 
277
+ # Access a named view by its @name property.
216
278
  view: (name)->
217
279
  Luca.cache(name)
218
280
 
219
- #### Navigation Hooks
220
- #
221
281
  # delegate to the main controller so that we can switch the active section
282
+ # easily directly from the application. If passed a callback, this function
283
+ # will get called in the context of the activated component. This method is useful
284
+ # inside of custom route handlers if you are manually defining them on a `Backbone.Router`
285
+ # instead of using the built in `@routes` helper.
222
286
  navigate_to: (component_name, callback)->
223
287
  @getMainController().navigate_to(component_name, callback)
224
288
 
225
- application.privateInterface
226
- keyHandler: (e)->
227
- return unless e and @keyEvents
228
-
229
- isInputEvent = $(e.target).is('input') || $(e.target).is('textarea')
230
-
231
- return if isInputEvent
232
-
233
- keyname = Luca.keyMap[ e.keyCode ]
234
-
235
- return unless keyname
236
-
237
- meta = e?.metaKey is true
238
- control = e?.ctrlKey is true
239
-
240
- source = @keyEvents
241
- source = if meta then @keyEvents.meta else source
242
- source = if control then @keyEvents.control else source
243
- source = if meta and control then @keyEvents.meta_control else source
244
-
245
- if keyEvent = source?[keyname]
246
- if @[keyEvent]? and _.isFunction(@[keyEvent])
247
- @[keyEvent]?.call(@)
248
- else
249
- @trigger(keyEvent, e, keyname)
250
-
289
+ application.privateMethods
290
+ # Any time the Application's main controller changes its active page
291
+ # we track the name of that page ( aka section ) on our state machine.
292
+ # If the active page on the main controller is another controller component,
293
+ # then we will track that controller's active component as our active sub section.
251
294
  setupControllerBindings: ()->
252
295
  app = @
253
296
  # any time the main controller card switches we should track
@@ -265,20 +308,30 @@ application.privateInterface
265
308
  @state.set(active_sub_section:current.name)
266
309
  app.trigger "action:change", previous.name, current.name
267
310
 
311
+ # A typical structure for a Luca.Application is that it will act as a `Viewport` which
312
+ # monopolizes the entire top level element in your dom ( either the body tag, or a top
313
+ # level element just underneath it) This `Viewport` is an abstract element where we can
314
+ # setup global event bindings, like keyBindings and such. The `Viewport` will generally
315
+ # contain a `Luca.components.Controller` instance called "main_controller" that is responsible
316
+ # for displaying the active page for a given route.
268
317
  setupMainController: ()->
269
318
  if @useController is true
270
319
  definedComponents = @components || []
271
-
272
- @components = [
320
+ base =
273
321
  type: 'controller'
274
322
  name: "main_controller"
275
323
  role: "main_controller"
276
324
  components: definedComponents
277
- ]
278
-
279
- @getMainController = ()=> @findComponentByRole('main_controller')
280
325
 
281
- @defer( @setupControllerBindings, false ).until("after:components")
326
+ if @mainControllerContainer?
327
+ _.extend(base, container: @mainControllerContainer)
328
+
329
+ @components = [base]
330
+
331
+ @getMainController = ()=>
332
+ @findComponentByRole('main_controller')
333
+
334
+ @defer( @setupControllerBindings, false ).until("after:components")
282
335
 
283
336
  setupCollectionManager: ()->
284
337
  return unless @useCollectionManager is true
@@ -314,12 +367,18 @@ application.privateInterface
314
367
  collectionManagerOptions.autoStart = false
315
368
  @collectionManager = new @collectionManagerClass( collectionManagerOptions )
316
369
 
370
+ # If our application is configured with a `@socketManagerOptions` property,
371
+ # it will create a socket manager instance for us automatically. It won't
372
+ # start the socket manager process until the `@boot()` method is called on the application.
317
373
  setupSocketManager: ()->
318
374
  return if _.isEmpty(@socketManagerOptions)
319
375
  _.extend(@socketManagerOptions, autoStart: false)
320
376
 
321
377
  @socket = new Luca.SocketManager(@socketManagerOptions)
322
-
378
+
379
+ # Sets up an instance of the Backbone.Router, and sets up the
380
+ # call to start the history tracking API once the appropriate
381
+ # application events have been fired.
323
382
  setupRouter: ()->
324
383
  return if not @router? and not @routes?
325
384
 
@@ -332,7 +391,11 @@ application.privateInterface
332
391
 
333
392
  if _.isObject( @routes )
334
393
  for routePattern, endpoint of @routes
335
- [page, action] = endpoint.split(' ')
394
+ if endpoint.match(/\ /)
395
+ [page, action] = endpoint.split(' ')
396
+ else if endpoint.match(/\#/)
397
+ [page, action] = endpoint.split('#')
398
+
336
399
  fn = _.uniqueId(page)
337
400
  routerConfig[fn] = Luca.Application.routeTo(page).action(action)
338
401
  routerConfig.routes[ routePattern ] = fn
@@ -346,6 +409,9 @@ application.privateInterface
346
409
  @autoStartHistory = "before:render" if @autoStartHistory is true
347
410
  @defer( Luca.Application.startHistory, false).until(@, @autoStartHistory)
348
411
 
412
+ # The default implementation of setupKeyHandler is kept around for backward
413
+ # compatibility purposes. In Luca 1.0 we will be using keymaster.js for our
414
+ # key binding setup.
349
415
  setupKeyHandler: ()->
350
416
  return unless @keyEvents
351
417
 
@@ -359,18 +425,20 @@ application.privateInterface
359
425
  for keyEvent in (@keypressEvents || ["keydown"])
360
426
  $( document ).on( keyEvent, handler )
361
427
 
362
- application.classInterface
428
+ application.classMethods
363
429
  instances:{}
364
430
 
365
- # Public: For purely informational purposes, describes the structure
366
- # of the Application's controller views, and their nested controllers views.
431
+ # An application inspection helper, it describes the structure of this application's
432
+ # controlled components. For an application that consists of multiple nested controllers
433
+ # it will recursively walk each controller and build a tree of the various pages / controlers.
367
434
  pageHierarchy: ()->
368
- app = Luca()
369
- mainController = app.getMainController()
435
+ app = Luca()
436
+ mainController = app.getMainController()
370
437
 
371
438
  getTree = (node)->
372
439
  return {} unless node.components? or node.pages?
373
440
 
441
+ # recursively walks the pages on a controller
374
442
  _( node.components || node.pages ).reduce (memo, page)->
375
443
  memo[ page.name ] = page.name
376
444
  memo[ page.name ] = getTree(page) if page.navigate_to?
@@ -379,19 +447,29 @@ application.classInterface
379
447
 
380
448
  getTree( mainController )
381
449
 
382
- # Private: registers the instance of the Luca.Appliction
450
+ # Registers this instance of the Luca.Appliction
383
451
  # so that it is available via the Luca() helper, or through
384
- # a call to Luca.Application.get() or Luca.getAppliction()
452
+ # a call to Luca.Application.get().
385
453
  registerInstance: (app)->
386
454
  Luca.Application.instances[ app.name ] = app
387
455
 
388
- # Private: Recursively navigates down the controller page hierarchy
389
- # to the page you specify by name. You can specify the
390
- # method which is to be called at the end of the chain.
391
- #
456
+ # If the keymaster library is present, swap out the
457
+ # setupKeyHandler method with something which will enable
458
+ # keymaster support instead of our legacy system.
459
+ checkForKeymaster: ()->
460
+ if window?.key?.noConflict
461
+ Luca.key = window.key.noConflict()
462
+
463
+ Luca.Application::setupKeyHandler = ()->
464
+ return unless @keyEvents
465
+ Luca.util.setupKeymaster(@keyEvents, "all").on(@)
466
+
392
467
  # This is used internally by the Application as it sets up
393
468
  # the @routes property and uses it to configure the Luca.Router
394
- # instance for your app.
469
+ # instance for your app. It allows you to specify the page you want
470
+ # to monopolize the viewport in your application by name, and regardless
471
+ # of how deeply nested that page may be among your controllers, it will know
472
+ # what to do.
395
473
  routeTo: (pages...)->
396
474
  last = _( pages ).last()
397
475
  first = _( pages ).first()
@@ -403,7 +481,7 @@ application.classInterface
403
481
  path = @app || Luca()
404
482
  index = 0
405
483
 
406
- # we can specify a page by name, and not have to know its full path
484
+ # we can specify a page by name, and not have to know its full path.
407
485
  if pages.length is 1 and target = Luca(first)
408
486
  pages = target.controllerPath()
409
487
 
@@ -413,6 +491,9 @@ application.classInterface
413
491
  target = Luca(page)
414
492
 
415
493
  if page is last
494
+ if specifiedAction? and not target[specifiedAction]? and not target.routeHandler?
495
+ console.log "You specified a component action to call when a route matches, but it does not exist on the component"
496
+
416
497
  callback = if specifiedAction? and target[ specifiedAction ]?
417
498
  _.bind(target[ specifiedAction ], target)
418
499
  else if target.routeHandler?
@@ -437,11 +518,13 @@ application.classInterface
437
518
  # modify how Backbone.history.start is called. This will get called
438
519
  # by the Application instance in response to the @autoStartHistory property.
439
520
  startHistory: ()->
440
- Backbone.history.start()
441
-
442
-
521
+ Backbone.history.start
522
+ pushState: @pushState
523
+ rootUrl: @rootUrl
524
+ silent: @startHistorySilently
443
525
 
444
526
  application.afterDefinition ()->
445
527
  Luca.routeHelper = Luca.Application.routeTo
528
+ Luca.Application.checkForKeymaster()
446
529
 
447
530
  application.register()