liquid_cms 0.3.1.0 → 0.3.2.0
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -1,162 +0,0 @@
|
|
1
|
-
var SparqlParser = Editor.Parser = (function() {
|
2
|
-
function wordRegexp(words) {
|
3
|
-
return new RegExp("^(?:" + words.join("|") + ")$", "i");
|
4
|
-
}
|
5
|
-
var ops = wordRegexp(["str", "lang", "langmatches", "datatype", "bound", "sameterm", "isiri", "isuri",
|
6
|
-
"isblank", "isliteral", "union", "a"]);
|
7
|
-
var keywords = wordRegexp(["base", "prefix", "select", "distinct", "reduced", "construct", "describe",
|
8
|
-
"ask", "from", "named", "where", "order", "limit", "offset", "filter", "optional",
|
9
|
-
"graph", "by", "asc", "desc"]);
|
10
|
-
var operatorChars = /[*+\-<>=&|]/;
|
11
|
-
|
12
|
-
var tokenizeSparql = (function() {
|
13
|
-
function normal(source, setState) {
|
14
|
-
var ch = source.next();
|
15
|
-
if (ch == "$" || ch == "?") {
|
16
|
-
source.nextWhileMatches(/[\w\d]/);
|
17
|
-
return "sp-var";
|
18
|
-
}
|
19
|
-
else if (ch == "<" && !source.matches(/[\s\u00a0=]/)) {
|
20
|
-
source.nextWhileMatches(/[^\s\u00a0>]/);
|
21
|
-
if (source.equals(">")) source.next();
|
22
|
-
return "sp-uri";
|
23
|
-
}
|
24
|
-
else if (ch == "\"" || ch == "'") {
|
25
|
-
setState(inLiteral(ch));
|
26
|
-
return null;
|
27
|
-
}
|
28
|
-
else if (/[{}\(\),\.;\[\]]/.test(ch)) {
|
29
|
-
return "sp-punc";
|
30
|
-
}
|
31
|
-
else if (ch == "#") {
|
32
|
-
while (!source.endOfLine()) source.next();
|
33
|
-
return "sp-comment";
|
34
|
-
}
|
35
|
-
else if (operatorChars.test(ch)) {
|
36
|
-
source.nextWhileMatches(operatorChars);
|
37
|
-
return "sp-operator";
|
38
|
-
}
|
39
|
-
else if (ch == ":") {
|
40
|
-
source.nextWhileMatches(/[\w\d\._\-]/);
|
41
|
-
return "sp-prefixed";
|
42
|
-
}
|
43
|
-
else {
|
44
|
-
source.nextWhileMatches(/[_\w\d]/);
|
45
|
-
if (source.equals(":")) {
|
46
|
-
source.next();
|
47
|
-
source.nextWhileMatches(/[\w\d_\-]/);
|
48
|
-
return "sp-prefixed";
|
49
|
-
}
|
50
|
-
var word = source.get(), type;
|
51
|
-
if (ops.test(word))
|
52
|
-
type = "sp-operator";
|
53
|
-
else if (keywords.test(word))
|
54
|
-
type = "sp-keyword";
|
55
|
-
else
|
56
|
-
type = "sp-word";
|
57
|
-
return {style: type, content: word};
|
58
|
-
}
|
59
|
-
}
|
60
|
-
|
61
|
-
function inLiteral(quote) {
|
62
|
-
return function(source, setState) {
|
63
|
-
var escaped = false;
|
64
|
-
while (!source.endOfLine()) {
|
65
|
-
var ch = source.next();
|
66
|
-
if (ch == quote && !escaped) {
|
67
|
-
setState(normal);
|
68
|
-
break;
|
69
|
-
}
|
70
|
-
escaped = !escaped && ch == "\\";
|
71
|
-
}
|
72
|
-
return "sp-literal";
|
73
|
-
};
|
74
|
-
}
|
75
|
-
|
76
|
-
return function(source, startState) {
|
77
|
-
return tokenizer(source, startState || normal);
|
78
|
-
};
|
79
|
-
})();
|
80
|
-
|
81
|
-
function indentSparql(context) {
|
82
|
-
return function(nextChars) {
|
83
|
-
var firstChar = nextChars && nextChars.charAt(0);
|
84
|
-
if (/[\]\}]/.test(firstChar))
|
85
|
-
while (context && context.type == "pattern") context = context.prev;
|
86
|
-
|
87
|
-
var closing = context && firstChar == matching[context.type];
|
88
|
-
if (!context)
|
89
|
-
return 0;
|
90
|
-
else if (context.type == "pattern")
|
91
|
-
return context.col;
|
92
|
-
else if (context.align)
|
93
|
-
return context.col - (closing ? context.width : 0);
|
94
|
-
else
|
95
|
-
return context.indent + (closing ? 0 : indentUnit);
|
96
|
-
}
|
97
|
-
}
|
98
|
-
|
99
|
-
function parseSparql(source) {
|
100
|
-
var tokens = tokenizeSparql(source);
|
101
|
-
var context = null, indent = 0, col = 0;
|
102
|
-
function pushContext(type, width) {
|
103
|
-
context = {prev: context, indent: indent, col: col, type: type, width: width};
|
104
|
-
}
|
105
|
-
function popContext() {
|
106
|
-
context = context.prev;
|
107
|
-
}
|
108
|
-
|
109
|
-
var iter = {
|
110
|
-
next: function() {
|
111
|
-
var token = tokens.next(), type = token.style, content = token.content, width = token.value.length;
|
112
|
-
|
113
|
-
if (content == "\n") {
|
114
|
-
token.indentation = indentSparql(context);
|
115
|
-
indent = col = 0;
|
116
|
-
if (context && context.align == null) context.align = false;
|
117
|
-
}
|
118
|
-
else if (type == "whitespace" && col == 0) {
|
119
|
-
indent = width;
|
120
|
-
}
|
121
|
-
else if (type != "sp-comment" && context && context.align == null) {
|
122
|
-
context.align = true;
|
123
|
-
}
|
124
|
-
|
125
|
-
if (content != "\n") col += width;
|
126
|
-
|
127
|
-
if (/[\[\{\(]/.test(content)) {
|
128
|
-
pushContext(content, width);
|
129
|
-
}
|
130
|
-
else if (/[\]\}\)]/.test(content)) {
|
131
|
-
while (context && context.type == "pattern")
|
132
|
-
popContext();
|
133
|
-
if (context && content == matching[context.type])
|
134
|
-
popContext();
|
135
|
-
}
|
136
|
-
else if (content == "." && context && context.type == "pattern") {
|
137
|
-
popContext();
|
138
|
-
}
|
139
|
-
else if ((type == "sp-word" || type == "sp-prefixed" || type == "sp-uri" || type == "sp-var" || type == "sp-literal") &&
|
140
|
-
context && /[\{\[]/.test(context.type)) {
|
141
|
-
pushContext("pattern", width);
|
142
|
-
}
|
143
|
-
|
144
|
-
return token;
|
145
|
-
},
|
146
|
-
|
147
|
-
copy: function() {
|
148
|
-
var _context = context, _indent = indent, _col = col, _tokenState = tokens.state;
|
149
|
-
return function(source) {
|
150
|
-
tokens = tokenizeSparql(source, _tokenState);
|
151
|
-
context = _context;
|
152
|
-
indent = _indent;
|
153
|
-
col = _col;
|
154
|
-
return iter;
|
155
|
-
};
|
156
|
-
}
|
157
|
-
};
|
158
|
-
return iter;
|
159
|
-
}
|
160
|
-
|
161
|
-
return {make: parseSparql, electricChars: "}]"};
|
162
|
-
})();
|
@@ -1,291 +0,0 @@
|
|
1
|
-
/* This file defines an XML parser, with a few kludges to make it
|
2
|
-
* useable for HTML. autoSelfClosers defines a set of tag names that
|
3
|
-
* are expected to not have a closing tag, and doNotIndent specifies
|
4
|
-
* the tags inside of which no indentation should happen (see Config
|
5
|
-
* object). These can be disabled by passing the editor an object like
|
6
|
-
* {useHTMLKludges: false} as parserConfig option.
|
7
|
-
*/
|
8
|
-
|
9
|
-
var XMLParser = Editor.Parser = (function() {
|
10
|
-
var Kludges = {
|
11
|
-
autoSelfClosers: {"br": true, "img": true, "hr": true, "link": true, "input": true,
|
12
|
-
"meta": true, "col": true, "frame": true, "base": true, "area": true},
|
13
|
-
doNotIndent: {"pre": true, "!cdata": true}
|
14
|
-
};
|
15
|
-
var NoKludges = {autoSelfClosers: {}, doNotIndent: {"!cdata": true}};
|
16
|
-
var UseKludges = Kludges;
|
17
|
-
var alignCDATA = false;
|
18
|
-
|
19
|
-
// Simple stateful tokenizer for XML documents. Returns a
|
20
|
-
// MochiKit-style iterator, with a state property that contains a
|
21
|
-
// function encapsulating the current state. See tokenize.js.
|
22
|
-
var tokenizeXML = (function() {
|
23
|
-
function inText(source, setState) {
|
24
|
-
var ch = source.next();
|
25
|
-
if (ch == "<") {
|
26
|
-
if (source.equals("!")) {
|
27
|
-
source.next();
|
28
|
-
if (source.equals("[")) {
|
29
|
-
if (source.lookAhead("[CDATA[", true)) {
|
30
|
-
setState(inBlock("xml-cdata", "]]>"));
|
31
|
-
return null;
|
32
|
-
}
|
33
|
-
else {
|
34
|
-
return "xml-text";
|
35
|
-
}
|
36
|
-
}
|
37
|
-
else if (source.lookAhead("--", true)) {
|
38
|
-
setState(inBlock("xml-comment", "-->"));
|
39
|
-
return null;
|
40
|
-
}
|
41
|
-
else if (source.lookAhead("DOCTYPE", true)) {
|
42
|
-
source.nextWhileMatches(/[\w\._\-]/);
|
43
|
-
setState(inBlock("xml-doctype", ">"));
|
44
|
-
return "xml-doctype";
|
45
|
-
}
|
46
|
-
else {
|
47
|
-
return "xml-text";
|
48
|
-
}
|
49
|
-
}
|
50
|
-
else if (source.equals("?")) {
|
51
|
-
source.next();
|
52
|
-
source.nextWhileMatches(/[\w\._\-]/);
|
53
|
-
setState(inBlock("xml-processing", "?>"));
|
54
|
-
return "xml-processing";
|
55
|
-
}
|
56
|
-
else {
|
57
|
-
if (source.equals("/")) source.next();
|
58
|
-
setState(inTag);
|
59
|
-
return "xml-punctuation";
|
60
|
-
}
|
61
|
-
}
|
62
|
-
else if (ch == "&") {
|
63
|
-
while (!source.endOfLine()) {
|
64
|
-
if (source.next() == ";")
|
65
|
-
break;
|
66
|
-
}
|
67
|
-
return "xml-entity";
|
68
|
-
}
|
69
|
-
else {
|
70
|
-
source.nextWhileMatches(/[^&<\n]/);
|
71
|
-
return "xml-text";
|
72
|
-
}
|
73
|
-
}
|
74
|
-
|
75
|
-
function inTag(source, setState) {
|
76
|
-
var ch = source.next();
|
77
|
-
if (ch == ">") {
|
78
|
-
setState(inText);
|
79
|
-
return "xml-punctuation";
|
80
|
-
}
|
81
|
-
else if (/[?\/]/.test(ch) && source.equals(">")) {
|
82
|
-
source.next();
|
83
|
-
setState(inText);
|
84
|
-
return "xml-punctuation";
|
85
|
-
}
|
86
|
-
else if (ch == "=") {
|
87
|
-
return "xml-punctuation";
|
88
|
-
}
|
89
|
-
else if (/[\'\"]/.test(ch)) {
|
90
|
-
setState(inAttribute(ch));
|
91
|
-
return null;
|
92
|
-
}
|
93
|
-
else {
|
94
|
-
source.nextWhileMatches(/[^\s\u00a0=<>\"\'\/?]/);
|
95
|
-
return "xml-name";
|
96
|
-
}
|
97
|
-
}
|
98
|
-
|
99
|
-
function inAttribute(quote) {
|
100
|
-
return function(source, setState) {
|
101
|
-
while (!source.endOfLine()) {
|
102
|
-
if (source.next() == quote) {
|
103
|
-
setState(inTag);
|
104
|
-
break;
|
105
|
-
}
|
106
|
-
}
|
107
|
-
return "xml-attribute";
|
108
|
-
};
|
109
|
-
}
|
110
|
-
|
111
|
-
function inBlock(style, terminator) {
|
112
|
-
return function(source, setState) {
|
113
|
-
while (!source.endOfLine()) {
|
114
|
-
if (source.lookAhead(terminator, true)) {
|
115
|
-
setState(inText);
|
116
|
-
break;
|
117
|
-
}
|
118
|
-
source.next();
|
119
|
-
}
|
120
|
-
return style;
|
121
|
-
};
|
122
|
-
}
|
123
|
-
|
124
|
-
return function(source, startState) {
|
125
|
-
return tokenizer(source, startState || inText);
|
126
|
-
};
|
127
|
-
})();
|
128
|
-
|
129
|
-
// The parser. The structure of this function largely follows that of
|
130
|
-
// parseJavaScript in parsejavascript.js (there is actually a bit more
|
131
|
-
// shared code than I'd like), but it is quite a bit simpler.
|
132
|
-
function parseXML(source) {
|
133
|
-
var tokens = tokenizeXML(source), token;
|
134
|
-
var cc = [base];
|
135
|
-
var tokenNr = 0, indented = 0;
|
136
|
-
var currentTag = null, context = null;
|
137
|
-
var consume;
|
138
|
-
|
139
|
-
function push(fs) {
|
140
|
-
for (var i = fs.length - 1; i >= 0; i--)
|
141
|
-
cc.push(fs[i]);
|
142
|
-
}
|
143
|
-
function cont() {
|
144
|
-
push(arguments);
|
145
|
-
consume = true;
|
146
|
-
}
|
147
|
-
function pass() {
|
148
|
-
push(arguments);
|
149
|
-
consume = false;
|
150
|
-
}
|
151
|
-
|
152
|
-
function markErr() {
|
153
|
-
token.style += " xml-error";
|
154
|
-
}
|
155
|
-
function expect(text) {
|
156
|
-
return function(style, content) {
|
157
|
-
if (content == text) cont();
|
158
|
-
else {markErr(); cont(arguments.callee);}
|
159
|
-
};
|
160
|
-
}
|
161
|
-
|
162
|
-
function pushContext(tagname, startOfLine) {
|
163
|
-
var noIndent = UseKludges.doNotIndent.hasOwnProperty(tagname) || (context && context.noIndent);
|
164
|
-
context = {prev: context, name: tagname, indent: indented, startOfLine: startOfLine, noIndent: noIndent};
|
165
|
-
}
|
166
|
-
function popContext() {
|
167
|
-
context = context.prev;
|
168
|
-
}
|
169
|
-
function computeIndentation(baseContext) {
|
170
|
-
return function(nextChars, current) {
|
171
|
-
var context = baseContext;
|
172
|
-
if (context && context.noIndent)
|
173
|
-
return current;
|
174
|
-
if (alignCDATA && /<!\[CDATA\[/.test(nextChars))
|
175
|
-
return 0;
|
176
|
-
if (context && /^<\//.test(nextChars))
|
177
|
-
context = context.prev;
|
178
|
-
while (context && !context.startOfLine)
|
179
|
-
context = context.prev;
|
180
|
-
if (context)
|
181
|
-
return context.indent + indentUnit;
|
182
|
-
else
|
183
|
-
return 0;
|
184
|
-
};
|
185
|
-
}
|
186
|
-
|
187
|
-
function base() {
|
188
|
-
return pass(element, base);
|
189
|
-
}
|
190
|
-
var harmlessTokens = {"xml-text": true, "xml-entity": true, "xml-comment": true, "xml-processing": true, "xml-doctype": true};
|
191
|
-
function element(style, content) {
|
192
|
-
if (content == "<") cont(tagname, attributes, endtag(tokenNr == 1));
|
193
|
-
else if (content == "</") cont(closetagname, expect(">"));
|
194
|
-
else if (style == "xml-cdata") {
|
195
|
-
if (!context || context.name != "!cdata") pushContext("!cdata");
|
196
|
-
if (/\]\]>$/.test(content)) popContext();
|
197
|
-
cont();
|
198
|
-
}
|
199
|
-
else if (harmlessTokens.hasOwnProperty(style)) cont();
|
200
|
-
else {markErr(); cont();}
|
201
|
-
}
|
202
|
-
function tagname(style, content) {
|
203
|
-
if (style == "xml-name") {
|
204
|
-
currentTag = content.toLowerCase();
|
205
|
-
token.style = "xml-tagname";
|
206
|
-
cont();
|
207
|
-
}
|
208
|
-
else {
|
209
|
-
currentTag = null;
|
210
|
-
pass();
|
211
|
-
}
|
212
|
-
}
|
213
|
-
function closetagname(style, content) {
|
214
|
-
if (style == "xml-name") {
|
215
|
-
token.style = "xml-tagname";
|
216
|
-
if (context && content.toLowerCase() == context.name) popContext();
|
217
|
-
else markErr();
|
218
|
-
}
|
219
|
-
cont();
|
220
|
-
}
|
221
|
-
function endtag(startOfLine) {
|
222
|
-
return function(style, content) {
|
223
|
-
if (content == "/>" || (content == ">" && UseKludges.autoSelfClosers.hasOwnProperty(currentTag))) cont();
|
224
|
-
else if (content == ">") {pushContext(currentTag, startOfLine); cont();}
|
225
|
-
else {markErr(); cont(arguments.callee);}
|
226
|
-
};
|
227
|
-
}
|
228
|
-
function attributes(style) {
|
229
|
-
if (style == "xml-name") {token.style = "xml-attname"; cont(attribute, attributes);}
|
230
|
-
else pass();
|
231
|
-
}
|
232
|
-
function attribute(style, content) {
|
233
|
-
if (content == "=") cont(value);
|
234
|
-
else if (content == ">" || content == "/>") pass(endtag);
|
235
|
-
else pass();
|
236
|
-
}
|
237
|
-
function value(style) {
|
238
|
-
if (style == "xml-attribute") cont(value);
|
239
|
-
else pass();
|
240
|
-
}
|
241
|
-
|
242
|
-
return {
|
243
|
-
indentation: function() {return indented;},
|
244
|
-
|
245
|
-
next: function(){
|
246
|
-
token = tokens.next();
|
247
|
-
if (token.style == "whitespace" && tokenNr == 0)
|
248
|
-
indented = token.value.length;
|
249
|
-
else
|
250
|
-
tokenNr++;
|
251
|
-
if (token.content == "\n") {
|
252
|
-
indented = tokenNr = 0;
|
253
|
-
token.indentation = computeIndentation(context);
|
254
|
-
}
|
255
|
-
|
256
|
-
if (token.style == "whitespace" || token.type == "xml-comment")
|
257
|
-
return token;
|
258
|
-
|
259
|
-
while(true){
|
260
|
-
consume = false;
|
261
|
-
cc.pop()(token.style, token.content);
|
262
|
-
if (consume) return token;
|
263
|
-
}
|
264
|
-
},
|
265
|
-
|
266
|
-
copy: function(){
|
267
|
-
var _cc = cc.concat([]), _tokenState = tokens.state, _context = context;
|
268
|
-
var parser = this;
|
269
|
-
|
270
|
-
return function(input){
|
271
|
-
cc = _cc.concat([]);
|
272
|
-
tokenNr = indented = 0;
|
273
|
-
context = _context;
|
274
|
-
tokens = tokenizeXML(input, _tokenState);
|
275
|
-
return parser;
|
276
|
-
};
|
277
|
-
}
|
278
|
-
};
|
279
|
-
}
|
280
|
-
|
281
|
-
return {
|
282
|
-
make: parseXML,
|
283
|
-
electricChars: "/",
|
284
|
-
configure: function(config) {
|
285
|
-
if (config.useHTMLKludges != null)
|
286
|
-
UseKludges = config.useHTMLKludges ? Kludges : NoKludges;
|
287
|
-
if (config.alignCDATA)
|
288
|
-
alignCDATA = config.alignCDATA;
|
289
|
-
}
|
290
|
-
};
|
291
|
-
})();
|