riojs 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (270) hide show
  1. data/LICENSE +20 -0
  2. data/README.rdoc +24 -0
  3. data/VERSION +1 -0
  4. data/bin/rio +5 -0
  5. data/generators/rio_app/USAGE +19 -0
  6. data/generators/rio_app/rio_app_generator.rb +40 -0
  7. data/generators/rio_app/templates/app.build +10 -0
  8. data/generators/rio_app/templates/app.css +0 -0
  9. data/generators/rio_app/templates/app.js +20 -0
  10. data/generators/rio_app/templates/app_view.html.erb +19 -0
  11. data/generators/rio_app/templates/fixture.js +4 -0
  12. data/generators/rio_app/templates/rio.html.erb +18 -0
  13. data/generators/rio_app/templates/rio_controller.rb +2 -0
  14. data/generators/rio_app/templates/spec.js +7 -0
  15. data/generators/rio_component/USAGE +13 -0
  16. data/generators/rio_component/rio_component_generator.rb +16 -0
  17. data/generators/rio_component/templates/component.css +0 -0
  18. data/generators/rio_component/templates/component.js +11 -0
  19. data/generators/rio_component/templates/fixture.js +3 -0
  20. data/generators/rio_component/templates/spec.js +6 -0
  21. data/generators/rio_model/USAGE +12 -0
  22. data/generators/rio_model/rio_model_generator.rb +21 -0
  23. data/generators/rio_model/templates/fixture.js +3 -0
  24. data/generators/rio_model/templates/model.js +9 -0
  25. data/generators/rio_model/templates/spec.js +6 -0
  26. data/generators/rio_page/USAGE +14 -0
  27. data/generators/rio_page/rio_page_generator.rb +16 -0
  28. data/generators/rio_page/templates/fixture.js +3 -0
  29. data/generators/rio_page/templates/page.css +12 -0
  30. data/generators/rio_page/templates/page.js +12 -0
  31. data/generators/rio_page/templates/page.jst +64 -0
  32. data/generators/rio_page/templates/spec.js +6 -0
  33. data/generators/rio_resource/USAGE +20 -0
  34. data/generators/rio_resource/rio_resource_generator.rb +10 -0
  35. data/generators/rio_resource/templates/controller.rb +3 -0
  36. data/init.rb +4 -0
  37. data/install/config/juggernaut_hosts.yml +18 -0
  38. data/install/lib/tasks/rio.rake +1 -0
  39. data/install/script/rio_server +37 -0
  40. data/lib/rio/autospec.rb +86 -0
  41. data/lib/rio/install.rb +90 -0
  42. data/lib/rio/juggernaut.rb +212 -0
  43. data/lib/rio/path.rb +3 -0
  44. data/lib/rio/rio_compressor.rb +219 -0
  45. data/lib/rio/rio_file_controller.rb +16 -0
  46. data/lib/rio/rio_on_rails.rb +586 -0
  47. data/lib/rio/rio_proxy_controller.rb +60 -0
  48. data/lib/rio/rio_push_controller.rb +48 -0
  49. data/lib/rio/rio_routes.rb +24 -0
  50. data/lib/rio/rio_spec_controller.rb +70 -0
  51. data/lib/riojs.rb +14 -0
  52. data/lib/tasks/rio.rb +63 -0
  53. data/public/images/background-chiffon.png +0 -0
  54. data/public/images/button-gradient-overlay-down.png +0 -0
  55. data/public/images/button-gradient-overlay.png +0 -0
  56. data/public/images/icons/add.png +0 -0
  57. data/public/images/icons/error-big.png +0 -0
  58. data/public/images/icons/warning-big.png +0 -0
  59. data/public/images/rio-logo-big.png +0 -0
  60. data/public/images/rio-logo.png +0 -0
  61. data/public/images/splitter-handle-horizontal.png +0 -0
  62. data/public/images/splitter-handle-vertical.png +0 -0
  63. data/public/images/tab-bar-gradient-overlay.png +0 -0
  64. data/public/images/title-gradient-overlay.png +0 -0
  65. data/public/images/trash.gif +0 -0
  66. data/public/javascripts/components/accordion.js +144 -0
  67. data/public/javascripts/components/alert_box.js +59 -0
  68. data/public/javascripts/components/base.js +47 -0
  69. data/public/javascripts/components/box.js +63 -0
  70. data/public/javascripts/components/button.js +98 -0
  71. data/public/javascripts/components/checkbox.js +44 -0
  72. data/public/javascripts/components/container.js +265 -0
  73. data/public/javascripts/components/grid_view.js +107 -0
  74. data/public/javascripts/components/image.js +19 -0
  75. data/public/javascripts/components/input.js +171 -0
  76. data/public/javascripts/components/label.js +15 -0
  77. data/public/javascripts/components/lightbox.js +160 -0
  78. data/public/javascripts/components/link.js +43 -0
  79. data/public/javascripts/components/list_item.js +44 -0
  80. data/public/javascripts/components/list_view.js +192 -0
  81. data/public/javascripts/components/marquee.js +131 -0
  82. data/public/javascripts/components/menu.js +89 -0
  83. data/public/javascripts/components/notification.js +75 -0
  84. data/public/javascripts/components/overlay.js +134 -0
  85. data/public/javascripts/components/panel.js +146 -0
  86. data/public/javascripts/components/radio.js +46 -0
  87. data/public/javascripts/components/splitter.js +65 -0
  88. data/public/javascripts/components/tab_bar.js +64 -0
  89. data/public/javascripts/components/tab_panel.js +57 -0
  90. data/public/javascripts/components/textarea.js +223 -0
  91. data/public/javascripts/components/toggle_button.js +22 -0
  92. data/public/javascripts/components/tooltip.js +80 -0
  93. data/public/javascripts/lib/application.js +482 -0
  94. data/public/javascripts/lib/attr.js +760 -0
  95. data/public/javascripts/lib/benchmark.js +235 -0
  96. data/public/javascripts/lib/blank.html +39 -0
  97. data/public/javascripts/lib/boot.js +300 -0
  98. data/public/javascripts/lib/clipboard.js +96 -0
  99. data/public/javascripts/lib/collection_entity.js +46 -0
  100. data/public/javascripts/lib/component.js +129 -0
  101. data/public/javascripts/lib/console.js +75 -0
  102. data/public/javascripts/lib/console/apps/console.build +43 -0
  103. data/public/javascripts/lib/console/apps/console.js +28 -0
  104. data/public/javascripts/lib/console/blank.html +39 -0
  105. data/public/javascripts/lib/console/components/benchmark.js +196 -0
  106. data/public/javascripts/lib/console/components/console.js +352 -0
  107. data/public/javascripts/lib/console/components/dependencies_list.js +17 -0
  108. data/public/javascripts/lib/console/components/docs.js +66 -0
  109. data/public/javascripts/lib/console/components/playground.js +30 -0
  110. data/public/javascripts/lib/console/console.html +27 -0
  111. data/public/javascripts/lib/console/console_commands.js +287 -0
  112. data/public/javascripts/lib/console/console_commands.js.rej +21 -0
  113. data/public/javascripts/lib/console/console_mixin.js +22 -0
  114. data/public/javascripts/lib/console/docs/files.html +579 -0
  115. data/public/javascripts/lib/console/docs/index.html +323 -0
  116. data/public/javascripts/lib/console/docs/symbols/Object.html +291 -0
  117. data/public/javascripts/lib/console/docs/symbols/_global_.html +413 -0
  118. data/public/javascripts/lib/console/docs/symbols/rio.AIM.html +490 -0
  119. data/public/javascripts/lib/console/docs/symbols/rio.Application.html +841 -0
  120. data/public/javascripts/lib/console/docs/symbols/rio.Attr.html +1075 -0
  121. data/public/javascripts/lib/console/docs/symbols/rio.Binding.html +272 -0
  122. data/public/javascripts/lib/console/docs/symbols/rio.Component.html +419 -0
  123. data/public/javascripts/lib/console/docs/symbols/rio.Cookie.html +543 -0
  124. data/public/javascripts/lib/console/docs/symbols/rio.DelayedTask#initialize.html +270 -0
  125. data/public/javascripts/lib/console/docs/symbols/rio.DelayedTask.html +391 -0
  126. data/public/javascripts/lib/console/docs/symbols/rio.JsTemplate.html +271 -0
  127. data/public/javascripts/lib/console/docs/symbols/rio.Juggernaut.html +329 -0
  128. data/public/javascripts/lib/console/docs/symbols/rio.Model.html +822 -0
  129. data/public/javascripts/lib/console/docs/symbols/rio.Page.html +383 -0
  130. data/public/javascripts/lib/console/docs/symbols/rio.Template.html +328 -0
  131. data/public/javascripts/lib/console/docs/symbols/rio.Utils.html +617 -0
  132. data/public/javascripts/lib/console/docs/symbols/rio.html +506 -0
  133. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_components_base.js.html +54 -0
  134. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_application.js.html +490 -0
  135. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_attr.js.html +768 -0
  136. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_boot.js.html +308 -0
  137. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_clipboard.js.html +103 -0
  138. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_collection_entity.js.html +53 -0
  139. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_component.js.html +137 -0
  140. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_cookie.js.html +81 -0
  141. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_delayed_task.js.html +68 -0
  142. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_file.js.html +80 -0
  143. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_flash_detect.js.html +129 -0
  144. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_form.js.html +95 -0
  145. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_id.js.html +50 -0
  146. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_inflector.js.html +167 -0
  147. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_js_template.js.html +283 -0
  148. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_juggernaut.js.html +303 -0
  149. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_key_map.js.html +68 -0
  150. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_layout_manager.js.html +175 -0
  151. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_log.js.html +17 -0
  152. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_model.js.html +1074 -0
  153. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_page.js.html +246 -0
  154. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_parameters.js.html +66 -0
  155. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_protohack.js.html +305 -0
  156. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_push.js.html +12 -0
  157. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_rsh.js.html +659 -0
  158. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_swfobject.js.html +12 -0
  159. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_tag.js.html +60 -0
  160. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_template.js.html +64 -0
  161. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_theme.js.html +105 -0
  162. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_undo.js.html +142 -0
  163. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_utils.js.html +87 -0
  164. data/public/javascripts/lib/console/docs/symbols/src/public_javascripts_lib_yaml.js.html +88 -0
  165. data/public/javascripts/lib/console/file-small.png +0 -0
  166. data/public/javascripts/lib/console/green-circle.png +0 -0
  167. data/public/javascripts/lib/console/loading.gif +0 -0
  168. data/public/javascripts/lib/console/pages/console_page.js +149 -0
  169. data/public/javascripts/lib/console/pages/console_page.jst +27 -0
  170. data/public/javascripts/lib/console/red-circle.png +0 -0
  171. data/public/javascripts/lib/cookie.js +74 -0
  172. data/public/javascripts/lib/delayed_task.js +61 -0
  173. data/public/javascripts/lib/dependencies.js +76 -0
  174. data/public/javascripts/lib/environment.js +30 -0
  175. data/public/javascripts/lib/event.simulate.js +137 -0
  176. data/public/javascripts/lib/expressinstall.swf +0 -0
  177. data/public/javascripts/lib/file.js +72 -0
  178. data/public/javascripts/lib/flash_detect.js +122 -0
  179. data/public/javascripts/lib/flashembed.min.js +16 -0
  180. data/public/javascripts/lib/form.js +88 -0
  181. data/public/javascripts/lib/id.js +43 -0
  182. data/public/javascripts/lib/inflector.js +160 -0
  183. data/public/javascripts/lib/instrumenter.js +106 -0
  184. data/public/javascripts/lib/js_template.js +275 -0
  185. data/public/javascripts/lib/jslint.js +4950 -0
  186. data/public/javascripts/lib/juggernaut.js +295 -0
  187. data/public/javascripts/lib/juggernaut.swf +0 -0
  188. data/public/javascripts/lib/key_map.js +60 -0
  189. data/public/javascripts/lib/layout_manager.js +167 -0
  190. data/public/javascripts/lib/model.js +1067 -0
  191. data/public/javascripts/lib/page.js +238 -0
  192. data/public/javascripts/lib/parameters.js +59 -0
  193. data/public/javascripts/lib/png_fix.js +75 -0
  194. data/public/javascripts/lib/protohack.js +297 -0
  195. data/public/javascripts/lib/push.js +5 -0
  196. data/public/javascripts/lib/rio.build +28 -0
  197. data/public/javascripts/lib/rio_development.build +5 -0
  198. data/public/javascripts/lib/rio_lint.js +66 -0
  199. data/public/javascripts/lib/rsh.js +651 -0
  200. data/public/javascripts/lib/spec.js +545 -0
  201. data/public/javascripts/lib/spec_runner.js +242 -0
  202. data/public/javascripts/lib/swfobject.js +5 -0
  203. data/public/javascripts/lib/tag.js +52 -0
  204. data/public/javascripts/lib/undo.js +134 -0
  205. data/public/javascripts/lib/utils.js +80 -0
  206. data/public/javascripts/lib/yaml.js +80 -0
  207. data/public/javascripts/pages/playground_page.js +15 -0
  208. data/public/javascripts/prototype/builder.js +146 -0
  209. data/public/javascripts/prototype/controls.js +1004 -0
  210. data/public/javascripts/prototype/dragdrop.js +1030 -0
  211. data/public/javascripts/prototype/effects.js +1137 -0
  212. data/public/javascripts/prototype/prototype.js +4320 -0
  213. data/public/javascripts/prototype/slider.js +283 -0
  214. data/public/javascripts/prototype/sound.js +67 -0
  215. data/public/javascripts/specs/components/box_spec.js +6 -0
  216. data/public/javascripts/specs/components/checkbox_spec.js +26 -0
  217. data/public/javascripts/specs/components/container_spec.js +6 -0
  218. data/public/javascripts/specs/components/input_spec.js +71 -0
  219. data/public/javascripts/specs/components/panel_spec.js +6 -0
  220. data/public/javascripts/specs/components/radio_spec.js +40 -0
  221. data/public/javascripts/specs/fixtures/components/box.js +3 -0
  222. data/public/javascripts/specs/fixtures/components/checkbox.js +9 -0
  223. data/public/javascripts/specs/fixtures/components/container.js +3 -0
  224. data/public/javascripts/specs/fixtures/components/input.js +12 -0
  225. data/public/javascripts/specs/fixtures/components/menu.js +19 -0
  226. data/public/javascripts/specs/fixtures/components/menu_item.js +18 -0
  227. data/public/javascripts/specs/fixtures/components/radio.js +11 -0
  228. data/public/javascripts/specs/lib/application_spec.js +281 -0
  229. data/public/javascripts/specs/lib/attr_spec.js +1514 -0
  230. data/public/javascripts/specs/lib/benchmark_spec.js +361 -0
  231. data/public/javascripts/specs/lib/collection_entity_spec.js +131 -0
  232. data/public/javascripts/specs/lib/component_spec.js +86 -0
  233. data/public/javascripts/specs/lib/form_spec.js +171 -0
  234. data/public/javascripts/specs/lib/id_spec.js +21 -0
  235. data/public/javascripts/specs/lib/instrumenter_spec.js +5 -0
  236. data/public/javascripts/specs/lib/js_template_spec.js +131 -0
  237. data/public/javascripts/specs/lib/key_map_spec.js +227 -0
  238. data/public/javascripts/specs/lib/model_spec.js +2268 -0
  239. data/public/javascripts/specs/lib/parameters_spec.js +94 -0
  240. data/public/javascripts/specs/lib/spec_spec.js +943 -0
  241. data/public/javascripts/specs/lib/undo_spec.js +105 -0
  242. data/public/javascripts/specs/lib/yaml_spec.js +127 -0
  243. data/public/sounds/basso.wav +0 -0
  244. data/public/sounds/purr.wav +0 -0
  245. data/public/stylesheets/components/accordion.css +24 -0
  246. data/public/stylesheets/components/alert_box.css +35 -0
  247. data/public/stylesheets/components/box.css +0 -0
  248. data/public/stylesheets/components/button.css +39 -0
  249. data/public/stylesheets/components/checkbox.css +9 -0
  250. data/public/stylesheets/components/container.css +3 -0
  251. data/public/stylesheets/components/grid_view.css +52 -0
  252. data/public/stylesheets/components/input.css +10 -0
  253. data/public/stylesheets/components/label.css +3 -0
  254. data/public/stylesheets/components/lightbox.css +31 -0
  255. data/public/stylesheets/components/link.css +4 -0
  256. data/public/stylesheets/components/list_view.css +23 -0
  257. data/public/stylesheets/components/marquee.css +29 -0
  258. data/public/stylesheets/components/menu.css +34 -0
  259. data/public/stylesheets/components/notification.css +52 -0
  260. data/public/stylesheets/components/overlay.css +8 -0
  261. data/public/stylesheets/components/panel.css +36 -0
  262. data/public/stylesheets/components/radio.css +9 -0
  263. data/public/stylesheets/components/splitter.css +35 -0
  264. data/public/stylesheets/components/tab_bar.css +59 -0
  265. data/public/stylesheets/components/tab_panel.css +15 -0
  266. data/public/stylesheets/components/textarea.css +11 -0
  267. data/public/stylesheets/components/tooltip.css +10 -0
  268. data/public/stylesheets/console.css +151 -0
  269. data/public/stylesheets/css_reset.css +55 -0
  270. metadata +343 -0
