liquid_cms 0.2.1.1 → 0.2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +7 -0
- data/README.rdoc +15 -1
- 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 -31
- data/app/liquid/cms_paperclip_extension.rb +75 -3
- 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 -1
- 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 +1 -1
- data/app/views/cms/pages/update.js.rjs +1 -0
- data/app/views/layouts/cms.html.erb +4 -3
- data/generators/liquid_cms/liquid_cms_generator.rb +1 -0
- data/generators/liquid_cms/templates/config/locales/cms/en.yml +4 -0
- data/generators/liquid_cms/templates/migration_rev2.rb +13 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/LICENSE +16 -20
- data/generators/liquid_cms/templates/public/cms/codemirror/lib/codemirror.css +68 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/lib/codemirror.js +2197 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/lib/overlay.js +51 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/lib/runmode.js +27 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/clike/clike.js +247 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/clike/index.html +102 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/clojure/clojure.js +207 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/clojure/index.html +85 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/coffeescript/LICENSE +22 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/coffeescript/coffeescript.js +325 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/coffeescript/index.html +722 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/css/css.js +124 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/css/index.html +56 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/diff/diff.css +3 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/diff/diff.js +13 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/diff/index.html +99 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/haskell/haskell.js +242 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/haskell/index.html +60 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/htmlmixed/htmlmixed.js +79 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/htmlmixed/index.html +52 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/javascript/index.html +78 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/javascript/javascript.js +352 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/jinja2/index.html +38 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/jinja2/jinja2.js +42 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/lua/index.html +72 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/lua/lua.js +140 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/markdown/index.html +340 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/markdown/markdown.css +10 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/markdown/markdown.js +230 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/ntriples/index.html +33 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/ntriples/ntriples.js +172 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/pascal/LICENSE +7 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/pascal/index.html +49 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/pascal/pascal.js +138 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/php/index.html +49 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/php/php.js +116 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/plsql/index.html +63 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/plsql/plsql.js +217 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/python/LICENSE.txt +21 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/python/index.html +123 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/python/python.js +320 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/r/LICENSE +24 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/r/index.html +74 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/r/r.js +141 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/rst/index.html +526 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/rst/rst.css +75 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/rst/rst.js +333 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/ruby/LICENSE +24 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/ruby/index.html +172 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/ruby/ruby.js +195 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/scheme/index.html +65 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/scheme/scheme.js +202 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/smalltalk/index.html +56 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/smalltalk/smalltalk.js +122 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/sparql/index.html +41 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/sparql/sparql.js +143 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/stex/index.html +96 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/stex/stex.js +167 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/velocity/index.html +103 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/velocity/velocity.js +146 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/xml/index.html +42 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/xml/xml.js +231 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/xmlpure/index.html +60 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/xmlpure/xmlpure.js +481 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/yaml/index.html +68 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/yaml/yaml.js +95 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/theme/cobalt.css +17 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/theme/default.css +19 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/theme/eclipse.css +24 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/theme/elegant.css +9 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/theme/neat.css +8 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/theme/night.css +20 -0
- data/generators/liquid_cms/templates/public/cms/javascripts/cms.js +1 -1
- data/generators/liquid_cms/templates/public/cms/javascripts/codemirror_custom.js +96 -0
- data/generators/liquid_cms/templates/public/cms/stylesheets/codemirror_changes.css +26 -0
- data/generators/liquid_cms/templates/public/cms/stylesheets/liquid.css +7 -0
- data/generators/liquid_cms/templates/public/cms/stylesheets/simple_form.css +0 -8
- data/lib/liquid_cms/version.rb +1 -1
- data/liquid_cms.gemspec +0 -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/config/environment.rb +1 -1
- data/test/rails_app/config/locales/cms/en.yml +19 -4
- data/test/rails_app/db/migrate/20110511161859_create_liquid_cms_upgrade_rev2.rb +13 -0
- data/test/unit/asset_test.rb +1 -1
- metadata +100 -58
- data/generators/liquid_cms/templates/public/cms/codemirror/css/csscolors.css +0 -55
- data/generators/liquid_cms/templates/public/cms/codemirror/css/docs.css +0 -158
- data/generators/liquid_cms/templates/public/cms/codemirror/css/font.js +0 -15
- data/generators/liquid_cms/templates/public/cms/codemirror/css/jscolors.css +0 -59
- data/generators/liquid_cms/templates/public/cms/codemirror/css/sparqlcolors.css +0 -43
- data/generators/liquid_cms/templates/public/cms/codemirror/css/xmlcolors.css +0 -55
- data/generators/liquid_cms/templates/public/cms/codemirror/js/codemirror.js +0 -582
- data/generators/liquid_cms/templates/public/cms/codemirror/js/editor.js +0 -1671
- data/generators/liquid_cms/templates/public/cms/codemirror/js/highlight.js +0 -68
- data/generators/liquid_cms/templates/public/cms/codemirror/js/mirrorframe.js +0 -81
- data/generators/liquid_cms/templates/public/cms/codemirror/js/parsecss.js +0 -161
- data/generators/liquid_cms/templates/public/cms/codemirror/js/parsedummy.js +0 -32
- data/generators/liquid_cms/templates/public/cms/codemirror/js/parsehtmlmixed.js +0 -93
- data/generators/liquid_cms/templates/public/cms/codemirror/js/parsejavascript.js +0 -359
- data/generators/liquid_cms/templates/public/cms/codemirror/js/parsesparql.js +0 -162
- data/generators/liquid_cms/templates/public/cms/codemirror/js/parsexml.js +0 -291
- data/generators/liquid_cms/templates/public/cms/codemirror/js/select.js +0 -699
- data/generators/liquid_cms/templates/public/cms/codemirror/js/stringstream.js +0 -159
- data/generators/liquid_cms/templates/public/cms/codemirror/js/tokenize.js +0 -57
- data/generators/liquid_cms/templates/public/cms/codemirror/js/tokenizejavascript.js +0 -174
- data/generators/liquid_cms/templates/public/cms/codemirror/js/undo.js +0 -413
- data/generators/liquid_cms/templates/public/cms/codemirror/js/unittests.js +0 -44
- data/generators/liquid_cms/templates/public/cms/codemirror/js/util.js +0 -133
@@ -0,0 +1,230 @@
|
|
1
|
+
CodeMirror.defineMode("markdown", function(cmCfg, modeCfg) {
|
2
|
+
|
3
|
+
var htmlMode = CodeMirror.getMode(cmCfg, { name: 'xml', htmlMode: true });
|
4
|
+
|
5
|
+
var header = 'header'
|
6
|
+
, code = 'code'
|
7
|
+
, quote = 'quote'
|
8
|
+
, list = 'list'
|
9
|
+
, hr = 'hr'
|
10
|
+
, linktext = 'linktext'
|
11
|
+
, linkhref = 'linkhref'
|
12
|
+
, em = 'em'
|
13
|
+
, strong = 'strong'
|
14
|
+
, emstrong = 'emstrong';
|
15
|
+
|
16
|
+
var hrRE = /^[*-=_]/
|
17
|
+
, ulRE = /^[*-+]\s+/
|
18
|
+
, olRE = /^[0-9]\.\s+/
|
19
|
+
, headerRE = /^(?:\={3,}|-{3,})$/
|
20
|
+
, codeRE = /^(k:\t|\s{4,})/
|
21
|
+
, textRE = /^[^\[*_\\<>`]+/;
|
22
|
+
|
23
|
+
function switchInline(stream, state, f) {
|
24
|
+
state.f = state.inline = f;
|
25
|
+
return f(stream, state);
|
26
|
+
}
|
27
|
+
|
28
|
+
function switchBlock(stream, state, f) {
|
29
|
+
state.f = state.block = f;
|
30
|
+
return f(stream, state);
|
31
|
+
}
|
32
|
+
|
33
|
+
|
34
|
+
// Blocks
|
35
|
+
|
36
|
+
function blockNormal(stream, state) {
|
37
|
+
if (stream.match(codeRE)) {
|
38
|
+
stream.skipToEnd();
|
39
|
+
return code;
|
40
|
+
}
|
41
|
+
|
42
|
+
if (stream.eatSpace()) {
|
43
|
+
return null;
|
44
|
+
}
|
45
|
+
|
46
|
+
if (stream.peek() === '#' || stream.match(headerRE)) {
|
47
|
+
stream.skipToEnd();
|
48
|
+
return header;
|
49
|
+
}
|
50
|
+
if (stream.eat('>')) {
|
51
|
+
state.indentation++;
|
52
|
+
return quote;
|
53
|
+
}
|
54
|
+
if (stream.peek() === '<') {
|
55
|
+
return switchBlock(stream, state, htmlBlock);
|
56
|
+
}
|
57
|
+
if (stream.peek() === '[') {
|
58
|
+
return switchInline(stream, state, footnoteLink);
|
59
|
+
}
|
60
|
+
if (hrRE.test(stream.peek())) {
|
61
|
+
var re = new RegExp('(?:\s*['+stream.peek()+']){3,}$');
|
62
|
+
if (stream.match(re, true)) {
|
63
|
+
return hr;
|
64
|
+
}
|
65
|
+
}
|
66
|
+
|
67
|
+
var match;
|
68
|
+
if (match = stream.match(ulRE, true) || stream.match(olRE, true)) {
|
69
|
+
state.indentation += match[0].length;
|
70
|
+
return list;
|
71
|
+
}
|
72
|
+
|
73
|
+
return switchInline(stream, state, state.inline);
|
74
|
+
}
|
75
|
+
|
76
|
+
function htmlBlock(stream, state) {
|
77
|
+
var type = htmlMode.token(stream, state.htmlState);
|
78
|
+
if (stream.eol() && !state.htmlState.context) {
|
79
|
+
state.block = blockNormal;
|
80
|
+
}
|
81
|
+
return type;
|
82
|
+
}
|
83
|
+
|
84
|
+
|
85
|
+
// Inline
|
86
|
+
|
87
|
+
function inlineNormal(stream, state) {
|
88
|
+
function getType() {
|
89
|
+
return state.strong ? (state.em ? emstrong : strong)
|
90
|
+
: (state.em ? em : null);
|
91
|
+
}
|
92
|
+
|
93
|
+
if (stream.match(textRE, true)) {
|
94
|
+
return getType();
|
95
|
+
}
|
96
|
+
|
97
|
+
var ch = stream.next();
|
98
|
+
|
99
|
+
if (ch === '\\') {
|
100
|
+
stream.next();
|
101
|
+
return getType();
|
102
|
+
}
|
103
|
+
if (ch === '`') {
|
104
|
+
return switchInline(stream, state, inlineElement(code, '`'));
|
105
|
+
}
|
106
|
+
if (ch === '<') {
|
107
|
+
return switchInline(stream, state, inlineElement(linktext, '>'));
|
108
|
+
}
|
109
|
+
if (ch === '[') {
|
110
|
+
return switchInline(stream, state, linkText);
|
111
|
+
}
|
112
|
+
|
113
|
+
var t = getType();
|
114
|
+
if (ch === '*' || ch === '_') {
|
115
|
+
if (stream.eat(ch)) {
|
116
|
+
return (state.strong = !state.strong) ? getType() : t;
|
117
|
+
}
|
118
|
+
return (state.em = !state.em) ? getType() : t;
|
119
|
+
}
|
120
|
+
|
121
|
+
return getType();
|
122
|
+
}
|
123
|
+
|
124
|
+
function linkText(stream, state) {
|
125
|
+
while (!stream.eol()) {
|
126
|
+
var ch = stream.next();
|
127
|
+
if (ch === '\\') stream.next();
|
128
|
+
if (ch === ']') {
|
129
|
+
state.inline = state.f = linkHref;
|
130
|
+
return linktext;
|
131
|
+
}
|
132
|
+
}
|
133
|
+
return linktext;
|
134
|
+
}
|
135
|
+
|
136
|
+
function linkHref(stream, state) {
|
137
|
+
stream.eatSpace();
|
138
|
+
var ch = stream.next();
|
139
|
+
if (ch === '(' || ch === '[') {
|
140
|
+
return switchInline(stream, state, inlineElement(linkhref, ch === '(' ? ')' : ']'));
|
141
|
+
}
|
142
|
+
return 'error';
|
143
|
+
}
|
144
|
+
|
145
|
+
function footnoteLink(stream, state) {
|
146
|
+
if (stream.match(/^[^\]]*\]:/, true)) {
|
147
|
+
state.f = footnoteUrl;
|
148
|
+
return linktext;
|
149
|
+
}
|
150
|
+
return switchInline(stream, state, inlineNormal);
|
151
|
+
}
|
152
|
+
|
153
|
+
function footnoteUrl(stream, state) {
|
154
|
+
stream.eatSpace();
|
155
|
+
stream.match(/^[^\s]+/, true);
|
156
|
+
state.f = state.inline = inlineNormal;
|
157
|
+
return linkhref;
|
158
|
+
}
|
159
|
+
|
160
|
+
function inlineElement(type, endChar, next) {
|
161
|
+
next = next || inlineNormal;
|
162
|
+
return function(stream, state) {
|
163
|
+
while (!stream.eol()) {
|
164
|
+
var ch = stream.next();
|
165
|
+
if (ch === '\\') stream.next();
|
166
|
+
if (ch === endChar) {
|
167
|
+
state.inline = state.f = next;
|
168
|
+
return type;
|
169
|
+
}
|
170
|
+
}
|
171
|
+
return type;
|
172
|
+
};
|
173
|
+
}
|
174
|
+
|
175
|
+
return {
|
176
|
+
startState: function() {
|
177
|
+
return {
|
178
|
+
f: blockNormal,
|
179
|
+
|
180
|
+
block: blockNormal,
|
181
|
+
htmlState: htmlMode.startState(),
|
182
|
+
indentation: 0,
|
183
|
+
|
184
|
+
inline: inlineNormal,
|
185
|
+
em: false,
|
186
|
+
strong: false
|
187
|
+
};
|
188
|
+
},
|
189
|
+
|
190
|
+
copyState: function(s) {
|
191
|
+
return {
|
192
|
+
f: s.f,
|
193
|
+
|
194
|
+
block: s.block,
|
195
|
+
htmlState: CodeMirror.copyState(htmlMode, s.htmlState),
|
196
|
+
indentation: s.indentation,
|
197
|
+
|
198
|
+
inline: s.inline,
|
199
|
+
em: s.em,
|
200
|
+
strong: s.strong
|
201
|
+
};
|
202
|
+
},
|
203
|
+
|
204
|
+
token: function(stream, state) {
|
205
|
+
if (stream.sol()) {
|
206
|
+
state.f = state.block;
|
207
|
+
var previousIndentation = state.indentation
|
208
|
+
, currentIndentation = 0;
|
209
|
+
while (previousIndentation > 0) {
|
210
|
+
if (stream.eat(' ')) {
|
211
|
+
previousIndentation--;
|
212
|
+
currentIndentation++;
|
213
|
+
} else if (previousIndentation >= 4 && stream.eat('\t')) {
|
214
|
+
previousIndentation -= 4;
|
215
|
+
currentIndentation += 4;
|
216
|
+
} else {
|
217
|
+
break;
|
218
|
+
}
|
219
|
+
}
|
220
|
+
state.indentation = currentIndentation;
|
221
|
+
|
222
|
+
if (currentIndentation > 0) return null;
|
223
|
+
}
|
224
|
+
return state.f(stream, state);
|
225
|
+
}
|
226
|
+
};
|
227
|
+
|
228
|
+
});
|
229
|
+
|
230
|
+
CodeMirror.defineMIME("text/x-markdown", "markdown");
|
@@ -0,0 +1,33 @@
|
|
1
|
+
<!doctype html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>CodeMirror 2: NTriples mode</title>
|
5
|
+
<link rel="stylesheet" href="../../lib/codemirror.css">
|
6
|
+
<script src="../../lib/codemirror.js"></script>
|
7
|
+
<script src="ntriples.js"></script>
|
8
|
+
<link rel="stylesheet" href="../../theme/default.css">
|
9
|
+
<link rel="stylesheet" href="../../css/docs.css">
|
10
|
+
<style type="text/css">
|
11
|
+
.CodeMirror {
|
12
|
+
border: 1px solid #eee;
|
13
|
+
}
|
14
|
+
</style>
|
15
|
+
</head>
|
16
|
+
<body>
|
17
|
+
<h1>CodeMirror 2: NTriples mode</h1>
|
18
|
+
<form>
|
19
|
+
<textarea id="ntriples" name="ntriples">
|
20
|
+
<http://Sub1> <http://pred1> <http://obj> .
|
21
|
+
<http://Sub2> <http://pred2#an2> "literal 1" .
|
22
|
+
<http://Sub3#an3> <http://pred3> _:bnode3 .
|
23
|
+
_:bnode4 <http://pred4> "literal 2"@lang .
|
24
|
+
_:bnode5 <http://pred5> "literal 3"^^<http://type> .
|
25
|
+
</textarea>
|
26
|
+
</form>
|
27
|
+
|
28
|
+
<script>
|
29
|
+
var editor = CodeMirror.fromTextArea(document.getElementById("ntriples"), {});
|
30
|
+
</script>
|
31
|
+
<p><strong>MIME types defined:</strong> <code>text/n-triples</code>.</p>
|
32
|
+
</body>
|
33
|
+
</html>
|
@@ -0,0 +1,172 @@
|
|
1
|
+
/**********************************************************
|
2
|
+
* This script provides syntax highlighting support for
|
3
|
+
* the Ntriples format.
|
4
|
+
* Ntriples format specification:
|
5
|
+
* http://www.w3.org/TR/rdf-testcases/#ntriples
|
6
|
+
***********************************************************/
|
7
|
+
|
8
|
+
/*
|
9
|
+
The following expression defines the defined ASF grammar transitions.
|
10
|
+
|
11
|
+
pre_subject ->
|
12
|
+
{
|
13
|
+
( writing_subject_uri | writing_bnode_uri )
|
14
|
+
-> pre_predicate
|
15
|
+
-> writing_predicate_uri
|
16
|
+
-> pre_object
|
17
|
+
-> writing_object_uri | writing_object_bnode |
|
18
|
+
(
|
19
|
+
writing_object_literal
|
20
|
+
-> writing_literal_lang | writing_literal_type
|
21
|
+
)
|
22
|
+
-> post_object
|
23
|
+
-> BEGIN
|
24
|
+
} otherwise {
|
25
|
+
-> ERROR
|
26
|
+
}
|
27
|
+
*/
|
28
|
+
CodeMirror.defineMode("ntriples", function() {
|
29
|
+
|
30
|
+
Location = {
|
31
|
+
PRE_SUBJECT : 0,
|
32
|
+
WRITING_SUB_URI : 1,
|
33
|
+
WRITING_BNODE_URI : 2,
|
34
|
+
PRE_PRED : 3,
|
35
|
+
WRITING_PRED_URI : 4,
|
36
|
+
PRE_OBJ : 5,
|
37
|
+
WRITING_OBJ_URI : 6,
|
38
|
+
WRITING_OBJ_BNODE : 7,
|
39
|
+
WRITING_OBJ_LITERAL : 8,
|
40
|
+
WRITING_LIT_LANG : 9,
|
41
|
+
WRITING_LIT_TYPE : 10,
|
42
|
+
POST_OBJ : 11,
|
43
|
+
ERROR : 12
|
44
|
+
};
|
45
|
+
function transitState(currState, c) {
|
46
|
+
var currLocation = currState.location;
|
47
|
+
var ret;
|
48
|
+
|
49
|
+
// Opening.
|
50
|
+
if (currLocation == Location.PRE_SUBJECT && c == '<') ret = Location.WRITING_SUB_URI;
|
51
|
+
else if(currLocation == Location.PRE_SUBJECT && c == '_') ret = Location.WRITING_BNODE_URI;
|
52
|
+
else if(currLocation == Location.PRE_PRED && c == '<') ret = Location.WRITING_PRED_URI;
|
53
|
+
else if(currLocation == Location.PRE_OBJ && c == '<') ret = Location.WRITING_OBJ_URI;
|
54
|
+
else if(currLocation == Location.PRE_OBJ && c == '_') ret = Location.WRITING_OBJ_BNODE;
|
55
|
+
else if(currLocation == Location.PRE_OBJ && c == '"') ret = Location.WRITING_OBJ_LITERAL;
|
56
|
+
|
57
|
+
// Closing.
|
58
|
+
else if(currLocation == Location.WRITING_SUB_URI && c == '>') ret = Location.PRE_PRED;
|
59
|
+
else if(currLocation == Location.WRITING_BNODE_URI && c == ' ') ret = Location.PRE_PRED;
|
60
|
+
else if(currLocation == Location.WRITING_PRED_URI && c == '>') ret = Location.PRE_OBJ;
|
61
|
+
else if(currLocation == Location.WRITING_OBJ_URI && c == '>') ret = Location.POST_OBJ;
|
62
|
+
else if(currLocation == Location.WRITING_OBJ_BNODE && c == ' ') ret = Location.POST_OBJ;
|
63
|
+
else if(currLocation == Location.WRITING_OBJ_LITERAL && c == '"') ret = Location.POST_OBJ;
|
64
|
+
else if(currLocation == Location.WRITING_LIT_LANG && c == ' ') ret = Location.POST_OBJ;
|
65
|
+
else if(currLocation == Location.WRITING_LIT_TYPE && c == '>') ret = Location.POST_OBJ;
|
66
|
+
|
67
|
+
// Closing typed and language literal.
|
68
|
+
else if(currLocation == Location.WRITING_OBJ_LITERAL && c == '@') ret = Location.WRITING_LIT_LANG;
|
69
|
+
else if(currLocation == Location.WRITING_OBJ_LITERAL && c == '^') ret = Location.WRITING_LIT_TYPE;
|
70
|
+
|
71
|
+
// Spaces.
|
72
|
+
else if( c == ' ' &&
|
73
|
+
(
|
74
|
+
currLocation == Location.PRE_SUBJECT ||
|
75
|
+
currLocation == Location.PRE_PRED ||
|
76
|
+
currLocation == Location.PRE_OBJ ||
|
77
|
+
currLocation == Location.POST_OBJ
|
78
|
+
)
|
79
|
+
) ret = currLocation;
|
80
|
+
|
81
|
+
// Reset.
|
82
|
+
else if(currLocation == Location.POST_OBJ && c == '.') ret = Location.PRE_SUBJECT;
|
83
|
+
|
84
|
+
// Error
|
85
|
+
else ret = Location.ERROR;
|
86
|
+
|
87
|
+
currState.location=ret;
|
88
|
+
}
|
89
|
+
|
90
|
+
untilSpace = function(c) { return c != ' '; };
|
91
|
+
untilEndURI = function(c) { return c != '>'; };
|
92
|
+
return {
|
93
|
+
startState: function() {
|
94
|
+
return {
|
95
|
+
location : Location.PRE_SUBJECT,
|
96
|
+
uris : [],
|
97
|
+
anchors : [],
|
98
|
+
bnodes : [],
|
99
|
+
langs : [],
|
100
|
+
types : []
|
101
|
+
};
|
102
|
+
},
|
103
|
+
token: function(stream, state) {
|
104
|
+
var ch = stream.next();
|
105
|
+
if(ch == '<') {
|
106
|
+
transitState(state, ch);
|
107
|
+
var parsedURI = '';
|
108
|
+
stream.eatWhile( function(c) { if( c != '#' && c != '>' ) { parsedURI += c; return true; } return false;} );
|
109
|
+
state.uris.push(parsedURI);
|
110
|
+
if( stream.match('#', false) ) return 'variable';
|
111
|
+
stream.next();
|
112
|
+
transitState(state, '>');
|
113
|
+
return 'variable';
|
114
|
+
}
|
115
|
+
if(ch == '#') {
|
116
|
+
var parsedAnchor = '';
|
117
|
+
stream.eatWhile(function(c) { if(c != '>' && c != ' ') { parsedAnchor+= c; return true; } return false});
|
118
|
+
state.anchors.push(parsedAnchor);
|
119
|
+
return 'variable-2';
|
120
|
+
}
|
121
|
+
if(ch == '>') {
|
122
|
+
transitState(state, '>');
|
123
|
+
return 'variable';
|
124
|
+
}
|
125
|
+
if(ch == '_') {
|
126
|
+
transitState(state, ch);
|
127
|
+
var parsedBNode = '';
|
128
|
+
stream.eatWhile(function(c) { if( c != ' ' ) { parsedBNode += c; return true; } return false;});
|
129
|
+
state.bnodes.push(parsedBNode);
|
130
|
+
stream.next();
|
131
|
+
transitState(state, ' ');
|
132
|
+
return 'builtin';
|
133
|
+
}
|
134
|
+
if(ch == '"') {
|
135
|
+
transitState(state, ch);
|
136
|
+
stream.eatWhile( function(c) { return c != '"'; } );
|
137
|
+
stream.next();
|
138
|
+
if( stream.peek() != '@' && stream.peek() != '^' ) {
|
139
|
+
transitState(state, '"');
|
140
|
+
}
|
141
|
+
return 'string';
|
142
|
+
}
|
143
|
+
if( ch == '@' ) {
|
144
|
+
transitState(state, '@');
|
145
|
+
var parsedLang = '';
|
146
|
+
stream.eatWhile(function(c) { if( c != ' ' ) { parsedLang += c; return true; } return false;});
|
147
|
+
state.langs.push(parsedLang);
|
148
|
+
stream.next();
|
149
|
+
transitState(state, ' ');
|
150
|
+
return 'string-2';
|
151
|
+
}
|
152
|
+
if( ch == '^' ) {
|
153
|
+
stream.next();
|
154
|
+
transitState(state, '^');
|
155
|
+
var parsedType = '';
|
156
|
+
stream.eatWhile(function(c) { if( c != '>' ) { parsedType += c; return true; } return false;} );
|
157
|
+
state.types.push(parsedType);
|
158
|
+
stream.next();
|
159
|
+
transitState(state, '>');
|
160
|
+
return 'variable';
|
161
|
+
}
|
162
|
+
if( ch == ' ' ) {
|
163
|
+
transitState(state, ch);
|
164
|
+
}
|
165
|
+
if( ch == '.' ) {
|
166
|
+
transitState(state, ch);
|
167
|
+
}
|
168
|
+
}
|
169
|
+
};
|
170
|
+
});
|
171
|
+
|
172
|
+
CodeMirror.defineMIME("text/n-triples", "ntriples");
|
@@ -0,0 +1,7 @@
|
|
1
|
+
Copyright (c) 2011 souceLair <support@sourcelair.com>
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
4
|
+
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
6
|
+
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,49 @@
|
|
1
|
+
<!doctype html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>CodeMirror 2: Pascal mode</title>
|
5
|
+
<link rel="stylesheet" href="../../lib/codemirror.css">
|
6
|
+
<script src="../../lib/codemirror.js"></script>
|
7
|
+
<script src="pascal.js"></script>
|
8
|
+
<link rel="stylesheet" href="../../theme/default.css">
|
9
|
+
<link rel="stylesheet" href="../../css/docs.css">
|
10
|
+
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
|
11
|
+
</head>
|
12
|
+
<body>
|
13
|
+
<h1>CodeMirror 2: Pascal mode</h1>
|
14
|
+
|
15
|
+
<div><textarea id="code" name="code">
|
16
|
+
(* Example Pascal code *)
|
17
|
+
|
18
|
+
while a <> b do writeln('Waiting');
|
19
|
+
|
20
|
+
if a > b then
|
21
|
+
writeln('Condition met')
|
22
|
+
else
|
23
|
+
writeln('Condition not met');
|
24
|
+
|
25
|
+
for i := 1 to 10 do
|
26
|
+
writeln('Iteration: ', i:1);
|
27
|
+
|
28
|
+
repeat
|
29
|
+
a := a + 1
|
30
|
+
until a = 10;
|
31
|
+
|
32
|
+
case i of
|
33
|
+
0: write('zero');
|
34
|
+
1: write('one');
|
35
|
+
2: write('two')
|
36
|
+
end;
|
37
|
+
</textarea></div>
|
38
|
+
|
39
|
+
<script>
|
40
|
+
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
41
|
+
lineNumbers: true,
|
42
|
+
matchBrackets: true,
|
43
|
+
mode: "text/x-pascal"
|
44
|
+
});
|
45
|
+
</script>
|
46
|
+
|
47
|
+
<p><strong>MIME types defined:</strong> <code>text/x-pascal</code>.</p>
|
48
|
+
</body>
|
49
|
+
</html>
|
@@ -0,0 +1,138 @@
|
|
1
|
+
CodeMirror.defineMode("pascal", function(config) {
|
2
|
+
function words(str) {
|
3
|
+
var obj = {}, words = str.split(" ");
|
4
|
+
for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
|
5
|
+
return obj;
|
6
|
+
}
|
7
|
+
var keywords = words("and array begin case const div do downto else end file for forward integer " +
|
8
|
+
"boolean char function goto if in label mod nil not of or packed procedure " +
|
9
|
+
"program record repeat set string then to type until var while with");
|
10
|
+
var blockKeywords = words("case do else for if switch while struct then of");
|
11
|
+
var atoms = {"null": true};
|
12
|
+
|
13
|
+
var isOperatorChar = /[+\-*&%=<>!?|\/]/;
|
14
|
+
var curPunc;
|
15
|
+
|
16
|
+
function tokenBase(stream, state) {
|
17
|
+
var ch = stream.next();
|
18
|
+
if (ch == "#" && state.startOfLine) {
|
19
|
+
stream.skipToEnd();
|
20
|
+
return "meta";
|
21
|
+
}
|
22
|
+
if (ch == '"' || ch == "'") {
|
23
|
+
state.tokenize = tokenString(ch);
|
24
|
+
return state.tokenize(stream, state);
|
25
|
+
}
|
26
|
+
if (ch == "(" && stream.eat("*")) {
|
27
|
+
state.tokenize = tokenComment;
|
28
|
+
return tokenComment(stream, state);
|
29
|
+
}
|
30
|
+
if (/[\[\]{}\(\),;\:\.]/.test(ch)) {
|
31
|
+
curPunc = ch;
|
32
|
+
return null
|
33
|
+
}
|
34
|
+
if (/\d/.test(ch)) {
|
35
|
+
stream.eatWhile(/[\w\.]/);
|
36
|
+
return "number";
|
37
|
+
}
|
38
|
+
if (ch == "/") {
|
39
|
+
if (stream.eat("/")) {
|
40
|
+
stream.skipToEnd();
|
41
|
+
return "comment";
|
42
|
+
}
|
43
|
+
}
|
44
|
+
if (isOperatorChar.test(ch)) {
|
45
|
+
stream.eatWhile(isOperatorChar);
|
46
|
+
return "operator";
|
47
|
+
}
|
48
|
+
stream.eatWhile(/[\w\$_]/);
|
49
|
+
var cur = stream.current();
|
50
|
+
if (keywords.propertyIsEnumerable(cur)) {
|
51
|
+
if (blockKeywords.propertyIsEnumerable(cur)) curPunc = "newstatement";
|
52
|
+
return "keyword";
|
53
|
+
}
|
54
|
+
if (atoms.propertyIsEnumerable(cur)) return "atom";
|
55
|
+
return "word";
|
56
|
+
}
|
57
|
+
|
58
|
+
function tokenString(quote) {
|
59
|
+
return function(stream, state) {
|
60
|
+
var escaped = false, next, end = false;
|
61
|
+
while ((next = stream.next()) != null) {
|
62
|
+
if (next == quote && !escaped) {end = true; break;}
|
63
|
+
escaped = !escaped && next == "\\";
|
64
|
+
}
|
65
|
+
if (end || !escaped) state.tokenize = null;
|
66
|
+
return "string";
|
67
|
+
};
|
68
|
+
}
|
69
|
+
|
70
|
+
function tokenComment(stream, state) {
|
71
|
+
var maybeEnd = false, ch;
|
72
|
+
while (ch = stream.next()) {
|
73
|
+
if (ch == ")" && maybeEnd) {
|
74
|
+
state.tokenize = null;
|
75
|
+
break;
|
76
|
+
}
|
77
|
+
maybeEnd = (ch == "*");
|
78
|
+
}
|
79
|
+
return "comment";
|
80
|
+
}
|
81
|
+
|
82
|
+
function Context(indented, column, type, align, prev) {
|
83
|
+
this.indented = indented;
|
84
|
+
this.column = column;
|
85
|
+
this.type = type;
|
86
|
+
this.align = align;
|
87
|
+
this.prev = prev;
|
88
|
+
}
|
89
|
+
function pushContext(state, col, type) {
|
90
|
+
return state.context = new Context(state.indented, col, type, null, state.context);
|
91
|
+
}
|
92
|
+
function popContext(state) {
|
93
|
+
var t = state.context.type;
|
94
|
+
if (t == ")" || t == "]" )
|
95
|
+
state.indented = state.context.indented;
|
96
|
+
return state.context = state.context.prev;
|
97
|
+
}
|
98
|
+
|
99
|
+
// Interface
|
100
|
+
|
101
|
+
return {
|
102
|
+
startState: function(basecolumn) {
|
103
|
+
return {
|
104
|
+
tokenize: null,
|
105
|
+
context: new Context((basecolumn || 0) - config.indentUnit, 0, "top", false),
|
106
|
+
indented: 0,
|
107
|
+
startOfLine: true
|
108
|
+
};
|
109
|
+
},
|
110
|
+
|
111
|
+
token: function(stream, state) {
|
112
|
+
var ctx = state.context;
|
113
|
+
if (stream.sol()) {
|
114
|
+
if (ctx.align == null) ctx.align = false;
|
115
|
+
state.indented = stream.indentation();
|
116
|
+
state.startOfLine = true;
|
117
|
+
}
|
118
|
+
if (stream.eatSpace()) return null;
|
119
|
+
curPunc = null;
|
120
|
+
var style = (state.tokenize || tokenBase)(stream, state);
|
121
|
+
if (style == "comment" || style == "meta") return style;
|
122
|
+
if (ctx.align == null) ctx.align = true;
|
123
|
+
|
124
|
+
if ((curPunc == ";" || curPunc == ":") && ctx.type == "statement") popContext(state);
|
125
|
+
else if (curPunc == "[") pushContext(state, stream.column(), "]");
|
126
|
+
else if (curPunc == "(") pushContext(state, stream.column(), ")");
|
127
|
+
else if (curPunc == ctx.type) popContext(state);
|
128
|
+
else if ( ctx.type == "top" || (ctx.type == "statement" && curPunc == "newstatement"))
|
129
|
+
pushContext(state, stream.column(), "statement");
|
130
|
+
state.startOfLine = false;
|
131
|
+
return style;
|
132
|
+
},
|
133
|
+
|
134
|
+
electricChars: "{}"
|
135
|
+
};
|
136
|
+
});
|
137
|
+
|
138
|
+
CodeMirror.defineMIME("text/x-pascal", "pascal");
|
@@ -0,0 +1,49 @@
|
|
1
|
+
<!doctype html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<title>CodeMirror 2: PHP mode</title>
|
5
|
+
<link rel="stylesheet" href="../../lib/codemirror.css">
|
6
|
+
<script src="../../lib/codemirror.js"></script>
|
7
|
+
<script src="../xml/xml.js"></script>
|
8
|
+
<script src="../javascript/javascript.js"></script>
|
9
|
+
<script src="../css/css.js"></script>
|
10
|
+
<script src="../clike/clike.js"></script>
|
11
|
+
<script src="php.js"></script>
|
12
|
+
<link rel="stylesheet" href="../../theme/default.css">
|
13
|
+
<style type="text/css">.CodeMirror {border-top: 1px solid black; border-bottom: 1px solid black;}</style>
|
14
|
+
<link rel="stylesheet" href="../../css/docs.css">
|
15
|
+
</head>
|
16
|
+
<body>
|
17
|
+
<h1>CodeMirror 2: PHP mode</h1>
|
18
|
+
|
19
|
+
<form><textarea id="code" name="code">
|
20
|
+
<?php
|
21
|
+
function hello($who) {
|
22
|
+
return "Hello " . $who;
|
23
|
+
}
|
24
|
+
?>
|
25
|
+
<p>The program says <?= hello("World") ?>.</p>
|
26
|
+
<script>
|
27
|
+
alert("And here is some JS code"); // also colored
|
28
|
+
</script>
|
29
|
+
</textarea></form>
|
30
|
+
|
31
|
+
<script>
|
32
|
+
var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
|
33
|
+
lineNumbers: true,
|
34
|
+
matchBrackets: true,
|
35
|
+
mode: "application/x-httpd-php",
|
36
|
+
indentUnit: 8,
|
37
|
+
indentWithTabs: true,
|
38
|
+
enterMode: "keep",
|
39
|
+
tabMode: "shift"
|
40
|
+
});
|
41
|
+
</script>
|
42
|
+
|
43
|
+
<p>Simple HTML/PHP mode based on
|
44
|
+
the <a href="../clike/">C-like</a> mode. Depends on XML,
|
45
|
+
JavaScript, CSS, and C-like modes.</p>
|
46
|
+
|
47
|
+
<p><strong>MIME types defined:</strong> <code>application/x-httpd-php</code> (HTML with PHP code), <code>text/x-php</code> (plain, non-wrapped PHP code).</p>
|
48
|
+
</body>
|
49
|
+
</html>
|