marty 0.5.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (345) hide show
  1. checksums.yaml +7 -0
  2. data/MIT-LICENSE +20 -0
  3. data/README.md +84 -0
  4. data/Rakefile +29 -0
  5. data/app/assets/javascripts/marty/application.js +15 -0
  6. data/app/assets/stylesheets/marty/application.css +13 -0
  7. data/app/components/marty/api_auth_view.rb +32 -0
  8. data/app/components/marty/auth_app.rb +55 -0
  9. data/app/components/marty/auth_app.rb~ +51 -0
  10. data/app/components/marty/auth_app/javascripts/auth_app.js +91 -0
  11. data/app/components/marty/auth_app/javascripts/auth_app.js~ +91 -0
  12. data/app/components/marty/cm_form_panel.rb~ +5 -0
  13. data/app/components/marty/cm_grid_panel.rb~ +35 -0
  14. data/app/components/marty/data_import_view.rb~ +142 -0
  15. data/app/components/marty/extras/layout.rb +46 -0
  16. data/app/components/marty/extras/layout.rb~ +46 -0
  17. data/app/components/marty/extras/misc.rb +18 -0
  18. data/app/components/marty/form.rb +6 -0
  19. data/app/components/marty/grid.rb +45 -0
  20. data/app/components/marty/grid_append_only.rb +12 -0
  21. data/app/components/marty/import_type_view.rb +53 -0
  22. data/app/components/marty/live_search_grid_panel.rb +46 -0
  23. data/app/components/marty/live_search_grid_panel.rb~ +49 -0
  24. data/app/components/marty/main_auth_app.rb +269 -0
  25. data/app/components/marty/main_auth_app.rb~ +238 -0
  26. data/app/components/marty/mcfly_grid_panel.rb +62 -0
  27. data/app/components/marty/mcfly_grid_panel.rb~ +80 -0
  28. data/app/components/marty/new_posting_form.rb +46 -0
  29. data/app/components/marty/new_posting_form.rb~ +46 -0
  30. data/app/components/marty/new_posting_window.rb +21 -0
  31. data/app/components/marty/new_posting_window.rb~ +21 -0
  32. data/app/components/marty/panel.rb +12 -0
  33. data/app/components/marty/pivot_grid.rb +52 -0
  34. data/app/components/marty/pivot_grid/endpoints.rb +45 -0
  35. data/app/components/marty/pivot_grid/javascripts/extensions.js +150 -0
  36. data/app/components/marty/pivot_grid/javascripts/pivot_grid.js +86 -0
  37. data/app/components/marty/pivot_grid/services.rb +44 -0
  38. data/app/components/marty/posting_grid.rb +139 -0
  39. data/app/components/marty/posting_grid.rb~ +140 -0
  40. data/app/components/marty/posting_window.rb +27 -0
  41. data/app/components/marty/promise_view.rb +177 -0
  42. data/app/components/marty/promise_view.rb~ +157 -0
  43. data/app/components/marty/promise_view/stylesheets/promise_view.css +26 -0
  44. data/app/components/marty/promise_view/stylesheets/promise_view.css~ +15 -0
  45. data/app/components/marty/report_form.rb +225 -0
  46. data/app/components/marty/report_form.rb~ +217 -0
  47. data/app/components/marty/report_select.rb +145 -0
  48. data/app/components/marty/report_select.rb~ +133 -0
  49. data/app/components/marty/reporting.rb +39 -0
  50. data/app/components/marty/reporting.rb~ +39 -0
  51. data/app/components/marty/script_detail.rb~ +430 -0
  52. data/app/components/marty/script_form.rb +233 -0
  53. data/app/components/marty/script_form.rb~ +233 -0
  54. data/app/components/marty/script_form/javascripts/Ext.ux.form.field.CodeMirror.js +698 -0
  55. data/app/components/marty/script_form/javascripts/Ext.ux.form.field.CodeMirror.js~ +909 -0
  56. data/app/components/marty/script_form/javascripts/codemirror.js +3130 -0
  57. data/app/components/marty/script_form/javascripts/mode/clike/clike.js +284 -0
  58. data/app/components/marty/script_form/javascripts/mode/clike/index.html +102 -0
  59. data/app/components/marty/script_form/javascripts/mode/clike/scala.html +766 -0
  60. data/app/components/marty/script_form/javascripts/mode/clojure/clojure.js +206 -0
  61. data/app/components/marty/script_form/javascripts/mode/clojure/index.html +67 -0
  62. data/app/components/marty/script_form/javascripts/mode/coffeescript/LICENSE +22 -0
  63. data/app/components/marty/script_form/javascripts/mode/coffeescript/coffeescript.js +346 -0
  64. data/app/components/marty/script_form/javascripts/mode/coffeescript/index.html +728 -0
  65. data/app/components/marty/script_form/javascripts/mode/commonlisp/commonlisp.js +101 -0
  66. data/app/components/marty/script_form/javascripts/mode/commonlisp/index.html +165 -0
  67. data/app/components/marty/script_form/javascripts/mode/css/css.js +448 -0
  68. data/app/components/marty/script_form/javascripts/mode/css/index.html +58 -0
  69. data/app/components/marty/script_form/javascripts/mode/css/test.js +501 -0
  70. data/app/components/marty/script_form/javascripts/mode/delorean/delorean.js +189 -0
  71. data/app/components/marty/script_form/javascripts/mode/diff/diff.js +32 -0
  72. data/app/components/marty/script_form/javascripts/mode/diff/index.html +105 -0
  73. data/app/components/marty/script_form/javascripts/mode/ecl/ecl.js +203 -0
  74. data/app/components/marty/script_form/javascripts/mode/ecl/index.html +42 -0
  75. data/app/components/marty/script_form/javascripts/mode/erlang/erlang.js +463 -0
  76. data/app/components/marty/script_form/javascripts/mode/erlang/index.html +63 -0
  77. data/app/components/marty/script_form/javascripts/mode/gfm/gfm.js +150 -0
  78. data/app/components/marty/script_form/javascripts/mode/gfm/index.html +48 -0
  79. data/app/components/marty/script_form/javascripts/mode/go/go.js +170 -0
  80. data/app/components/marty/script_form/javascripts/mode/go/index.html +73 -0
  81. data/app/components/marty/script_form/javascripts/mode/groovy/groovy.js +210 -0
  82. data/app/components/marty/script_form/javascripts/mode/groovy/index.html +72 -0
  83. data/app/components/marty/script_form/javascripts/mode/haskell/haskell.js +242 -0
  84. data/app/components/marty/script_form/javascripts/mode/haskell/index.html +61 -0
  85. data/app/components/marty/script_form/javascripts/mode/haxe/haxe.js +429 -0
  86. data/app/components/marty/script_form/javascripts/mode/haxe/index.html +91 -0
  87. data/app/components/marty/script_form/javascripts/mode/htmlembedded/htmlembedded.js +72 -0
  88. data/app/components/marty/script_form/javascripts/mode/htmlembedded/index.html +50 -0
  89. data/app/components/marty/script_form/javascripts/mode/htmlmixed/htmlmixed.js +84 -0
  90. data/app/components/marty/script_form/javascripts/mode/htmlmixed/index.html +52 -0
  91. data/app/components/marty/script_form/javascripts/mode/javascript/index.html +78 -0
  92. data/app/components/marty/script_form/javascripts/mode/javascript/javascript.js +361 -0
  93. data/app/components/marty/script_form/javascripts/mode/jinja2/index.html +38 -0
  94. data/app/components/marty/script_form/javascripts/mode/jinja2/jinja2.js +42 -0
  95. data/app/components/marty/script_form/javascripts/mode/less/index.html +740 -0
  96. data/app/components/marty/script_form/javascripts/mode/less/less.js +266 -0
  97. data/app/components/marty/script_form/javascripts/mode/lua/index.html +73 -0
  98. data/app/components/marty/script_form/javascripts/mode/lua/lua.js +140 -0
  99. data/app/components/marty/script_form/javascripts/mode/markdown/index.html +343 -0
  100. data/app/components/marty/script_form/javascripts/mode/markdown/markdown.js +382 -0
  101. data/app/components/marty/script_form/javascripts/mode/markdown/test.js +1084 -0
  102. data/app/components/marty/script_form/javascripts/mode/mysql/index.html +42 -0
  103. data/app/components/marty/script_form/javascripts/mode/mysql/mysql.js +186 -0
  104. data/app/components/marty/script_form/javascripts/mode/ntriples/index.html +33 -0
  105. data/app/components/marty/script_form/javascripts/mode/ntriples/ntriples.js +172 -0
  106. data/app/components/marty/script_form/javascripts/mode/ocaml/index.html +130 -0
  107. data/app/components/marty/script_form/javascripts/mode/ocaml/ocaml.js +114 -0
  108. data/app/components/marty/script_form/javascripts/mode/pascal/LICENSE +7 -0
  109. data/app/components/marty/script_form/javascripts/mode/pascal/index.html +49 -0
  110. data/app/components/marty/script_form/javascripts/mode/pascal/pascal.js +94 -0
  111. data/app/components/marty/script_form/javascripts/mode/perl/LICENSE +19 -0
  112. data/app/components/marty/script_form/javascripts/mode/perl/index.html +63 -0
  113. data/app/components/marty/script_form/javascripts/mode/perl/perl.js +816 -0
  114. data/app/components/marty/script_form/javascripts/mode/php/index.html +49 -0
  115. data/app/components/marty/script_form/javascripts/mode/php/php.js +148 -0
  116. data/app/components/marty/script_form/javascripts/mode/pig/index.html +43 -0
  117. data/app/components/marty/script_form/javascripts/mode/pig/pig.js +172 -0
  118. data/app/components/marty/script_form/javascripts/mode/plsql/index.html +63 -0
  119. data/app/components/marty/script_form/javascripts/mode/plsql/plsql.js +217 -0
  120. data/app/components/marty/script_form/javascripts/mode/properties/index.html +41 -0
  121. data/app/components/marty/script_form/javascripts/mode/properties/properties.js +63 -0
  122. data/app/components/marty/script_form/javascripts/mode/python/LICENSE.txt +21 -0
  123. data/app/components/marty/script_form/javascripts/mode/python/index.html +123 -0
  124. data/app/components/marty/script_form/javascripts/mode/python/python.js +338 -0
  125. data/app/components/marty/script_form/javascripts/mode/r/LICENSE +24 -0
  126. data/app/components/marty/script_form/javascripts/mode/r/index.html +74 -0
  127. data/app/components/marty/script_form/javascripts/mode/r/r.js +141 -0
  128. data/app/components/marty/script_form/javascripts/mode/rpm/changes/changes.js +19 -0
  129. data/app/components/marty/script_form/javascripts/mode/rpm/changes/index.html +54 -0
  130. data/app/components/marty/script_form/javascripts/mode/rpm/spec/index.html +100 -0
  131. data/app/components/marty/script_form/javascripts/mode/rpm/spec/spec.css +5 -0
  132. data/app/components/marty/script_form/javascripts/mode/rpm/spec/spec.js +66 -0
  133. data/app/components/marty/script_form/javascripts/mode/rst/index.html +526 -0
  134. data/app/components/marty/script_form/javascripts/mode/rst/rst.js +326 -0
  135. data/app/components/marty/script_form/javascripts/mode/ruby/LICENSE +24 -0
  136. data/app/components/marty/script_form/javascripts/mode/ruby/index.html +172 -0
  137. data/app/components/marty/script_form/javascripts/mode/ruby/ruby.js +195 -0
  138. data/app/components/marty/script_form/javascripts/mode/rust/index.html +49 -0
  139. data/app/components/marty/script_form/javascripts/mode/rust/rust.js +432 -0
  140. data/app/components/marty/script_form/javascripts/mode/scheme/index.html +65 -0
  141. data/app/components/marty/script_form/javascripts/mode/scheme/scheme.js +230 -0
  142. data/app/components/marty/script_form/javascripts/mode/shell/index.html +50 -0
  143. data/app/components/marty/script_form/javascripts/mode/shell/shell.js +118 -0
  144. data/app/components/marty/script_form/javascripts/mode/sieve/LICENSE +23 -0
  145. data/app/components/marty/script_form/javascripts/mode/sieve/index.html +81 -0
  146. data/app/components/marty/script_form/javascripts/mode/sieve/sieve.js +156 -0
  147. data/app/components/marty/script_form/javascripts/mode/smalltalk/index.html +56 -0
  148. data/app/components/marty/script_form/javascripts/mode/smalltalk/smalltalk.js +139 -0
  149. data/app/components/marty/script_form/javascripts/mode/smarty/index.html +83 -0
  150. data/app/components/marty/script_form/javascripts/mode/smarty/smarty.js +148 -0
  151. data/app/components/marty/script_form/javascripts/mode/sparql/index.html +41 -0
  152. data/app/components/marty/script_form/javascripts/mode/sparql/sparql.js +143 -0
  153. data/app/components/marty/script_form/javascripts/mode/stex/index.html +98 -0
  154. data/app/components/marty/script_form/javascripts/mode/stex/stex.js +182 -0
  155. data/app/components/marty/script_form/javascripts/mode/stex/test.js +343 -0
  156. data/app/components/marty/script_form/javascripts/mode/tiddlywiki/index.html +141 -0
  157. data/app/components/marty/script_form/javascripts/mode/tiddlywiki/tiddlywiki.css +14 -0
  158. data/app/components/marty/script_form/javascripts/mode/tiddlywiki/tiddlywiki.js +384 -0
  159. data/app/components/marty/script_form/javascripts/mode/tiki/index.html +83 -0
  160. data/app/components/marty/script_form/javascripts/mode/tiki/tiki.css +26 -0
  161. data/app/components/marty/script_form/javascripts/mode/tiki/tiki.js +309 -0
  162. data/app/components/marty/script_form/javascripts/mode/vb/LICENSE.txt +21 -0
  163. data/app/components/marty/script_form/javascripts/mode/vb/index.html +89 -0
  164. data/app/components/marty/script_form/javascripts/mode/vb/vb.js +260 -0
  165. data/app/components/marty/script_form/javascripts/mode/vbscript/index.html +43 -0
  166. data/app/components/marty/script_form/javascripts/mode/vbscript/vbscript.js +26 -0
  167. data/app/components/marty/script_form/javascripts/mode/velocity/index.html +104 -0
  168. data/app/components/marty/script_form/javascripts/mode/velocity/velocity.js +146 -0
  169. data/app/components/marty/script_form/javascripts/mode/verilog/index.html +211 -0
  170. data/app/components/marty/script_form/javascripts/mode/verilog/verilog.js +194 -0
  171. data/app/components/marty/script_form/javascripts/mode/xml/index.html +45 -0
  172. data/app/components/marty/script_form/javascripts/mode/xml/xml.js +318 -0
  173. data/app/components/marty/script_form/javascripts/mode/xquery/LICENSE +20 -0
  174. data/app/components/marty/script_form/javascripts/mode/xquery/index.html +223 -0
  175. data/app/components/marty/script_form/javascripts/mode/xquery/test/index.html +27 -0
  176. data/app/components/marty/script_form/javascripts/mode/xquery/test/testBase.js +42 -0
  177. data/app/components/marty/script_form/javascripts/mode/xquery/test/testEmptySequenceKeyword.js +16 -0
  178. data/app/components/marty/script_form/javascripts/mode/xquery/test/testMultiAttr.js +16 -0
  179. data/app/components/marty/script_form/javascripts/mode/xquery/test/testNamespaces.js +91 -0
  180. data/app/components/marty/script_form/javascripts/mode/xquery/test/testProcessingInstructions.js +16 -0
  181. data/app/components/marty/script_form/javascripts/mode/xquery/test/testQuotes.js +19 -0
  182. data/app/components/marty/script_form/javascripts/mode/xquery/xquery.js +451 -0
  183. data/app/components/marty/script_form/javascripts/mode/yaml/index.html +68 -0
  184. data/app/components/marty/script_form/javascripts/mode/yaml/yaml.js +95 -0
  185. data/app/components/marty/script_form/javascripts/util/closetag.js +164 -0
  186. data/app/components/marty/script_form/javascripts/util/dialog.css +27 -0
  187. data/app/components/marty/script_form/javascripts/util/dialog.js +70 -0
  188. data/app/components/marty/script_form/javascripts/util/foldcode.js +196 -0
  189. data/app/components/marty/script_form/javascripts/util/formatting.js +193 -0
  190. data/app/components/marty/script_form/javascripts/util/javascript-hint.js +134 -0
  191. data/app/components/marty/script_form/javascripts/util/loadmode.js +51 -0
  192. data/app/components/marty/script_form/javascripts/util/match-highlighter.js +44 -0
  193. data/app/components/marty/script_form/javascripts/util/multiplex.js +77 -0
  194. data/app/components/marty/script_form/javascripts/util/overlay.js +54 -0
  195. data/app/components/marty/script_form/javascripts/util/pig-hint.js +123 -0
  196. data/app/components/marty/script_form/javascripts/util/runmode-standalone.js +90 -0
  197. data/app/components/marty/script_form/javascripts/util/runmode.js +53 -0
  198. data/app/components/marty/script_form/javascripts/util/search.js +118 -0
  199. data/app/components/marty/script_form/javascripts/util/searchcursor.js +119 -0
  200. data/app/components/marty/script_form/javascripts/util/simple-hint.css +16 -0
  201. data/app/components/marty/script_form/javascripts/util/simple-hint.js +97 -0
  202. data/app/components/marty/script_form/javascripts/util/xml-hint.js +137 -0
  203. data/app/components/marty/script_form/stylesheets/codemirror.css +172 -0
  204. data/app/components/marty/script_form/stylesheets/delorean.css +10 -0
  205. data/app/components/marty/script_form/stylesheets/theme/ambiance.css +81 -0
  206. data/app/components/marty/script_form/stylesheets/theme/blackboard.css +25 -0
  207. data/app/components/marty/script_form/stylesheets/theme/cobalt.css +18 -0
  208. data/app/components/marty/script_form/stylesheets/theme/eclipse.css +25 -0
  209. data/app/components/marty/script_form/stylesheets/theme/elegant.css +10 -0
  210. data/app/components/marty/script_form/stylesheets/theme/erlang-dark.css +21 -0
  211. data/app/components/marty/script_form/stylesheets/theme/lesser-dark.css +44 -0
  212. data/app/components/marty/script_form/stylesheets/theme/monokai.css +28 -0
  213. data/app/components/marty/script_form/stylesheets/theme/neat.css +9 -0
  214. data/app/components/marty/script_form/stylesheets/theme/night.css +21 -0
  215. data/app/components/marty/script_form/stylesheets/theme/rubyblue.css +21 -0
  216. data/app/components/marty/script_form/stylesheets/theme/vibrant-ink.css +27 -0
  217. data/app/components/marty/script_form/stylesheets/theme/xq-dark.css +46 -0
  218. data/app/components/marty/script_grid.rb +104 -0
  219. data/app/components/marty/script_grid.rb~ +99 -0
  220. data/app/components/marty/script_tester.rb +114 -0
  221. data/app/components/marty/script_tester.rb~ +213 -0
  222. data/app/components/marty/scripting.rb +132 -0
  223. data/app/components/marty/scripting.rb~ +124 -0
  224. data/app/components/marty/select_report.rb~ +143 -0
  225. data/app/components/marty/simple_app.rb +97 -0
  226. data/app/components/marty/simple_app.rb~ +101 -0
  227. data/app/components/marty/simple_app/javascripts/simple_app.js +50 -0
  228. data/app/components/marty/simple_app/javascripts/statusbar_ext.js +8 -0
  229. data/app/components/marty/tag_grid.rb +83 -0
  230. data/app/components/marty/tag_grid.rb~ +89 -0
  231. data/app/components/marty/tree_panel.rb~ +256 -0
  232. data/app/components/marty/tree_panel/javascripts/tree_panel.js~ +317 -0
  233. data/app/components/marty/user_pivot.rb +128 -0
  234. data/app/components/marty/user_view.rb +181 -0
  235. data/app/components/marty/user_view.rb~ +188 -0
  236. data/app/controllers/marty/application_controller.rb +124 -0
  237. data/app/controllers/marty/application_controller.rb~ +133 -0
  238. data/app/controllers/marty/components_controller.rb +41 -0
  239. data/app/controllers/marty/components_controller.rb~ +37 -0
  240. data/app/controllers/marty/job_controller.rb +28 -0
  241. data/app/controllers/marty/job_controller.rb~ +28 -0
  242. data/app/controllers/marty/rpc_controller.rb +64 -0
  243. data/app/controllers/marty/rpc_controller.rb~ +61 -0
  244. data/app/helpers/marty/application_helper.rb +4 -0
  245. data/app/helpers/marty/script_set.rb +57 -0
  246. data/app/helpers/marty/script_set.rb~ +59 -0
  247. data/app/models/marty/api_auth.rb +44 -0
  248. data/app/models/marty/api_auth.rb~ +48 -0
  249. data/app/models/marty/base.rb +4 -0
  250. data/app/models/marty/data_change.rb +179 -0
  251. data/app/models/marty/data_change.rb~ +141 -0
  252. data/app/models/marty/enum.rb +22 -0
  253. data/app/models/marty/enum.rb~ +16 -0
  254. data/app/models/marty/import_type.rb +44 -0
  255. data/app/models/marty/import_type.rb~ +48 -0
  256. data/app/models/marty/poop.rb~ +169 -0
  257. data/app/models/marty/posting.rb +101 -0
  258. data/app/models/marty/posting.rb~ +86 -0
  259. data/app/models/marty/posting_type.rb +12 -0
  260. data/app/models/marty/posting_type.rb~ +21 -0
  261. data/app/models/marty/promise.rb +252 -0
  262. data/app/models/marty/promise.rb~ +196 -0
  263. data/app/models/marty/role.rb +6 -0
  264. data/app/models/marty/role.rb~ +10 -0
  265. data/app/models/marty/script.rb +144 -0
  266. data/app/models/marty/script.rb~ +62 -0
  267. data/app/models/marty/tag.rb +96 -0
  268. data/app/models/marty/tag.rb~ +91 -0
  269. data/app/models/marty/token.rb +30 -0
  270. data/app/models/marty/user.rb +146 -0
  271. data/app/models/marty/user.rb~ +148 -0
  272. data/app/models/marty/user_role.rb +7 -0
  273. data/app/models/marty/user_role.rb~ +13 -0
  274. data/app/views/layouts/marty/application.html.erb +12 -0
  275. data/app/views/layouts/marty/application.html.erb~ +11 -0
  276. data/config/locales/en.yml +134 -0
  277. data/config/routes.rb +6 -0
  278. data/config/routes.rb~ +10 -0
  279. data/db/migrate/001_create_marty_scripts.rb +14 -0
  280. data/db/migrate/003_create_marty_users.rb +12 -0
  281. data/db/migrate/004_create_marty_roles.rb +7 -0
  282. data/db/migrate/005_create_marty_user_roles.rb +14 -0
  283. data/db/migrate/006_create_marty_tokens.rb +14 -0
  284. data/db/migrate/008_create_marty_posting_types.rb +7 -0
  285. data/db/migrate/019_create_marty_postings.rb +18 -0
  286. data/db/migrate/019_create_marty_postings.rb~ +19 -0
  287. data/db/migrate/068_create_marty_import_types.rb +12 -0
  288. data/db/migrate/069_create_marty_import_synonyms.rb +15 -0
  289. data/db/migrate/070_create_versions.rb +18 -0
  290. data/db/migrate/071_add_object_changes_column_to_versions.rb +9 -0
  291. data/db/migrate/072_add_validation_function_to_import_types.rb +6 -0
  292. data/db/migrate/073_add_preprocess_function_to_import_types.rb +5 -0
  293. data/db/migrate/090_create_delayed_jobs.rb +22 -0
  294. data/db/migrate/091_create_marty_promises.rb +36 -0
  295. data/db/migrate/095_create_marty_tags.rb +14 -0
  296. data/db/migrate/095_create_marty_tags.rb~ +19 -0
  297. data/db/migrate/096_add_user_roles_to_import_types.rb +11 -0
  298. data/db/migrate/097_drop_versions.rb +9 -0
  299. data/db/migrate/098_create_marty_api_auths.rb +20 -0
  300. data/db/seeds.rb +48 -0
  301. data/lib/marty.rb +18 -0
  302. data/lib/marty.rb~ +13 -0
  303. data/lib/marty/content_handler.rb +97 -0
  304. data/lib/marty/content_handler.rb~ +93 -0
  305. data/lib/marty/data_conversion.rb +298 -0
  306. data/lib/marty/data_exporter.rb +150 -0
  307. data/lib/marty/data_exporter.rb~ +137 -0
  308. data/lib/marty/data_importer.rb +122 -0
  309. data/lib/marty/data_importer.rb~ +114 -0
  310. data/lib/marty/data_row_processor.rb~ +206 -0
  311. data/lib/marty/drop_folder_hook.rb~ +17 -0
  312. data/lib/marty/engine.rb +10 -0
  313. data/lib/marty/folder_hook.rb~ +9 -0
  314. data/lib/marty/lazy_column_loader.rb +57 -0
  315. data/lib/marty/lazy_column_loader.rb~ +47 -0
  316. data/lib/marty/mcfly_query.rb +189 -0
  317. data/lib/marty/mcfly_query.rb~ +188 -0
  318. data/lib/marty/migrations.rb +108 -0
  319. data/lib/marty/migrations.rb~ +65 -0
  320. data/lib/marty/monkey.rb +163 -0
  321. data/lib/marty/monkey.rb~ +160 -0
  322. data/lib/marty/permissions.rb +64 -0
  323. data/lib/marty/permissions.rb~ +69 -0
  324. data/lib/marty/promise.rb~ +41 -0
  325. data/lib/marty/promise_job.rb +123 -0
  326. data/lib/marty/promise_job.rb~ +121 -0
  327. data/lib/marty/promise_proxy.rb +94 -0
  328. data/lib/marty/promise_proxy.rb~ +69 -0
  329. data/lib/marty/railtie.rb +5 -0
  330. data/lib/marty/relation.rb +39 -0
  331. data/lib/marty/util.rb +110 -0
  332. data/lib/marty/util.rb~ +80 -0
  333. data/lib/marty/version.rb +3 -0
  334. data/lib/marty/version.rb~ +3 -0
  335. data/lib/marty/xl.rb +527 -0
  336. data/lib/marty/xl.rb~ +526 -0
  337. data/lib/pyxll/README.txt +19 -0
  338. data/lib/pyxll/README.txt~ +16 -0
  339. data/lib/pyxll/gemini.py +155 -0
  340. data/lib/pyxll/gemini.py~ +110 -0
  341. data/lib/pyxll/pyxll.cfg +12 -0
  342. data/lib/pyxll/pyxll.cfg~ +12 -0
  343. data/lib/pyxll/sample.xlsx +0 -0
  344. data/lib/tasks/marty_tasks.rake +37 -0
  345. metadata +517 -0