@@ -0,0 +1,43 @@
1
+ rio.Id = Class.create({
2
+ initialize: function(id) {
3
+ if (id) {
4
+ this._val = id;
5
+ this._temporary = false;
6
+ } else {
7
+ this._val = (Math.random() * -1000000000).round();
8
+ this._temporary = true;
9
+ }
10
+ this._cacheKey = this._val;
11
+ this._todos = [];
12
+ },
13
+
14
+ temporary: function() {
15
+ return this._temporary;
16
+ },
17
+
18
+ cacheKey: function() {
19
+ return this._cacheKey;
20
+ },
21
+
22
+ reify: function(realId) {
23
+ if (!this._temporary) { return; }
24
+ this._val = realId;
25
+ this._temporary = false;
26
+ this._todos.each(function(todo) { todo(); });
27
+ },
28
+
29
+ doAfterReification: function(todo) {
30
+ if(!this._temporary) {todo();}
31
+ this._todos.push(todo);
32
+ },
33
+
34
+ toString: function() {
35
+ return this._val.toString();
36
+ },
37
+
38
+ value: function() {
39
+ return this._val;
40
+ }
41
+ });
42
+
43
+ rio.Id.toString = function() { return "Id"; };
@@ -0,0 +1,160 @@
1
+ // based on the Inflector class from JavascriptMVC (http://javascriptmvc.com/index.html)
2
+ // based on the Inflector class found on a DZone snippet contributed by Todd Sayre
3
+ // http://snippets.dzone.com/posts/show/3205
4
+
5
+ /*
6
+ This needs test coverage.
7
+
8
+ I have found a few issues so far:
9
+
10
+ "ax".singularize()
11
+ "mice".pluralize()
12
+
13
+ etc...
14
+
15
+ I attempted to fix these by adding the "return word;" lines at the end of singularize and pluralize.
16
+ */
17
+
18
+ rio.Inflector = {
19
+ Inflections: {
20
+ plural: [
21
+ [/(quiz)$/i, "$1zes" ],
22
+ [/^(ox)$/i, "$1en" ],
23
+ [/([m|l])ouse$/i, "$1ice" ],
24
+ [/(matr|vert|ind)ix|ex$/i, "$1ices" ],
25
+ [/(x|ch|ss|sh)$/i, "$1es" ],
26
+ [/([^aeiouy]|qu)y$/i, "$1ies" ],
27
+ [/(hive)$/i, "$1s" ],
28
+ [/(?:([^f])fe|([lr])f)$/i, "$1$2ves"],
29
+ [/sis$/i, "ses" ],
30
+ [/([ti])um$/i, "$1a" ],
31
+ [/(buffal|tomat)o$/i, "$1oes" ],
32
+ [/(bu)s$/i, "$1ses" ],
33
+ [/(alias|status)$/i, "$1es" ],
34
+ [/(octop|vir)us$/i, "$1i" ],
35
+ [/(ax|test)is$/i, "$1es" ],
36
+ [/s$/i, "s" ],
37
+ [/$/, "s" ]
38
+ ],
39
+ singular: [
40
+ [/(quiz)zes$/i, "$1" ],
41
+ [/(matr)ices$/i, "$1ix" ],
42
+ [/(vert|ind)ices$/i, "$1ex" ],
43
+ [/^(ox)en/i, "$1" ],
44
+ [/(alias|status)es$/i, "$1" ],
45
+ [/(octop|vir)i$/i, "$1us" ],
46
+ [/(cris|ax|test)es$/i, "$1is" ],
47
+ [/(shoe)s$/i, "$1" ],
48
+ [/(o)es$/i, "$1" ],
49
+ [/(bus)es$/i, "$1" ],
50
+ [/([m|l])ice$/i, "$1ouse" ],
51
+ [/(x|ch|ss|sh)es$/i, "$1" ],
52
+ [/(m)ovies$/i, "$1ovie" ],
53
+ [/(s)eries$/i, "$1eries"],
54
+ [/([^aeiouy]|qu)ies$/i, "$1y" ],
55
+ [/([lr])ves$/i, "$1f" ],
56
+ [/(tive)s$/i, "$1" ],
57
+ [/(hive)s$/i, "$1" ],
58
+ [/([^f])ves$/i, "$1fe" ],
59
+ [/(^analy)ses$/i, "$1sis" ],
60
+ [/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i, "$1$2sis"],
61
+ [/([ti])a$/i, "$1um" ],
62
+ [/(n)ews$/i, "$1ews" ],
63
+ [/s$/i, "" ]
64
+ ],
65
+ irregular: [
66
+ ['move', 'moves' ],
67
+ ['sex', 'sexes' ],
68
+ ['child', 'children'],
69
+ ['man', 'men' ],
70
+ ['foreman', 'foremen'],
71
+ ['person', 'people' ]
72
+ ],
73
+ uncountable: [
74
+ "sheep",
75
+ "fish",
76
+ "series",
77
+ "species",
78
+ "money",
79
+ "rice",
80
+ "information",
81
+ "equipment"
82
+ ]
83
+ },
84
+ pluralize: function(word) {
85
+ var i;
86
+ for (i = 0; i < this.Inflections.uncountable.length; i++) {
87
+ var uncountable = this.Inflections.uncountable[i];
88
+ if (word.toLowerCase() == uncountable) {
89
+ return uncountable;
90
+ }
91
+ }
92
+ for (i = 0; i < this.Inflections.irregular.length; i++) {
93
+ var singular = this.Inflections.irregular[i][0];
94
+ var plural = this.Inflections.irregular[i][1];
95
+ if ((word.toLowerCase() == singular) || (word == plural)) {
96
+ return word.substring(0,1)+plural.substring(1);
97
+ }
98
+ }
99
+ for (i = 0; i < this.Inflections.plural.length; i++) {
100
+ var regex = this.Inflections.plural[i][0];
101
+ var replaceString = this.Inflections.plural[i][1];
102
+ if (regex.test(word)) {
103
+ return word.replace(regex, replaceString);
104
+ }
105
+ }
106
+
107
+ return word;
108
+ },
109
+ singularize: function(word) {
110
+ var i;
111
+ for (i = 0; i < this.Inflections.uncountable.length; i++) {
112
+ var uncountable = this.Inflections.uncountable[i];
113
+ if (word.toLowerCase() == uncountable) {
114
+ return uncountable;
115
+ }
116
+ }
117
+ for (i = 0; i < this.Inflections.irregular.length; i++) {
118
+ var singular = this.Inflections.irregular[i][0];
119
+ var plural = this.Inflections.irregular[i][1];
120
+ if ((word.toLowerCase() == singular) || (word.toLowerCase() == plural)) {
121
+ return word.substring(0,1)+singular.substring(1);
122
+ }
123
+ }
124
+ for (i = 0; i < this.Inflections.singular.length; i++) {
125
+ var regex = this.Inflections.singular[i][0];
126
+ var replaceString = this.Inflections.singular[i][1];
127
+ if (regex.test(word)) {
128
+ return word.replace(regex, replaceString);
129
+ }
130
+ }
131
+
132
+ return word;
133
+ }
134
+ };
135
+
136
+
137
+ Object.extend(String.prototype, {
138
+ pluralize: function(count, plural) {
139
+ if (typeof count == 'undefined') {
140
+ return rio.Inflector.pluralize(this);
141
+ } else {
142
+ return count + ' ' + (1 == parseInt(count, 10) ? this : plural || rio.Inflector.pluralize(this));
143
+ }
144
+ },
145
+
146
+ singularize: function(count) {
147
+ if (count == undefined) {
148
+ return rio.Inflector.singularize(this);
149
+ } else {
150
+ return count + " " + rio.Inflector.singularize(this);
151
+ }
152
+ },
153
+
154
+ isSingular: function(){
155
+ if(this.singularize() == this) {
156
+ return true;
157
+ }
158
+ return false;
159
+ }
160
+ });
@@ -0,0 +1,106 @@
1
+ rio.Instrumenter = {
2
+ instrument: function(filePath) {
3
+ rio.File.open(rio.boot.appRoot + filePath + ".js", {
4
+ asynchronous: false,
5
+ onSuccess: function(text) {
6
+ this.parseBlocks(text);
7
+ }.bind(this)
8
+ });
9
+ },
10
+
11
+ parseBlocks: function(text) {
12
+ var tokens = this.tokenize(text);
13
+ rio.log(tokens.map(function(t) { return t.token; }).join("\n"));
14
+ var CONTEXTS = {
15
+ NONE: 0,
16
+ FUNCTION: 1,
17
+ OBJECT: 2,
18
+ ARRAY: 3,
19
+ COMMENT: 4
20
+ };
21
+
22
+ var context = CONTEXTS.NONE;
23
+ var out = "";
24
+ for (var i = 0; i < text.length; i++) {
25
+
26
+ }
27
+ },
28
+
29
+ tokenize: function(text) {
30
+ var CONTEXTS = {
31
+ NONE: 0,
32
+ STRING: 1,
33
+ COMMENT: 2,
34
+ BLOCK_COMMENT: 3,
35
+ NUMBER: 4
36
+ };
37
+ var context = CONTEXTS.NONE;
38
+
39
+ var lineNumber = 1;
40
+ var tokens = [];
41
+ var soFar = "";
42
+ var addToken = function() {
43
+ tokens.push({
44
+ lineNumber: lineNumber,
45
+ token: soFar
46
+ });
47
+ soFar = "";
48
+ };
49
+ for (var i = 0; i < text.length; i++) {
50
+ var c = text[i];
51
+ switch(context) {
52
+ case CONTEXTS.NONE:
53
+ switch(c) {
54
+ case ' ':
55
+ case '\t':
56
+ case '\n':
57
+ if (soFar != "") { addToken(); }
58
+ break;
59
+ case '"':
60
+
61
+ break;
62
+ default:
63
+ if (soFar == "/" && c == "*") {
64
+ context = CONTEXTS.BLOCK_COMMENT;
65
+ soFar = "";
66
+ } else if (soFar == "/" && c == "/") {
67
+ context = CONTEXTS.COMMENT;
68
+ soFar = "";
69
+ } else {
70
+ soFar += c;
71
+ }
72
+ }
73
+ break;
74
+ case CONTEXTS.STRING:
75
+ break;
76
+ case CONTEXTS.COMMENT:
77
+ switch(c) {
78
+ case "\n":
79
+ context = CONTEXTS.NONE;
80
+ }
81
+ break;
82
+ case CONTEXTS.BLOCK_COMMENT:
83
+ switch(c) {
84
+ case "*":
85
+ soFar = "*";
86
+ break;
87
+ case "/":
88
+ if (soFar == "*") { context = CONTEXTS.NONE };
89
+ default:
90
+ soFar = "";
91
+ }
92
+ break;
93
+ }
94
+
95
+ if (c == "\n") { lineNumber += 1; }
96
+ }
97
+ return tokens;
98
+ },
99
+
100
+ wrap: function(fcn) {
101
+ rio.log("WRAP");
102
+ return fcn();
103
+ },
104
+
105
+ toString: function() { return "Instrumenter"; }
106
+ };
@@ -0,0 +1,275 @@
1
+ /**
2
+ @class
3
+
4
+ JsTemplates are used to parse rio templates (*.jst files). JsTemplates are created by rio pages as a starting point
5
+ for a pages html state. You should rarely have to instantiate this class directly.
6
+ */
7
+ rio.JsTemplate = Class.create({
8
+ initialize: function(options) {
9
+ this._name = options.name || "template";
10
+ this._template = options.text.gsub("&nbsp;", "\u00a0");
11
+ this._path = options.path;
12
+ },
13
+
14
+ mixinMethods: function() {
15
+ var template = this;
16
+ return {
17
+ buildHtml: function() {
18
+ return template.render(this);
19
+ }
20
+ };
21
+ },
22
+
23
+ xml: function() {
24
+ return '<div style="height: 100%;" class="' + this._name + '" xmlns:rio="http://riojs.com">' + this._template + "</div>";
25
+ },
26
+
27
+ parse: function() {
28
+ return rio.JsTemplate.parse(this._path ? this._template : this.xml());
29
+ },
30
+
31
+ render: function(context) {
32
+ var xml = this.parse();
33
+ try {
34
+ if (this._path) {
35
+ var nodes = xml.childNodes.item(0).getElementsByTagName(this._path)[0].childNodes;
36
+ var divNode;
37
+ var i = 0;
38
+ while (divNode == undefined) {
39
+ var node = nodes.item(i);
40
+ if (node.nodeType == 1) {
41
+ divNode = node;
42
+ }
43
+ i++;
44
+ }
45
+ return this.renderElement(node, context);
46
+ } else {
47
+ return this.renderElement(xml.childNodes.item(0), context);
48
+ }
49
+ } catch(e) {
50
+ rio.error(e, "Rendering error. Your xml might be malformed.\nRemember to escape these characters [<, \", &] with [&lt;, &quot;, &amp;])");
51
+ throw(e);
52
+ }
53
+ },
54
+
55
+ renderElement: function(xmlElement, context) {
56
+ var nodes = xmlElement.childNodes;
57
+
58
+ var htmlChildren = [];
59
+ var i, item;
60
+ for (i = 0; i < nodes.length; i++) {
61
+ item = nodes.item(i);
62
+
63
+ switch(item.nodeType) {
64
+ case 1: // Element
65
+ if (item.nodeName.startsWith("rio:")) {
66
+ htmlChildren.push(this.renderComponent(item, context).html());
67
+ } else {
68
+ htmlChildren.push(this.renderElement(item, context));
69
+ }
70
+ break;
71
+ case 3: // Text
72
+ htmlChildren.push(item.nodeValue);
73
+ break;
74
+ }
75
+ }
76
+
77
+ var htmlAttributes = {};
78
+ var attributes = xmlElement.attributes;
79
+ var rioId;
80
+ for (i = 0; i < attributes.length; i++) {
81
+ item = attributes.item(i);
82
+ if (item.nodeName == "rio:id") {
83
+ rioId = item.nodeValue;
84
+ } else {
85
+ htmlAttributes[item.nodeName] = item.nodeValue;
86
+ }
87
+ }
88
+
89
+ var htmlElement = rio.Tag.build(xmlElement.nodeName, htmlChildren, htmlAttributes);
90
+
91
+ if (rioId) {
92
+ context[("get-" + rioId + "Element").camelize()] = function() {
93
+ return htmlElement;
94
+ };
95
+ }
96
+
97
+ return htmlElement;
98
+ },
99
+
100
+ renderChildNodes: function(xmlElement, context) {
101
+ var nodes = xmlElement.childNodes;
102
+
103
+ var renderedChildren = [];
104
+ for (var i = 0; i < nodes.length; i++) {
105
+ var item = nodes.item(i);
106
+
107
+ switch(item.nodeType) {
108
+ case 1: // Element
109
+ if (item.nodeName.startsWith("rio:")) {
110
+ if (item.nodeName == "rio:Object") {
111
+ renderedChildren.push(this.renderRioObject(item, context));
112
+ } else {
113
+ renderedChildren.push(this.renderComponent(item, context));
114
+ }
115
+ } else {
116
+ renderedChildren.push(this.renderElement(item, context));
117
+ }
118
+ break;
119
+ case 3: // Text
120
+ if (item.nodeValue.strip() != "") {
121
+ renderedChildren.push(item.nodeValue);
122
+ }
123
+ break;
124
+ }
125
+ }
126
+ return renderedChildren.reduce();
127
+ },
128
+
129
+ renderRioObject: function(xmlElement, context) {
130
+ var obj = {};
131
+ var nodes = xmlElement.childNodes;
132
+ for (var i = 0; i < nodes.length; i++) {
133
+ var item = nodes.item(i);
134
+ if (item.nodeType == 1) {
135
+ obj[item.nodeName] = this.renderChildNodes(item, context);
136
+ }
137
+ }
138
+
139
+ return obj;
140
+ },
141
+
142
+ renderComponent: function(xmlElement, context) {
143
+ var componentType = xmlElement.nodeName.match(/rio:(.*)/)[1];
144
+
145
+
146
+ var componentAttributes = {};
147
+ var attributes = xmlElement.attributes;
148
+ var rioId, i, item;
149
+
150
+ for (i = 0; i < attributes.length; i++) {
151
+ item = attributes.item(i);
152
+ if (item.nodeName == "rio:id") {
153
+ rioId = item.nodeValue;
154
+ } else {
155
+ var value = item.nodeValue;
156
+ var executable = value.match(/\{(.*)\}/);
157
+ if (executable) {
158
+ rio.pageBinding = context;
159
+ try {
160
+ value = eval("(function() { return " + executable[1] + "; }).bind(rio.pageBinding)();");
161
+ } catch(e) {
162
+ rio.error(e, "Error evaluating " + this._name.classize() + " template attribute: " + executable[1]);
163
+ throw(e);
164
+ }
165
+ delete rio.pageBinding;
166
+ }
167
+ componentAttributes[item.nodeName] = value;
168
+ }
169
+ }
170
+
171
+ var nodes = xmlElement.childNodes;
172
+ for (i = 0; i < nodes.length; i++) {
173
+ item = nodes.item(i);
174
+
175
+ if (item.nodeType == 1) {
176
+ if (item.nodeName == "rio:id") {
177
+ rioId = item.nodeValue;
178
+ } else {
179
+ componentAttributes[item.nodeName] = this.renderChildNodes(item, context);
180
+ }
181
+ }
182
+ }
183
+ try {
184
+ var component = new rio.components[componentType](componentAttributes);
185
+ } catch(e2) {
186
+ if (rio.components[componentType] == undefined) {
187
+ rio.error(e2, componentType + " not found. Add 'components/" + componentType.underscore() + "' to the " + this._name.classize() + " require list.");
188
+ }
189
+ throw(e2);
190
+ }
191
+
192
+ if (rioId) {
193
+ context[("get-" + rioId).camelize()] = function() {
194
+ return component;
195
+ };
196
+ }
197
+
198
+ return component;
199
+ },
200
+
201
+ name: function() {
202
+ return this._name;
203
+ }
204
+ });
205
+ Object.extend(rio.JsTemplate, {
206
+ build: function(path) {
207
+ path = rio.boot.appRoot + path;
208
+ if (this._templatePreloaded(path)) {
209
+ return new rio.JsTemplate({
210
+ name: this._templateNameFromPath(path),
211
+ text: this._allTemplatesFile,
212
+ path: path.gsub("/", "--")
213
+ });
214
+ } else {
215
+ rio.log("missed: " + path);
216
+ return new rio.JsTemplate({
217
+ name: this._templateNameFromPath(path),
218
+ text: this._templateFile(path)
219
+ });
220
+ }
221
+ },
222
+
223
+ preload: function(path) {
224
+ this._allTemplatesFile = this._templateFile(path);
225
+ this._allTemplatesList = [];
226
+
227
+ var doc = this.parse(this._allTemplatesFile);
228
+ var templateNodes = doc.childNodes.item(0).childNodes;
229
+ for (var i = 0; i < templateNodes.length; i++) {
230
+ var item = templateNodes.item(i);
231
+ if (item.nodeType == 1) {
232
+ this._allTemplatesList.push(item.nodeName.gsub("--", "/"));
233
+ }
234
+ }
235
+ },
236
+
237
+ parse: function(xml) {
238
+ var xmlDoc;
239
+ if (Prototype.Browser.IE) {
240
+ xmlDoc = new ActiveXObject("Microsoft.XMLDOM");
241
+ xmlDoc.async="false";
242
+ xmlDoc.loadXML(xml);
243
+ } else {
244
+ try {
245
+ var parser = new DOMParser();
246
+ xmlDoc = parser.parseFromString(xml,"text/xml");
247
+ } catch(e) {
248
+ rio.log(e);
249
+ }
250
+ }
251
+ return xmlDoc;
252
+ },
253
+
254
+ _templatePreloaded: function(path) {
255
+ return (this._allTemplatesList || []).include(path);
256
+ },
257
+
258
+ _templateNameFromPath: function(path) {
259
+ return path.split("/").last().camelize();
260
+ },
261
+
262
+ _templateFile: function(path) {
263
+ return rio.File.open(rio.boot.root + rio.boot.appRoot + path + ".jst", {
264
+ asynchronous: false,
265
+ onFailure: function() {
266
+ rio.Application.fail("Failed loading template - " + path);
267
+ }
268
+ });
269
+ },
270
+
271
+ toString: function() {
272
+ return "JsTemplate";
273
+ }
274
+ });
275
+