liquid_cms 0.3.1.0 → 0.3.2.0
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.
- data/CHANGELOG.rdoc +10 -0
- data/Gemfile +0 -3
- data/README.rdoc +16 -2
- data/TODO.rdoc +0 -2
- data/app/controllers/cms/assets_controller.rb +20 -6
- data/app/controllers/cms/components_controller.rb +11 -3
- data/app/controllers/cms/pages_controller.rb +15 -4
- data/app/helpers/cms/common_helper.rb +31 -32
- data/app/liquid/cms_paperclip_extension.rb +75 -3
- data/app/liquid/tags/{data_tag.rb → cms/data_tag.rb} +0 -0
- data/app/models/cms/asset.rb +1 -1
- data/app/models/cms/component.rb +3 -3
- data/app/views/cms/assets/_form.html.erb +1 -2
- data/app/views/cms/assets/update.js.rjs +1 -0
- data/app/views/cms/components/update.js.rjs +1 -0
- data/app/views/cms/pages/_form.html.erb +3 -3
- data/app/views/cms/pages/update.js.rjs +1 -0
- data/app/views/layouts/cms.html.erb +4 -3
- data/config/initializers/cms/simple_form.rb +70 -12
- data/config/initializers/cms/simple_form_updates.rb +9 -3
- data/config/locales/cms/en.yml +6 -0
- data/lib/generators/liquid_cms/install_generator.rb +5 -1
- data/lib/generators/liquid_cms/templates/migration_rev2.rb +13 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/LICENSE +16 -20
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/lib/codemirror.css +68 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/lib/codemirror.js +2197 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/lib/overlay.js +51 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/lib/runmode.js +27 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/clike/clike.js +247 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/clike/index.html +102 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/clojure/clojure.js +207 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/clojure/index.html +85 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/coffeescript/LICENSE +22 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/coffeescript/coffeescript.js +325 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/coffeescript/index.html +722 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/css/css.js +124 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/css/index.html +56 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/diff/diff.css +3 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/diff/diff.js +13 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/diff/index.html +99 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/haskell/haskell.js +242 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/haskell/index.html +60 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/htmlmixed/htmlmixed.js +79 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/htmlmixed/index.html +52 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/javascript/index.html +78 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/javascript/javascript.js +352 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/jinja2/index.html +38 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/jinja2/jinja2.js +42 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/lua/index.html +72 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/lua/lua.js +140 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/markdown/index.html +340 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/markdown/markdown.css +10 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/markdown/markdown.js +230 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/ntriples/index.html +33 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/ntriples/ntriples.js +172 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/pascal/LICENSE +7 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/pascal/index.html +49 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/pascal/pascal.js +138 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/php/index.html +49 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/php/php.js +116 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/plsql/index.html +63 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/plsql/plsql.js +217 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/python/LICENSE.txt +21 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/python/index.html +123 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/python/python.js +320 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/r/LICENSE +24 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/r/index.html +74 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/r/r.js +141 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/rst/index.html +526 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/rst/rst.css +75 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/rst/rst.js +333 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/ruby/LICENSE +24 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/ruby/index.html +172 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/ruby/ruby.js +195 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/scheme/index.html +65 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/scheme/scheme.js +202 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/smalltalk/index.html +56 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/smalltalk/smalltalk.js +122 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/sparql/index.html +41 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/sparql/sparql.js +143 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/stex/index.html +96 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/stex/stex.js +167 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/velocity/index.html +103 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/velocity/velocity.js +146 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/xml/index.html +42 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/xml/xml.js +231 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/xmlpure/index.html +60 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/xmlpure/xmlpure.js +481 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/yaml/index.html +68 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/yaml/yaml.js +95 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/theme/cobalt.css +17 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/theme/default.css +19 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/theme/eclipse.css +24 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/theme/elegant.css +9 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/theme/neat.css +8 -0
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/theme/night.css +20 -0
- data/lib/generators/liquid_cms/templates/public/cms/javascripts/cms.js +1 -1
- data/lib/generators/liquid_cms/templates/public/cms/javascripts/codemirror_custom.js +96 -0
- data/lib/generators/liquid_cms/templates/public/cms/stylesheets/codemirror_changes.css +26 -0
- data/lib/generators/liquid_cms/templates/public/cms/stylesheets/liquid.css +7 -0
- data/lib/generators/liquid_cms/templates/public/cms/stylesheets/simple_form.css +0 -8
- data/lib/liquid_cms/version.rb +1 -1
- data/liquid_cms.gemspec +1 -1
- data/test/functional/assets_controller_test.rb +35 -20
- data/test/functional/components_controller_test.rb +15 -5
- data/test/functional/pages_controller_test.rb +19 -6
- data/test/rails_app/Gemfile +1 -2
- data/test/rails_app/config/locales/cms/en.yml +26 -4
- data/test/rails_app/db/migrate/20110511161859_create_liquid_cms_upgrade_rev2.rb +13 -0
- data/test/unit/asset_test.rb +1 -1
- data/test/unit/component_test.rb +1 -1
- metadata +89 -32
- data/generators/liquid_cms/templates/migration_rev1.rb +0 -38
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/css/csscolors.css +0 -55
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/css/docs.css +0 -158
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/css/font.js +0 -15
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/css/jscolors.css +0 -59
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/css/sparqlcolors.css +0 -43
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/css/xmlcolors.css +0 -55
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/js/codemirror.js +0 -582
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/js/editor.js +0 -1671
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/js/highlight.js +0 -68
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/js/mirrorframe.js +0 -81
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/js/parsecss.js +0 -161
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/js/parsedummy.js +0 -32
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/js/parsehtmlmixed.js +0 -93
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/js/parsejavascript.js +0 -359
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/js/parsesparql.js +0 -162
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/js/parsexml.js +0 -291
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/js/select.js +0 -699
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/js/stringstream.js +0 -159
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/js/tokenize.js +0 -57
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/js/tokenizejavascript.js +0 -174
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/js/undo.js +0 -413
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/js/unittests.js +0 -44
- data/lib/generators/liquid_cms/templates/public/cms/codemirror/js/util.js +0 -133
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
CodeMirror.defineMode("css", function(config) {
|
|
2
|
+
var indentUnit = config.indentUnit, type;
|
|
3
|
+
function ret(style, tp) {type = tp; return style;}
|
|
4
|
+
|
|
5
|
+
function tokenBase(stream, state) {
|
|
6
|
+
var ch = stream.next();
|
|
7
|
+
if (ch == "@") {stream.eatWhile(/[\w\\\-]/); return ret("meta", stream.current());}
|
|
8
|
+
else if (ch == "/" && stream.eat("*")) {
|
|
9
|
+
state.tokenize = tokenCComment;
|
|
10
|
+
return tokenCComment(stream, state);
|
|
11
|
+
}
|
|
12
|
+
else if (ch == "<" && stream.eat("!")) {
|
|
13
|
+
state.tokenize = tokenSGMLComment;
|
|
14
|
+
return tokenSGMLComment(stream, state);
|
|
15
|
+
}
|
|
16
|
+
else if (ch == "=") ret(null, "compare");
|
|
17
|
+
else if ((ch == "~" || ch == "|") && stream.eat("=")) return ret(null, "compare");
|
|
18
|
+
else if (ch == "\"" || ch == "'") {
|
|
19
|
+
state.tokenize = tokenString(ch);
|
|
20
|
+
return state.tokenize(stream, state);
|
|
21
|
+
}
|
|
22
|
+
else if (ch == "#") {
|
|
23
|
+
stream.eatWhile(/[\w\\\-]/);
|
|
24
|
+
return ret("atom", "hash");
|
|
25
|
+
}
|
|
26
|
+
else if (ch == "!") {
|
|
27
|
+
stream.match(/^\s*\w*/);
|
|
28
|
+
return ret("keyword", "important");
|
|
29
|
+
}
|
|
30
|
+
else if (/\d/.test(ch)) {
|
|
31
|
+
stream.eatWhile(/[\w.%]/);
|
|
32
|
+
return ret("number", "unit");
|
|
33
|
+
}
|
|
34
|
+
else if (/[,.+>*\/]/.test(ch)) {
|
|
35
|
+
return ret(null, "select-op");
|
|
36
|
+
}
|
|
37
|
+
else if (/[;{}:\[\]]/.test(ch)) {
|
|
38
|
+
return ret(null, ch);
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
stream.eatWhile(/[\w\\\-]/);
|
|
42
|
+
return ret("variable", "variable");
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
function tokenCComment(stream, state) {
|
|
47
|
+
var maybeEnd = false, ch;
|
|
48
|
+
while ((ch = stream.next()) != null) {
|
|
49
|
+
if (maybeEnd && ch == "/") {
|
|
50
|
+
state.tokenize = tokenBase;
|
|
51
|
+
break;
|
|
52
|
+
}
|
|
53
|
+
maybeEnd = (ch == "*");
|
|
54
|
+
}
|
|
55
|
+
return ret("comment", "comment");
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
function tokenSGMLComment(stream, state) {
|
|
59
|
+
var dashes = 0, ch;
|
|
60
|
+
while ((ch = stream.next()) != null) {
|
|
61
|
+
if (dashes >= 2 && ch == ">") {
|
|
62
|
+
state.tokenize = tokenBase;
|
|
63
|
+
break;
|
|
64
|
+
}
|
|
65
|
+
dashes = (ch == "-") ? dashes + 1 : 0;
|
|
66
|
+
}
|
|
67
|
+
return ret("comment", "comment");
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function tokenString(quote) {
|
|
71
|
+
return function(stream, state) {
|
|
72
|
+
var escaped = false, ch;
|
|
73
|
+
while ((ch = stream.next()) != null) {
|
|
74
|
+
if (ch == quote && !escaped)
|
|
75
|
+
break;
|
|
76
|
+
escaped = !escaped && ch == "\\";
|
|
77
|
+
}
|
|
78
|
+
if (!escaped) state.tokenize = tokenBase;
|
|
79
|
+
return ret("string", "string");
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return {
|
|
84
|
+
startState: function(base) {
|
|
85
|
+
return {tokenize: tokenBase,
|
|
86
|
+
baseIndent: base || 0,
|
|
87
|
+
stack: []};
|
|
88
|
+
},
|
|
89
|
+
|
|
90
|
+
token: function(stream, state) {
|
|
91
|
+
if (stream.eatSpace()) return null;
|
|
92
|
+
var style = state.tokenize(stream, state);
|
|
93
|
+
|
|
94
|
+
var context = state.stack[state.stack.length-1];
|
|
95
|
+
if (type == "hash" && context == "rule") style = "atom";
|
|
96
|
+
else if (style == "variable") {
|
|
97
|
+
if (context == "rule") style = "number";
|
|
98
|
+
else if (!context || context == "@media{") style = "tag";
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (context == "rule" && /^[\{\};]$/.test(type))
|
|
102
|
+
state.stack.pop();
|
|
103
|
+
if (type == "{") {
|
|
104
|
+
if (context == "@media") state.stack[state.stack.length-1] = "@media{";
|
|
105
|
+
else state.stack.push("{");
|
|
106
|
+
}
|
|
107
|
+
else if (type == "}") state.stack.pop();
|
|
108
|
+
else if (type == "@media") state.stack.push("@media");
|
|
109
|
+
else if (context == "{" && type != "comment") state.stack.push("rule");
|
|
110
|
+
return style;
|
|
111
|
+
},
|
|
112
|
+
|
|
113
|
+
indent: function(state, textAfter) {
|
|
114
|
+
var n = state.stack.length;
|
|
115
|
+
if (/^\}/.test(textAfter))
|
|
116
|
+
n -= state.stack[state.stack.length-1] == "rule" ? 2 : 1;
|
|
117
|
+
return state.baseIndent + n * indentUnit;
|
|
118
|
+
},
|
|
119
|
+
|
|
120
|
+
electricChars: "}"
|
|
121
|
+
};
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
CodeMirror.defineMIME("text/css", "css");
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>CodeMirror 2: CSS mode</title>
|
|
5
|
+
<link rel="stylesheet" href="../../lib/codemirror.css">
|
|
6
|
+
<script src="../../lib/codemirror.js"></script>
|
|
7
|
+
<script src="css.js"></script>
|
|
8
|
+
<link rel="stylesheet" href="../../theme/default.css">
|
|
9
|
+
<style>.CodeMirror {background: #f8f8f8;}</style>
|
|
10
|
+
<link rel="stylesheet" href="../../css/docs.css">
|
|
11
|
+
</head>
|
|
12
|
+
<body>
|
|
13
|
+
<h1>CodeMirror 2: CSS mode</h1>
|
|
14
|
+
<form><textarea id="code" name="code">
|
|
15
|
+
/* Some example CSS */
|
|
16
|
+
|
|
17
|
+
@import url("something.css");
|
|
18
|
+
|
|
19
|
+
body {
|
|
20
|
+
margin: 0;
|
|
21
|
+
padding: 3em 6em;
|
|
22
|
+
font-family: tahoma, arial, sans-serif;
|
|
23
|
+
color: #000;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
#navigation a {
|
|
27
|
+
font-weight: bold;
|
|
28
|
+
text-decoration: none !important;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
h1 {
|
|
32
|
+
font-size: 2.5em;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
h2 {
|
|
36
|
+
font-size: 1.7em;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
h1:before, h2:before {
|
|
40
|
+
content: "::";
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
code {
|
|
44
|
+
font-family: courier, monospace;
|
|
45
|
+
font-size: 80%;
|
|
46
|
+
color: #418A8A;
|
|
47
|
+
}
|
|
48
|
+
</textarea></form>
|
|
49
|
+
<script>
|
|
50
|
+
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {});
|
|
51
|
+
</script>
|
|
52
|
+
|
|
53
|
+
<p><strong>MIME types defined:</strong> <code>text/css</code>.</p>
|
|
54
|
+
|
|
55
|
+
</body>
|
|
56
|
+
</html>
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
CodeMirror.defineMode("diff", function() {
|
|
2
|
+
return {
|
|
3
|
+
token: function(stream) {
|
|
4
|
+
var ch = stream.next();
|
|
5
|
+
stream.skipToEnd();
|
|
6
|
+
if (ch == "+") return "plus";
|
|
7
|
+
if (ch == "-") return "minus";
|
|
8
|
+
if (ch == "@") return "rangeinfo";
|
|
9
|
+
}
|
|
10
|
+
};
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
CodeMirror.defineMIME("text/x-diff", "diff");
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
<!doctype html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>CodeMirror 2: Diff mode</title>
|
|
5
|
+
<link rel="stylesheet" href="../../lib/codemirror.css">
|
|
6
|
+
<script src="../../lib/codemirror.js"></script>
|
|
7
|
+
<script src="diff.js"></script>
|
|
8
|
+
<link rel="stylesheet" href="diff.css">
|
|
9
|
+
<style>.CodeMirror {border-top: 1px solid #ddd; border-bottom: 1px solid #ddd;}</style>
|
|
10
|
+
<link rel="stylesheet" href="../../css/docs.css">
|
|
11
|
+
</head>
|
|
12
|
+
<body>
|
|
13
|
+
<h1>CodeMirror 2: Diff mode</h1>
|
|
14
|
+
<form><textarea id="code" name="code">
|
|
15
|
+
diff --git a/index.html b/index.html
|
|
16
|
+
index c1d9156..7764744 100644
|
|
17
|
+
--- a/index.html
|
|
18
|
+
+++ b/index.html
|
|
19
|
+
@@ -95,7 +95,8 @@ StringStream.prototype = {
|
|
20
|
+
<script>
|
|
21
|
+
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
|
22
|
+
lineNumbers: true,
|
|
23
|
+
- autoMatchBrackets: true
|
|
24
|
+
+ autoMatchBrackets: true,
|
|
25
|
+
+ onGutterClick: function(x){console.log(x);}
|
|
26
|
+
});
|
|
27
|
+
</script>
|
|
28
|
+
</body>
|
|
29
|
+
diff --git a/lib/codemirror.js b/lib/codemirror.js
|
|
30
|
+
index 04646a9..9a39cc7 100644
|
|
31
|
+
--- a/lib/codemirror.js
|
|
32
|
+
+++ b/lib/codemirror.js
|
|
33
|
+
@@ -399,10 +399,16 @@ var CodeMirror = (function() {
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function onMouseDown(e) {
|
|
37
|
+
- var start = posFromMouse(e), last = start;
|
|
38
|
+
+ var start = posFromMouse(e), last = start, target = e.target();
|
|
39
|
+
if (!start) return;
|
|
40
|
+
setCursor(start.line, start.ch, false);
|
|
41
|
+
if (e.button() != 1) return;
|
|
42
|
+
+ if (target.parentNode == gutter) {
|
|
43
|
+
+ if (options.onGutterClick)
|
|
44
|
+
+ options.onGutterClick(indexOf(gutter.childNodes, target) + showingFrom);
|
|
45
|
+
+ return;
|
|
46
|
+
+ }
|
|
47
|
+
+
|
|
48
|
+
if (!focused) onFocus();
|
|
49
|
+
|
|
50
|
+
e.stop();
|
|
51
|
+
@@ -808,7 +814,7 @@ var CodeMirror = (function() {
|
|
52
|
+
for (var i = showingFrom; i < showingTo; ++i) {
|
|
53
|
+
var marker = lines[i].gutterMarker;
|
|
54
|
+
if (marker) html.push('<div class="' + marker.style + '">' + htmlEscape(marker.text) + '</div>');
|
|
55
|
+
- else html.push("<div>" + (options.lineNumbers ? i + 1 : "\u00a0") + "</div>");
|
|
56
|
+
+ else html.push("<div>" + (options.lineNumbers ? i + options.firstLineNumber : "\u00a0") + "</div>");
|
|
57
|
+
}
|
|
58
|
+
gutter.style.display = "none"; // TODO test whether this actually helps
|
|
59
|
+
gutter.innerHTML = html.join("");
|
|
60
|
+
@@ -1371,10 +1377,8 @@ var CodeMirror = (function() {
|
|
61
|
+
if (option == "parser") setParser(value);
|
|
62
|
+
else if (option === "lineNumbers") setLineNumbers(value);
|
|
63
|
+
else if (option === "gutter") setGutter(value);
|
|
64
|
+
- else if (option === "readOnly") options.readOnly = value;
|
|
65
|
+
- else if (option === "indentUnit") {options.indentUnit = indentUnit = value; setParser(options.parser);}
|
|
66
|
+
- else if (/^(?:enterMode|tabMode|indentWithTabs|readOnly|autoMatchBrackets|undoDepth)$/.test(option)) options[option] = value;
|
|
67
|
+
- else throw new Error("Can't set option " + option);
|
|
68
|
+
+ else if (option === "indentUnit") {options.indentUnit = value; setParser(options.parser);}
|
|
69
|
+
+ else options[option] = value;
|
|
70
|
+
},
|
|
71
|
+
cursorCoords: cursorCoords,
|
|
72
|
+
undo: operation(undo),
|
|
73
|
+
@@ -1402,7 +1406,8 @@ var CodeMirror = (function() {
|
|
74
|
+
replaceRange: operation(replaceRange),
|
|
75
|
+
|
|
76
|
+
operation: function(f){return operation(f)();},
|
|
77
|
+
- refresh: function(){updateDisplay([{from: 0, to: lines.length}]);}
|
|
78
|
+
+ refresh: function(){updateDisplay([{from: 0, to: lines.length}]);},
|
|
79
|
+
+ getInputField: function(){return input;}
|
|
80
|
+
};
|
|
81
|
+
return instance;
|
|
82
|
+
}
|
|
83
|
+
@@ -1420,6 +1425,7 @@ var CodeMirror = (function() {
|
|
84
|
+
readOnly: false,
|
|
85
|
+
onChange: null,
|
|
86
|
+
onCursorActivity: null,
|
|
87
|
+
+ onGutterClick: null,
|
|
88
|
+
autoMatchBrackets: false,
|
|
89
|
+
workTime: 200,
|
|
90
|
+
workDelay: 300,
|
|
91
|
+
</textarea></form>
|
|
92
|
+
<script>
|
|
93
|
+
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {});
|
|
94
|
+
</script>
|
|
95
|
+
|
|
96
|
+
<p><strong>MIME types defined:</strong> <code>text/x-diff</code>.</p>
|
|
97
|
+
|
|
98
|
+
</body>
|
|
99
|
+
</html>
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
CodeMirror.defineMode("haskell", function(cmCfg, modeCfg) {
|
|
2
|
+
|
|
3
|
+
function switchState(source, setState, f) {
|
|
4
|
+
setState(f);
|
|
5
|
+
return f(source, setState);
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
// These should all be Unicode extended, as per the Haskell 2010 report
|
|
9
|
+
var smallRE = /[a-z_]/;
|
|
10
|
+
var largeRE = /[A-Z]/;
|
|
11
|
+
var digitRE = /[0-9]/;
|
|
12
|
+
var hexitRE = /[0-9A-Fa-f]/;
|
|
13
|
+
var octitRE = /[0-7]/;
|
|
14
|
+
var idRE = /[a-z_A-Z0-9']/;
|
|
15
|
+
var symbolRE = /[-!#$%&*+.\/<=>?@\\^|~:]/;
|
|
16
|
+
var specialRE = /[(),;[\]`{}]/;
|
|
17
|
+
var whiteCharRE = /[ \t\v\f]/; // newlines are handled in tokenizer
|
|
18
|
+
|
|
19
|
+
function normal(source, setState) {
|
|
20
|
+
if (source.eatWhile(whiteCharRE)) {
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
var ch = source.next();
|
|
25
|
+
if (specialRE.test(ch)) {
|
|
26
|
+
if (ch == '{' && source.eat('-')) {
|
|
27
|
+
var t = "comment";
|
|
28
|
+
if (source.eat('#')) {
|
|
29
|
+
t = "meta";
|
|
30
|
+
}
|
|
31
|
+
return switchState(source, setState, ncomment(t, 1));
|
|
32
|
+
}
|
|
33
|
+
return null;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
if (ch == '\'') {
|
|
37
|
+
if (source.eat('\\')) {
|
|
38
|
+
source.next(); // should handle other escapes here
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
source.next();
|
|
42
|
+
}
|
|
43
|
+
if (source.eat('\'')) {
|
|
44
|
+
return "string";
|
|
45
|
+
}
|
|
46
|
+
return "error";
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (ch == '"') {
|
|
50
|
+
return switchState(source, setState, stringLiteral);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (largeRE.test(ch)) {
|
|
54
|
+
source.eatWhile(idRE);
|
|
55
|
+
if (source.eat('.')) {
|
|
56
|
+
return "qualifier";
|
|
57
|
+
}
|
|
58
|
+
return "variable-2";
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
if (smallRE.test(ch)) {
|
|
62
|
+
source.eatWhile(idRE);
|
|
63
|
+
return "variable";
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (digitRE.test(ch)) {
|
|
67
|
+
if (ch == '0') {
|
|
68
|
+
if (source.eat(/[xX]/)) {
|
|
69
|
+
source.eatWhile(hexitRE); // should require at least 1
|
|
70
|
+
return "integer";
|
|
71
|
+
}
|
|
72
|
+
if (source.eat(/[oO]/)) {
|
|
73
|
+
source.eatWhile(octitRE); // should require at least 1
|
|
74
|
+
return "number";
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
source.eatWhile(digitRE);
|
|
78
|
+
var t = "number";
|
|
79
|
+
if (source.eat('.')) {
|
|
80
|
+
t = "number";
|
|
81
|
+
source.eatWhile(digitRE); // should require at least 1
|
|
82
|
+
}
|
|
83
|
+
if (source.eat(/[eE]/)) {
|
|
84
|
+
t = "number";
|
|
85
|
+
source.eat(/[-+]/);
|
|
86
|
+
source.eatWhile(digitRE); // should require at least 1
|
|
87
|
+
}
|
|
88
|
+
return t;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (symbolRE.test(ch)) {
|
|
92
|
+
if (ch == '-' && source.eat(/-/)) {
|
|
93
|
+
source.eatWhile(/-/);
|
|
94
|
+
if (!source.eat(symbolRE)) {
|
|
95
|
+
source.skipToEnd();
|
|
96
|
+
return "comment";
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
var t = "variable";
|
|
100
|
+
if (ch == ':') {
|
|
101
|
+
t = "variable-2";
|
|
102
|
+
}
|
|
103
|
+
source.eatWhile(symbolRE);
|
|
104
|
+
return t;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return "error";
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
function ncomment(type, nest) {
|
|
111
|
+
if (nest == 0) {
|
|
112
|
+
return normal;
|
|
113
|
+
}
|
|
114
|
+
return function(source, setState) {
|
|
115
|
+
var currNest = nest;
|
|
116
|
+
while (!source.eol()) {
|
|
117
|
+
var ch = source.next();
|
|
118
|
+
if (ch == '{' && source.eat('-')) {
|
|
119
|
+
++currNest;
|
|
120
|
+
}
|
|
121
|
+
else if (ch == '-' && source.eat('}')) {
|
|
122
|
+
--currNest;
|
|
123
|
+
if (currNest == 0) {
|
|
124
|
+
setState(normal);
|
|
125
|
+
return type;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
setState(ncomment(type, currNest));
|
|
130
|
+
return type;
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function stringLiteral(source, setState) {
|
|
135
|
+
while (!source.eol()) {
|
|
136
|
+
var ch = source.next();
|
|
137
|
+
if (ch == '"') {
|
|
138
|
+
setState(normal);
|
|
139
|
+
return "string";
|
|
140
|
+
}
|
|
141
|
+
if (ch == '\\') {
|
|
142
|
+
if (source.eol() || source.eat(whiteCharRE)) {
|
|
143
|
+
setState(stringGap);
|
|
144
|
+
return "string";
|
|
145
|
+
}
|
|
146
|
+
if (source.eat('&')) {
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
source.next(); // should handle other escapes here
|
|
150
|
+
}
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
setState(normal);
|
|
154
|
+
return "error";
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function stringGap(source, setState) {
|
|
158
|
+
if (source.eat('\\')) {
|
|
159
|
+
return switchState(source, setState, stringLiteral);
|
|
160
|
+
}
|
|
161
|
+
source.next();
|
|
162
|
+
setState(normal);
|
|
163
|
+
return "error";
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
var wellKnownWords = (function() {
|
|
168
|
+
var wkw = {};
|
|
169
|
+
function setType(t) {
|
|
170
|
+
return function () {
|
|
171
|
+
for (var i = 0; i < arguments.length; i++)
|
|
172
|
+
wkw[arguments[i]] = t;
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
setType("keyword")(
|
|
177
|
+
"case", "class", "data", "default", "deriving", "do", "else", "foreign",
|
|
178
|
+
"if", "import", "in", "infix", "infixl", "infixr", "instance", "let",
|
|
179
|
+
"module", "newtype", "of", "then", "type", "where", "_");
|
|
180
|
+
|
|
181
|
+
setType("keyword")(
|
|
182
|
+
"\.\.", ":", "::", "=", "\\", "\"", "<-", "->", "@", "~", "=>");
|
|
183
|
+
|
|
184
|
+
setType("builtin")(
|
|
185
|
+
"!!", "$!", "$", "&&", "+", "++", "-", ".", "/", "/=", "<", "<=", "=<<",
|
|
186
|
+
"==", ">", ">=", ">>", ">>=", "^", "^^", "||", "*", "**");
|
|
187
|
+
|
|
188
|
+
setType("builtin")(
|
|
189
|
+
"Bool", "Bounded", "Char", "Double", "EQ", "Either", "Enum", "Eq",
|
|
190
|
+
"False", "FilePath", "Float", "Floating", "Fractional", "Functor", "GT",
|
|
191
|
+
"IO", "IOError", "Int", "Integer", "Integral", "Just", "LT", "Left",
|
|
192
|
+
"Maybe", "Monad", "Nothing", "Num", "Ord", "Ordering", "Rational", "Read",
|
|
193
|
+
"ReadS", "Real", "RealFloat", "RealFrac", "Right", "Show", "ShowS",
|
|
194
|
+
"String", "True");
|
|
195
|
+
|
|
196
|
+
setType("builtin")(
|
|
197
|
+
"abs", "acos", "acosh", "all", "and", "any", "appendFile", "asTypeOf",
|
|
198
|
+
"asin", "asinh", "atan", "atan2", "atanh", "break", "catch", "ceiling",
|
|
199
|
+
"compare", "concat", "concatMap", "const", "cos", "cosh", "curry",
|
|
200
|
+
"cycle", "decodeFloat", "div", "divMod", "drop", "dropWhile", "either",
|
|
201
|
+
"elem", "encodeFloat", "enumFrom", "enumFromThen", "enumFromThenTo",
|
|
202
|
+
"enumFromTo", "error", "even", "exp", "exponent", "fail", "filter",
|
|
203
|
+
"flip", "floatDigits", "floatRadix", "floatRange", "floor", "fmap",
|
|
204
|
+
"foldl", "foldl1", "foldr", "foldr1", "fromEnum", "fromInteger",
|
|
205
|
+
"fromIntegral", "fromRational", "fst", "gcd", "getChar", "getContents",
|
|
206
|
+
"getLine", "head", "id", "init", "interact", "ioError", "isDenormalized",
|
|
207
|
+
"isIEEE", "isInfinite", "isNaN", "isNegativeZero", "iterate", "last",
|
|
208
|
+
"lcm", "length", "lex", "lines", "log", "logBase", "lookup", "map",
|
|
209
|
+
"mapM", "mapM_", "max", "maxBound", "maximum", "maybe", "min", "minBound",
|
|
210
|
+
"minimum", "mod", "negate", "not", "notElem", "null", "odd", "or",
|
|
211
|
+
"otherwise", "pi", "pred", "print", "product", "properFraction",
|
|
212
|
+
"putChar", "putStr", "putStrLn", "quot", "quotRem", "read", "readFile",
|
|
213
|
+
"readIO", "readList", "readLn", "readParen", "reads", "readsPrec",
|
|
214
|
+
"realToFrac", "recip", "rem", "repeat", "replicate", "return", "reverse",
|
|
215
|
+
"round", "scaleFloat", "scanl", "scanl1", "scanr", "scanr1", "seq",
|
|
216
|
+
"sequence", "sequence_", "show", "showChar", "showList", "showParen",
|
|
217
|
+
"showString", "shows", "showsPrec", "significand", "signum", "sin",
|
|
218
|
+
"sinh", "snd", "span", "splitAt", "sqrt", "subtract", "succ", "sum",
|
|
219
|
+
"tail", "take", "takeWhile", "tan", "tanh", "toEnum", "toInteger",
|
|
220
|
+
"toRational", "truncate", "uncurry", "undefined", "unlines", "until",
|
|
221
|
+
"unwords", "unzip", "unzip3", "userError", "words", "writeFile", "zip",
|
|
222
|
+
"zip3", "zipWith", "zipWith3");
|
|
223
|
+
|
|
224
|
+
return wkw;
|
|
225
|
+
})();
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
return {
|
|
230
|
+
startState: function () { return { f: normal }; },
|
|
231
|
+
copyState: function (s) { return { f: s.f }; },
|
|
232
|
+
|
|
233
|
+
token: function(stream, state) {
|
|
234
|
+
var t = state.f(stream, function(s) { state.f = s; });
|
|
235
|
+
var w = stream.current();
|
|
236
|
+
return (w in wellKnownWords) ? wellKnownWords[w] : t;
|
|
237
|
+
}
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
});
|
|
241
|
+
|
|
242
|
+
CodeMirror.defineMIME("text/x-haskell", "haskell");
|