marty 2.4.7 → 2.4.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (225) hide show
  1. checksums.yaml +4 -4
  2. data/Dockerfile.dummy +8 -5
  3. data/Gemfile.lock +1 -1
  4. data/README.md +8 -0
  5. data/app/assets/javascripts/marty/application.js +1 -0
  6. data/app/assets/javascripts/marty/codemirror/codemirror.js +9730 -0
  7. data/app/{components/marty/script_form/client → assets/javascripts/marty/codemirror}/mode/delorean/delorean.js +0 -0
  8. data/app/assets/javascripts/marty/codemirror/mode/javascript/javascript.js +900 -0
  9. data/app/assets/javascripts/marty/codemirror/mode/python/python.js +399 -0
  10. data/app/{components/marty/script_form/client → assets/javascripts/marty/codemirror}/mode/ruby/ruby.js +135 -34
  11. data/app/{components/marty/script_form/client/Ext.ux.form.field.CodeMirror.js → assets/javascripts/marty/extjs/extensions/marty.js} +87 -6
  12. data/app/assets/stylesheets/marty/application.css +1 -13
  13. data/app/assets/stylesheets/marty/codemirror/codemirror.css +346 -0
  14. data/app/{components/marty/script_form/client → assets/stylesheets/marty/codemirror}/delorean.css +0 -0
  15. data/app/components/marty/auth_app/client/auth_app.js +82 -80
  16. data/app/components/marty/data_grid_view.rb +1 -54
  17. data/app/components/marty/data_grid_view/client/data_grid_view.js +49 -0
  18. data/app/components/marty/form.rb +1 -5
  19. data/app/components/marty/form/client/form.js +5 -0
  20. data/app/components/marty/grid.rb +1 -146
  21. data/app/components/marty/grid/client/grid.js +146 -0
  22. data/app/components/marty/import_view.rb +1 -32
  23. data/app/components/marty/import_view/client/import_view.js +32 -0
  24. data/app/components/marty/live_search_grid_panel.rb +1 -21
  25. data/app/components/marty/live_search_grid_panel/client/live_search_grid_panel.js +27 -0
  26. data/app/components/marty/main_auth_app.rb +4 -145
  27. data/app/components/marty/main_auth_app/client/main_auth_app.js +124 -0
  28. data/app/components/marty/mcfly_grid_panel.rb +1 -17
  29. data/app/components/marty/mcfly_grid_panel/client/mcfly_grid_panel.js +37 -0
  30. data/app/components/marty/new_posting_form.rb +1 -6
  31. data/app/components/marty/new_posting_form/client/new_posting_form.js +6 -0
  32. data/app/components/marty/panel.rb +1 -5
  33. data/app/components/marty/panel/client/panel.js +5 -0
  34. data/app/components/marty/posting_grid.rb +4 -55
  35. data/app/components/marty/posting_grid/client/posting_grid.js +50 -0
  36. data/app/components/marty/promise_view.rb +2 -75
  37. data/app/components/marty/promise_view/client/promise_view.css +12 -9
  38. data/app/components/marty/promise_view/client/promise_view.js +57 -0
  39. data/app/components/marty/report_form.rb +3 -69
  40. data/app/components/marty/report_form/client/report_form.js +78 -0
  41. data/app/components/marty/report_select.rb +1 -45
  42. data/app/components/marty/report_select/client/report_select.js +50 -0
  43. data/app/components/marty/reporting.rb +1 -8
  44. data/app/components/marty/reporting/client/reporting.js +8 -0
  45. data/app/components/marty/script_form.rb +2 -63
  46. data/app/components/marty/script_form/client/script_form.js +44 -0
  47. data/app/components/marty/script_tester.rb +1 -7
  48. data/app/components/marty/script_tester/client/script_tester.js +7 -0
  49. data/app/components/marty/scripting.rb +1 -55
  50. data/app/components/marty/scripting/client/scripting.js +62 -0
  51. data/app/components/marty/simple_app/client/simple_app.js +21 -13
  52. data/app/models/marty/promise.rb +22 -1
  53. data/app/views/layouts/marty/application.html.erb +8 -6
  54. data/docker-compose.dummy.yml +2 -0
  55. data/lib/marty/monkey.rb +0 -16
  56. data/lib/marty/version.rb +1 -1
  57. data/spec/dummy/config/initializers/assets.rb +1 -0
  58. data/spec/features/reporting_spec.rb +1 -0
  59. data/spec/features/scripting_spec.rb +4 -4
  60. data/spec/spec_helper.rb +1 -0
  61. data/spec/support/chromedriver.rb +5 -1
  62. data/spec/support/shared_connection_db_helpers.rb +42 -2
  63. metadata +29 -168
  64. data/app/assets/images/marty/.gitkeep +0 -0
  65. data/app/components/marty/mcfly_grid_panel/client/dup_in_form.js +0 -20
  66. data/app/components/marty/script_form/client/codemirror.css +0 -172
  67. data/app/components/marty/script_form/client/codemirror.js +0 -3130
  68. data/app/components/marty/script_form/client/mode/clike/clike.js +0 -284
  69. data/app/components/marty/script_form/client/mode/clike/index.html +0 -102
  70. data/app/components/marty/script_form/client/mode/clike/scala.html +0 -766
  71. data/app/components/marty/script_form/client/mode/clojure/clojure.js +0 -206
  72. data/app/components/marty/script_form/client/mode/clojure/index.html +0 -67
  73. data/app/components/marty/script_form/client/mode/coffeescript/LICENSE +0 -22
  74. data/app/components/marty/script_form/client/mode/coffeescript/coffeescript.js +0 -346
  75. data/app/components/marty/script_form/client/mode/coffeescript/index.html +0 -728
  76. data/app/components/marty/script_form/client/mode/commonlisp/commonlisp.js +0 -101
  77. data/app/components/marty/script_form/client/mode/commonlisp/index.html +0 -165
  78. data/app/components/marty/script_form/client/mode/css/css.js +0 -448
  79. data/app/components/marty/script_form/client/mode/css/index.html +0 -58
  80. data/app/components/marty/script_form/client/mode/css/test.js +0 -501
  81. data/app/components/marty/script_form/client/mode/diff/diff.js +0 -32
  82. data/app/components/marty/script_form/client/mode/diff/index.html +0 -105
  83. data/app/components/marty/script_form/client/mode/ecl/ecl.js +0 -203
  84. data/app/components/marty/script_form/client/mode/ecl/index.html +0 -42
  85. data/app/components/marty/script_form/client/mode/erlang/erlang.js +0 -463
  86. data/app/components/marty/script_form/client/mode/erlang/index.html +0 -63
  87. data/app/components/marty/script_form/client/mode/gfm/gfm.js +0 -150
  88. data/app/components/marty/script_form/client/mode/gfm/index.html +0 -48
  89. data/app/components/marty/script_form/client/mode/go/go.js +0 -170
  90. data/app/components/marty/script_form/client/mode/go/index.html +0 -73
  91. data/app/components/marty/script_form/client/mode/groovy/groovy.js +0 -210
  92. data/app/components/marty/script_form/client/mode/groovy/index.html +0 -72
  93. data/app/components/marty/script_form/client/mode/haskell/haskell.js +0 -242
  94. data/app/components/marty/script_form/client/mode/haskell/index.html +0 -61
  95. data/app/components/marty/script_form/client/mode/haxe/haxe.js +0 -429
  96. data/app/components/marty/script_form/client/mode/haxe/index.html +0 -91
  97. data/app/components/marty/script_form/client/mode/htmlembedded/htmlembedded.js +0 -72
  98. data/app/components/marty/script_form/client/mode/htmlembedded/index.html +0 -50
  99. data/app/components/marty/script_form/client/mode/htmlmixed/htmlmixed.js +0 -84
  100. data/app/components/marty/script_form/client/mode/htmlmixed/index.html +0 -52
  101. data/app/components/marty/script_form/client/mode/javascript/index.html +0 -78
  102. data/app/components/marty/script_form/client/mode/javascript/javascript.js +0 -361
  103. data/app/components/marty/script_form/client/mode/jinja2/index.html +0 -38
  104. data/app/components/marty/script_form/client/mode/jinja2/jinja2.js +0 -42
  105. data/app/components/marty/script_form/client/mode/less/index.html +0 -740
  106. data/app/components/marty/script_form/client/mode/less/less.js +0 -266
  107. data/app/components/marty/script_form/client/mode/lua/index.html +0 -73
  108. data/app/components/marty/script_form/client/mode/lua/lua.js +0 -140
  109. data/app/components/marty/script_form/client/mode/markdown/index.html +0 -343
  110. data/app/components/marty/script_form/client/mode/markdown/markdown.js +0 -382
  111. data/app/components/marty/script_form/client/mode/markdown/test.js +0 -1084
  112. data/app/components/marty/script_form/client/mode/mysql/index.html +0 -42
  113. data/app/components/marty/script_form/client/mode/mysql/mysql.js +0 -186
  114. data/app/components/marty/script_form/client/mode/ntriples/index.html +0 -33
  115. data/app/components/marty/script_form/client/mode/ntriples/ntriples.js +0 -172
  116. data/app/components/marty/script_form/client/mode/ocaml/index.html +0 -130
  117. data/app/components/marty/script_form/client/mode/ocaml/ocaml.js +0 -114
  118. data/app/components/marty/script_form/client/mode/pascal/LICENSE +0 -7
  119. data/app/components/marty/script_form/client/mode/pascal/index.html +0 -49
  120. data/app/components/marty/script_form/client/mode/pascal/pascal.js +0 -94
  121. data/app/components/marty/script_form/client/mode/perl/LICENSE +0 -19
  122. data/app/components/marty/script_form/client/mode/perl/index.html +0 -63
  123. data/app/components/marty/script_form/client/mode/perl/perl.js +0 -816
  124. data/app/components/marty/script_form/client/mode/php/index.html +0 -49
  125. data/app/components/marty/script_form/client/mode/php/php.js +0 -148
  126. data/app/components/marty/script_form/client/mode/pig/index.html +0 -43
  127. data/app/components/marty/script_form/client/mode/pig/pig.js +0 -172
  128. data/app/components/marty/script_form/client/mode/plsql/index.html +0 -63
  129. data/app/components/marty/script_form/client/mode/plsql/plsql.js +0 -217
  130. data/app/components/marty/script_form/client/mode/properties/index.html +0 -41
  131. data/app/components/marty/script_form/client/mode/properties/properties.js +0 -63
  132. data/app/components/marty/script_form/client/mode/python/LICENSE.txt +0 -21
  133. data/app/components/marty/script_form/client/mode/python/index.html +0 -123
  134. data/app/components/marty/script_form/client/mode/python/python.js +0 -338
  135. data/app/components/marty/script_form/client/mode/r/LICENSE +0 -24
  136. data/app/components/marty/script_form/client/mode/r/index.html +0 -74
  137. data/app/components/marty/script_form/client/mode/r/r.js +0 -141
  138. data/app/components/marty/script_form/client/mode/rpm/changes/changes.js +0 -19
  139. data/app/components/marty/script_form/client/mode/rpm/changes/index.html +0 -54
  140. data/app/components/marty/script_form/client/mode/rpm/spec/index.html +0 -100
  141. data/app/components/marty/script_form/client/mode/rpm/spec/spec.css +0 -5
  142. data/app/components/marty/script_form/client/mode/rpm/spec/spec.js +0 -66
  143. data/app/components/marty/script_form/client/mode/rst/index.html +0 -526
  144. data/app/components/marty/script_form/client/mode/rst/rst.js +0 -326
  145. data/app/components/marty/script_form/client/mode/ruby/LICENSE +0 -24
  146. data/app/components/marty/script_form/client/mode/ruby/index.html +0 -172
  147. data/app/components/marty/script_form/client/mode/rust/index.html +0 -49
  148. data/app/components/marty/script_form/client/mode/rust/rust.js +0 -432
  149. data/app/components/marty/script_form/client/mode/scheme/index.html +0 -65
  150. data/app/components/marty/script_form/client/mode/scheme/scheme.js +0 -230
  151. data/app/components/marty/script_form/client/mode/shell/index.html +0 -50
  152. data/app/components/marty/script_form/client/mode/shell/shell.js +0 -118
  153. data/app/components/marty/script_form/client/mode/sieve/LICENSE +0 -23
  154. data/app/components/marty/script_form/client/mode/sieve/index.html +0 -81
  155. data/app/components/marty/script_form/client/mode/sieve/sieve.js +0 -156
  156. data/app/components/marty/script_form/client/mode/smalltalk/index.html +0 -56
  157. data/app/components/marty/script_form/client/mode/smalltalk/smalltalk.js +0 -139
  158. data/app/components/marty/script_form/client/mode/smarty/index.html +0 -83
  159. data/app/components/marty/script_form/client/mode/smarty/smarty.js +0 -148
  160. data/app/components/marty/script_form/client/mode/sparql/index.html +0 -41
  161. data/app/components/marty/script_form/client/mode/sparql/sparql.js +0 -143
  162. data/app/components/marty/script_form/client/mode/stex/index.html +0 -98
  163. data/app/components/marty/script_form/client/mode/stex/stex.js +0 -182
  164. data/app/components/marty/script_form/client/mode/stex/test.js +0 -343
  165. data/app/components/marty/script_form/client/mode/tiddlywiki/index.html +0 -141
  166. data/app/components/marty/script_form/client/mode/tiddlywiki/tiddlywiki.css +0 -14
  167. data/app/components/marty/script_form/client/mode/tiddlywiki/tiddlywiki.js +0 -384
  168. data/app/components/marty/script_form/client/mode/tiki/index.html +0 -83
  169. data/app/components/marty/script_form/client/mode/tiki/tiki.css +0 -26
  170. data/app/components/marty/script_form/client/mode/tiki/tiki.js +0 -309
  171. data/app/components/marty/script_form/client/mode/vb/LICENSE.txt +0 -21
  172. data/app/components/marty/script_form/client/mode/vb/index.html +0 -89
  173. data/app/components/marty/script_form/client/mode/vb/vb.js +0 -260
  174. data/app/components/marty/script_form/client/mode/vbscript/index.html +0 -43
  175. data/app/components/marty/script_form/client/mode/vbscript/vbscript.js +0 -26
  176. data/app/components/marty/script_form/client/mode/velocity/index.html +0 -104
  177. data/app/components/marty/script_form/client/mode/velocity/velocity.js +0 -146
  178. data/app/components/marty/script_form/client/mode/verilog/index.html +0 -211
  179. data/app/components/marty/script_form/client/mode/verilog/verilog.js +0 -194
  180. data/app/components/marty/script_form/client/mode/xml/index.html +0 -45
  181. data/app/components/marty/script_form/client/mode/xml/xml.js +0 -318
  182. data/app/components/marty/script_form/client/mode/xquery/LICENSE +0 -20
  183. data/app/components/marty/script_form/client/mode/xquery/index.html +0 -223
  184. data/app/components/marty/script_form/client/mode/xquery/test/index.html +0 -27
  185. data/app/components/marty/script_form/client/mode/xquery/test/testBase.js +0 -42
  186. data/app/components/marty/script_form/client/mode/xquery/test/testEmptySequenceKeyword.js +0 -16
  187. data/app/components/marty/script_form/client/mode/xquery/test/testMultiAttr.js +0 -16
  188. data/app/components/marty/script_form/client/mode/xquery/test/testNamespaces.js +0 -91
  189. data/app/components/marty/script_form/client/mode/xquery/test/testProcessingInstructions.js +0 -16
  190. data/app/components/marty/script_form/client/mode/xquery/test/testQuotes.js +0 -19
  191. data/app/components/marty/script_form/client/mode/xquery/xquery.js +0 -451
  192. data/app/components/marty/script_form/client/mode/yaml/index.html +0 -68
  193. data/app/components/marty/script_form/client/mode/yaml/yaml.js +0 -95
  194. data/app/components/marty/script_form/client/theme/ambiance.css +0 -81
  195. data/app/components/marty/script_form/client/theme/blackboard.css +0 -25
  196. data/app/components/marty/script_form/client/theme/cobalt.css +0 -18
  197. data/app/components/marty/script_form/client/theme/eclipse.css +0 -25
  198. data/app/components/marty/script_form/client/theme/elegant.css +0 -10
  199. data/app/components/marty/script_form/client/theme/erlang-dark.css +0 -21
  200. data/app/components/marty/script_form/client/theme/lesser-dark.css +0 -44
  201. data/app/components/marty/script_form/client/theme/monokai.css +0 -28
  202. data/app/components/marty/script_form/client/theme/neat.css +0 -9
  203. data/app/components/marty/script_form/client/theme/night.css +0 -21
  204. data/app/components/marty/script_form/client/theme/rubyblue.css +0 -21
  205. data/app/components/marty/script_form/client/theme/vibrant-ink.css +0 -27
  206. data/app/components/marty/script_form/client/theme/xq-dark.css +0 -46
  207. data/app/components/marty/script_form/client/util/closetag.js +0 -164
  208. data/app/components/marty/script_form/client/util/dialog.css +0 -27
  209. data/app/components/marty/script_form/client/util/dialog.js +0 -70
  210. data/app/components/marty/script_form/client/util/foldcode.js +0 -196
  211. data/app/components/marty/script_form/client/util/formatting.js +0 -193
  212. data/app/components/marty/script_form/client/util/javascript-hint.js +0 -134
  213. data/app/components/marty/script_form/client/util/loadmode.js +0 -51
  214. data/app/components/marty/script_form/client/util/match-highlighter.js +0 -44
  215. data/app/components/marty/script_form/client/util/multiplex.js +0 -77
  216. data/app/components/marty/script_form/client/util/overlay.js +0 -54
  217. data/app/components/marty/script_form/client/util/pig-hint.js +0 -123
  218. data/app/components/marty/script_form/client/util/runmode-standalone.js +0 -90
  219. data/app/components/marty/script_form/client/util/runmode.js +0 -53
  220. data/app/components/marty/script_form/client/util/search.js +0 -118
  221. data/app/components/marty/script_form/client/util/searchcursor.js +0 -119
  222. data/app/components/marty/script_form/client/util/simple-hint.css +0 -16
  223. data/app/components/marty/script_form/client/util/simple-hint.js +0 -97
  224. data/app/components/marty/script_form/client/util/xml-hint.js +0 -137
  225. data/lib/marty/javascript/grid_view_in_form.js +0 -81
