swagr 0.0.7 → 0.0.8

Sign up to get free protection for your applications and to get access to all the features.
Files changed (359) hide show
  1. data/bin/swagr +15 -0
  2. data/examples/examples01/app.rb +6 -2
  3. data/examples/examples01/coffee/data_port.coffee +2 -0
  4. data/examples/examples01/static/css/codemirror.css +1247 -0
  5. data/examples/examples01/static/js/codemirror-compressed-3-0.js +5 -0
  6. data/examples/examples01/static/js/codemirror/keymap/emacs.js +30 -0
  7. data/examples/examples01/static/js/codemirror/keymap/vim.js +2298 -0
  8. data/examples/examples01/static/js/codemirror/lib/codemirror.css +239 -0
  9. data/examples/examples01/static/js/codemirror/lib/codemirror.js +4553 -0
  10. data/examples/examples01/static/js/codemirror/lib/util/closetag.js +85 -0
  11. data/examples/examples01/static/js/codemirror/lib/util/colorize.js +29 -0
  12. data/examples/examples01/static/js/codemirror/lib/util/continuecomment.js +36 -0
  13. data/examples/examples01/static/js/codemirror/lib/util/continuelist.js +28 -0
  14. data/examples/examples01/static/js/codemirror/lib/util/dialog.css +32 -0
  15. data/examples/examples01/static/js/codemirror/lib/util/dialog.js +75 -0
  16. data/examples/examples01/static/js/codemirror/lib/util/foldcode.js +182 -0
  17. data/examples/examples01/static/js/codemirror/lib/util/formatting.js +108 -0
  18. data/examples/examples01/static/js/codemirror/lib/util/javascript-hint.js +137 -0
  19. data/examples/examples01/static/js/codemirror/lib/util/loadmode.js +51 -0
  20. data/examples/examples01/static/js/codemirror/lib/util/match-highlighter.js +46 -0
  21. data/examples/examples01/static/js/codemirror/lib/util/matchbrackets.js +63 -0
  22. data/examples/examples01/static/js/codemirror/lib/util/multiplex.js +95 -0
  23. data/examples/examples01/static/js/codemirror/lib/util/overlay.js +59 -0
  24. data/examples/examples01/static/js/codemirror/lib/util/pig-hint.js +117 -0
  25. data/examples/examples01/static/js/codemirror/lib/util/runmode-standalone.js +90 -0
  26. data/examples/examples01/static/js/codemirror/lib/util/runmode.js +52 -0
  27. data/examples/examples01/static/js/codemirror/lib/util/search.js +119 -0
  28. data/examples/examples01/static/js/codemirror/lib/util/searchcursor.js +119 -0
  29. data/examples/examples01/static/js/codemirror/lib/util/simple-hint.css +16 -0
  30. data/examples/examples01/static/js/codemirror/lib/util/simple-hint.js +102 -0
  31. data/examples/examples01/static/js/codemirror/lib/util/xml-hint.js +131 -0
  32. data/examples/examples01/static/js/codemirror/mode/clike/clike.js +300 -0
  33. data/examples/examples01/static/js/codemirror/mode/clike/index.html +103 -0
  34. data/examples/examples01/static/js/codemirror/mode/clike/scala.html +767 -0
  35. data/examples/examples01/static/js/codemirror/mode/clojure/clojure.js +206 -0
  36. data/examples/examples01/static/js/codemirror/mode/clojure/index.html +67 -0
  37. data/examples/examples01/static/js/codemirror/mode/coffeescript/LICENSE +22 -0
  38. data/examples/examples01/static/js/codemirror/mode/coffeescript/coffeescript.js +346 -0
  39. data/examples/examples01/static/js/codemirror/mode/coffeescript/index.html +728 -0
  40. data/examples/examples01/static/js/codemirror/mode/commonlisp/commonlisp.js +101 -0
  41. data/examples/examples01/static/js/codemirror/mode/commonlisp/index.html +165 -0
  42. data/examples/examples01/static/js/codemirror/mode/css/css.js +465 -0
  43. data/examples/examples01/static/js/codemirror/mode/css/index.html +58 -0
  44. data/examples/examples01/static/js/codemirror/mode/css/test.js +501 -0
  45. data/examples/examples01/static/js/codemirror/mode/diff/diff.js +32 -0
  46. data/examples/examples01/static/js/codemirror/mode/diff/index.html +105 -0
  47. data/examples/examples01/static/js/codemirror/mode/ecl/ecl.js +192 -0
  48. data/examples/examples01/static/js/codemirror/mode/ecl/index.html +39 -0
  49. data/examples/examples01/static/js/codemirror/mode/erlang/erlang.js +463 -0
  50. data/examples/examples01/static/js/codemirror/mode/erlang/index.html +64 -0
  51. data/examples/examples01/static/js/codemirror/mode/gfm/gfm.js +94 -0
  52. data/examples/examples01/static/js/codemirror/mode/gfm/index.html +70 -0
  53. data/examples/examples01/static/js/codemirror/mode/gfm/test.js +225 -0
  54. data/examples/examples01/static/js/codemirror/mode/go/go.js +165 -0
  55. data/examples/examples01/static/js/codemirror/mode/go/index.html +74 -0
  56. data/examples/examples01/static/js/codemirror/mode/groovy/groovy.js +210 -0
  57. data/examples/examples01/static/js/codemirror/mode/groovy/index.html +73 -0
  58. data/examples/examples01/static/js/codemirror/mode/haskell/haskell.js +242 -0
  59. data/examples/examples01/static/js/codemirror/mode/haskell/index.html +62 -0
  60. data/examples/examples01/static/js/codemirror/mode/haxe/haxe.js +429 -0
  61. data/examples/examples01/static/js/codemirror/mode/haxe/index.html +90 -0
  62. data/examples/examples01/static/js/codemirror/mode/htmlembedded/htmlembedded.js +73 -0
  63. data/examples/examples01/static/js/codemirror/mode/htmlembedded/index.html +49 -0
  64. data/examples/examples01/static/js/codemirror/mode/htmlmixed/htmlmixed.js +84 -0
  65. data/examples/examples01/static/js/codemirror/mode/htmlmixed/index.html +52 -0
  66. data/examples/examples01/static/js/codemirror/mode/http/http.js +98 -0
  67. data/examples/examples01/static/js/codemirror/mode/http/index.html +32 -0
  68. data/examples/examples01/static/js/codemirror/mode/javascript/index.html +88 -0
  69. data/examples/examples01/static/js/codemirror/mode/javascript/javascript.js +411 -0
  70. data/examples/examples01/static/js/codemirror/mode/javascript/typescript.html +48 -0
  71. data/examples/examples01/static/js/codemirror/mode/jinja2/index.html +38 -0
  72. data/examples/examples01/static/js/codemirror/mode/jinja2/jinja2.js +42 -0
  73. data/examples/examples01/static/js/codemirror/mode/less/index.html +741 -0
  74. data/examples/examples01/static/js/codemirror/mode/less/less.js +266 -0
  75. data/examples/examples01/static/js/codemirror/mode/lua/index.html +74 -0
  76. data/examples/examples01/static/js/codemirror/mode/lua/lua.js +140 -0
  77. data/examples/examples01/static/js/codemirror/mode/markdown/index.html +344 -0
  78. data/examples/examples01/static/js/codemirror/mode/markdown/markdown.js +474 -0
  79. data/examples/examples01/static/js/codemirror/mode/markdown/test.js +1266 -0
  80. data/examples/examples01/static/js/codemirror/mode/mysql/index.html +41 -0
  81. data/examples/examples01/static/js/codemirror/mode/mysql/mysql.js +203 -0
  82. data/examples/examples01/static/js/codemirror/mode/ntriples/index.html +33 -0
  83. data/examples/examples01/static/js/codemirror/mode/ntriples/ntriples.js +170 -0
  84. data/examples/examples01/static/js/codemirror/mode/ocaml/index.html +131 -0
  85. data/examples/examples01/static/js/codemirror/mode/ocaml/ocaml.js +113 -0
  86. data/examples/examples01/static/js/codemirror/mode/pascal/LICENSE +7 -0
  87. data/examples/examples01/static/js/codemirror/mode/pascal/index.html +48 -0
  88. data/examples/examples01/static/js/codemirror/mode/pascal/pascal.js +94 -0
  89. data/examples/examples01/static/js/codemirror/mode/perl/LICENSE +19 -0
  90. data/examples/examples01/static/js/codemirror/mode/perl/index.html +62 -0
  91. data/examples/examples01/static/js/codemirror/mode/perl/perl.js +816 -0
  92. data/examples/examples01/static/js/codemirror/mode/php/index.html +51 -0
  93. data/examples/examples01/static/js/codemirror/mode/php/php.js +129 -0
  94. data/examples/examples01/static/js/codemirror/mode/pig/index.html +42 -0
  95. data/examples/examples01/static/js/codemirror/mode/pig/pig.js +171 -0
  96. data/examples/examples01/static/js/codemirror/mode/plsql/index.html +62 -0
  97. data/examples/examples01/static/js/codemirror/mode/plsql/plsql.js +216 -0
  98. data/examples/examples01/static/js/codemirror/mode/properties/index.html +41 -0
  99. data/examples/examples01/static/js/codemirror/mode/properties/properties.js +63 -0
  100. data/examples/examples01/static/js/codemirror/mode/python/LICENSE.txt +21 -0
  101. data/examples/examples01/static/js/codemirror/mode/python/index.html +124 -0
  102. data/examples/examples01/static/js/codemirror/mode/python/python.js +340 -0
  103. data/examples/examples01/static/js/codemirror/mode/r/LICENSE +24 -0
  104. data/examples/examples01/static/js/codemirror/mode/r/index.html +74 -0
  105. data/examples/examples01/static/js/codemirror/mode/r/r.js +141 -0
  106. data/examples/examples01/static/js/codemirror/mode/rpm/changes/changes.js +19 -0
  107. data/examples/examples01/static/js/codemirror/mode/rpm/changes/index.html +53 -0
  108. data/examples/examples01/static/js/codemirror/mode/rpm/spec/index.html +99 -0
  109. data/examples/examples01/static/js/codemirror/mode/rpm/spec/spec.css +5 -0
  110. data/examples/examples01/static/js/codemirror/mode/rpm/spec/spec.js +66 -0
  111. data/examples/examples01/static/js/codemirror/mode/rst/index.html +526 -0
  112. data/examples/examples01/static/js/codemirror/mode/rst/rst.js +314 -0
  113. data/examples/examples01/static/js/codemirror/mode/ruby/LICENSE +24 -0
  114. data/examples/examples01/static/js/codemirror/mode/ruby/index.html +173 -0
  115. data/examples/examples01/static/js/codemirror/mode/ruby/ruby.js +195 -0
  116. data/examples/examples01/static/js/codemirror/mode/rust/index.html +48 -0
  117. data/examples/examples01/static/js/codemirror/mode/rust/rust.js +432 -0
  118. data/examples/examples01/static/js/codemirror/mode/scheme/index.html +65 -0
  119. data/examples/examples01/static/js/codemirror/mode/scheme/scheme.js +230 -0
  120. data/examples/examples01/static/js/codemirror/mode/shell/index.html +51 -0
  121. data/examples/examples01/static/js/codemirror/mode/shell/shell.js +118 -0
  122. data/examples/examples01/static/js/codemirror/mode/sieve/LICENSE +23 -0
  123. data/examples/examples01/static/js/codemirror/mode/sieve/index.html +81 -0
  124. data/examples/examples01/static/js/codemirror/mode/sieve/sieve.js +156 -0
  125. data/examples/examples01/static/js/codemirror/mode/smalltalk/index.html +57 -0
  126. data/examples/examples01/static/js/codemirror/mode/smalltalk/smalltalk.js +139 -0
  127. data/examples/examples01/static/js/codemirror/mode/smarty/index.html +83 -0
  128. data/examples/examples01/static/js/codemirror/mode/smarty/smarty.js +148 -0
  129. data/examples/examples01/static/js/codemirror/mode/sparql/index.html +42 -0
  130. data/examples/examples01/static/js/codemirror/mode/sparql/sparql.js +143 -0
  131. data/examples/examples01/static/js/codemirror/mode/stex/index.html +98 -0
  132. data/examples/examples01/static/js/codemirror/mode/stex/stex.js +175 -0
  133. data/examples/examples01/static/js/codemirror/mode/stex/test.js +343 -0
  134. data/examples/examples01/static/js/codemirror/mode/tiddlywiki/index.html +142 -0
  135. data/examples/examples01/static/js/codemirror/mode/tiddlywiki/tiddlywiki.css +14 -0
  136. data/examples/examples01/static/js/codemirror/mode/tiddlywiki/tiddlywiki.js +353 -0
  137. data/examples/examples01/static/js/codemirror/mode/tiki/index.html +81 -0
  138. data/examples/examples01/static/js/codemirror/mode/tiki/tiki.css +26 -0
  139. data/examples/examples01/static/js/codemirror/mode/tiki/tiki.js +309 -0
  140. data/examples/examples01/static/js/codemirror/mode/vb/LICENSE.txt +21 -0
  141. data/examples/examples01/static/js/codemirror/mode/vb/index.html +88 -0
  142. data/examples/examples01/static/js/codemirror/mode/vb/vb.js +260 -0
  143. data/examples/examples01/static/js/codemirror/mode/vbscript/index.html +42 -0
  144. data/examples/examples01/static/js/codemirror/mode/vbscript/vbscript.js +26 -0
  145. data/examples/examples01/static/js/codemirror/mode/velocity/index.html +103 -0
  146. data/examples/examples01/static/js/codemirror/mode/velocity/velocity.js +144 -0
  147. data/examples/examples01/static/js/codemirror/mode/verilog/index.html +210 -0
  148. data/examples/examples01/static/js/codemirror/mode/verilog/verilog.js +182 -0
  149. data/examples/examples01/static/js/codemirror/mode/xml/index.html +45 -0
  150. data/examples/examples01/static/js/codemirror/mode/xml/xml.js +324 -0
  151. data/examples/examples01/static/js/codemirror/mode/xquery/LICENSE +20 -0
  152. data/examples/examples01/static/js/codemirror/mode/xquery/index.html +221 -0
  153. data/examples/examples01/static/js/codemirror/mode/xquery/test.js +77 -0
  154. data/examples/examples01/static/js/codemirror/mode/xquery/xquery.js +450 -0
  155. data/examples/examples01/static/js/codemirror/mode/yaml/index.html +68 -0
  156. data/examples/examples01/static/js/codemirror/mode/yaml/yaml.js +95 -0
  157. data/examples/examples01/static/js/codemirror/mode/z80/index.html +39 -0
  158. data/examples/examples01/static/js/codemirror/mode/z80/z80.js +113 -0
  159. data/examples/examples01/static/js/codemirror/theme/ambiance-mobile.css +6 -0
  160. data/examples/examples01/static/js/codemirror/theme/ambiance.css +76 -0
  161. data/examples/examples01/static/js/codemirror/theme/blackboard.css +25 -0
  162. data/examples/examples01/static/js/codemirror/theme/cobalt.css +18 -0
  163. data/examples/examples01/static/js/codemirror/theme/eclipse.css +25 -0
  164. data/examples/examples01/static/js/codemirror/theme/elegant.css +10 -0
  165. data/examples/examples01/static/js/codemirror/theme/erlang-dark.css +21 -0
  166. data/examples/examples01/static/js/codemirror/theme/lesser-dark.css +44 -0
  167. data/examples/examples01/static/js/codemirror/theme/monokai.css +28 -0
  168. data/examples/examples01/static/js/codemirror/theme/neat.css +9 -0
  169. data/examples/examples01/static/js/codemirror/theme/night.css +21 -0
  170. data/examples/examples01/static/js/codemirror/theme/rubyblue.css +21 -0
  171. data/examples/examples01/static/js/codemirror/theme/solarized.css +207 -0
  172. data/examples/examples01/static/js/codemirror/theme/twilight.css +26 -0
  173. data/examples/examples01/static/js/codemirror/theme/vibrant-ink.css +27 -0
  174. data/examples/examples01/static/js/codemirror/theme/xq-dark.css +46 -0
  175. data/examples/examples01/static/js/d3.v3.min.js +2 -2
  176. data/examples/examples01/static/test/cm.html +33 -0
  177. data/examples/examples01/views/about.slim +15 -0
  178. data/examples/examples01/views/index.slim +1 -1
  179. data/examples/examples01/views/layout.slim +1 -0
  180. data/examples/examples01/views/layout_cm.slim +17 -0
  181. data/examples/examples01/views/navbar.slim +4 -4
  182. data/lib/swagr/version.rb +1 -1
  183. data/templates/app.rb +4 -0
  184. data/templates/static/js/codemirror/keymap/emacs.js +30 -0
  185. data/templates/static/js/codemirror/keymap/vim.js +2298 -0
  186. data/templates/static/js/codemirror/lib/codemirror.css +239 -0
  187. data/templates/static/js/codemirror/lib/codemirror.js +4553 -0
  188. data/templates/static/js/codemirror/lib/util/closetag.js +85 -0
  189. data/templates/static/js/codemirror/lib/util/colorize.js +29 -0
  190. data/templates/static/js/codemirror/lib/util/continuecomment.js +36 -0
  191. data/templates/static/js/codemirror/lib/util/continuelist.js +28 -0
  192. data/templates/static/js/codemirror/lib/util/dialog.css +32 -0
  193. data/templates/static/js/codemirror/lib/util/dialog.js +75 -0
  194. data/templates/static/js/codemirror/lib/util/foldcode.js +182 -0
  195. data/templates/static/js/codemirror/lib/util/formatting.js +108 -0
  196. data/templates/static/js/codemirror/lib/util/javascript-hint.js +137 -0
  197. data/templates/static/js/codemirror/lib/util/loadmode.js +51 -0
  198. data/templates/static/js/codemirror/lib/util/match-highlighter.js +46 -0
  199. data/templates/static/js/codemirror/lib/util/matchbrackets.js +63 -0
  200. data/templates/static/js/codemirror/lib/util/multiplex.js +95 -0
  201. data/templates/static/js/codemirror/lib/util/overlay.js +59 -0
  202. data/templates/static/js/codemirror/lib/util/pig-hint.js +117 -0
  203. data/templates/static/js/codemirror/lib/util/runmode-standalone.js +90 -0
  204. data/templates/static/js/codemirror/lib/util/runmode.js +52 -0
  205. data/templates/static/js/codemirror/lib/util/search.js +119 -0
  206. data/templates/static/js/codemirror/lib/util/searchcursor.js +119 -0
  207. data/templates/static/js/codemirror/lib/util/simple-hint.css +16 -0
  208. data/templates/static/js/codemirror/lib/util/simple-hint.js +102 -0
  209. data/templates/static/js/codemirror/lib/util/xml-hint.js +131 -0
  210. data/templates/static/js/codemirror/mode/clike/clike.js +300 -0
  211. data/templates/static/js/codemirror/mode/clike/index.html +103 -0
  212. data/templates/static/js/codemirror/mode/clike/scala.html +767 -0
  213. data/templates/static/js/codemirror/mode/clojure/clojure.js +206 -0
  214. data/templates/static/js/codemirror/mode/clojure/index.html +67 -0
  215. data/templates/static/js/codemirror/mode/coffeescript/LICENSE +22 -0
  216. data/templates/static/js/codemirror/mode/coffeescript/coffeescript.js +346 -0
  217. data/templates/static/js/codemirror/mode/coffeescript/index.html +728 -0
  218. data/templates/static/js/codemirror/mode/commonlisp/commonlisp.js +101 -0
  219. data/templates/static/js/codemirror/mode/commonlisp/index.html +165 -0
  220. data/templates/static/js/codemirror/mode/css/css.js +465 -0
  221. data/templates/static/js/codemirror/mode/css/index.html +58 -0
  222. data/templates/static/js/codemirror/mode/css/test.js +501 -0
  223. data/templates/static/js/codemirror/mode/diff/diff.js +32 -0
  224. data/templates/static/js/codemirror/mode/diff/index.html +105 -0
  225. data/templates/static/js/codemirror/mode/ecl/ecl.js +192 -0
  226. data/templates/static/js/codemirror/mode/ecl/index.html +39 -0
  227. data/templates/static/js/codemirror/mode/erlang/erlang.js +463 -0
  228. data/templates/static/js/codemirror/mode/erlang/index.html +64 -0
  229. data/templates/static/js/codemirror/mode/gfm/gfm.js +94 -0
  230. data/templates/static/js/codemirror/mode/gfm/index.html +70 -0
  231. data/templates/static/js/codemirror/mode/gfm/test.js +225 -0
  232. data/templates/static/js/codemirror/mode/go/go.js +165 -0
  233. data/templates/static/js/codemirror/mode/go/index.html +74 -0
  234. data/templates/static/js/codemirror/mode/groovy/groovy.js +210 -0
  235. data/templates/static/js/codemirror/mode/groovy/index.html +73 -0
  236. data/templates/static/js/codemirror/mode/haskell/haskell.js +242 -0
  237. data/templates/static/js/codemirror/mode/haskell/index.html +62 -0
  238. data/templates/static/js/codemirror/mode/haxe/haxe.js +429 -0
  239. data/templates/static/js/codemirror/mode/haxe/index.html +90 -0
  240. data/templates/static/js/codemirror/mode/htmlembedded/htmlembedded.js +73 -0
  241. data/templates/static/js/codemirror/mode/htmlembedded/index.html +49 -0
  242. data/templates/static/js/codemirror/mode/htmlmixed/htmlmixed.js +84 -0
  243. data/templates/static/js/codemirror/mode/htmlmixed/index.html +52 -0
  244. data/templates/static/js/codemirror/mode/http/http.js +98 -0
  245. data/templates/static/js/codemirror/mode/http/index.html +32 -0
  246. data/templates/static/js/codemirror/mode/javascript/index.html +88 -0
  247. data/templates/static/js/codemirror/mode/javascript/javascript.js +411 -0
  248. data/templates/static/js/codemirror/mode/javascript/typescript.html +48 -0
  249. data/templates/static/js/codemirror/mode/jinja2/index.html +38 -0
  250. data/templates/static/js/codemirror/mode/jinja2/jinja2.js +42 -0
  251. data/templates/static/js/codemirror/mode/less/index.html +741 -0
  252. data/templates/static/js/codemirror/mode/less/less.js +266 -0
  253. data/templates/static/js/codemirror/mode/lua/index.html +74 -0
  254. data/templates/static/js/codemirror/mode/lua/lua.js +140 -0
  255. data/templates/static/js/codemirror/mode/markdown/index.html +344 -0
  256. data/templates/static/js/codemirror/mode/markdown/markdown.js +474 -0
  257. data/templates/static/js/codemirror/mode/markdown/test.js +1266 -0
  258. data/templates/static/js/codemirror/mode/mysql/index.html +41 -0
  259. data/templates/static/js/codemirror/mode/mysql/mysql.js +203 -0
  260. data/templates/static/js/codemirror/mode/ntriples/index.html +33 -0
  261. data/templates/static/js/codemirror/mode/ntriples/ntriples.js +170 -0
  262. data/templates/static/js/codemirror/mode/ocaml/index.html +131 -0
  263. data/templates/static/js/codemirror/mode/ocaml/ocaml.js +113 -0
  264. data/templates/static/js/codemirror/mode/pascal/LICENSE +7 -0
  265. data/templates/static/js/codemirror/mode/pascal/index.html +48 -0
  266. data/templates/static/js/codemirror/mode/pascal/pascal.js +94 -0
  267. data/templates/static/js/codemirror/mode/perl/LICENSE +19 -0
  268. data/templates/static/js/codemirror/mode/perl/index.html +62 -0
  269. data/templates/static/js/codemirror/mode/perl/perl.js +816 -0
  270. data/templates/static/js/codemirror/mode/php/index.html +51 -0
  271. data/templates/static/js/codemirror/mode/php/php.js +129 -0
  272. data/templates/static/js/codemirror/mode/pig/index.html +42 -0
  273. data/templates/static/js/codemirror/mode/pig/pig.js +171 -0
  274. data/templates/static/js/codemirror/mode/plsql/index.html +62 -0
  275. data/templates/static/js/codemirror/mode/plsql/plsql.js +216 -0
  276. data/templates/static/js/codemirror/mode/properties/index.html +41 -0
  277. data/templates/static/js/codemirror/mode/properties/properties.js +63 -0
  278. data/templates/static/js/codemirror/mode/python/LICENSE.txt +21 -0
  279. data/templates/static/js/codemirror/mode/python/index.html +124 -0
  280. data/templates/static/js/codemirror/mode/python/python.js +340 -0
  281. data/templates/static/js/codemirror/mode/r/LICENSE +24 -0
  282. data/templates/static/js/codemirror/mode/r/index.html +74 -0
  283. data/templates/static/js/codemirror/mode/r/r.js +141 -0
  284. data/templates/static/js/codemirror/mode/rpm/changes/changes.js +19 -0
  285. data/templates/static/js/codemirror/mode/rpm/changes/index.html +53 -0
  286. data/templates/static/js/codemirror/mode/rpm/spec/index.html +99 -0
  287. data/templates/static/js/codemirror/mode/rpm/spec/spec.css +5 -0
  288. data/templates/static/js/codemirror/mode/rpm/spec/spec.js +66 -0
  289. data/templates/static/js/codemirror/mode/rst/index.html +526 -0
  290. data/templates/static/js/codemirror/mode/rst/rst.js +314 -0
  291. data/templates/static/js/codemirror/mode/ruby/LICENSE +24 -0
  292. data/templates/static/js/codemirror/mode/ruby/index.html +173 -0
  293. data/templates/static/js/codemirror/mode/ruby/ruby.js +195 -0
  294. data/templates/static/js/codemirror/mode/rust/index.html +48 -0
  295. data/templates/static/js/codemirror/mode/rust/rust.js +432 -0
  296. data/templates/static/js/codemirror/mode/scheme/index.html +65 -0
  297. data/templates/static/js/codemirror/mode/scheme/scheme.js +230 -0
  298. data/templates/static/js/codemirror/mode/shell/index.html +51 -0
  299. data/templates/static/js/codemirror/mode/shell/shell.js +118 -0
  300. data/templates/static/js/codemirror/mode/sieve/LICENSE +23 -0
  301. data/templates/static/js/codemirror/mode/sieve/index.html +81 -0
  302. data/templates/static/js/codemirror/mode/sieve/sieve.js +156 -0
  303. data/templates/static/js/codemirror/mode/smalltalk/index.html +57 -0
  304. data/templates/static/js/codemirror/mode/smalltalk/smalltalk.js +139 -0
  305. data/templates/static/js/codemirror/mode/smarty/index.html +83 -0
  306. data/templates/static/js/codemirror/mode/smarty/smarty.js +148 -0
  307. data/templates/static/js/codemirror/mode/sparql/index.html +42 -0
  308. data/templates/static/js/codemirror/mode/sparql/sparql.js +143 -0
  309. data/templates/static/js/codemirror/mode/stex/index.html +98 -0
  310. data/templates/static/js/codemirror/mode/stex/stex.js +175 -0
  311. data/templates/static/js/codemirror/mode/stex/test.js +343 -0
  312. data/templates/static/js/codemirror/mode/tiddlywiki/index.html +142 -0
  313. data/templates/static/js/codemirror/mode/tiddlywiki/tiddlywiki.css +14 -0
  314. data/templates/static/js/codemirror/mode/tiddlywiki/tiddlywiki.js +353 -0
  315. data/templates/static/js/codemirror/mode/tiki/index.html +81 -0
  316. data/templates/static/js/codemirror/mode/tiki/tiki.css +26 -0
  317. data/templates/static/js/codemirror/mode/tiki/tiki.js +309 -0
  318. data/templates/static/js/codemirror/mode/vb/LICENSE.txt +21 -0
  319. data/templates/static/js/codemirror/mode/vb/index.html +88 -0
  320. data/templates/static/js/codemirror/mode/vb/vb.js +260 -0
  321. data/templates/static/js/codemirror/mode/vbscript/index.html +42 -0
  322. data/templates/static/js/codemirror/mode/vbscript/vbscript.js +26 -0
  323. data/templates/static/js/codemirror/mode/velocity/index.html +103 -0
  324. data/templates/static/js/codemirror/mode/velocity/velocity.js +144 -0
  325. data/templates/static/js/codemirror/mode/verilog/index.html +210 -0
  326. data/templates/static/js/codemirror/mode/verilog/verilog.js +182 -0
  327. data/templates/static/js/codemirror/mode/xml/index.html +45 -0
  328. data/templates/static/js/codemirror/mode/xml/xml.js +324 -0
  329. data/templates/static/js/codemirror/mode/xquery/LICENSE +20 -0
  330. data/templates/static/js/codemirror/mode/xquery/index.html +221 -0
  331. data/templates/static/js/codemirror/mode/xquery/test.js +77 -0
  332. data/templates/static/js/codemirror/mode/xquery/xquery.js +450 -0
  333. data/templates/static/js/codemirror/mode/yaml/index.html +68 -0
  334. data/templates/static/js/codemirror/mode/yaml/yaml.js +95 -0
  335. data/templates/static/js/codemirror/mode/z80/index.html +39 -0
  336. data/templates/static/js/codemirror/mode/z80/z80.js +113 -0
  337. data/templates/static/js/codemirror/theme/ambiance-mobile.css +6 -0
  338. data/templates/static/js/codemirror/theme/ambiance.css +76 -0
  339. data/templates/static/js/codemirror/theme/blackboard.css +25 -0
  340. data/templates/static/js/codemirror/theme/cobalt.css +18 -0
  341. data/templates/static/js/codemirror/theme/eclipse.css +25 -0
  342. data/templates/static/js/codemirror/theme/elegant.css +10 -0
  343. data/templates/static/js/codemirror/theme/erlang-dark.css +21 -0
  344. data/templates/static/js/codemirror/theme/lesser-dark.css +44 -0
  345. data/templates/static/js/codemirror/theme/monokai.css +28 -0
  346. data/templates/static/js/codemirror/theme/neat.css +9 -0
  347. data/templates/static/js/codemirror/theme/night.css +21 -0
  348. data/templates/static/js/codemirror/theme/rubyblue.css +21 -0
  349. data/templates/static/js/codemirror/theme/solarized.css +207 -0
  350. data/templates/static/js/codemirror/theme/twilight.css +26 -0
  351. data/templates/static/js/codemirror/theme/vibrant-ink.css +27 -0
  352. data/templates/static/js/codemirror/theme/xq-dark.css +46 -0
  353. data/templates/static/js/d3.v3.min.js +2 -2
  354. data/templates/static/test/cm.html +33 -0
  355. data/templates/views/about.slim +15 -0
  356. data/templates/views/index.slim +1 -1
  357. data/templates/views/layout.slim +1 -0
  358. data/templates/views/navbar.slim +4 -4
  359. metadata +347 -2