@@ -0,0 +1,909 @@
1
+ /*
2
+
3
+ This is a modified version of the ExtJS Codemirror component from
4
+ http://www.mzsolutions.eu/Extjs-CodeMirror-component.html. It's been
5
+ modified to remove the toolbar and also it uses delorean mode by
6
+ default.
7
+
8
+ */
9
+
10
+ /**
11
+ * @private
12
+ * @class Ext.ux.layout.component.field.CodeMirror
13
+ * @extends Ext.layout.component.field.Field
14
+ * @author Adrian Teodorescu (ateodorescu@gmail.com)
15
+ *
16
+ * Layout class for {@link Ext.ux.form.field.CodeMirror} fields. Handles sizing the codemirror field.
17
+ */
18
+ Ext.define('Ext.ux.layout.component.field.CodeMirror', {
19
+ extend: 'Ext.layout.component.field.Field',
20
+ alias: ['layout.codemirror'],
21
+
22
+ type: 'codemirror',
23
+
24
+ beginLayout: function(ownerContext) {
25
+ this.callParent(arguments);
26
+
27
+ ownerContext.textAreaContext = ownerContext.getEl('textareaEl');
28
+ ownerContext.editorContext = ownerContext.getEl('editorEl');
29
+ },
30
+
31
+ renderItems: Ext.emptyFn,
32
+
33
+ getRenderTarget: function() {
34
+ return this.owner.bodyEl;
35
+ },
36
+
37
+ publishInnerHeight: function (ownerContext, height) {
38
+ var me = this,
39
+ innerHeight = height - me.measureLabelErrorHeight(ownerContext) -
40
+ ownerContext.bodyCellContext.getPaddingInfo().height;
41
+
42
+
43
+ if (Ext.isNumber(innerHeight)) {
44
+ ownerContext.textAreaContext.setHeight(innerHeight);
45
+ ownerContext.editorContext.setHeight(innerHeight);
46
+ } else {
47
+ me.done = false;
48
+ }
49
+ },
50
+
51
+ publishInnerWidth: function (ownerContext, width) {
52
+ var me = this;
53
+
54
+ if (Ext.isNumber(width)) {
55
+ ownerContext.textAreaContext.setWidth(width);
56
+ ownerContext.editorContext.setWidth(width);
57
+ } else {
58
+ me.done = false;
59
+ }
60
+ }
61
+ });
62
+
63
+ /**
64
+ * @class Ext.ux.form.field.CodeMirror
65
+ * @extends Ext.form.field.Base
66
+ * @author Adrian Teodorescu (ateodorescu@gmail.com; http://www.mzsolutions.eu)
67
+ * @docauthor Adrian Teodorescu (ateodorescu@gmail.com; http://www.mzsolutions.eu)
68
+ * @license [MIT][1]
69
+ *
70
+ * @version 1.5
71
+ *
72
+ *
73
+ * Provides a [CodeMirror][2] component wrapper for Sencha. The supported and tested CodeMirror versions are 2.2, 2.3 and 2.4.
74
+ * The component works with Extjs 4.1.x.
75
+ *
76
+ * [1]: http://www.mzsolutions.eu/extjs/license.txt
77
+ * [2]: http://codemirror.net/
78
+ *
79
+ *
80
+ * The editor's toolbar buttons have tooltips defined in the {@link #buttonTips} property, but they are not
81
+ * enabled by default unless the global {@link Ext.tip.QuickTipManager} singleton is {@link Ext.tip.QuickTipManager#init initialized}.
82
+ *
83
+ * If you include the modes script files by yourself then ignore the {@link #modes} property.
84
+ * If you also include the extensions script files by yourself then ignore the {@link #extensions} property.
85
+ *
86
+ *
87
+ *
88
+ #Example usage:#
89
+
90
+ {@img Ext.ux.form.field.CodeMirror.png Ext.ux.form.field.CodeMirror component}
91
+
92
+ var form = Ext.create('Ext.form.Panel', {
93
+ title: 'Function info',
94
+ bodyPadding: 10,
95
+ width: 500,
96
+ renderTo: Ext.getBody(),
97
+ items: [{
98
+ xtype: 'textfield',
99
+ name: 'name',
100
+ anchor: '100%',
101
+ fieldLabel: 'Name',
102
+ allowBlank: false // requires a non-empty value
103
+ }, {
104
+ xtype: 'codemirror',
105
+ name: 'function',
106
+ fieldLabel: 'Code',
107
+ anchor: '100%'
108
+ }],
109
+
110
+ buttons: [{
111
+ text: 'Save',
112
+ handler: function(){
113
+ if(form.getForm().isValid()){
114
+ alert(form.getForm().getValues().function);
115
+ }
116
+ }
117
+ }]
118
+ });
119
+
120
+
121
+ #Plugin example for the CodeMirror component:#
122
+
123
+ Ext.define('Ext.ux.form.plugin.CodeMirror', {
124
+ mixins: {
125
+ observable: 'Ext.util.Observable'
126
+ },
127
+ alternateClassName: 'Ext.form.plugin.CodeMirror',
128
+ requires: [
129
+ 'Ext.tip.QuickTipManager',
130
+ 'Ext.ux.form.field.CodeMirror'
131
+ ],
132
+
133
+ constructor: function(config) {
134
+ Ext.apply(this, config);
135
+ },
136
+
137
+ init: function(codemirror){
138
+ var me = this;
139
+ me.codemirror = codemirror;
140
+ me.mon(codemirror, 'initialize', me.onInitialize, me);
141
+ },
142
+
143
+ onInitialize: function(){
144
+ var me = this, undef,
145
+ items = [],
146
+ baseCSSPrefix = Ext.baseCSSPrefix,
147
+ tipsEnabled = Ext.tip.QuickTipManager && Ext.tip.QuickTipManager.isEnabled();
148
+
149
+ function btn(id, toggle, handler){
150
+ return {
151
+ itemId : id,
152
+ cls : baseCSSPrefix + 'btn-icon',
153
+ iconCls: baseCSSPrefix + 'edit-'+id,
154
+ enableToggle:toggle !== false,
155
+ scope: me,
156
+ handler:handler||me.relayBtnCmd,
157
+ clickEvent:'mousedown',
158
+ tooltip: tipsEnabled ? me.buttonTips[id] || undef : undef,
159
+ overflowText: me.buttonTips[id].title || undef,
160
+ tabIndex:-1
161
+ };
162
+ }
163
+
164
+ items.push(btn('test', false));
165
+ if(items.length > 0){
166
+ me.codemirror.getToolbar().add(items);
167
+ }
168
+ },
169
+
170
+ relayBtnCmd: function(btn){
171
+ alert('test');
172
+ },
173
+
174
+ buttonTips : {
175
+ test : {
176
+ title: 'Test',
177
+ text: 'Test button.',
178
+ cls: Ext.baseCSSPrefix + 'html-editor-tip'
179
+ }
180
+ }
181
+
182
+ });
183
+
184
+
185
+ */
186
+ Ext.define('Ext.ux.form.field.CodeMirror', {
187
+ extend: 'Ext.Component',
188
+ mixins: {
189
+ labelable: 'Ext.form.Labelable',
190
+ field: 'Ext.form.field.Field'
191
+ },
192
+ alias: 'widget.codemirror',
193
+ alternateClassName: 'Ext.form.CodeMirror',
194
+ requires: [
195
+ 'Ext.tip.QuickTipManager',
196
+ 'Ext.util.Format',
197
+ 'Ext.ux.layout.component.field.CodeMirror'
198
+ ],
199
+
200
+ childEls: [
201
+ 'editorEl', 'textareaEl'
202
+ ],
203
+
204
+ fieldSubTpl: [
205
+ '<textarea id="{cmpId}-textareaEl" name="{name}" tabIndex="-1" class="{textareaCls}" ',
206
+ 'style="{size}" autocomplete="off"></textarea>',
207
+ '<div id="{cmpId}-editorEl" class="{editorCls}" name="{editorName}" style="{size}"></div>',
208
+ {
209
+ disableFormats: true
210
+ }
211
+ ],
212
+
213
+ componentLayout: 'codemirror',
214
+
215
+ editorWrapCls: Ext.baseCSSPrefix + 'html-editor-wrap',
216
+
217
+ maskOnDisable: true,
218
+
219
+ afterBodyEl: '</div>',
220
+
221
+ /**
222
+ * @cfg {String} mode The default mode to use when the editor is initialized. When not given, this will default to the first mode that was loaded.
223
+ * It may be a string, which either simply names the mode or is a MIME type associated with the mode. Alternatively,
224
+ * it may be an object containing configuration options for the mode, with a name property that names the mode
225
+ * (for example {name: "javascript", json: true}). The demo pages for each mode contain information about what
226
+ * configuration parameters the mode supports.
227
+ */
228
+ mode: 'text/plain',
229
+
230
+ /**
231
+ * @cfg {Boolean} showAutoIndent Enable auto indent button for indenting the selected range
232
+ */
233
+ showAutoIndent: true,
234
+
235
+ /**
236
+ * @cfg {Boolean} showLineNumbers Enable line numbers button in the toolbar.
237
+ */
238
+ showLineNumbers: true,
239
+
240
+ /**
241
+ * @cfg {Boolean} enableMatchBrackets Force matching-bracket-highlighting to happen
242
+ */
243
+ enableMatchBrackets: true,
244
+
245
+ /**
246
+ * @cfg {Boolean} enableElectricChars Configures whether the editor should re-indent the current line when a character is typed
247
+ * that might change its proper indentation (only works if the mode supports indentation).
248
+ */
249
+ enableElectricChars: false,
250
+
251
+ /**
252
+ * @cfg {Boolean} enableIndentWithTabs Whether, when indenting, the first N*tabSize spaces should be replaced by N tabs.
253
+ */
254
+ enableIndentWithTabs: true,
255
+
256
+ /**
257
+ * @cfg {Boolean} enableSmartIndent Whether to use the context-sensitive indentation that the mode provides (or just indent the same as the line before).
258
+ */
259
+ enableSmartIndent: true,
260
+
261
+ /**
262
+ * @cfg {Boolean} enableLineWrapping Whether CodeMirror should scroll or wrap for long lines.
263
+ */
264
+ enableLineWrapping: false,
265
+
266
+ /**
267
+ * @cfg {Boolean} enableLineNumbers Whether to show line numbers to the left of the editor.
268
+ */
269
+ enableLineNumbers: true,
270
+
271
+ /**
272
+ * @cfg {Boolean} enableGutter Can be used to force a 'gutter' (empty space on the left of the editor) to be shown even
273
+ * when no line numbers are active. This is useful for setting markers.
274
+ */
275
+ enableGutter: true,
276
+
277
+ /**
278
+ * @cfg {Boolean} enableFixedGutter When enabled (off by default), this will make the gutter stay visible when the
279
+ * document is scrolled horizontally.
280
+ */
281
+ enableFixedGutter: false,
282
+
283
+ /**
284
+ * @cfg {Number} firstLineNumber At which number to start counting lines.
285
+ */
286
+ firstLineNumber: 1,
287
+
288
+ /**
289
+ * @cfg {Boolean} readOnly <tt>true</tt> to mark the field as readOnly.
290
+ */
291
+ readOnly : false,
292
+
293
+ /**
294
+ * @cfg {Number} pollInterval Indicates how quickly (miliseconds) CodeMirror should poll its input textarea for changes.
295
+ * Most input is captured by events, but some things, like IME input on some browsers, doesn't generate events
296
+ * that allow CodeMirror to properly detect it. Thus, it polls.
297
+ */
298
+ pollInterval: 100,
299
+
300
+ /**
301
+ * @cfg {Number} indentUnit How many spaces a block (whatever that means in the edited language) should be indented.
302
+ */
303
+ indentUnit: 4,
304
+
305
+ /**
306
+ * @cfg {Number} tabSize The width of a tab character.
307
+ */
308
+ tabSize: 4,
309
+
310
+ /**
311
+ * @cfg {String} theme The theme to style the editor with. You must make sure the CSS file defining the corresponding
312
+ * .cm-s-[name] styles is loaded (see the theme directory in the distribution). The default is "default", for which
313
+ * colors are included in codemirror.css. It is possible to use multiple theming classes at once—for example
314
+ * "foo bar" will assign both the cm-s-foo and the cm-s-bar classes to the editor.
315
+ */
316
+ theme: 'default',
317
+
318
+ /**
319
+ * @property {String} pathModes Path to the modes folder to dinamically load the required scripts. You could also
320
+ * include all your required modes in a big script file and this path will be ignored.
321
+ * Do not fill in the trailing slash.
322
+ */
323
+ pathModes: 'mode',
324
+
325
+ /**
326
+ * @property {String} pathExtensions Path to the extensions folder to dinamically load the required scripts. You could also
327
+ * include all your required extensions in a big script file and this path will be ignored.
328
+ * Do not fill in the trailing slash.
329
+ */
330
+ pathExtensions: 'lib/util',
331
+
332
+ /**
333
+ * @property {Array} extensions Define here extensions script dependencies; This is used by toolbar buttons to automatically
334
+ * load the scripts before using an extension.
335
+ */
336
+ extensions:{
337
+ format: {
338
+ dependencies: ['formatting.js']
339
+ }
340
+ },
341
+
342
+ scriptsLoaded: [],
343
+ lastMode: '',
344
+
345
+ initComponent : function(){
346
+ var me = this;
347
+
348
+ me.addEvents(
349
+ /**
350
+ * @event initialize
351
+ * Fires when the editor is fully initialized (including the iframe)
352
+ * @param {Ext.ux.form.field.CodeMirror} this
353
+ */
354
+ 'initialize',
355
+ /**
356
+ * @event activate
357
+ * Fires when the editor is first receives the focus. Any insertion must wait
358
+ * until after this event.
359
+ * @param {Ext.ux.form.field.CodeMirror} this
360
+ */
361
+ 'activate',
362
+ /**
363
+ * @event deactivate
364
+ * Fires when the editor looses the focus.
365
+ * @param {Ext.ux.form.field.CodeMirror} this
366
+ */
367
+ 'deactivate',
368
+ /**
369
+ * @event change
370
+ * Fires when the content of the editor is changed.
371
+ * @param {Ext.ux.form.field.CodeMirror} this
372
+ * @param {String} newValue New value
373
+ * @param {String} oldValue Old value
374
+ * @param {Array} options
375
+ */
376
+ 'change',
377
+ /**
378
+ * @event modechanged
379
+ * Fires when the editor mode changes.
380
+ * @param {Ext.ux.form.field.CodeMirror} this
381
+ * @param {String} newMode New mode
382
+ * @param {String} oldMode Old mode
383
+ */
384
+ 'modechanged',
385
+ /**
386
+ * @event cursoractivity
387
+ * Fires when the cursor or selection moves, or any change is made to the editor content.
388
+ * @param {Ext.ux.form.field.CodeMirror} this
389
+ */
390
+ 'cursoractivity',
391
+ /**
392
+ * @event gutterclick
393
+ * Fires whenever the editor gutter (the line-number area) is clicked.
394
+ * @param {Ext.ux.form.field.CodeMirror} this
395
+ * @param {Number} lineNumber Zero-based number of the line that was clicked
396
+ * @param {Object} event The raw mousedown event
397
+ */
398
+ 'gutterclick',
399
+ /**
400
+ * @event scroll
401
+ * Fires whenever the editor is scrolled.
402
+ * @param {Ext.ux.form.field.CodeMirror} this
403
+ */
404
+ 'scroll',
405
+ /**
406
+ * @event highlightcomplete
407
+ * Fires whenever the editor's content has been fully highlighted.
408
+ * @param {Ext.ux.form.field.CodeMirror} this
409
+ */
410
+ 'highlightcomplete',
411
+ /**
412
+ * @event update
413
+ * Fires whenever CodeMirror updates its DOM display.
414
+ * @param {Ext.ux.form.field.CodeMirror} this
415
+ */
416
+ 'update',
417
+ /**
418
+ * @event keyevent
419
+ * Fires on eery keydown, keyup, and keypress event that CodeMirror captures.
420
+ * @param {Ext.ux.form.field.CodeMirror} this
421
+ * @param {Object} event This key event is pretty much the raw key event, except that a stop() method is always
422
+ * added to it. You could feed it to, for example, jQuery.Event to further normalize it. This function can inspect
423
+ * the key event, and handle it if it wants to. It may return true to tell CodeMirror to ignore the event.
424
+ * Be wary that, on some browsers, stopping a keydown does not stop the keypress from firing, whereas on others
425
+ * it does. If you respond to an event, you should probably inspect its type property and only do something when
426
+ * it is keydown (or keypress for actions that need character data).
427
+ */
428
+ 'keyevent'
429
+ );
430
+
431
+
432
+ me.callParent(arguments);
433
+
434
+ me.initLabelable();
435
+ me.initField();
436
+
437
+ /*
438
+ Fix resize issues as suggested by user koblass on the Extjs forums
439
+ http://www.sencha.com/forum/showthread.php?167047-Ext.ux.form.field.CodeMirror-for-Ext-4.x&p=860535&viewfull=1#post860535
440
+ */
441
+ me.on('resize', function() {
442
+ if (me.editor) {
443
+ me.editor.refresh();
444
+ }
445
+ }, me);
446
+
447
+ },
448
+
449
+ getMaskTarget: function(){
450
+ return this.bodyEl;
451
+ },
452
+
453
+ /**
454
+ * @private override
455
+ */
456
+ getSubTplData: function() {
457
+ var cssPrefix = Ext.baseCSSPrefix;
458
+ return {
459
+ $comp : this,
460
+ cmpId : this.id,
461
+ id : this.getInputId(),
462
+ toolbarWrapCls : cssPrefix + 'html-editor-tb',
463
+ textareaCls : cssPrefix + 'hidden',
464
+ editorCls : cssPrefix + 'codemirror',
465
+ editorName : Ext.id(),
466
+ //size : 'height:100px;width:100%'
467
+ // PennyMac: setting height to 100%.
468
+ size : 'height:100%;width:100%',
469
+ };
470
+ },
471
+
472
+ getSubTplMarkup: function() {
473
+ return this.getTpl('fieldSubTpl').apply(this.getSubTplData());
474
+ },
475
+
476
+ finishRenderChildren: function () {
477
+ this.callParent();
478
+ },
479
+
480
+ /**
481
+ * @private override
482
+ */
483
+ onRender: function() {
484
+ var me = this;
485
+
486
+ me.callParent(arguments);
487
+ me.inputEl = me.editorEl;
488
+
489
+ me.disableItems(true);
490
+ me.initEditor();
491
+
492
+ me.rendered = true;
493
+ },
494
+
495
+ initRenderTpl: function() {
496
+ var me = this;
497
+ if (!me.hasOwnProperty('renderTpl')) {
498
+ me.renderTpl = me.getTpl('labelableRenderTpl');
499
+ }
500
+ return me.callParent();
501
+ },
502
+
503
+ initRenderData: function() {
504
+ this.beforeSubTpl = '<div class="' + this.editorWrapCls + '">';
505
+ return Ext.applyIf(this.callParent(), this.getLabelableRenderData());
506
+ },
507
+
508
+ /**
509
+ * @private override
510
+ */
511
+ initEditor : function(){
512
+ var me = this,
513
+ mode = "text/x-delorean";
514
+
515
+ // if no mode is loaded we could get an error like "Object #<Object> has no method 'startState'"
516
+ // search mime to find script dependencies
517
+ var item = me.getMime(me.mode);
518
+ if(item) {
519
+ mode = me.getMimeMode(me.mode);
520
+ if(!mode){
521
+ mode = "text/x-delorean";
522
+ }
523
+ }
524
+
525
+ me.editor = CodeMirror(me.editorEl, {
526
+ matchBrackets: me.enableMatchBrackets,
527
+ electricChars: me.enableElectricChars,
528
+ autoClearEmptyLines:true,
529
+ value: me.rawValue,
530
+ indentUnit: me.indentUnit,
531
+ smartIndent: me.enableSmartIndent,
532
+ indentWithTabs: me.indentWithTabs,
533
+ pollInterval: me.pollInterval,
534
+ lineNumbers: me.enableLineNumbers,
535
+ lineWrapping: me.enableLineWrapping,
536
+ firstLineNumber: me.firstLineNumber,
537
+ tabSize: me.tabSize,
538
+ gutter: me.enableGutter,
539
+ fixedGutter: me.enableFixedGutter,
540
+ theme: me.theme,
541
+ mode: mode,
542
+ onChange: function(editor, tc){
543
+ me.checkChange();
544
+ //me.fireEvent('change', me, tc.from, tc.to, tc.text, tc.next || null);
545
+ },
546
+ onCursorActivity: function(editor){
547
+ me.fireEvent('cursoractivity', me);
548
+ },
549
+ onGutterClick: function(editor, line, event){
550
+ me.fireEvent('gutterclick', me, line, event);
551
+ },
552
+ onFocus: function(editor){
553
+ me.fireEvent('activate', me);
554
+ },
555
+ onBlur: function(editor){
556
+ me.fireEvent('deactivate', me);
557
+ },
558
+ onScroll: function(editor){
559
+ me.fireEvent('scroll', me);
560
+ },
561
+ onHighlightComplete: function(editor){
562
+ me.fireEvent('highlightcomplete', me);
563
+ },
564
+ onUpdate: function(editor){
565
+ me.fireEvent('update', me);
566
+ },
567
+ onKeyEvent: function(editor, event){
568
+ event.cancelBubble = true; // fix suggested by koblass user on Sencha forums (http://www.sencha.com/forum/showthread.php?167047-Ext.ux.form.field.CodeMirror-for-Ext-4.x&p=862029&viewfull=1#post862029)
569
+ me.fireEvent('keyevent', me, event);
570
+ }
571
+ });
572
+ //me.editor.setValue(me.rawValue);
573
+ me.setMode(me.mode);
574
+ me.setReadOnly(me.readOnly);
575
+ me.fireEvent('initialize', me);
576
+
577
+ // change the codemirror css
578
+ var css = Ext.util.CSS.getRule('.CodeMirror');
579
+ if(css){
580
+ css.style.height = '100%';
581
+ css.style.position = 'relative';
582
+ css.style.overflow = 'hidden';
583
+ }
584
+ var css = Ext.util.CSS.getRule('.CodeMirror-Scroll');
585
+ if(css){
586
+ css.style.height = '100%';
587
+ }
588
+
589
+ // PennyMac: align the body to the top. Otherwise it ends up
590
+ // in the center of the enclosing table.
591
+ var el = document.getElementById(me.bodyEl.id);
592
+ el.setAttribute("valign", "top");
593
+ },
594
+
595
+ /**
596
+ * @private
597
+ */
598
+ relayBtnCmd: function(btn){
599
+ this.relayCmd(btn.getItemId());
600
+ },
601
+
602
+ /**
603
+ * @private
604
+ */
605
+ relayCmd: function(cmd){
606
+ Ext.defer(function() {
607
+ var me = this;
608
+ me.editor.focus();
609
+ switch(cmd){
610
+ // auto formatting
611
+ case 'justifycenter':
612
+ if(!CodeMirror.extensions.autoIndentRange){
613
+ me.loadDependencies(me.extensions.format, me.pathExtensions, me.doIndentSelection, me);
614
+ }else{
615
+ me.doIndentSelection();
616
+ }
617
+ break;
618
+
619
+ // line numbers
620
+ case 'insertorderedlist':
621
+ me.doChangeLineNumbers();
622
+ break;
623
+ }
624
+ }, 10, this);
625
+ },
626
+
627
+ /**
628
+ * @private
629
+ * Reload all CodeMirror extensions for the current instance;
630
+ *
631
+ */
632
+ reloadExtentions: function(){
633
+ var me = this;
634
+
635
+ for (var ext in CodeMirror.extensions)
636
+ if (CodeMirror.extensions.propertyIsEnumerable(ext) &&
637
+ !me.editor.propertyIsEnumerable(ext))
638
+ me.editor[ext] = CodeMirror.extensions[ext];
639
+ },
640
+
641
+ doChangeLineNumbers: function(){
642
+ var me = this;
643
+
644
+ me.enableLineNumbers = !me.enableLineNumbers;
645
+ me.editor.setOption('lineNumbers', me.enableLineNumbers);
646
+ },
647
+
648
+ /**
649
+ * @private
650
+ */
651
+ doIndentSelection: function(){
652
+ var me = this;
653
+
654
+ me.reloadExtentions();
655
+
656
+ try{
657
+ var range = { from: me.editor.getCursor(true), to: me.editor.getCursor(false) };
658
+ me.editor.autoIndentRange(range.from, range.to);
659
+ }catch(err){}
660
+ },
661
+
662
+ modes: [
663
+ {
664
+ mime: ["text/x-delorean"],
665
+ dependencies: []
666
+ },
667
+ ],
668
+
669
+ /**
670
+ * @private
671
+ */
672
+ getMime: function(mime){
673
+ var me = this, item, found = false;
674
+
675
+ for(var i=0;i<me.modes.length;i++){
676
+ item = me.modes[i];
677
+ if(Ext.isArray(item.mime)){
678
+ if(Ext.Array.contains(item.mime, mime)){
679
+ found = true;
680
+ break;
681
+ }
682
+ }else{
683
+ if(item == mime){
684
+ found = true;
685
+ break;
686
+ }
687
+ }
688
+ }
689
+ if(found)
690
+ return item;
691
+ else
692
+ return null;
693
+ },
694
+
695
+ /**
696
+ * @private
697
+ */
698
+ loadDependencies: function(item, path, handler, scope){
699
+ var me = this;
700
+
701
+ me.scripts = [];
702
+ me.scriptIndex = -1;
703
+
704
+ // load the dependencies
705
+ for(var i=0; i < item.dependencies.length; i++){
706
+ if(!Ext.Array.contains(me.scriptsLoaded, path + '/' + item.dependencies[i])){
707
+ var options = {
708
+ url: path + '/' + item.dependencies[i],
709
+ index: ++me.scriptIndex,
710
+ onLoad: function(options){
711
+ var ok = true;
712
+ for(j=0; j < me.scripts.length; j++){
713
+ if(me.scripts[j].called) {// this event could be raised before one script if fetched
714
+ ok = ok && me.scripts[j].success;
715
+ if(me.scripts[j].success && !Ext.Array.contains(me.scriptsLoaded, me.scripts[j].url)){
716
+ me.scriptsLoaded.push(me.scripts[j].url);
717
+ }
718
+ }else{
719
+ ok = false;
720
+ }
721
+ }
722
+ if(ok){
723
+ handler.call(scope || me.editor);
724
+ }
725
+ }
726
+ };
727
+
728
+ me.scripts[me.scriptIndex] = {
729
+ url: options.url,
730
+ success: true,
731
+ called: false,
732
+ options: options,
733
+ onLoad: options.onLoad || Ext.emptyFn,
734
+ onError: options.onError || Ext.emptyFn
735
+ };
736
+ }
737
+ }
738
+ for(var i=0; i < me.scripts.length; i++){
739
+ me.loadScript(me.scripts[i].options);
740
+ }
741
+ },
742
+
743
+ /**
744
+ * @private
745
+ */
746
+ loadScript: function(options){
747
+ var me = this;
748
+ Ext.Ajax.request({
749
+ url: options.url,
750
+ scriptIndex: options.index,
751
+ success: function(response, options) {
752
+ var script = 'Ext.getCmp("' + this.id + '").scripts[' + options.scriptIndex + ']';
753
+ window.setTimeout('try { ' + response.responseText + ' } catch(e) { '+script+'.success = false; '+script+'.onError('+script+'.options, e); }; ' + script + '.called = true; if ('+script+'.success) '+script+'.onLoad('+script+'.options);', 0);
754
+ },
755
+ failure: function(response, options) {
756
+ var script = this.scripts[options.scriptIndex];
757
+ script.success = false;
758
+ script.called = true;
759
+ script.onError(script.options, response.status);
760
+ },
761
+ scope: me
762
+ });
763
+ },
764
+
765
+ /**
766
+ * @private
767
+ * Return mode depending on the mime; If the mime is not loaded then return null
768
+ *
769
+ * @param mime
770
+ */
771
+ getMimeMode: function(mime){
772
+ var mode = null;
773
+ var mimes = CodeMirror.listMIMEs();
774
+ for(var i=0; i<mimes.length; i++){
775
+ if(mimes[i].mime == mime){
776
+ mode = mimes[i].mode;
777
+ if(typeof mode == "object")
778
+ mode = mode.name;
779
+ break;
780
+ }
781
+ }
782
+ return mode;
783
+ },
784
+
785
+ /**
786
+ * Change the CodeMirror mode to the specified mime.
787
+ *
788
+ * @param {String} mime The MIME value according to the CodeMirror documentation
789
+ */
790
+ setMode: function(mime){
791
+ var me = this,
792
+ found = false;
793
+ // search mime to find script dependencies
794
+ var item = me.getMime(mime);
795
+
796
+ if(!item) {
797
+ // mime not found
798
+ return;
799
+ }
800
+
801
+ var mode = me.getMimeMode(mime);
802
+
803
+ if(!mode){
804
+ me.loadDependencies(item, me.pathModes, function(){
805
+ var mode = me.getMimeMode(mime);
806
+ if(typeof mode == "string")
807
+ me.editor.setOption('mode', mime);
808
+ else
809
+ me.editor.setOption('mode', mode);
810
+ });
811
+ }else{
812
+ if(typeof mode == "string")
813
+ me.editor.setOption('mode', mime);
814
+ else
815
+ me.editor.setOption('mode', mode);
816
+ }
817
+
818
+ if(me.modesSelect){
819
+ me.modesSelect.dom.value = mime;
820
+ }
821
+ try{
822
+ me.fireEvent('modechanged', me, mime, me.lastMode);
823
+ me.lastMode = mime;
824
+ }catch(err){}
825
+ },
826
+
827
+ /**
828
+ * Set the editor as read only
829
+ *
830
+ * @param {Boolean} readOnly
831
+ */
832
+ setReadOnly: function(readOnly) {
833
+ var me = this;
834
+
835
+ if(me.editor){
836
+ me.editor.setOption('readOnly', readOnly);
837
+ me.disableItems(readOnly);
838
+ }
839
+ },
840
+
841
+ onDisable: function() {
842
+ this.bodyEl.mask();
843
+ this.callParent(arguments);
844
+ },
845
+
846
+ onEnable: function() {
847
+ this.bodyEl.unmask();
848
+ this.callParent(arguments);
849
+ },
850
+
851
+ disableItems: function(disabled) {
852
+ },
853
+
854
+ /**
855
+ * Sets a data value into the field and runs the change detection.
856
+ * @param {Mixed} value The value to set
857
+ * @return {Ext.ux.form.field.CodeMirror} this
858
+ */
859
+ setValue: function(value){
860
+ var me = this;
861
+
862
+ me.mixins.field.setValue.call(me, value);
863
+ me.rawValue = value;
864
+ if(me.editor)
865
+ me.editor.setValue(value);
866
+ return me;
867
+ },
868
+
869
+ /**
870
+ * Return submit value to the owner form.
871
+ * @return {Mixed} The field value
872
+ */
873
+ getSubmitValue: function(){
874
+ var me = this;
875
+ return me.getValue();
876
+ },
877
+
878
+ /**
879
+ * Return the value of the CodeMirror editor
880
+ * @return {Mixed} The field value
881
+ */
882
+ getValue: function(){
883
+ var me = this;
884
+
885
+ if(me.editor)
886
+ return me.editor.getValue();
887
+ else
888
+ return null;
889
+ },
890
+
891
+ /**
892
+ * @private
893
+ */
894
+ onDestroy: function(){
895
+ var me = this;
896
+ if(me.rendered){
897
+ try {
898
+ Ext.EventManager.removeAll(me.editor);
899
+ for (prop in me.editor) {
900
+ if (me.editor.hasOwnProperty(prop)) {
901
+ delete me.editor[prop];
902
+ }
903
+ }
904
+ }catch(e){}
905
+ }
906
+ me.callParent();
907
+ },
908
+
909
+ });