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,20 @@
1
+ Copyright (C) 2011 by MarkLogic Corporation
2
+ Author: Mike Brevoort <mike@brevoort.com>
3
+
4
+ Permission is hereby granted, free of charge, to any person obtaining a copy
5
+ of this software and associated documentation files (the "Software"), to deal
6
+ in the Software without restriction, including without limitation the rights
7
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
8
+ copies of the Software, and to permit persons to whom the Software is
9
+ furnished to do so, subject to the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be included in
12
+ all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
18
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
19
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
20
+ THE SOFTWARE.
@@ -0,0 +1,221 @@
1
+ <!doctype html>
2
+ <html>
3
+ <!--
4
+ /*
5
+ Copyright (C) 2011 by MarkLogic Corporation
6
+ Author: Mike Brevoort <mike@brevoort.com>
7
+
8
+ Permission is hereby granted, free of charge, to any person obtaining a copy
9
+ of this software and associated documentation files (the "Software"), to deal
10
+ in the Software without restriction, including without limitation the rights
11
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
+ copies of the Software, and to permit persons to whom the Software is
13
+ furnished to do so, subject to the following conditions:
14
+
15
+ The above copyright notice and this permission notice shall be included in
16
+ all copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
+ THE SOFTWARE.
25
+ */
26
+ -->
27
+ <head>
28
+ <meta charset="utf-8">
29
+ <title>CodeMirror: XQuery mode</title>
30
+ <link rel="stylesheet" href="../../lib/codemirror.css">
31
+ <script src="../../lib/codemirror.js"></script>
32
+ <script src="xquery.js"></script>
33
+ <link rel="stylesheet" href="../../doc/docs.css">
34
+ <link rel="stylesheet" href="../../theme/xq-dark.css">
35
+ <style type="text/css">
36
+ .CodeMirror {
37
+ border-top: 1px solid black; border-bottom: 1px solid black;
38
+ height:400px;
39
+ }
40
+ </style>
41
+ </head>
42
+ <body>
43
+ <h1>CodeMirror: XQuery mode</h1>
44
+
45
+ <div class="cm-s-default">
46
+ <textarea id="code" name="code">
47
+ xquery version &quot;1.0-ml&quot;;
48
+ (: this is
49
+ : a
50
+ "comment" :)
51
+ let $let := &lt;x attr=&quot;value&quot;&gt;&quot;test&quot;&lt;func&gt;function() $var {function()} {$var}&lt;/func&gt;&lt;/x&gt;
52
+ let $joe:=1
53
+ return element element {
54
+ attribute attribute { 1 },
55
+ element test { &#39;a&#39; },
56
+ attribute foo { &quot;bar&quot; },
57
+ fn:doc()[ foo/@bar eq $let ],
58
+ //x }
59
+
60
+ (: a more 'evil' test :)
61
+ (: Modified Blakeley example (: with nested comment :) ... :)
62
+ declare private function local:declare() {()};
63
+ declare private function local:private() {()};
64
+ declare private function local:function() {()};
65
+ declare private function local:local() {()};
66
+ let $let := &lt;let&gt;let $let := &quot;let&quot;&lt;/let&gt;
67
+ return element element {
68
+ attribute attribute { try { xdmp:version() } catch($e) { xdmp:log($e) } },
69
+ attribute fn:doc { &quot;bar&quot; castable as xs:string },
70
+ element text { text { &quot;text&quot; } },
71
+ fn:doc()[ child::eq/(@bar | attribute::attribute) eq $let ],
72
+ //fn:doc
73
+ }
74
+
75
+
76
+
77
+ xquery version &quot;1.0-ml&quot;;
78
+
79
+ (: Copyright 2006-2010 Mark Logic Corporation. :)
80
+
81
+ (:
82
+ : Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
83
+ : you may not use this file except in compliance with the License.
84
+ : You may obtain a copy of the License at
85
+ :
86
+ : http://www.apache.org/licenses/LICENSE-2.0
87
+ :
88
+ : Unless required by applicable law or agreed to in writing, software
89
+ : distributed under the License is distributed on an &quot;AS IS&quot; BASIS,
90
+ : WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
91
+ : See the License for the specific language governing permissions and
92
+ : limitations under the License.
93
+ :)
94
+
95
+ module namespace json = &quot;http://marklogic.com/json&quot;;
96
+ declare default function namespace &quot;http://www.w3.org/2005/xpath-functions&quot;;
97
+
98
+ (: Need to backslash escape any double quotes, backslashes, and newlines :)
99
+ declare function json:escape($s as xs:string) as xs:string {
100
+ let $s := replace($s, &quot;\\&quot;, &quot;\\\\&quot;)
101
+ let $s := replace($s, &quot;&quot;&quot;&quot;, &quot;\\&quot;&quot;&quot;)
102
+ let $s := replace($s, codepoints-to-string((13, 10)), &quot;\\n&quot;)
103
+ let $s := replace($s, codepoints-to-string(13), &quot;\\n&quot;)
104
+ let $s := replace($s, codepoints-to-string(10), &quot;\\n&quot;)
105
+ return $s
106
+ };
107
+
108
+ declare function json:atomize($x as element()) as xs:string {
109
+ if (count($x/node()) = 0) then 'null'
110
+ else if ($x/@type = &quot;number&quot;) then
111
+ let $castable := $x castable as xs:float or
112
+ $x castable as xs:double or
113
+ $x castable as xs:decimal
114
+ return
115
+ if ($castable) then xs:string($x)
116
+ else error(concat(&quot;Not a number: &quot;, xdmp:describe($x)))
117
+ else if ($x/@type = &quot;boolean&quot;) then
118
+ let $castable := $x castable as xs:boolean
119
+ return
120
+ if ($castable) then xs:string(xs:boolean($x))
121
+ else error(concat(&quot;Not a boolean: &quot;, xdmp:describe($x)))
122
+ else concat('&quot;', json:escape($x), '&quot;')
123
+ };
124
+
125
+ (: Print the thing that comes after the colon :)
126
+ declare function json:print-value($x as element()) as xs:string {
127
+ if (count($x/*) = 0) then
128
+ json:atomize($x)
129
+ else if ($x/@quote = &quot;true&quot;) then
130
+ concat('&quot;', json:escape(xdmp:quote($x/node())), '&quot;')
131
+ else
132
+ string-join(('{',
133
+ string-join(for $i in $x/* return json:print-name-value($i), &quot;,&quot;),
134
+ '}'), &quot;&quot;)
135
+ };
136
+
137
+ (: Print the name and value both :)
138
+ declare function json:print-name-value($x as element()) as xs:string? {
139
+ let $name := name($x)
140
+ let $first-in-array :=
141
+ count($x/preceding-sibling::*[name(.) = $name]) = 0 and
142
+ (count($x/following-sibling::*[name(.) = $name]) &gt; 0 or $x/@array = &quot;true&quot;)
143
+ let $later-in-array := count($x/preceding-sibling::*[name(.) = $name]) &gt; 0
144
+ return
145
+
146
+ if ($later-in-array) then
147
+ () (: I was handled previously :)
148
+ else if ($first-in-array) then
149
+ string-join(('&quot;', json:escape($name), '&quot;:[',
150
+ string-join((for $i in ($x, $x/following-sibling::*[name(.) = $name]) return json:print-value($i)), &quot;,&quot;),
151
+ ']'), &quot;&quot;)
152
+ else
153
+ string-join(('&quot;', json:escape($name), '&quot;:', json:print-value($x)), &quot;&quot;)
154
+ };
155
+
156
+ (:~
157
+ Transforms an XML element into a JSON string representation. See http://json.org.
158
+ &lt;p/&gt;
159
+ Sample usage:
160
+ &lt;pre&gt;
161
+ xquery version &quot;1.0-ml&quot;;
162
+ import module namespace json=&quot;http://marklogic.com/json&quot; at &quot;json.xqy&quot;;
163
+ json:serialize(&amp;lt;foo&amp;gt;&amp;lt;bar&amp;gt;kid&amp;lt;/bar&amp;gt;&amp;lt;/foo&amp;gt;)
164
+ &lt;/pre&gt;
165
+ Sample transformations:
166
+ &lt;pre&gt;
167
+ &amp;lt;e/&amp;gt; becomes {&quot;e&quot;:null}
168
+ &amp;lt;e&amp;gt;text&amp;lt;/e&amp;gt; becomes {&quot;e&quot;:&quot;text&quot;}
169
+ &amp;lt;e&amp;gt;quote &quot; escaping&amp;lt;/e&amp;gt; becomes {&quot;e&quot;:&quot;quote \&quot; escaping&quot;}
170
+ &amp;lt;e&amp;gt;backslash \ escaping&amp;lt;/e&amp;gt; becomes {&quot;e&quot;:&quot;backslash \\ escaping&quot;}
171
+ &amp;lt;e&amp;gt;&amp;lt;a&amp;gt;text1&amp;lt;/a&amp;gt;&amp;lt;b&amp;gt;text2&amp;lt;/b&amp;gt;&amp;lt;/e&amp;gt; becomes {&quot;e&quot;:{&quot;a&quot;:&quot;text1&quot;,&quot;b&quot;:&quot;text2&quot;}}
172
+ &amp;lt;e&amp;gt;&amp;lt;a&amp;gt;text1&amp;lt;/a&amp;gt;&amp;lt;a&amp;gt;text2&amp;lt;/a&amp;gt;&amp;lt;/e&amp;gt; becomes {&quot;e&quot;:{&quot;a&quot;:[&quot;text1&quot;,&quot;text2&quot;]}}
173
+ &amp;lt;e&amp;gt;&amp;lt;a array=&quot;true&quot;&amp;gt;text1&amp;lt;/a&amp;gt;&amp;lt;/e&amp;gt; becomes {&quot;e&quot;:{&quot;a&quot;:[&quot;text1&quot;]}}
174
+ &amp;lt;e&amp;gt;&amp;lt;a type=&quot;boolean&quot;&amp;gt;false&amp;lt;/a&amp;gt;&amp;lt;/e&amp;gt; becomes {&quot;e&quot;:{&quot;a&quot;:false}}
175
+ &amp;lt;e&amp;gt;&amp;lt;a type=&quot;number&quot;&amp;gt;123.5&amp;lt;/a&amp;gt;&amp;lt;/e&amp;gt; becomes {&quot;e&quot;:{&quot;a&quot;:123.5}}
176
+ &amp;lt;e quote=&quot;true&quot;&amp;gt;&amp;lt;div attrib=&quot;value&quot;/&amp;gt;&amp;lt;/e&amp;gt; becomes {&quot;e&quot;:&quot;&amp;lt;div attrib=\&quot;value\&quot;/&amp;gt;&quot;}
177
+ &lt;/pre&gt;
178
+ &lt;p/&gt;
179
+ Namespace URIs are ignored. Namespace prefixes are included in the JSON name.
180
+ &lt;p/&gt;
181
+ Attributes are ignored, except for the special attribute @array=&quot;true&quot; that
182
+ indicates the JSON serialization should write the node, even if single, as an
183
+ array, and the attribute @type that can be set to &quot;boolean&quot; or &quot;number&quot; to
184
+ dictate the value should be written as that type (unquoted). There's also
185
+ an @quote attribute that when set to true writes the inner content as text
186
+ rather than as structured JSON, useful for sending some XHTML over the
187
+ wire.
188
+ &lt;p/&gt;
189
+ Text nodes within mixed content are ignored.
190
+
191
+ @param $x Element node to convert
192
+ @return String holding JSON serialized representation of $x
193
+
194
+ @author Jason Hunter
195
+ @version 1.0.1
196
+
197
+ Ported to xquery 1.0-ml; double escaped backslashes in json:escape
198
+ :)
199
+ declare function json:serialize($x as element()) as xs:string {
200
+ string-join(('{', json:print-name-value($x), '}'), &quot;&quot;)
201
+ };
202
+ </textarea>
203
+ </div>
204
+
205
+ <script>
206
+ var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
207
+ lineNumbers: true,
208
+ matchBrackets: true,
209
+ theme: "xq-dark"
210
+ });
211
+ </script>
212
+
213
+ <p><strong>MIME types defined:</strong> <code>application/xquery</code>.</p>
214
+
215
+ <p>Development of the CodeMirror XQuery mode was sponsored by
216
+ <a href="http://marklogic.com">MarkLogic</a> and developed by
217
+ <a href="https://twitter.com/mbrevoort">Mike Brevoort</a>.
218
+ </p>
219
+
220
+ </body>
221
+ </html>
@@ -0,0 +1,77 @@
1
+ // Initiate ModeTest and set defaults
2
+ var MT = ModeTest;
3
+ MT.modeName = "xquery";
4
+ MT.modeOptions = {};
5
+
6
+ MT.testMode("eviltest",
7
+ 'xquery version &quot;1.0-ml&quot;;\
8
+ (: this is\
9
+ : a \
10
+ "comment" :)\
11
+ let $let := &lt;x attr=&quot;value&quot;&gt;&quot;test&quot;&lt;func&gt;function() $var {function()} {$var}&lt;/func&gt;&lt;/x&gt;\
12
+ let $joe:=1\
13
+ return element element {\
14
+ attribute attribute { 1 },\
15
+ element test { &#39;a&#39; }, \
16
+ attribute foo { &quot;bar&quot; },\
17
+ fn:doc()[ foo/@bar eq $let ],\
18
+ //x } \
19
+ \
20
+ (: a more \'evil\' test :)\
21
+ (: Modified Blakeley example (: with nested comment :) ... :)\
22
+ declare private function local:declare() {()};\
23
+ declare private function local:private() {()};\
24
+ declare private function local:function() {()};\
25
+ declare private function local:local() {()};\
26
+ let $let := &lt;let&gt;let $let := &quot;let&quot;&lt;/let&gt;\
27
+ return element element {\
28
+ attribute attribute { try { xdmp:version() } catch($e) { xdmp:log($e) } },\
29
+ attribute fn:doc { &quot;bar&quot; castable as xs:string },\
30
+ element text { text { &quot;text&quot; } },\
31
+ fn:doc()[ child::eq/(@bar | attribute::attribute) eq $let ],\
32
+ //fn:doc\
33
+ }', ["keyword","xquery",null," ","keyword","version",null," ","variable","&quot;1","keyword",".","atom","0","keyword","-","variable","ml&quot;","def variable",";",null," ","comment","(: this is : a \"comment\" :)",null," ","keyword","let",null," ","variable","$let",null," ","keyword",":=",null," ","variable","&lt;x",null," ","variable","attr","keyword","=","variable","&quot;value&quot;&gt;&quot;test&quot;&lt;func&gt","def variable",";function","","()",null," ","variable","$var",null," ","","{","keyword","function","","()}",null," ","","{","variable","$var","","}","variable","&lt;","keyword","/","variable","func&gt;&lt;","keyword","/","variable","x&gt;",null," ","keyword","let",null," ","variable","$joe","keyword",":=","atom","1",null," ","keyword","return",null," ","keyword","element",null," ","variable","element",null," ","","{",null," ","keyword","attribute",null," ","variable","attribute",null," ","","{",null," ","atom","1",null," ","","},",null," ","keyword","element",null," ","variable","test",null," ","","{",null," ","variable","&#39;a&#39;",null," ","","},",null," ","keyword","attribute",null," ","variable","foo",null," ","","{",null," ","variable","&quot;bar&quot;",null," ","","},",null," ","def variable","fn:doc","","()[",null," ","variable","foo","keyword","/","variable","@bar",null," ","keyword","eq",null," ","variable","$let",null," ","","],",null," ","keyword","//","variable","x",null," ","","}",null," ","comment","(: a more 'evil' test :)",null," ","comment","(: Modified Blakeley example (: with nested comment :) ... :)",null," ","keyword","declare",null," ","keyword","private",null," ","keyword","function",null," ","def variable","local:declare","","()",null," ","","{()}","variable",";",null," ","keyword","declare",null," ","keyword","private",null," ","keyword","function",null," ","def variable","local:private","","()",null," ","","{()}","variable",";",null," ","keyword","declare",null," ","keyword","private",null," ","keyword","function",null," ","def variable","local:function","","()",null," ","","{()}","variable",";",null," ","keyword","declare",null," ","keyword","private",null," ","keyword","function",null," ","def variable","local:local","","()",null," ","","{()}","variable",";",null," ","keyword","let",null," ","variable","$let",null," ","keyword",":=",null," ","variable","&lt;let&gt;let",null," ","variable","$let",null," ","keyword",":=",null," ","variable","&quot;let&quot;&lt;","keyword","/let","variable","&gt;",null," ","keyword","return",null," ","keyword","element",null," ","variable","element",null," ","","{",null," ","keyword","attribute",null," ","variable","attribute",null," ","","{",null," ","keyword","try",null," ","","{",null," ","def variable","xdmp:version","","()",null," ","","}",null," ","keyword","catch","","(","variable","$e","",")",null," ","","{",null," ","def variable","xdmp:log","","(","variable","$e","",")",null," ","","}",null," ","","},",null," ","keyword","attribute",null," ","variable","fn:doc",null," ","","{",null," ","variable","&quot;bar&quot;",null," ","variable","castable",null," ","keyword","as",null," ","atom","xs:string",null," ","","},",null," ","keyword","element",null," ","variable","text",null," ","","{",null," ","keyword","text",null," ","","{",null," ","variable","&quot;text&quot;",null," ","","}",null," ","","},",null," ","def variable","fn:doc","","()[",null," ","qualifier","child::","variable","eq","keyword","/","","(","variable","@bar",null," ","keyword","|",null," ","qualifier","attribute::","variable","attribute","",")",null," ","keyword","eq",null," ","variable","$let",null," ","","],",null," ","keyword","//","variable","fn:doc",null," ","","}"]);
34
+
35
+ MT.testMode("testEmptySequenceKeyword",
36
+ '"foo" instance of empty-sequence()',
37
+ ["string","\"foo\"",null," ","keyword","instance",null," ","keyword","of",null," ","keyword","empty-sequence","","()"]);
38
+
39
+
40
+ MT.testMode("testMultiAttr",
41
+ '<p a1="foo" a2="bar">hello world</p>',
42
+ ["tag","<p ","attribute","a1","","=","string","\"foo\"",null," ","attribute","a2","","=","string","\"bar\"","tag",">","variable","hello",null," ","variable","world","tag","</p>"]);
43
+
44
+ MT.testMode("test namespaced variable",
45
+ 'declare namespace e = "http://example.com/ANamespace";\
46
+ declare variable $e:exampleComThisVarIsNotRecognized as element(*) external;',
47
+ ["keyword","declare",null," ","keyword","namespace",null," ","variable","e",null," ","keyword","=",null," ","string","\"http://example.com/ANamespace\"","variable",";declare",null," ","keyword","variable",null," ","variable","$e:exampleComThisVarIsNotRecognized",null," ","keyword","as",null," ","keyword","element","","(","keyword","*","",")",null," ","variable","external;"]);
48
+
49
+ MT.testMode("test EQName variable",
50
+ 'declare variable $"http://www.example.com/ns/my":var := 12;\
51
+ <out>{$"http://www.example.com/ns/my":var}</out>',
52
+ ["keyword","declare",null," ","keyword","variable",null," ","variable","$\"http://www.example.com/ns/my\":var",null," ","keyword",":=",null," ","atom","12","variable",";","tag","<out>","","{","variable","$\"http://www.example.com/ns/my\":var","","}","tag","</out>"]);
53
+
54
+ MT.testMode("test EQName function",
55
+ 'declare function "http://www.example.com/ns/my":fn ($a as xs:integer) as xs:integer {\
56
+ $a + 2\
57
+ };\
58
+ <out>{"http://www.example.com/ns/my":fn(12)}</out>',
59
+ ["keyword","declare",null," ","keyword","function",null," ","def variable","\"http://www.example.com/ns/my\":fn",null," ","","(","variable","$a",null," ","keyword","as",null," ","atom","xs:integer","",")",null," ","keyword","as",null," ","atom","xs:integer",null," ","","{",null," ","variable","$a",null," ","keyword","+",null," ","atom","2","","}","variable",";","tag","<out>","","{","def variable","\"http://www.example.com/ns/my\":fn","","(","atom","12","",")}","tag","</out>"]);
60
+
61
+ MT.testMode("test EQName function with single quotes",
62
+ 'declare function \'http://www.example.com/ns/my\':fn ($a as xs:integer) as xs:integer {\
63
+ $a + 2\
64
+ };\
65
+ <out>{\'http://www.example.com/ns/my\':fn(12)}</out>',
66
+ ["keyword","declare",null," ","keyword","function",null," ","def variable","'http://www.example.com/ns/my':fn",null," ","","(","variable","$a",null," ","keyword","as",null," ","atom","xs:integer","",")",null," ","keyword","as",null," ","atom","xs:integer",null," ","","{",null," ","variable","$a",null," ","keyword","+",null," ","atom","2","","}","variable",";","tag","<out>","","{","def variable","'http://www.example.com/ns/my':fn","","(","atom","12","",")}","tag","</out>"]);
67
+
68
+ MT.testMode("testProcessingInstructions",
69
+ 'data(<?target content?>) instance of xs:string',
70
+ ["def variable","data","","(","comment meta","<?target content?>","",")",null," ","keyword","instance",null," ","keyword","of",null," ","atom","xs:string"]);
71
+
72
+ MT.testMode("testQuoteEscapeDouble",
73
+ 'let $rootfolder := "c:\\builds\\winnt\\HEAD\\qa\\scripts\\"\
74
+ let $keysfolder := concat($rootfolder, "keys\\")\
75
+ return\
76
+ $keysfolder',
77
+ ["keyword","let",null," ","variable","$rootfolder",null," ","keyword",":=",null," ","string","\"c:\\builds\\winnt\\HEAD\\qa\\scripts\\\"","keyword","let",null," ","variable","$keysfolder",null," ","keyword",":=",null," ","def variable","concat","","(","variable","$rootfolder","",",",null," ","string","\"keys\\\"","",")","variable","return$keysfolder"]);
@@ -0,0 +1,450 @@
1
+ /*
2
+ Copyright (C) 2011 by MarkLogic Corporation
3
+ Author: Mike Brevoort <mike@brevoort.com>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
22
+ */
23
+ CodeMirror.defineMode("xquery", function() {
24
+
25
+ // The keywords object is set to the result of this self executing
26
+ // function. Each keyword is a property of the keywords object whose
27
+ // value is {type: atype, style: astyle}
28
+ var keywords = function(){
29
+ // conveinence functions used to build keywords object
30
+ function kw(type) {return {type: type, style: "keyword"};}
31
+ var A = kw("keyword a")
32
+ , B = kw("keyword b")
33
+ , C = kw("keyword c")
34
+ , operator = kw("operator")
35
+ , atom = {type: "atom", style: "atom"}
36
+ , punctuation = {type: "punctuation", style: ""}
37
+ , qualifier = {type: "axis_specifier", style: "qualifier"};
38
+
39
+ // kwObj is what is return from this function at the end
40
+ var kwObj = {
41
+ 'if': A, 'switch': A, 'while': A, 'for': A,
42
+ 'else': B, 'then': B, 'try': B, 'finally': B, 'catch': B,
43
+ 'element': C, 'attribute': C, 'let': C, 'implements': C, 'import': C, 'module': C, 'namespace': C,
44
+ 'return': C, 'super': C, 'this': C, 'throws': C, 'where': C, 'private': C,
45
+ ',': punctuation,
46
+ 'null': atom, 'fn:false()': atom, 'fn:true()': atom
47
+ };
48
+
49
+ // a list of 'basic' keywords. For each add a property to kwObj with the value of
50
+ // {type: basic[i], style: "keyword"} e.g. 'after' --> {type: "after", style: "keyword"}
51
+ var basic = ['after','ancestor','ancestor-or-self','and','as','ascending','assert','attribute','before',
52
+ 'by','case','cast','child','comment','declare','default','define','descendant','descendant-or-self',
53
+ 'descending','document','document-node','element','else','eq','every','except','external','following',
54
+ 'following-sibling','follows','for','function','if','import','in','instance','intersect','item',
55
+ 'let','module','namespace','node','node','of','only','or','order','parent','precedes','preceding',
56
+ 'preceding-sibling','processing-instruction','ref','return','returns','satisfies','schema','schema-element',
57
+ 'self','some','sortby','stable','text','then','to','treat','typeswitch','union','variable','version','where',
58
+ 'xquery', 'empty-sequence'];
59
+ for(var i=0, l=basic.length; i < l; i++) { kwObj[basic[i]] = kw(basic[i]);};
60
+
61
+ // a list of types. For each add a property to kwObj with the value of
62
+ // {type: "atom", style: "atom"}
63
+ var types = ['xs:string', 'xs:float', 'xs:decimal', 'xs:double', 'xs:integer', 'xs:boolean', 'xs:date', 'xs:dateTime',
64
+ 'xs:time', 'xs:duration', 'xs:dayTimeDuration', 'xs:time', 'xs:yearMonthDuration', 'numeric', 'xs:hexBinary',
65
+ 'xs:base64Binary', 'xs:anyURI', 'xs:QName', 'xs:byte','xs:boolean','xs:anyURI','xf:yearMonthDuration'];
66
+ for(var i=0, l=types.length; i < l; i++) { kwObj[types[i]] = atom;};
67
+
68
+ // each operator will add a property to kwObj with value of {type: "operator", style: "keyword"}
69
+ var operators = ['eq', 'ne', 'lt', 'le', 'gt', 'ge', ':=', '=', '>', '>=', '<', '<=', '.', '|', '?', 'and', 'or', 'div', 'idiv', 'mod', '*', '/', '+', '-'];
70
+ for(var i=0, l=operators.length; i < l; i++) { kwObj[operators[i]] = operator;};
71
+
72
+ // each axis_specifiers will add a property to kwObj with value of {type: "axis_specifier", style: "qualifier"}
73
+ var axis_specifiers = ["self::", "attribute::", "child::", "descendant::", "descendant-or-self::", "parent::",
74
+ "ancestor::", "ancestor-or-self::", "following::", "preceding::", "following-sibling::", "preceding-sibling::"];
75
+ for(var i=0, l=axis_specifiers.length; i < l; i++) { kwObj[axis_specifiers[i]] = qualifier; };
76
+
77
+ return kwObj;
78
+ }();
79
+
80
+ // Used as scratch variables to communicate multiple values without
81
+ // consing up tons of objects.
82
+ var type, content;
83
+
84
+ function ret(tp, style, cont) {
85
+ type = tp; content = cont;
86
+ return style;
87
+ }
88
+
89
+ function chain(stream, state, f) {
90
+ state.tokenize = f;
91
+ return f(stream, state);
92
+ }
93
+
94
+ // the primary mode tokenizer
95
+ function tokenBase(stream, state) {
96
+ var ch = stream.next(),
97
+ mightBeFunction = false,
98
+ isEQName = isEQNameAhead(stream);
99
+
100
+ // an XML tag (if not in some sub, chained tokenizer)
101
+ if (ch == "<") {
102
+ if(stream.match("!--", true))
103
+ return chain(stream, state, tokenXMLComment);
104
+
105
+ if(stream.match("![CDATA", false)) {
106
+ state.tokenize = tokenCDATA;
107
+ return ret("tag", "tag");
108
+ }
109
+
110
+ if(stream.match("?", false)) {
111
+ return chain(stream, state, tokenPreProcessing);
112
+ }
113
+
114
+ var isclose = stream.eat("/");
115
+ stream.eatSpace();
116
+ var tagName = "", c;
117
+ while ((c = stream.eat(/[^\s\u00a0=<>\"\'\/?]/))) tagName += c;
118
+
119
+ return chain(stream, state, tokenTag(tagName, isclose));
120
+ }
121
+ // start code block
122
+ else if(ch == "{") {
123
+ pushStateStack(state,{ type: "codeblock"});
124
+ return ret("", "");
125
+ }
126
+ // end code block
127
+ else if(ch == "}") {
128
+ popStateStack(state);
129
+ return ret("", "");
130
+ }
131
+ // if we're in an XML block
132
+ else if(isInXmlBlock(state)) {
133
+ if(ch == ">")
134
+ return ret("tag", "tag");
135
+ else if(ch == "/" && stream.eat(">")) {
136
+ popStateStack(state);
137
+ return ret("tag", "tag");
138
+ }
139
+ else
140
+ return ret("word", "variable");
141
+ }
142
+ // if a number
143
+ else if (/\d/.test(ch)) {
144
+ stream.match(/^\d*(?:\.\d*)?(?:E[+\-]?\d+)?/);
145
+ return ret("number", "atom");
146
+ }
147
+ // comment start
148
+ else if (ch === "(" && stream.eat(":")) {
149
+ pushStateStack(state, { type: "comment"});
150
+ return chain(stream, state, tokenComment);
151
+ }
152
+ // quoted string
153
+ else if ( !isEQName && (ch === '"' || ch === "'"))
154
+ return chain(stream, state, tokenString(ch));
155
+ // variable
156
+ else if(ch === "$") {
157
+ return chain(stream, state, tokenVariable);
158
+ }
159
+ // assignment
160
+ else if(ch ===":" && stream.eat("=")) {
161
+ return ret("operator", "keyword");
162
+ }
163
+ // open paren
164
+ else if(ch === "(") {
165
+ pushStateStack(state, { type: "paren"});
166
+ return ret("", "");
167
+ }
168
+ // close paren
169
+ else if(ch === ")") {
170
+ popStateStack(state);
171
+ return ret("", "");
172
+ }
173
+ // open paren
174
+ else if(ch === "[") {
175
+ pushStateStack(state, { type: "bracket"});
176
+ return ret("", "");
177
+ }
178
+ // close paren
179
+ else if(ch === "]") {
180
+ popStateStack(state);
181
+ return ret("", "");
182
+ }
183
+ else {
184
+ var known = keywords.propertyIsEnumerable(ch) && keywords[ch];
185
+
186
+ // if there's a EQName ahead, consume the rest of the string portion, it's likely a function
187
+ if(isEQName && ch === '\"') while(stream.next() !== '"'){}
188
+ if(isEQName && ch === '\'') while(stream.next() !== '\''){}
189
+
190
+ // gobble up a word if the character is not known
191
+ if(!known) stream.eatWhile(/[\w\$_-]/);
192
+
193
+ // gobble a colon in the case that is a lib func type call fn:doc
194
+ var foundColon = stream.eat(":");
195
+
196
+ // if there's not a second colon, gobble another word. Otherwise, it's probably an axis specifier
197
+ // which should get matched as a keyword
198
+ if(!stream.eat(":") && foundColon) {
199
+ stream.eatWhile(/[\w\$_-]/);
200
+ }
201
+ // if the next non whitespace character is an open paren, this is probably a function (if not a keyword of other sort)
202
+ if(stream.match(/^[ \t]*\(/, false)) {
203
+ mightBeFunction = true;
204
+ }
205
+ // is the word a keyword?
206
+ var word = stream.current();
207
+ known = keywords.propertyIsEnumerable(word) && keywords[word];
208
+
209
+ // if we think it's a function call but not yet known,
210
+ // set style to variable for now for lack of something better
211
+ if(mightBeFunction && !known) known = {type: "function_call", style: "variable def"};
212
+
213
+ // if the previous word was element, attribute, axis specifier, this word should be the name of that
214
+ if(isInXmlConstructor(state)) {
215
+ popStateStack(state);
216
+ return ret("word", "variable", word);
217
+ }
218
+ // as previously checked, if the word is element,attribute, axis specifier, call it an "xmlconstructor" and
219
+ // push the stack so we know to look for it on the next word
220
+ if(word == "element" || word == "attribute" || known.type == "axis_specifier") pushStateStack(state, {type: "xmlconstructor"});
221
+
222
+ // if the word is known, return the details of that else just call this a generic 'word'
223
+ return known ? ret(known.type, known.style, word) :
224
+ ret("word", "variable", word);
225
+ }
226
+ }
227
+
228
+ // handle comments, including nested
229
+ function tokenComment(stream, state) {
230
+ var maybeEnd = false, maybeNested = false, nestedCount = 0, ch;
231
+ while (ch = stream.next()) {
232
+ if (ch == ")" && maybeEnd) {
233
+ if(nestedCount > 0)
234
+ nestedCount--;
235
+ else {
236
+ popStateStack(state);
237
+ break;
238
+ }
239
+ }
240
+ else if(ch == ":" && maybeNested) {
241
+ nestedCount++;
242
+ }
243
+ maybeEnd = (ch == ":");
244
+ maybeNested = (ch == "(");
245
+ }
246
+
247
+ return ret("comment", "comment");
248
+ }
249
+
250
+ // tokenizer for string literals
251
+ // optionally pass a tokenizer function to set state.tokenize back to when finished
252
+ function tokenString(quote, f) {
253
+ return function(stream, state) {
254
+ var ch;
255
+
256
+ if(isInString(state) && stream.current() == quote) {
257
+ popStateStack(state);
258
+ if(f) state.tokenize = f;
259
+ return ret("string", "string");
260
+ }
261
+
262
+ pushStateStack(state, { type: "string", name: quote, tokenize: tokenString(quote, f) });
263
+
264
+ // if we're in a string and in an XML block, allow an embedded code block
265
+ if(stream.match("{", false) && isInXmlAttributeBlock(state)) {
266
+ state.tokenize = tokenBase;
267
+ return ret("string", "string");
268
+ }
269
+
270
+
271
+ while (ch = stream.next()) {
272
+ if (ch == quote) {
273
+ popStateStack(state);
274
+ if(f) state.tokenize = f;
275
+ break;
276
+ }
277
+ else {
278
+ // if we're in a string and in an XML block, allow an embedded code block in an attribute
279
+ if(stream.match("{", false) && isInXmlAttributeBlock(state)) {
280
+ state.tokenize = tokenBase;
281
+ return ret("string", "string");
282
+ }
283
+
284
+ }
285
+ }
286
+
287
+ return ret("string", "string");
288
+ };
289
+ }
290
+
291
+ // tokenizer for variables
292
+ function tokenVariable(stream, state) {
293
+ var isVariableChar = /[\w\$_-]/;
294
+
295
+ // a variable may start with a quoted EQName so if the next character is quote, consume to the next quote
296
+ if(stream.eat("\"")) {
297
+ while(stream.next() !== '\"'){};
298
+ stream.eat(":");
299
+ } else {
300
+ stream.eatWhile(isVariableChar);
301
+ if(!stream.match(":=", false)) stream.eat(":");
302
+ }
303
+ stream.eatWhile(isVariableChar);
304
+ state.tokenize = tokenBase;
305
+ return ret("variable", "variable");
306
+ }
307
+
308
+ // tokenizer for XML tags
309
+ function tokenTag(name, isclose) {
310
+ return function(stream, state) {
311
+ stream.eatSpace();
312
+ if(isclose && stream.eat(">")) {
313
+ popStateStack(state);
314
+ state.tokenize = tokenBase;
315
+ return ret("tag", "tag");
316
+ }
317
+ // self closing tag without attributes?
318
+ if(!stream.eat("/"))
319
+ pushStateStack(state, { type: "tag", name: name, tokenize: tokenBase});
320
+ if(!stream.eat(">")) {
321
+ state.tokenize = tokenAttribute;
322
+ return ret("tag", "tag");
323
+ }
324
+ else {
325
+ state.tokenize = tokenBase;
326
+ }
327
+ return ret("tag", "tag");
328
+ };
329
+ }
330
+
331
+ // tokenizer for XML attributes
332
+ function tokenAttribute(stream, state) {
333
+ var ch = stream.next();
334
+
335
+ if(ch == "/" && stream.eat(">")) {
336
+ if(isInXmlAttributeBlock(state)) popStateStack(state);
337
+ if(isInXmlBlock(state)) popStateStack(state);
338
+ return ret("tag", "tag");
339
+ }
340
+ if(ch == ">") {
341
+ if(isInXmlAttributeBlock(state)) popStateStack(state);
342
+ return ret("tag", "tag");
343
+ }
344
+ if(ch == "=")
345
+ return ret("", "");
346
+ // quoted string
347
+ if (ch == '"' || ch == "'")
348
+ return chain(stream, state, tokenString(ch, tokenAttribute));
349
+
350
+ if(!isInXmlAttributeBlock(state))
351
+ pushStateStack(state, { type: "attribute", name: name, tokenize: tokenAttribute});
352
+
353
+ stream.eat(/[a-zA-Z_:]/);
354
+ stream.eatWhile(/[-a-zA-Z0-9_:.]/);
355
+ stream.eatSpace();
356
+
357
+ // the case where the attribute has not value and the tag was closed
358
+ if(stream.match(">", false) || stream.match("/", false)) {
359
+ popStateStack(state);
360
+ state.tokenize = tokenBase;
361
+ }
362
+
363
+ return ret("attribute", "attribute");
364
+ }
365
+
366
+ // handle comments, including nested
367
+ function tokenXMLComment(stream, state) {
368
+ var ch;
369
+ while (ch = stream.next()) {
370
+ if (ch == "-" && stream.match("->", true)) {
371
+ state.tokenize = tokenBase;
372
+ return ret("comment", "comment");
373
+ }
374
+ }
375
+ }
376
+
377
+
378
+ // handle CDATA
379
+ function tokenCDATA(stream, state) {
380
+ var ch;
381
+ while (ch = stream.next()) {
382
+ if (ch == "]" && stream.match("]", true)) {
383
+ state.tokenize = tokenBase;
384
+ return ret("comment", "comment");
385
+ }
386
+ }
387
+ }
388
+
389
+ // handle preprocessing instructions
390
+ function tokenPreProcessing(stream, state) {
391
+ var ch;
392
+ while (ch = stream.next()) {
393
+ if (ch == "?" && stream.match(">", true)) {
394
+ state.tokenize = tokenBase;
395
+ return ret("comment", "comment meta");
396
+ }
397
+ }
398
+ }
399
+
400
+
401
+ // functions to test the current context of the state
402
+ function isInXmlBlock(state) { return isIn(state, "tag"); }
403
+ function isInXmlAttributeBlock(state) { return isIn(state, "attribute"); }
404
+ function isInXmlConstructor(state) { return isIn(state, "xmlconstructor"); }
405
+ function isInString(state) { return isIn(state, "string"); }
406
+
407
+ function isEQNameAhead(stream) {
408
+ // assume we've already eaten a quote (")
409
+ if(stream.current() === '"')
410
+ return stream.match(/^[^\"]+\"\:/, false);
411
+ else if(stream.current() === '\'')
412
+ return stream.match(/^[^\"]+\'\:/, false);
413
+ else
414
+ return false;
415
+ }
416
+
417
+ function isIn(state, type) {
418
+ return (state.stack.length && state.stack[state.stack.length - 1].type == type);
419
+ }
420
+
421
+ function pushStateStack(state, newState) {
422
+ state.stack.push(newState);
423
+ }
424
+
425
+ function popStateStack(state) {
426
+ state.stack.pop();
427
+ var reinstateTokenize = state.stack.length && state.stack[state.stack.length-1].tokenize;
428
+ state.tokenize = reinstateTokenize || tokenBase;
429
+ }
430
+
431
+ // the interface for the mode API
432
+ return {
433
+ startState: function() {
434
+ return {
435
+ tokenize: tokenBase,
436
+ cc: [],
437
+ stack: []
438
+ };
439
+ },
440
+
441
+ token: function(stream, state) {
442
+ if (stream.eatSpace()) return null;
443
+ var style = state.tokenize(stream, state);
444
+ return style;
445
+ }
446
+ };
447
+
448
+ });
449
+
450
+ CodeMirror.defineMIME("application/xquery", "xquery");