@@ -0,0 +1,32 @@
1
+ CodeMirror.defineMode("diff", function() {
2
+
3
+ var TOKEN_NAMES = {
4
+ '+': 'positive',
5
+ '-': 'negative',
6
+ '@': 'meta'
7
+ };
8
+
9
+ return {
10
+ token: function(stream) {
11
+ var tw_pos = stream.string.search(/[\t ]+?$/);
12
+
13
+ if (!stream.sol() || tw_pos === 0) {
14
+ stream.skipToEnd();
15
+ return ("error " + (
16
+ TOKEN_NAMES[stream.string.charAt(0)] || '')).replace(/ $/, '');
17
+ }
18
+
19
+ var token_name = TOKEN_NAMES[stream.peek()] || stream.skipToEnd();
20
+
21
+ if (tw_pos === -1) {
22
+ stream.skipToEnd();
23
+ } else {
24
+ stream.pos = tw_pos;
25
+ }
26
+
27
+ return token_name;
28
+ }
29
+ };
30
+ });
31
+
32
+ CodeMirror.defineMIME("text/x-diff", "diff");
@@ -0,0 +1,105 @@
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>CodeMirror: Diff mode</title>
6
+ <link rel="stylesheet" href="../../lib/codemirror.css">
7
+ <script src="../../lib/codemirror.js"></script>
8
+ <script src="diff.js"></script>
9
+ <style>
10
+ .CodeMirror {border-top: 1px solid #ddd; border-bottom: 1px solid #ddd;}
11
+ span.cm-meta {color: #a0b !important;}
12
+ span.cm-error { background-color: black; opacity: 0.4;}
13
+ span.cm-error.cm-string { background-color: red; }
14
+ span.cm-error.cm-tag { background-color: #2b2; }
15
+ </style>
16
+ <link rel="stylesheet" href="../../doc/docs.css">
17
+ </head>
18
+ <body>
19
+ <h1>CodeMirror: Diff mode</h1>
20
+ <form><textarea id="code" name="code">
21
+ diff --git a/index.html b/index.html
22
+ index c1d9156..7764744 100644
23
+ --- a/index.html
24
+ +++ b/index.html
25
+ @@ -95,7 +95,8 @@ StringStream.prototype = {
26
+ <script>
27
+ var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
28
+ lineNumbers: true,
29
+ - autoMatchBrackets: true
30
+ + autoMatchBrackets: true,
31
+ + onGutterClick: function(x){console.log(x);}
32
+ });
33
+ </script>
34
+ </body>
35
+ diff --git a/lib/codemirror.js b/lib/codemirror.js
36
+ index 04646a9..9a39cc7 100644
37
+ --- a/lib/codemirror.js
38
+ +++ b/lib/codemirror.js
39
+ @@ -399,10 +399,16 @@ var CodeMirror = (function() {
40
+ }
41
+
42
+ function onMouseDown(e) {
43
+ - var start = posFromMouse(e), last = start;
44
+ + var start = posFromMouse(e), last = start, target = e.target();
45
+ if (!start) return;
46
+ setCursor(start.line, start.ch, false);
47
+ if (e.button() != 1) return;
48
+ + if (target.parentNode == gutter) {
49
+ + if (options.onGutterClick)
50
+ + options.onGutterClick(indexOf(gutter.childNodes, target) + showingFrom);
51
+ + return;
52
+ + }
53
+ +
54
+ if (!focused) onFocus();
55
+
56
+ e.stop();
57
+ @@ -808,7 +814,7 @@ var CodeMirror = (function() {
58
+ for (var i = showingFrom; i < showingTo; ++i) {
59
+ var marker = lines[i].gutterMarker;
60
+ if (marker) html.push('<div class="' + marker.style + '">' + htmlEscape(marker.text) + '</div>');
61
+ - else html.push("<div>" + (options.lineNumbers ? i + 1 : "\u00a0") + "</div>");
62
+ + else html.push("<div>" + (options.lineNumbers ? i + options.firstLineNumber : "\u00a0") + "</div>");
63
+ }
64
+ gutter.style.display = "none"; // TODO test whether this actually helps
65
+ gutter.innerHTML = html.join("");
66
+ @@ -1371,10 +1377,8 @@ var CodeMirror = (function() {
67
+ if (option == "parser") setParser(value);
68
+ else if (option === "lineNumbers") setLineNumbers(value);
69
+ else if (option === "gutter") setGutter(value);
70
+ - else if (option === "readOnly") options.readOnly = value;
71
+ - else if (option === "indentUnit") {options.indentUnit = indentUnit = value; setParser(options.parser);}
72
+ - else if (/^(?:enterMode|tabMode|indentWithTabs|readOnly|autoMatchBrackets|undoDepth)$/.test(option)) options[option] = value;
73
+ - else throw new Error("Can't set option " + option);
74
+ + else if (option === "indentUnit") {options.indentUnit = value; setParser(options.parser);}
75
+ + else options[option] = value;
76
+ },
77
+ cursorCoords: cursorCoords,
78
+ undo: operation(undo),
79
+ @@ -1402,7 +1406,8 @@ var CodeMirror = (function() {
80
+ replaceRange: operation(replaceRange),
81
+
82
+ operation: function(f){return operation(f)();},
83
+ - refresh: function(){updateDisplay([{from: 0, to: lines.length}]);}
84
+ + refresh: function(){updateDisplay([{from: 0, to: lines.length}]);},
85
+ + getInputField: function(){return input;}
86
+ };
87
+ return instance;
88
+ }
89
+ @@ -1420,6 +1425,7 @@ var CodeMirror = (function() {
90
+ readOnly: false,
91
+ onChange: null,
92
+ onCursorActivity: null,
93
+ + onGutterClick: null,
94
+ autoMatchBrackets: false,
95
+ workTime: 200,
96
+ workDelay: 300,
97
+ </textarea></form>
98
+ <script>
99
+ var editor = CodeMirror.fromTextArea(document.getElementById("code"), {});
100
+ </script>
101
+
102
+ <p><strong>MIME types defined:</strong> <code>text/x-diff</code>.</p>
103
+
104
+ </body>
105
+ </html>
@@ -0,0 +1,192 @@
1
+ CodeMirror.defineMode("ecl", function(config) {
2
+
3
+ function words(str) {
4
+ var obj = {}, words = str.split(" ");
5
+ for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
6
+ return obj;
7
+ }
8
+
9
+ function metaHook(stream, state) {
10
+ if (!state.startOfLine) return false;
11
+ stream.skipToEnd();
12
+ return "meta";
13
+ }
14
+
15
+ var indentUnit = config.indentUnit;
16
+ var keyword = words("abs acos allnodes ascii asin asstring atan atan2 ave case choose choosen choosesets clustersize combine correlation cos cosh count covariance cron dataset dedup define denormalize distribute distributed distribution ebcdic enth error evaluate event eventextra eventname exists exp failcode failmessage fetch fromunicode getisvalid global graph group hash hash32 hash64 hashcrc hashmd5 having if index intformat isvalid iterate join keyunicode length library limit ln local log loop map matched matchlength matchposition matchtext matchunicode max merge mergejoin min nolocal nonempty normalize parse pipe power preload process project pull random range rank ranked realformat recordof regexfind regexreplace regroup rejected rollup round roundup row rowdiff sample set sin sinh sizeof soapcall sort sorted sqrt stepped stored sum table tan tanh thisnode topn tounicode transfer trim truncate typeof ungroup unicodeorder variance which workunit xmldecode xmlencode xmltext xmlunicode");
17
+ var variable = words("apply assert build buildindex evaluate fail keydiff keypatch loadxml nothor notify output parallel sequential soapcall wait");
18
+ var variable_2 = words("__compressed__ all and any as atmost before beginc++ best between case const counter csv descend encrypt end endc++ endmacro except exclusive expire export extend false few first flat from full function group header heading hole ifblock import in interface joined keep keyed last left limit load local locale lookup macro many maxcount maxlength min skew module named nocase noroot noscan nosort not of only opt or outer overwrite packed partition penalty physicallength pipe quote record relationship repeat return right scan self separator service shared skew skip sql store terminator thor threshold token transform trim true type unicodeorder unsorted validate virtual whole wild within xml xpath");
19
+ var variable_3 = words("ascii big_endian boolean data decimal ebcdic integer pattern qstring real record rule set of string token udecimal unicode unsigned varstring varunicode");
20
+ var builtin = words("checkpoint deprecated failcode failmessage failure global independent onwarning persist priority recovery stored success wait when");
21
+ var blockKeywords = words("catch class do else finally for if switch try while");
22
+ var atoms = words("true false null");
23
+ var hooks = {"#": metaHook};
24
+ var multiLineStrings;
25
+ var isOperatorChar = /[+\-*&%=<>!?|\/]/;
26
+
27
+ var curPunc;
28
+
29
+ function tokenBase(stream, state) {
30
+ var ch = stream.next();
31
+ if (hooks[ch]) {
32
+ var result = hooks[ch](stream, state);
33
+ if (result !== false) return result;
34
+ }
35
+ if (ch == '"' || ch == "'") {
36
+ state.tokenize = tokenString(ch);
37
+ return state.tokenize(stream, state);
38
+ }
39
+ if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
40
+ curPunc = ch;
41
+ return null;
42
+ }
43
+ if (/\d/.test(ch)) {
44
+ stream.eatWhile(/[\w\.]/);
45
+ return "number";
46
+ }
47
+ if (ch == "/") {
48
+ if (stream.eat("*")) {
49
+ state.tokenize = tokenComment;
50
+ return tokenComment(stream, state);
51
+ }
52
+ if (stream.eat("/")) {
53
+ stream.skipToEnd();
54
+ return "comment";
55
+ }
56
+ }
57
+ if (isOperatorChar.test(ch)) {
58
+ stream.eatWhile(isOperatorChar);
59
+ return "operator";
60
+ }
61
+ stream.eatWhile(/[\w\$_]/);
62
+ var cur = stream.current().toLowerCase();
63
+ if (keyword.propertyIsEnumerable(cur)) {
64
+ if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
65
+ return "keyword";
66
+ } else if (variable.propertyIsEnumerable(cur)) {
67
+ if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
68
+ return "variable";
69
+ } else if (variable_2.propertyIsEnumerable(cur)) {
70
+ if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
71
+ return "variable-2";
72
+ } else if (variable_3.propertyIsEnumerable(cur)) {
73
+ if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
74
+ return "variable-3";
75
+ } else if (builtin.propertyIsEnumerable(cur)) {
76
+ if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
77
+ return "builtin";
78
+ } else { //Data types are of from KEYWORD##
79
+ var i = cur.length - 1;
80
+ while(i >= 0 && (!isNaN(cur[i]) || cur[i] == '_'))
81
+ --i;
82
+
83
+ if (i > 0) {
84
+ var cur2 = cur.substr(0, i + 1);
85
+ if (variable_3.propertyIsEnumerable(cur2)) {
86
+ if (blockKeywords.propertyIsEnumerable(cur2)) curPunc = "newstatement";
87
+ return "variable-3";
88
+ }
89
+ }
90
+ }
91
+ if (atoms.propertyIsEnumerable(cur)) return "atom";
92
+ return null;
93
+ }
94
+
95
+ function tokenString(quote) {
96
+ return function(stream, state) {
97
+ var escaped = false, next, end = false;
98
+ while ((next = stream.next()) != null) {
99
+ if (next == quote && !escaped) {end = true; break;}
100
+ escaped = !escaped && next == "\\";
101
+ }
102
+ if (end || !(escaped || multiLineStrings))
103
+ state.tokenize = tokenBase;
104
+ return "string";
105
+ };
106
+ }
107
+
108
+ function tokenComment(stream, state) {
109
+ var maybeEnd = false, ch;
110
+ while (ch = stream.next()) {
111
+ if (ch == "/" && maybeEnd) {
112
+ state.tokenize = tokenBase;
113
+ break;
114
+ }
115
+ maybeEnd = (ch == "*");
116
+ }
117
+ return "comment";
118
+ }
119
+
120
+ function Context(indented, column, type, align, prev) {
121
+ this.indented = indented;
122
+ this.column = column;
123
+ this.type = type;
124
+ this.align = align;
125
+ this.prev = prev;
126
+ }
127
+ function pushContext(state, col, type) {
128
+ return state.context = new Context(state.indented, col, type, null, state.context);
129
+ }
130
+ function popContext(state) {
131
+ var t = state.context.type;
132
+ if (t == ")" || t == "]" || t == "}")
133
+ state.indented = state.context.indented;
134
+ return state.context = state.context.prev;
135
+ }
136
+
137
+ // Interface
138
+
139
+ return {
140
+ startState: function(basecolumn) {
141
+ return {
142
+ tokenize: null,
143
+ context: new Context((basecolumn || 0) - indentUnit, 0, "top", false),
144
+ indented: 0,
145
+ startOfLine: true
146
+ };
147
+ },
148
+
149
+ token: function(stream, state) {
150
+ var ctx = state.context;
151
+ if (stream.sol()) {
152
+ if (ctx.align == null) ctx.align = false;
153
+ state.indented = stream.indentation();
154
+ state.startOfLine = true;
155
+ }
156
+ if (stream.eatSpace()) return null;
157
+ curPunc = null;
158
+ var style = (state.tokenize || tokenBase)(stream, state);
159
+ if (style == "comment" || style == "meta") return style;
160
+ if (ctx.align == null) ctx.align = true;
161
+
162
+ if ((curPunc == ";" || curPunc == ":") && ctx.type == "statement") popContext(state);
163
+ else if (curPunc == "{") pushContext(state, stream.column(), "}");
164
+ else if (curPunc == "[") pushContext(state, stream.column(), "]");
165
+ else if (curPunc == "(") pushContext(state, stream.column(), ")");
166
+ else if (curPunc == "}") {
167
+ while (ctx.type == "statement") ctx = popContext(state);
168
+ if (ctx.type == "}") ctx = popContext(state);
169
+ while (ctx.type == "statement") ctx = popContext(state);
170
+ }
171
+ else if (curPunc == ctx.type) popContext(state);
172
+ else if (ctx.type == "}" || ctx.type == "top" || (ctx.type == "statement" && curPunc == "newstatement"))
173
+ pushContext(state, stream.column(), "statement");
174
+ state.startOfLine = false;
175
+ return style;
176
+ },
177
+
178
+ indent: function(state, textAfter) {
179
+ if (state.tokenize != tokenBase && state.tokenize != null) return 0;
180
+ var ctx = state.context, firstChar = textAfter && textAfter.charAt(0);
181
+ if (ctx.type == "statement" && firstChar == "}") ctx = ctx.prev;
182
+ var closing = firstChar == ctx.type;
183
+ if (ctx.type == "statement") return ctx.indented + (firstChar == "{" ? 0 : indentUnit);
184
+ else if (ctx.align) return ctx.column + (closing ? 0 : 1);
185
+ else return ctx.indented + (closing ? 0 : indentUnit);
186
+ },
187
+
188
+ electricChars: "{}"
189
+ };
190
+ });
191
+
192
+ CodeMirror.defineMIME("text/x-ecl", "ecl");
@@ -0,0 +1,39 @@
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+ <title>CodeMirror: ECL mode</title>
5
+ <link rel="stylesheet" href="../../lib/codemirror.css">
6
+ <script src="../../lib/codemirror.js"></script>
7
+ <script src="ecl.js"></script>
8
+ <link rel="stylesheet" href="../../doc/docs.css">
9
+ <style>.CodeMirror {border: 1px solid black;}</style>
10
+ </head>
11
+ <body>
12
+ <h1>CodeMirror: ECL mode</h1>
13
+ <form><textarea id="code" name="code">
14
+ /*
15
+ sample useless code to demonstrate ecl syntax highlighting
16
+ this is a multiline comment!
17
+ */
18
+
19
+ // this is a singleline comment!
20
+
21
+ import ut;
22
+ r :=
23
+ record
24
+ string22 s1 := '123';
25
+ integer4 i1 := 123;
26
+ end;
27
+ #option('tmp', true);
28
+ d := dataset('tmp::qb', r, thor);
29
+ output(d);
30
+ </textarea></form>
31
+ <script>
32
+ var editor = CodeMirror.fromTextArea(document.getElementById("code"), {});
33
+ </script>
34
+
35
+ <p>Based on CodeMirror's clike mode. For more information see <a href="http://hpccsystems.com">HPCC Systems</a> web site.</p>
36
+ <p><strong>MIME types defined:</strong> <code>text/x-ecl</code>.</p>
37
+
38
+ </body>
39
+ </html>
@@ -0,0 +1,463 @@
1
+ // block; "begin", "case", "fun", "if", "receive", "try": closed by "end"
2
+ // block internal; "after", "catch", "of"
3
+ // guard; "when", closed by "->"
4
+ // "->" opens a clause, closed by ";" or "."
5
+ // "<<" opens a binary, closed by ">>"
6
+ // "," appears in arglists, lists, tuples and terminates lines of code
7
+ // "." resets indentation to 0
8
+ // obsolete; "cond", "let", "query"
9
+
10
+ CodeMirror.defineMIME("text/x-erlang", "erlang");
11
+
12
+ CodeMirror.defineMode("erlang", function(cmCfg) {
13
+
14
+ function rval(state,stream,type) {
15
+ // distinguish between "." as terminator and record field operator
16
+ if (type == "record") {
17
+ state.context = "record";
18
+ }else{
19
+ state.context = false;
20
+ }
21
+
22
+ // remember last significant bit on last line for indenting
23
+ if (type != "whitespace" && type != "comment") {
24
+ state.lastToken = stream.current();
25
+ }
26
+ // erlang -> CodeMirror tag
27
+ switch (type) {
28
+ case "atom": return "atom";
29
+ case "attribute": return "attribute";
30
+ case "builtin": return "builtin";
31
+ case "comment": return "comment";
32
+ case "fun": return "meta";
33
+ case "function": return "tag";
34
+ case "guard": return "property";
35
+ case "keyword": return "keyword";
36
+ case "macro": return "variable-2";
37
+ case "number": return "number";
38
+ case "operator": return "operator";
39
+ case "record": return "bracket";
40
+ case "string": return "string";
41
+ case "type": return "def";
42
+ case "variable": return "variable";
43
+ case "error": return "error";
44
+ case "separator": return null;
45
+ case "open_paren": return null;
46
+ case "close_paren": return null;
47
+ default: return null;
48
+ }
49
+ }
50
+
51
+ var typeWords = [
52
+ "-type", "-spec", "-export_type", "-opaque"];
53
+
54
+ var keywordWords = [
55
+ "after","begin","catch","case","cond","end","fun","if",
56
+ "let","of","query","receive","try","when"];
57
+
58
+ var separatorWords = [
59
+ "->",";",":",".",","];
60
+
61
+ var operatorWords = [
62
+ "and","andalso","band","bnot","bor","bsl","bsr","bxor",
63
+ "div","not","or","orelse","rem","xor"];
64
+
65
+ var symbolWords = [
66
+ "+","-","*","/",">",">=","<","=<","=:=","==","=/=","/=","||","<-"];
67
+
68
+ var openParenWords = [
69
+ "<<","(","[","{"];
70
+
71
+ var closeParenWords = [
72
+ "}","]",")",">>"];
73
+
74
+ var guardWords = [
75
+ "is_atom","is_binary","is_bitstring","is_boolean","is_float",
76
+ "is_function","is_integer","is_list","is_number","is_pid",
77
+ "is_port","is_record","is_reference","is_tuple",
78
+ "atom","binary","bitstring","boolean","function","integer","list",
79
+ "number","pid","port","record","reference","tuple"];
80
+
81
+ var bifWords = [
82
+ "abs","adler32","adler32_combine","alive","apply","atom_to_binary",
83
+ "atom_to_list","binary_to_atom","binary_to_existing_atom",
84
+ "binary_to_list","binary_to_term","bit_size","bitstring_to_list",
85
+ "byte_size","check_process_code","contact_binary","crc32",
86
+ "crc32_combine","date","decode_packet","delete_module",
87
+ "disconnect_node","element","erase","exit","float","float_to_list",
88
+ "garbage_collect","get","get_keys","group_leader","halt","hd",
89
+ "integer_to_list","internal_bif","iolist_size","iolist_to_binary",
90
+ "is_alive","is_atom","is_binary","is_bitstring","is_boolean",
91
+ "is_float","is_function","is_integer","is_list","is_number","is_pid",
92
+ "is_port","is_process_alive","is_record","is_reference","is_tuple",
93
+ "length","link","list_to_atom","list_to_binary","list_to_bitstring",
94
+ "list_to_existing_atom","list_to_float","list_to_integer",
95
+ "list_to_pid","list_to_tuple","load_module","make_ref","module_loaded",
96
+ "monitor_node","node","node_link","node_unlink","nodes","notalive",
97
+ "now","open_port","pid_to_list","port_close","port_command",
98
+ "port_connect","port_control","pre_loaded","process_flag",
99
+ "process_info","processes","purge_module","put","register",
100
+ "registered","round","self","setelement","size","spawn","spawn_link",
101
+ "spawn_monitor","spawn_opt","split_binary","statistics",
102
+ "term_to_binary","time","throw","tl","trunc","tuple_size",
103
+ "tuple_to_list","unlink","unregister","whereis"];
104
+
105
+ // ignored for indenting purposes
106
+ var ignoreWords = [
107
+ ",", ":", "catch", "after", "of", "cond", "let", "query"];
108
+
109
+
110
+ var smallRE = /[a-z_]/;
111
+ var largeRE = /[A-Z_]/;
112
+ var digitRE = /[0-9]/;
113
+ var octitRE = /[0-7]/;
114
+ var anumRE = /[a-z_A-Z0-9]/;
115
+ var symbolRE = /[\+\-\*\/<>=\|:]/;
116
+ var openParenRE = /[<\(\[\{]/;
117
+ var closeParenRE = /[>\)\]\}]/;
118
+ var sepRE = /[\->\.,:;]/;
119
+
120
+ function isMember(element,list) {
121
+ return (-1 < list.indexOf(element));
122
+ }
123
+
124
+ function isPrev(stream,string) {
125
+ var start = stream.start;
126
+ var len = string.length;
127
+ if (len <= start) {
128
+ var word = stream.string.slice(start-len,start);
129
+ return word == string;
130
+ }else{
131
+ return false;
132
+ }
133
+ }
134
+
135
+ function tokenize(stream, state) {
136
+ if (stream.eatSpace()) {
137
+ return rval(state,stream,"whitespace");
138
+ }
139
+
140
+ // attributes and type specs
141
+ if ((peekToken(state).token == "" || peekToken(state).token == ".") &&
142
+ stream.peek() == '-') {
143
+ stream.next();
144
+ if (stream.eat(smallRE) && stream.eatWhile(anumRE)) {
145
+ if (isMember(stream.current(),typeWords)) {
146
+ return rval(state,stream,"type");
147
+ }else{
148
+ return rval(state,stream,"attribute");
149
+ }
150
+ }
151
+ stream.backUp(1);
152
+ }
153
+
154
+ var ch = stream.next();
155
+
156
+ // comment
157
+ if (ch == '%') {
158
+ stream.skipToEnd();
159
+ return rval(state,stream,"comment");
160
+ }
161
+
162
+ // macro
163
+ if (ch == '?') {
164
+ stream.eatWhile(anumRE);
165
+ return rval(state,stream,"macro");
166
+ }
167
+
168
+ // record
169
+ if ( ch == "#") {
170
+ stream.eatWhile(anumRE);
171
+ return rval(state,stream,"record");
172
+ }
173
+
174
+ // char
175
+ if ( ch == "$") {
176
+ if (stream.next() == "\\") {
177
+ if (!stream.eatWhile(octitRE)) {
178
+ stream.next();
179
+ }
180
+ }
181
+ return rval(state,stream,"string");
182
+ }
183
+
184
+ // quoted atom
185
+ if (ch == '\'') {
186
+ if (singleQuote(stream)) {
187
+ return rval(state,stream,"atom");
188
+ }else{
189
+ return rval(state,stream,"error");
190
+ }
191
+ }
192
+
193
+ // string
194
+ if (ch == '"') {
195
+ if (doubleQuote(stream)) {
196
+ return rval(state,stream,"string");
197
+ }else{
198
+ return rval(state,stream,"error");
199
+ }
200
+ }
201
+
202
+ // variable
203
+ if (largeRE.test(ch)) {
204
+ stream.eatWhile(anumRE);
205
+ return rval(state,stream,"variable");
206
+ }
207
+
208
+ // atom/keyword/BIF/function
209
+ if (smallRE.test(ch)) {
210
+ stream.eatWhile(anumRE);
211
+
212
+ if (stream.peek() == "/") {
213
+ stream.next();
214
+ if (stream.eatWhile(digitRE)) {
215
+ return rval(state,stream,"fun"); // f/0 style fun
216
+ }else{
217
+ stream.backUp(1);
218
+ return rval(state,stream,"atom");
219
+ }
220
+ }
221
+
222
+ var w = stream.current();
223
+
224
+ if (isMember(w,keywordWords)) {
225
+ pushToken(state,stream);
226
+ return rval(state,stream,"keyword");
227
+ }
228
+ if (stream.peek() == "(") {
229
+ // 'put' and 'erlang:put' are bifs, 'foo:put' is not
230
+ if (isMember(w,bifWords) &&
231
+ (!isPrev(stream,":") || isPrev(stream,"erlang:"))) {
232
+ return rval(state,stream,"builtin");
233
+ }else{
234
+ return rval(state,stream,"function");
235
+ }
236
+ }
237
+ if (isMember(w,guardWords)) {
238
+ return rval(state,stream,"guard");
239
+ }
240
+ if (isMember(w,operatorWords)) {
241
+ return rval(state,stream,"operator");
242
+ }
243
+ if (stream.peek() == ":") {
244
+ if (w == "erlang") {
245
+ return rval(state,stream,"builtin");
246
+ } else {
247
+ return rval(state,stream,"function");
248
+ }
249
+ }
250
+ return rval(state,stream,"atom");
251
+ }
252
+
253
+ // number
254
+ if (digitRE.test(ch)) {
255
+ stream.eatWhile(digitRE);
256
+ if (stream.eat('#')) {
257
+ stream.eatWhile(digitRE); // 16#10 style integer
258
+ } else {
259
+ if (stream.eat('.')) { // float
260
+ stream.eatWhile(digitRE);
261
+ }
262
+ if (stream.eat(/[eE]/)) {
263
+ stream.eat(/[-+]/); // float with exponent
264
+ stream.eatWhile(digitRE);
265
+ }
266
+ }
267
+ return rval(state,stream,"number"); // normal integer
268
+ }
269
+
270
+ // open parens
271
+ if (nongreedy(stream,openParenRE,openParenWords)) {
272
+ pushToken(state,stream);
273
+ return rval(state,stream,"open_paren");
274
+ }
275
+
276
+ // close parens
277
+ if (nongreedy(stream,closeParenRE,closeParenWords)) {
278
+ pushToken(state,stream);
279
+ return rval(state,stream,"close_paren");
280
+ }
281
+
282
+ // separators
283
+ if (greedy(stream,sepRE,separatorWords)) {
284
+ // distinguish between "." as terminator and record field operator
285
+ if (state.context == false) {
286
+ pushToken(state,stream);
287
+ }
288
+ return rval(state,stream,"separator");
289
+ }
290
+
291
+ // operators
292
+ if (greedy(stream,symbolRE,symbolWords)) {
293
+ return rval(state,stream,"operator");
294
+ }
295
+
296
+ return rval(state,stream,null);
297
+ }
298
+
299
+ function nongreedy(stream,re,words) {
300
+ if (stream.current().length == 1 && re.test(stream.current())) {
301
+ stream.backUp(1);
302
+ while (re.test(stream.peek())) {
303
+ stream.next();
304
+ if (isMember(stream.current(),words)) {
305
+ return true;
306
+ }
307
+ }
308
+ stream.backUp(stream.current().length-1);
309
+ }
310
+ return false;
311
+ }
312
+
313
+ function greedy(stream,re,words) {
314
+ if (stream.current().length == 1 && re.test(stream.current())) {
315
+ while (re.test(stream.peek())) {
316
+ stream.next();
317
+ }
318
+ while (0 < stream.current().length) {
319
+ if (isMember(stream.current(),words)) {
320
+ return true;
321
+ }else{
322
+ stream.backUp(1);
323
+ }
324
+ }
325
+ stream.next();
326
+ }
327
+ return false;
328
+ }
329
+
330
+ function doubleQuote(stream) {
331
+ return quote(stream, '"', '\\');
332
+ }
333
+
334
+ function singleQuote(stream) {
335
+ return quote(stream,'\'','\\');
336
+ }
337
+
338
+ function quote(stream,quoteChar,escapeChar) {
339
+ while (!stream.eol()) {
340
+ var ch = stream.next();
341
+ if (ch == quoteChar) {
342
+ return true;
343
+ }else if (ch == escapeChar) {
344
+ stream.next();
345
+ }
346
+ }
347
+ return false;
348
+ }
349
+
350
+ function Token(stream) {
351
+ this.token = stream ? stream.current() : "";
352
+ this.column = stream ? stream.column() : 0;
353
+ this.indent = stream ? stream.indentation() : 0;
354
+ }
355
+
356
+ function myIndent(state,textAfter) {
357
+ var indent = cmCfg.indentUnit;
358
+ var outdentWords = ["after","catch"];
359
+ var token = (peekToken(state)).token;
360
+ var wordAfter = takewhile(textAfter,/[^a-z]/);
361
+
362
+ if (isMember(token,openParenWords)) {
363
+ return (peekToken(state)).column+token.length;
364
+ }else if (token == "." || token == ""){
365
+ return 0;
366
+ }else if (token == "->") {
367
+ if (wordAfter == "end") {
368
+ return peekToken(state,2).column;
369
+ }else if (peekToken(state,2).token == "fun") {
370
+ return peekToken(state,2).column+indent;
371
+ }else{
372
+ return (peekToken(state)).indent+indent;
373
+ }
374
+ }else if (isMember(wordAfter,outdentWords)) {
375
+ return (peekToken(state)).indent;
376
+ }else{
377
+ return (peekToken(state)).column+indent;
378
+ }
379
+ }
380
+
381
+ function takewhile(str,re) {
382
+ var m = str.match(re);
383
+ return m ? str.slice(0,m.index) : str;
384
+ }
385
+
386
+ function popToken(state) {
387
+ return state.tokenStack.pop();
388
+ }
389
+
390
+ function peekToken(state,depth) {
391
+ var len = state.tokenStack.length;
392
+ var dep = (depth ? depth : 1);
393
+ if (len < dep) {
394
+ return new Token;
395
+ }else{
396
+ return state.tokenStack[len-dep];
397
+ }
398
+ }
399
+
400
+ function pushToken(state,stream) {
401
+ var token = stream.current();
402
+ var prev_token = peekToken(state).token;
403
+ if (isMember(token,ignoreWords)) {
404
+ return false;
405
+ }else if (drop_both(prev_token,token)) {
406
+ popToken(state);
407
+ return false;
408
+ }else if (drop_first(prev_token,token)) {
409
+ popToken(state);
410
+ return pushToken(state,stream);
411
+ }else{
412
+ state.tokenStack.push(new Token(stream));
413
+ return true;
414
+ }
415
+ }
416
+
417
+ function drop_first(open, close) {
418
+ switch (open+" "+close) {
419
+ case "when ->": return true;
420
+ case "-> end": return true;
421
+ case "-> .": return true;
422
+ case ". .": return true;
423
+ default: return false;
424
+ }
425
+ }
426
+
427
+ function drop_both(open, close) {
428
+ switch (open+" "+close) {
429
+ case "( )": return true;
430
+ case "[ ]": return true;
431
+ case "{ }": return true;
432
+ case "<< >>": return true;
433
+ case "begin end": return true;
434
+ case "case end": return true;
435
+ case "fun end": return true;
436
+ case "if end": return true;
437
+ case "receive end": return true;
438
+ case "try end": return true;
439
+ case "-> ;": return true;
440
+ default: return false;
441
+ }
442
+ }
443
+
444
+ return {
445
+ startState:
446
+ function() {
447
+ return {tokenStack: [],
448
+ context: false,
449
+ lastToken: null};
450
+ },
451
+
452
+ token:
453
+ function(stream, state) {
454
+ return tokenize(stream, state);
455
+ },
456
+
457
+ indent:
458
+ function(state, textAfter) {
459
+ // console.log(state.tokenStack);
460
+ return myIndent(state,textAfter);
461
+ }
462
+ };
463
+ });