erp_app 3.0.12 → 3.0.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (29) hide show
  1. data/lib/erp_app/version.rb +1 -1
  2. data/public/javascripts/erp_app/codemirror/doc/compress.html +27 -25
  3. data/public/javascripts/erp_app/codemirror/doc/manual.html +8 -1
  4. data/public/javascripts/erp_app/codemirror/doc/oldrelease.html +51 -0
  5. data/public/javascripts/erp_app/codemirror/doc/realworld.html +72 -0
  6. data/public/javascripts/erp_app/codemirror/keymap/vim.js +9 -10
  7. data/public/javascripts/erp_app/codemirror/lib/codemirror.css +1 -0
  8. data/public/javascripts/erp_app/codemirror/lib/codemirror.js +53 -31
  9. data/public/javascripts/erp_app/codemirror/lib/util/overlay.js +6 -1
  10. data/public/javascripts/erp_app/codemirror/lib/util/runmode.js +1 -1
  11. data/public/javascripts/erp_app/codemirror/lib/util/searchcursor.js +3 -3
  12. data/public/javascripts/erp_app/codemirror/lib/util/simple-hint.js +9 -4
  13. data/public/javascripts/erp_app/codemirror/mode/clike/clike.js +1 -0
  14. data/public/javascripts/erp_app/codemirror/mode/css/css.js +1 -1
  15. data/public/javascripts/erp_app/codemirror/mode/css/test.js +2 -2
  16. data/public/javascripts/erp_app/codemirror/mode/gfm/gfm.js +83 -139
  17. data/public/javascripts/erp_app/codemirror/mode/gfm/index.html +27 -4
  18. data/public/javascripts/erp_app/codemirror/mode/gfm/test.js +225 -0
  19. data/public/javascripts/erp_app/codemirror/mode/htmlembedded/htmlembedded.js +1 -0
  20. data/public/javascripts/erp_app/codemirror/mode/javascript/index.html +11 -4
  21. data/public/javascripts/erp_app/codemirror/mode/javascript/javascript.js +63 -15
  22. data/public/javascripts/erp_app/codemirror/mode/javascript/typescript.html +48 -0
  23. data/public/javascripts/erp_app/codemirror/mode/lua/lua.js +1 -1
  24. data/public/javascripts/erp_app/codemirror/mode/markdown/markdown.js +122 -23
  25. data/public/javascripts/erp_app/codemirror/mode/markdown/test.js +183 -1
  26. data/public/javascripts/erp_app/codemirror/package.json +1 -1
  27. data/public/javascripts/erp_app/codemirror/test/index.html +3 -0
  28. data/public/javascripts/erp_app/codemirror/test/test.js +11 -6
  29. metadata +15 -32