@@ -1,141 +0,0 @@
1
- <!doctype html>
2
- <html>
3
- <head>
4
- <meta charset="utf-8">
5
- <title>CodeMirror: TiddlyWiki mode</title>
6
- <link rel="stylesheet" href="../../lib/codemirror.css">
7
- <script src="../../lib/codemirror.js"></script>
8
- <script src="tiddlywiki.js"></script>
9
- <link rel="stylesheet" href="tiddlywiki.css">
10
- <link rel="stylesheet" href="../../doc/docs.css">
11
- <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
12
- </head>
13
- <body>
14
- <h1>CodeMirror: TiddlyWiki mode</h1>
15
-
16
- <div><textarea id="code" name="code">
17
- !TiddlyWiki Formatting
18
- * Rendered versions can be found at: http://www.tiddlywiki.com/#Reference
19
-
20
- |!Option | !Syntax |
21
- |bold font | ''bold'' |
22
- |italic type | //italic// |
23
- |underlined text | __underlined__ |
24
- |strikethrough text | --strikethrough-- |
25
- |superscript text | super^^script^^ |
26
- |subscript text | sub~~script~~ |
27
- |highlighted text | @@highlighted@@ |
28
- |preformatted text | {{{preformatted}}} |
29
-
30
- !Block Elements
31
- <<<
32
- !Heading 1
33
-
34
- !!Heading 2
35
-
36
- !!!Heading 3
37
-
38
- !!!!Heading 4
39
-
40
- !!!!!Heading 5
41
- <<<
42
-
43
- !!Lists
44
- <<<
45
- * unordered list, level 1
46
- ** unordered list, level 2
47
- *** unordered list, level 3
48
-
49
- # ordered list, level 1
50
- ## ordered list, level 2
51
- ### unordered list, level 3
52
-
53
- ; definition list, term
54
- : definition list, description
55
- <<<
56
-
57
- !!Blockquotes
58
- <<<
59
- > blockquote, level 1
60
- >> blockquote, level 2
61
- >>> blockquote, level 3
62
-
63
- > blockquote
64
- <<<
65
-
66
- !!Preformatted Text
67
- <<<
68
- {{{
69
- preformatted (e.g. code)
70
- }}}
71
- <<<
72
-
73
- !!Code Sections
74
- <<<
75
- {{{
76
- Text style code
77
- }}}
78
-
79
- //{{{
80
- JS styled code. TiddlyWiki mixed mode should support highlighter switching in the future.
81
- //}}}
82
-
83
- <!--{{{-->
84
- XML styled code. TiddlyWiki mixed mode should support highlighter switching in the future.
85
- <!--}}}-->
86
- <<<
87
-
88
- !!Tables
89
- <<<
90
- |CssClass|k
91
- |!heading column 1|!heading column 2|
92
- |row 1, column 1|row 1, column 2|
93
- |row 2, column 1|row 2, column 2|
94
- |>|COLSPAN|
95
- |ROWSPAN| ... |
96
- |~| ... |
97
- |CssProperty:value;...| ... |
98
- |caption|c
99
-
100
- ''Annotation:''
101
- * The {{{>}}} marker creates a "colspan", causing the current cell to merge with the one to the right.
102
- * The {{{~}}} marker creates a "rowspan", causing the current cell to merge with the one above.
103
- <<<
104
- !!Images /% TODO %/
105
- cf. [[TiddlyWiki.com|http://www.tiddlywiki.com/#EmbeddedImages]]
106
-
107
- !Hyperlinks
108
- * [[WikiWords|WikiWord]] are automatically transformed to hyperlinks to the respective tiddler
109
- ** the automatic transformation can be suppressed by preceding the respective WikiWord with a tilde ({{{~}}}): {{{~WikiWord}}}
110
- * [[PrettyLinks]] are enclosed in square brackets and contain the desired tiddler name: {{{[[tiddler name]]}}}
111
- ** optionally, a custom title or description can be added, separated by a pipe character ({{{|}}}): {{{[[title|target]]}}}<br>'''N.B.:''' In this case, the target can also be any website (i.e. URL).
112
-
113
- !Custom Styling
114
- * {{{@@CssProperty:value;CssProperty:value;...@@}}}<br>''N.B.:'' CSS color definitions should use lowercase letters to prevent the inadvertent creation of WikiWords.
115
- * <html><code>{{customCssClass{...}}}</code></html>
116
- * raw HTML can be inserted by enclosing the respective code in HTML tags: {{{<html> ... </html>}}}
117
-
118
- !Special Markers
119
- * {{{<br>}}} forces a manual line break
120
- * {{{----}}} creates a horizontal ruler
121
- * [[HTML entities|http://www.tiddlywiki.com/#HtmlEntities]]
122
- * [[HTML entities local|HtmlEntities]]
123
- * {{{<<macroName>>}}} calls the respective [[macro|Macros]]
124
- * To hide text within a tiddler so that it is not displayed, it can be wrapped in {{{/%}}} and {{{%/}}}.<br/>This can be a useful trick for hiding drafts or annotating complex markup.
125
- * To prevent wiki markup from taking effect for a particular section, that section can be enclosed in three double quotes: e.g. {{{"""WikiWord"""}}}.
126
- </textarea></div>
127
-
128
- <script>
129
- var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
130
- mode: 'tiddlywiki',
131
- lineNumbers: true,
132
- enterMode: 'keep',
133
- matchBrackets: true
134
- });
135
- </script>
136
-
137
- <p>TiddlyWiki mode supports a single configuration.</p>
138
-
139
- <p><strong>MIME types defined:</strong> <code>text/x-tiddlywiki</code>.</p>
140
- </body>
141
- </html>
@@ -1,14 +0,0 @@
1
- span.cm-underlined {
2
- text-decoration: underline;
3
- }
4
- span.cm-strikethrough {
5
- text-decoration: line-through;
6
- }
7
- span.cm-brace {
8
- color: #170;
9
- font-weight: bold;
10
- }
11
- span.cm-table {
12
- color: blue;
13
- font-weight: bold;
14
- }
@@ -1,384 +0,0 @@
1
- /***
2
- |''Name''|tiddlywiki.js|
3
- |''Description''|Enables TiddlyWikiy syntax highlighting using CodeMirror|
4
- |''Author''|PMario|
5
- |''Version''|0.1.7|
6
- |''Status''|''stable''|
7
- |''Source''|[[GitHub|https://github.com/pmario/CodeMirror2/blob/tw-syntax/mode/tiddlywiki]]|
8
- |''Documentation''|http://codemirror.tiddlyspace.com/|
9
- |''License''|[[MIT License|http://www.opensource.org/licenses/mit-license.php]]|
10
- |''CoreVersion''|2.5.0|
11
- |''Requires''|codemirror.js|
12
- |''Keywords''|syntax highlighting color code mirror codemirror|
13
- ! Info
14
- CoreVersion parameter is needed for TiddlyWiki only!
15
- ***/
16
- //{{{
17
- CodeMirror.defineMode("tiddlywiki", function (config, parserConfig) {
18
- var indentUnit = config.indentUnit;
19
-
20
- // Tokenizer
21
- var textwords = function () {
22
- function kw(type) {
23
- return {
24
- type: type,
25
- style: "text"
26
- };
27
- }
28
- return {};
29
- }();
30
-
31
- var keywords = function () {
32
- function kw(type) {
33
- return { type: type, style: "macro"};
34
- }
35
- return {
36
- "allTags": kw('allTags'), "closeAll": kw('closeAll'), "list": kw('list'),
37
- "newJournal": kw('newJournal'), "newTiddler": kw('newTiddler'),
38
- "permaview": kw('permaview'), "saveChanges": kw('saveChanges'),
39
- "search": kw('search'), "slider": kw('slider'), "tabs": kw('tabs'),
40
- "tag": kw('tag'), "tagging": kw('tagging'), "tags": kw('tags'),
41
- "tiddler": kw('tiddler'), "timeline": kw('timeline'),
42
- "today": kw('today'), "version": kw('version'), "option": kw('option'),
43
-
44
- "with": kw('with'),
45
- "filter": kw('filter')
46
- };
47
- }();
48
-
49
- var isSpaceName = /[\w_\-]/i,
50
- reHR = /^\-\-\-\-+$/, // <hr>
51
- reWikiCommentStart = /^\/\*\*\*$/, // /***
52
- reWikiCommentStop = /^\*\*\*\/$/, // ***/
53
- reBlockQuote = /^<<<$/,
54
-
55
- reJsCodeStart = /^\/\/\{\{\{$/, // //{{{ js block start
56
- reJsCodeStop = /^\/\/\}\}\}$/, // //}}} js stop
57
- reXmlCodeStart = /^<!--\{\{\{-->$/, // xml block start
58
- reXmlCodeStop = /^<!--\}\}\}-->$/, // xml stop
59
-
60
- reCodeBlockStart = /^\{\{\{$/, // {{{ TW text div block start
61
- reCodeBlockStop = /^\}\}\}$/, // }}} TW text stop
62
-
63
- reCodeStart = /\{\{\{/, // {{{ code span start
64
- reUntilCodeStop = /.*?\}\}\}/;
65
-
66
- function chain(stream, state, f) {
67
- state.tokenize = f;
68
- return f(stream, state);
69
- }
70
-
71
- // used for strings
72
- function nextUntilUnescaped(stream, end) {
73
- var escaped = false,
74
- next;
75
- while ((next = stream.next()) != null) {
76
- if (next == end && !escaped) return false;
77
- escaped = !escaped && next == "\\";
78
- }
79
- return escaped;
80
- }
81
-
82
- // Used as scratch variables to communicate multiple values without
83
- // consing up tons of objects.
84
- var type, content;
85
-
86
- function ret(tp, style, cont) {
87
- type = tp;
88
- content = cont;
89
- return style;
90
- }
91
-
92
- function jsTokenBase(stream, state) {
93
- var sol = stream.sol(),
94
- ch, tch;
95
-
96
- state.block = false; // indicates the start of a code block.
97
-
98
- ch = stream.peek(); // don't eat, to make matching simpler
99
-
100
- // check start of blocks
101
- if (sol && /[<\/\*{}\-]/.test(ch)) {
102
- if (stream.match(reCodeBlockStart)) {
103
- state.block = true;
104
- return chain(stream, state, twTokenCode);
105
- }
106
- if (stream.match(reBlockQuote)) {
107
- return ret('quote', 'quote');
108
- }
109
- if (stream.match(reWikiCommentStart) || stream.match(reWikiCommentStop)) {
110
- return ret('code', 'comment');
111
- }
112
- if (stream.match(reJsCodeStart) || stream.match(reJsCodeStop) || stream.match(reXmlCodeStart) || stream.match(reXmlCodeStop)) {
113
- return ret('code', 'comment');
114
- }
115
- if (stream.match(reHR)) {
116
- return ret('hr', 'hr');
117
- }
118
- } // sol
119
- ch = stream.next();
120
-
121
- if (sol && /[\/\*!#;:>|]/.test(ch)) {
122
- if (ch == "!") { // tw header
123
- stream.skipToEnd();
124
- return ret("header", "header");
125
- }
126
- if (ch == "*") { // tw list
127
- stream.eatWhile('*');
128
- return ret("list", "comment");
129
- }
130
- if (ch == "#") { // tw numbered list
131
- stream.eatWhile('#');
132
- return ret("list", "comment");
133
- }
134
- if (ch == ";") { // definition list, term
135
- stream.eatWhile(';');
136
- return ret("list", "comment");
137
- }
138
- if (ch == ":") { // definition list, description
139
- stream.eatWhile(':');
140
- return ret("list", "comment");
141
- }
142
- if (ch == ">") { // single line quote
143
- stream.eatWhile(">");
144
- return ret("quote", "quote");
145
- }
146
- if (ch == '|') {
147
- return ret('table', 'header');
148
- }
149
- }
150
-
151
- if (ch == '{' && stream.match(/\{\{/)) {
152
- return chain(stream, state, twTokenCode);
153
- }
154
-
155
- // rudimentary html:// file:// link matching. TW knows much more ...
156
- if (/[hf]/i.test(ch)) {
157
- if (/[ti]/i.test(stream.peek()) && stream.match(/\b(ttps?|tp|ile):\/\/[\-A-Z0-9+&@#\/%?=~_|$!:,.;]*[A-Z0-9+&@#\/%=~_|$]/i)) {
158
- return ret("link", "link");
159
- }
160
- }
161
- // just a little string indicator, don't want to have the whole string covered
162
- if (ch == '"') {
163
- return ret('string', 'string');
164
- }
165
- if (ch == '~') { // _no_ CamelCase indicator should be bold
166
- return ret('text', 'brace');
167
- }
168
- if (/[\[\]]/.test(ch)) { // check for [[..]]
169
- if (stream.peek() == ch) {
170
- stream.next();
171
- return ret('brace', 'brace');
172
- }
173
- }
174
- if (ch == "@") { // check for space link. TODO fix @@...@@ highlighting
175
- stream.eatWhile(isSpaceName);
176
- return ret("link", "link");
177
- }
178
- if (/\d/.test(ch)) { // numbers
179
- stream.eatWhile(/\d/);
180
- return ret("number", "number");
181
- }
182
- if (ch == "/") { // tw invisible comment
183
- if (stream.eat("%")) {
184
- return chain(stream, state, twTokenComment);
185
- }
186
- else if (stream.eat("/")) { //
187
- return chain(stream, state, twTokenEm);
188
- }
189
- }
190
- if (ch == "_") { // tw underline
191
- if (stream.eat("_")) {
192
- return chain(stream, state, twTokenUnderline);
193
- }
194
- }
195
- // strikethrough and mdash handling
196
- if (ch == "-") {
197
- if (stream.eat("-")) {
198
- // if strikethrough looks ugly, change CSS.
199
- if (stream.peek() != ' ')
200
- return chain(stream, state, twTokenStrike);
201
- // mdash
202
- if (stream.peek() == ' ')
203
- return ret('text', 'brace');
204
- }
205
- }
206
- if (ch == "'") { // tw bold
207
- if (stream.eat("'")) {
208
- return chain(stream, state, twTokenStrong);
209
- }
210
- }
211
- if (ch == "<") { // tw macro
212
- if (stream.eat("<")) {
213
- return chain(stream, state, twTokenMacro);
214
- }
215
- }
216
- else {
217
- return ret(ch);
218
- }
219
-
220
- // core macro handling
221
- stream.eatWhile(/[\w\$_]/);
222
- var word = stream.current(),
223
- known = textwords.propertyIsEnumerable(word) && textwords[word];
224
-
225
- return known ? ret(known.type, known.style, word) : ret("text", null, word);
226
-
227
- } // jsTokenBase()
228
-
229
- function twTokenString(quote) {
230
- return function (stream, state) {
231
- if (!nextUntilUnescaped(stream, quote)) state.tokenize = jsTokenBase;
232
- return ret("string", "string");
233
- };
234
- }
235
-
236
- // tw invisible comment
237
- function twTokenComment(stream, state) {
238
- var maybeEnd = false,
239
- ch;
240
- while (ch = stream.next()) {
241
- if (ch == "/" && maybeEnd) {
242
- state.tokenize = jsTokenBase;
243
- break;
244
- }
245
- maybeEnd = (ch == "%");
246
- }
247
- return ret("comment", "comment");
248
- }
249
-
250
- // tw strong / bold
251
- function twTokenStrong(stream, state) {
252
- var maybeEnd = false,
253
- ch;
254
- while (ch = stream.next()) {
255
- if (ch == "'" && maybeEnd) {
256
- state.tokenize = jsTokenBase;
257
- break;
258
- }
259
- maybeEnd = (ch == "'");
260
- }
261
- return ret("text", "strong");
262
- }
263
-
264
- // tw code
265
- function twTokenCode(stream, state) {
266
- var ch, sb = state.block;
267
-
268
- if (sb && stream.current()) {
269
- return ret("code", "comment");
270
- }
271
-
272
- if (!sb && stream.match(reUntilCodeStop)) {
273
- state.tokenize = jsTokenBase;
274
- return ret("code", "comment");
275
- }
276
-
277
- if (sb && stream.sol() && stream.match(reCodeBlockStop)) {
278
- state.tokenize = jsTokenBase;
279
- return ret("code", "comment");
280
- }
281
-
282
- ch = stream.next();
283
- return (sb) ? ret("code", "comment") : ret("code", "comment");
284
- }
285
-
286
- // tw em / italic
287
- function twTokenEm(stream, state) {
288
- var maybeEnd = false,
289
- ch;
290
- while (ch = stream.next()) {
291
- if (ch == "/" && maybeEnd) {
292
- state.tokenize = jsTokenBase;
293
- break;
294
- }
295
- maybeEnd = (ch == "/");
296
- }
297
- return ret("text", "em");
298
- }
299
-
300
- // tw underlined text
301
- function twTokenUnderline(stream, state) {
302
- var maybeEnd = false,
303
- ch;
304
- while (ch = stream.next()) {
305
- if (ch == "_" && maybeEnd) {
306
- state.tokenize = jsTokenBase;
307
- break;
308
- }
309
- maybeEnd = (ch == "_");
310
- }
311
- return ret("text", "underlined");
312
- }
313
-
314
- // tw strike through text looks ugly
315
- // change CSS if needed
316
- function twTokenStrike(stream, state) {
317
- var maybeEnd = false,
318
- ch, nr;
319
-
320
- while (ch = stream.next()) {
321
- if (ch == "-" && maybeEnd) {
322
- state.tokenize = jsTokenBase;
323
- break;
324
- }
325
- maybeEnd = (ch == "-");
326
- }
327
- return ret("text", "strikethrough");
328
- }
329
-
330
- // macro
331
- function twTokenMacro(stream, state) {
332
- var ch, tmp, word, known;
333
-
334
- if (stream.current() == '<<') {
335
- return ret('brace', 'macro');
336
- }
337
-
338
- ch = stream.next();
339
- if (!ch) {
340
- state.tokenize = jsTokenBase;
341
- return ret(ch);
342
- }
343
- if (ch == ">") {
344
- if (stream.peek() == '>') {
345
- stream.next();
346
- state.tokenize = jsTokenBase;
347
- return ret("brace", "macro");
348
- }
349
- }
350
-
351
- stream.eatWhile(/[\w\$_]/);
352
- word = stream.current();
353
- known = keywords.propertyIsEnumerable(word) && keywords[word];
354
-
355
- if (known) {
356
- return ret(known.type, known.style, word);
357
- }
358
- else {
359
- return ret("macro", null, word);
360
- }
361
- }
362
-
363
- // Interface
364
- return {
365
- startState: function (basecolumn) {
366
- return {
367
- tokenize: jsTokenBase,
368
- indented: 0,
369
- level: 0
370
- };
371
- },
372
-
373
- token: function (stream, state) {
374
- if (stream.eatSpace()) return null;
375
- var style = state.tokenize(stream, state);
376
- return style;
377
- },
378
-
379
- electricChars: ""
380
- };
381
- });
382
-
383
- CodeMirror.defineMIME("text/x-tiddlywiki", "tiddlywiki");
384
- //}}}