@@ -217,9 +217,9 @@ MT.testMode(
217
217
 
218
218
  MT.testMode(
219
219
  'classSelector',
220
- '.foo { }',
220
+ '.foo-bar_hello { }',
221
221
  [
222
- 'qualifier', '.foo',
222
+ 'qualifier', '.foo-bar_hello',
223
223
  null, ' { }'
224
224
  ]
225
225
  );
@@ -1,150 +1,94 @@
1
1
  CodeMirror.defineMode("gfm", function(config, parserConfig) {
2
- var mdMode = CodeMirror.getMode(config, "markdown");
3
- var aliases = {
4
- html: "htmlmixed",
5
- js: "javascript",
6
- json: "application/json",
7
- c: "text/x-csrc",
8
- "c++": "text/x-c++src",
9
- java: "text/x-java",
10
- csharp: "text/x-csharp",
11
- "c#": "text/x-csharp"
12
- };
13
-
14
- // make this lazy so that we don't need to load GFM last
15
- var getMode = (function () {
16
- var i, modes = {}, mimes = {}, mime;
17
-
18
- var list = CodeMirror.listModes();
19
- for (i = 0; i < list.length; i++) {
20
- modes[list[i]] = list[i];
21
- }
22
- var mimesList = CodeMirror.listMIMEs();
23
- for (i = 0; i < mimesList.length; i++) {
24
- mime = mimesList[i].mime;
25
- mimes[mime] = mimesList[i].mime;
26
- }
27
-
28
- for (var a in aliases) {
29
- if (aliases[a] in modes || aliases[a] in mimes)
30
- modes[a] = aliases[a];
31
- }
32
-
33
- return function (lang) {
34
- return modes[lang] ? CodeMirror.getMode(config, modes[lang]) : null;
35
- };
36
- }());
37
-
38
- function markdown(stream, state) {
39
- // intercept fenced code blocks
40
- if (stream.sol() && stream.match(/^```([\w+#]*)/)) {
41
- // try switching mode
42
- state.localMode = getMode(RegExp.$1);
43
- if (state.localMode)
44
- state.localState = state.localMode.startState();
45
-
46
- state.token = local;
47
- return 'code';
48
- }
49
-
50
- return mdMode.token(stream, state.mdState);
51
- }
52
-
53
- function local(stream, state) {
54
- if (stream.sol() && stream.match(/^```/)) {
55
- state.localMode = state.localState = null;
56
- state.token = markdown;
57
- return 'code';
58
- }
59
- else if (state.localMode) {
60
- return state.localMode.token(stream, state.localState);
61
- } else {
62
- stream.skipToEnd();
63
- return 'code';
64
- }
65
- }
66
-
67
- // custom handleText to prevent emphasis in the middle of a word
68
- // and add autolinking
69
- function handleText(stream, mdState) {
70
- var match;
71
- if (stream.match(/^\w+:\/\/\S+/)) {
72
- return 'link';
73
- }
74
- if (stream.match(/^[^\[*\\<>` _][^\[*\\<>` ]*[^\[*\\<>` _]/)) {
75
- return mdMode.getType(mdState);
76
- }
77
- if (match = stream.match(/^[^\[*\\<>` ]+/)) {
78
- var word = match[0];
79
- if (word[0] === '_' && word[word.length-1] === '_') {
80
- stream.backUp(word.length);
81
- return undefined;
82
- }
83
- return mdMode.getType(mdState);
84
- }
85
- if (stream.eatSpace()) {
86
- return null;
87
- }
2
+ var codeDepth = 0;
3
+ function blankLine(state) {
4
+ state.code = false;
5
+ return null;
88
6
  }
89
-
90
- return {
7
+ var gfmOverlay = {
91
8
  startState: function() {
92
- var mdState = mdMode.startState();
93
- mdState.text = handleText;
94
- return {token: markdown, mode: "markdown", mdState: mdState,
95
- localMode: null, localState: null};
9
+ return {
10
+ code: false,
11
+ codeBlock: false,
12
+ ateSpace: false
13
+ };
96
14
  },
97
-
98
- copyState: function(state) {
99
- return {token: state.token, mdState: CodeMirror.copyState(mdMode, state.mdState),
100
- localMode: state.localMode,
101
- localState: state.localMode ? CodeMirror.copyState(state.localMode, state.localState) : null};
15
+ copyState: function(s) {
16
+ return {
17
+ code: s.code,
18
+ codeBlock: s.codeBlock,
19
+ ateSpace: s.ateSpace
20
+ };
102
21
  },
103
-
104
22
  token: function(stream, state) {
105
- /* Parse GFM double bracket links */
106
- var ch;
107
- if ((ch = stream.peek()) != undefined && ch == '[') {
108
- stream.next(); // Advance the stream
109
-
110
- /* Only handle double bracket links */
111
- if ((ch = stream.peek()) == undefined || ch != '[') {
112
- stream.backUp(1);
113
- return state.token(stream, state);
114
- }
115
-
116
- while ((ch = stream.next()) != undefined && ch != ']') {}
117
-
118
- if (ch == ']' && (ch = stream.next()) != undefined && ch == ']')
119
- return 'link';
120
-
121
- /* If we did not find the second ']' */
122
- stream.backUp(1);
123
- }
124
-
125
- /* Match GFM latex formulas, as well as latex formulas within '$' */
126
- if (stream.match(/^\$[^\$]+\$/)) {
127
- return "string";
23
+ // Hack to prevent formatting override inside code blocks (block and inline)
24
+ if (state.codeBlock) {
25
+ if (stream.match(/^```/)) {
26
+ state.codeBlock = false;
27
+ return null;
128
28
  }
129
-
130
- if (stream.match(/^\\\((.*?)\\\)/)) {
131
- return "string";
132
- }
133
-
134
- if (stream.match(/^\$\$[^\$]+\$\$/)) {
135
- return "string";
29
+ stream.skipToEnd();
30
+ return null;
31
+ }
32
+ if (stream.sol()) {
33
+ state.code = false;
34
+ }
35
+ if (stream.sol() && stream.match(/^```/)) {
36
+ stream.skipToEnd();
37
+ state.codeBlock = true;
38
+ return null;
39
+ }
40
+ // If this block is changed, it may need to be updated in Markdown mode
41
+ if (stream.peek() === '`') {
42
+ stream.next();
43
+ var before = stream.pos;
44
+ stream.eatWhile('`');
45
+ var difference = 1 + stream.pos - before;
46
+ if (!state.code) {
47
+ codeDepth = difference;
48
+ state.code = true;
49
+ } else {
50
+ if (difference === codeDepth) { // Must be exact
51
+ state.code = false;
52
+ }
136
53
  }
137
-
138
- if (stream.match(/^\\\[(.*?)\\\]/)) {
139
- return "string";
54
+ return null;
55
+ } else if (state.code) {
56
+ stream.next();
57
+ return null;
58
+ }
59
+ // Check if space. If so, links can be formatted later on
60
+ if (stream.eatSpace()) {
61
+ state.ateSpace = true;
62
+ return null;
63
+ }
64
+ if (stream.sol() || state.ateSpace) {
65
+ state.ateSpace = false;
66
+ if(stream.match(/^(?:[a-zA-Z0-9\-_]+\/)?(?:[a-zA-Z0-9\-_]+@)?(?:[a-f0-9]{7,40}\b)/)) {
67
+ // User/Project@SHA
68
+ // User@SHA
69
+ // SHA
70
+ return "link";
71
+ } else if (stream.match(/^(?:[a-zA-Z0-9\-_]+\/)?(?:[a-zA-Z0-9\-_]+)?#[0-9]+\b/)) {
72
+ // User/Project#Num
73
+ // User#Num
74
+ // #Num
75
+ return "link";
140
76
  }
141
-
142
- return state.token(stream, state);
77
+ }
78
+ if (stream.match(/^((?:[a-z][\w-]+:(?:\/{1,3}|[a-z0-9%])|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}\/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'".,<>?«»“”‘’]))/i)) {
79
+ // URLs
80
+ // Taken from http://daringfireball.net/2010/07/improved_regex_for_matching_urls
81
+ return "link";
82
+ }
83
+ stream.next();
84
+ return null;
143
85
  },
144
-
145
- innerMode: function(state) {
146
- if (state.token == markdown) return {state: state.mdState, mode: mdMode};
147
- else return {state: state.localState, mode: state.localMode};
148
- }
86
+ blankLine: blankLine
149
87
  };
150
- }, "markdown");
88
+ CodeMirror.defineMIME("gfmBase", {
89
+ name: "markdown",
90
+ underscoresBreakWords: false,
91
+ fencedCodeBlocks: true
92
+ });
93
+ return CodeMirror.overlayMode(CodeMirror.getMode(config, "gfmBase"), gfmOverlay);
94
+ });
@@ -5,10 +5,17 @@
5
5
  <title>CodeMirror: GFM mode</title>
6
6
  <link rel="stylesheet" href="../../lib/codemirror.css">
7
7
  <script src="../../lib/codemirror.js"></script>
8
+ <script src="../../lib/util/overlay.js"></script>
8
9
  <script src="../xml/xml.js"></script>
9
10
  <script src="../markdown/markdown.js"></script>
10
11
  <script src="gfm.js"></script>
12
+
13
+ <!-- Code block highlighting modes -->
11
14
  <script src="../javascript/javascript.js"></script>
15
+ <script src="../css/css.js"></script>
16
+ <script src="../htmlmixed/htmlmixed.js"></script>
17
+ <script src="../clike/clike.js"></script>
18
+
12
19
  <link rel="stylesheet" href="../markdown/markdown.css">
13
20
  <style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
14
21
  <link rel="stylesheet" href="../../doc/docs.css">
@@ -16,14 +23,17 @@
16
23
  <body>
17
24
  <h1>CodeMirror: GFM mode</h1>
18
25
 
19
- <!-- source: http://daringfireball.net/projects/markdown/basics.text -->
20
26
  <form><textarea id="code" name="code">
21
- Github Flavored Markdown
27
+ GitHub Flavored Markdown
22
28
  ========================
23
29
 
24
30
  Everything from markdown plus GFM features:
25
31
 
26
- ## Fenced code blocks
32
+ ## URL autolinking
33
+
34
+ Underscores_are_allowed_between_words.
35
+
36
+ ## Fenced code blocks (and syntax highlighting... someday)
27
37
 
28
38
  ```javascript
29
39
  for (var i = 0; i &lt; items.length; i++) {
@@ -31,7 +41,16 @@ for (var i = 0; i &lt; items.length; i++) {
31
41
  }
32
42
  ```
33
43
 
34
- See http://github.github.com/github-flavored-markdown/
44
+ ## A bit of GitHub spice
45
+
46
+ * SHA: be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2
47
+ * User@SHA ref: mojombo@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2
48
+ * User/Project@SHA: mojombo/god@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2
49
+ * \#Num: #1
50
+ * User/#Num: mojombo#1
51
+ * User/Project#Num: mojombo/god#1
52
+
53
+ See http://github.github.com/github-flavored-markdown/.
35
54
 
36
55
  </textarea></form>
37
56
 
@@ -44,5 +63,9 @@ See http://github.github.com/github-flavored-markdown/
44
63
  });
45
64
  </script>
46
65
 
66
+ <p>Optionally depends on other modes for properly highlighted code blocks.</p>
67
+
68
+ <p><strong>Parsing/Highlighting Tests:</strong> <a href="../../test/index.html#gfm_*">normal</a>, <a href="../../test/index.html#verbose,gfm_*">verbose</a>.</p>
69
+
47
70
  </body>
48
71
  </html>
@@ -0,0 +1,225 @@
1
+ // Initiate ModeTest and set defaults
2
+ var MT = ModeTest;
3
+ MT.modeName = 'gfm';
4
+ MT.modeOptions = {};
5
+
6
+ // Emphasis characters within a word
7
+ MT.testMode(
8
+ 'emInWordAsterisk',
9
+ 'foo*bar*hello',
10
+ [
11
+ null, 'foo',
12
+ 'em', '*bar*',
13
+ null, 'hello'
14
+ ]
15
+ );
16
+ MT.testMode(
17
+ 'emInWordUnderscore',
18
+ 'foo_bar_hello',
19
+ [
20
+ null, 'foo_bar_hello'
21
+ ]
22
+ );
23
+ MT.testMode(
24
+ 'emStrongUnderscore',
25
+ '___foo___ bar',
26
+ [
27
+ 'strong', '__',
28
+ 'emstrong', '_foo__',
29
+ 'em', '_',
30
+ null, ' bar'
31
+ ]
32
+ );
33
+
34
+ // Fenced code blocks
35
+ MT.testMode(
36
+ 'fencedCodeBlocks',
37
+ '```\nfoo\n\n```\nbar',
38
+ [
39
+ 'comment', '```',
40
+ 'comment', 'foo',
41
+ 'comment', '```',
42
+ null, 'bar'
43
+ ]
44
+ );
45
+ // Fenced code block mode switching
46
+ MT.testMode(
47
+ 'fencedCodeBlockModeSwitching',
48
+ '```javascript\nfoo\n\n```\nbar',
49
+ [
50
+ 'comment', '```javascript',
51
+ 'variable', 'foo',
52
+ 'comment', '```',
53
+ null, 'bar'
54
+ ]
55
+ );
56
+
57
+ // SHA
58
+ MT.testMode(
59
+ 'SHA',
60
+ 'foo be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2 bar',
61
+ [
62
+ null, 'foo ',
63
+ 'link', 'be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2',
64
+ null, ' bar'
65
+ ]
66
+ );
67
+ // GitHub highlights hashes 7-40 chars in length
68
+ MT.testMode(
69
+ 'shortSHA',
70
+ 'foo be6a8cc bar',
71
+ [
72
+ null, 'foo ',
73
+ 'link', 'be6a8cc',
74
+ null, ' bar'
75
+ ]
76
+ );
77
+ // Invalid SHAs
78
+ //
79
+ // GitHub does not highlight hashes shorter than 7 chars
80
+ MT.testMode(
81
+ 'tooShortSHA',
82
+ 'foo be6a8c bar',
83
+ [
84
+ null, 'foo be6a8c bar'
85
+ ]
86
+ );
87
+ // GitHub does not highlight hashes longer than 40 chars
88
+ MT.testMode(
89
+ 'longSHA',
90
+ 'foo be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd22 bar',
91
+ [
92
+ null, 'foo be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd22 bar'
93
+ ]
94
+ );
95
+ MT.testMode(
96
+ 'badSHA',
97
+ 'foo be6a8cc1c1ecfe9489fb51e4869af15a13fc2cg2 bar',
98
+ [
99
+ null, 'foo be6a8cc1c1ecfe9489fb51e4869af15a13fc2cg2 bar'
100
+ ]
101
+ );
102
+ // User@SHA
103
+ MT.testMode(
104
+ 'userSHA',
105
+ 'foo bar@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2 hello',
106
+ [
107
+ null, 'foo ',
108
+ 'link', 'bar@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2',
109
+ null, ' hello'
110
+ ]
111
+ );
112
+ // User/Project@SHA
113
+ MT.testMode(
114
+ 'userProjectSHA',
115
+ 'foo bar/hello@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2 world',
116
+ [
117
+ null, 'foo ',
118
+ 'link', 'bar/hello@be6a8cc1c1ecfe9489fb51e4869af15a13fc2cd2',
119
+ null, ' world'
120
+ ]
121
+ );
122
+
123
+ // #Num
124
+ MT.testMode(
125
+ 'num',
126
+ 'foo #1 bar',
127
+ [
128
+ null, 'foo ',
129
+ 'link', '#1',
130
+ null, ' bar'
131
+ ]
132
+ );
133
+ // bad #Num
134
+ MT.testMode(
135
+ 'badNum',
136
+ 'foo #1bar hello',
137
+ [
138
+ null, 'foo #1bar hello'
139
+ ]
140
+ );
141
+ // User#Num
142
+ MT.testMode(
143
+ 'userNum',
144
+ 'foo bar#1 hello',
145
+ [
146
+ null, 'foo ',
147
+ 'link', 'bar#1',
148
+ null, ' hello'
149
+ ]
150
+ );
151
+ // User/Project#Num
152
+ MT.testMode(
153
+ 'userProjectNum',
154
+ 'foo bar/hello#1 world',
155
+ [
156
+ null, 'foo ',
157
+ 'link', 'bar/hello#1',
158
+ null, ' world'
159
+ ]
160
+ );
161
+
162
+ // Vanilla links
163
+ MT.testMode(
164
+ 'vanillaLink',
165
+ 'foo http://www.example.com/ bar',
166
+ [
167
+ null, 'foo ',
168
+ 'link', 'http://www.example.com/',
169
+ null, ' bar'
170
+ ]
171
+ );
172
+ MT.testMode(
173
+ 'vanillaLinkPunctuation',
174
+ 'foo http://www.example.com/. bar',
175
+ [
176
+ null, 'foo ',
177
+ 'link', 'http://www.example.com/',
178
+ null, '. bar'
179
+ ]
180
+ );
181
+ MT.testMode(
182
+ 'vanillaLinkExtension',
183
+ 'foo http://www.example.com/index.html bar',
184
+ [
185
+ null, 'foo ',
186
+ 'link', 'http://www.example.com/index.html',
187
+ null, ' bar'
188
+ ]
189
+ );
190
+ // Not a link
191
+ MT.testMode(
192
+ 'notALink',
193
+ '```css\nfoo {color:black;}\n```http://www.example.com/',
194
+ [
195
+ 'comment', '```css',
196
+ 'tag', 'foo',
197
+ null, ' {',
198
+ 'property', 'color',
199
+ 'operator', ':',
200
+ 'keyword', 'black',
201
+ null, ';}',
202
+ 'comment', '```',
203
+ 'link', 'http://www.example.com/'
204
+ ]
205
+ );
206
+ // Not a link
207
+ MT.testMode(
208
+ 'notALink',
209
+ '``foo `bar` http://www.example.com/`` hello',
210
+ [
211
+ 'comment', '``foo `bar` http://www.example.com/``',
212
+ null, ' hello'
213
+ ]
214
+ );
215
+ // Not a link
216
+ MT.testMode(
217
+ 'notALink',
218
+ '`foo\nhttp://www.example.com/\n`foo\n\nhttp://www.example.com/',
219
+ [
220
+ 'comment', '`foo',
221
+ 'link', 'http://www.example.com/',
222
+ 'comment', '`foo',
223
+ 'link', 'http://www.example.com/'
224
+ ]
225
+ );
@@ -70,3 +70,4 @@ CodeMirror.defineMode("htmlembedded", function(config, parserConfig) {
70
70
  CodeMirror.defineMIME("application/x-ejs", { name: "htmlembedded", scriptingModeSpec:"javascript"});
71
71
  CodeMirror.defineMIME("application/x-aspx", { name: "htmlembedded", scriptingModeSpec:"text/x-csharp"});
72
72
  CodeMirror.defineMIME("application/x-jsp", { name: "htmlembedded", scriptingModeSpec:"text/x-java"});
73
+ CodeMirror.defineMIME("application/x-erb", { name: "htmlembedded", scriptingModeSpec:"ruby"});
@@ -69,10 +69,17 @@ StringStream.prototype = {
69
69
  });
70
70
  </script>
71
71
 
72
- <p>JavaScript mode supports a single configuration
73
- option, <code>json</code>, which will set the mode to expect JSON
74
- data rather than a JavaScript program.</p>
72
+ <p>
73
+ JavaScript mode supports a two configuration
74
+ options:
75
+ <ul>
76
+ <li><code>json</code> which will set the mode to expect JSON data rather than a JavaScript program.</li>
77
+ <li>
78
+ <code>typescript</code> which will activate additional syntax highlighting and some other things for TypeScript code (<a href="typescript.html">demo</a>).
79
+ </li>
80
+ </ul>
81
+ </p>
75
82
 
76
- <p><strong>MIME types defined:</strong> <code>text/javascript</code>, <code>application/json</code>.</p>
83
+ <p><strong>MIME types defined:</strong> <code>text/javascript</code>, <code>application/json</code>, <code>text/typescript</code>, <code>application/typescript</code>.</p>
77
84
  </body>
78
85
  </html>