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.
Files changed (130) hide show
  1. data/CHANGELOG.rdoc +7 -0
  2. data/README.rdoc +15 -1
  3. data/TODO.rdoc +0 -2
  4. data/app/controllers/cms/assets_controller.rb +20 -6
  5. data/app/controllers/cms/components_controller.rb +11 -3
  6. data/app/controllers/cms/pages_controller.rb +15 -4
  7. data/app/helpers/cms/common_helper.rb +31 -31
  8. data/app/liquid/cms_paperclip_extension.rb +75 -3
  9. data/app/models/cms/asset.rb +1 -1
  10. data/app/models/cms/component.rb +3 -3
  11. data/app/views/cms/assets/_form.html.erb +1 -1
  12. data/app/views/cms/assets/update.js.rjs +1 -0
  13. data/app/views/cms/components/update.js.rjs +1 -0
  14. data/app/views/cms/pages/_form.html.erb +1 -1
  15. data/app/views/cms/pages/update.js.rjs +1 -0
  16. data/app/views/layouts/cms.html.erb +4 -3
  17. data/generators/liquid_cms/liquid_cms_generator.rb +1 -0
  18. data/generators/liquid_cms/templates/config/locales/cms/en.yml +4 -0
  19. data/generators/liquid_cms/templates/migration_rev2.rb +13 -0
  20. data/generators/liquid_cms/templates/public/cms/codemirror/LICENSE +16 -20
  21. data/generators/liquid_cms/templates/public/cms/codemirror/lib/codemirror.css +68 -0
  22. data/generators/liquid_cms/templates/public/cms/codemirror/lib/codemirror.js +2197 -0
  23. data/generators/liquid_cms/templates/public/cms/codemirror/lib/overlay.js +51 -0
  24. data/generators/liquid_cms/templates/public/cms/codemirror/lib/runmode.js +27 -0
  25. data/generators/liquid_cms/templates/public/cms/codemirror/mode/clike/clike.js +247 -0
  26. data/generators/liquid_cms/templates/public/cms/codemirror/mode/clike/index.html +102 -0
  27. data/generators/liquid_cms/templates/public/cms/codemirror/mode/clojure/clojure.js +207 -0
  28. data/generators/liquid_cms/templates/public/cms/codemirror/mode/clojure/index.html +85 -0
  29. data/generators/liquid_cms/templates/public/cms/codemirror/mode/coffeescript/LICENSE +22 -0
  30. data/generators/liquid_cms/templates/public/cms/codemirror/mode/coffeescript/coffeescript.js +325 -0
  31. data/generators/liquid_cms/templates/public/cms/codemirror/mode/coffeescript/index.html +722 -0
  32. data/generators/liquid_cms/templates/public/cms/codemirror/mode/css/css.js +124 -0
  33. data/generators/liquid_cms/templates/public/cms/codemirror/mode/css/index.html +56 -0
  34. data/generators/liquid_cms/templates/public/cms/codemirror/mode/diff/diff.css +3 -0
  35. data/generators/liquid_cms/templates/public/cms/codemirror/mode/diff/diff.js +13 -0
  36. data/generators/liquid_cms/templates/public/cms/codemirror/mode/diff/index.html +99 -0
  37. data/generators/liquid_cms/templates/public/cms/codemirror/mode/haskell/haskell.js +242 -0
  38. data/generators/liquid_cms/templates/public/cms/codemirror/mode/haskell/index.html +60 -0
  39. data/generators/liquid_cms/templates/public/cms/codemirror/mode/htmlmixed/htmlmixed.js +79 -0
  40. data/generators/liquid_cms/templates/public/cms/codemirror/mode/htmlmixed/index.html +52 -0
  41. data/generators/liquid_cms/templates/public/cms/codemirror/mode/javascript/index.html +78 -0
  42. data/generators/liquid_cms/templates/public/cms/codemirror/mode/javascript/javascript.js +352 -0
  43. data/generators/liquid_cms/templates/public/cms/codemirror/mode/jinja2/index.html +38 -0
  44. data/generators/liquid_cms/templates/public/cms/codemirror/mode/jinja2/jinja2.js +42 -0
  45. data/generators/liquid_cms/templates/public/cms/codemirror/mode/lua/index.html +72 -0
  46. data/generators/liquid_cms/templates/public/cms/codemirror/mode/lua/lua.js +140 -0
  47. data/generators/liquid_cms/templates/public/cms/codemirror/mode/markdown/index.html +340 -0
  48. data/generators/liquid_cms/templates/public/cms/codemirror/mode/markdown/markdown.css +10 -0
  49. data/generators/liquid_cms/templates/public/cms/codemirror/mode/markdown/markdown.js +230 -0
  50. data/generators/liquid_cms/templates/public/cms/codemirror/mode/ntriples/index.html +33 -0
  51. data/generators/liquid_cms/templates/public/cms/codemirror/mode/ntriples/ntriples.js +172 -0
  52. data/generators/liquid_cms/templates/public/cms/codemirror/mode/pascal/LICENSE +7 -0
  53. data/generators/liquid_cms/templates/public/cms/codemirror/mode/pascal/index.html +49 -0
  54. data/generators/liquid_cms/templates/public/cms/codemirror/mode/pascal/pascal.js +138 -0
  55. data/generators/liquid_cms/templates/public/cms/codemirror/mode/php/index.html +49 -0
  56. data/generators/liquid_cms/templates/public/cms/codemirror/mode/php/php.js +116 -0
  57. data/generators/liquid_cms/templates/public/cms/codemirror/mode/plsql/index.html +63 -0
  58. data/generators/liquid_cms/templates/public/cms/codemirror/mode/plsql/plsql.js +217 -0
  59. data/generators/liquid_cms/templates/public/cms/codemirror/mode/python/LICENSE.txt +21 -0
  60. data/generators/liquid_cms/templates/public/cms/codemirror/mode/python/index.html +123 -0
  61. data/generators/liquid_cms/templates/public/cms/codemirror/mode/python/python.js +320 -0
  62. data/generators/liquid_cms/templates/public/cms/codemirror/mode/r/LICENSE +24 -0
  63. data/generators/liquid_cms/templates/public/cms/codemirror/mode/r/index.html +74 -0
  64. data/generators/liquid_cms/templates/public/cms/codemirror/mode/r/r.js +141 -0
  65. data/generators/liquid_cms/templates/public/cms/codemirror/mode/rst/index.html +526 -0
  66. data/generators/liquid_cms/templates/public/cms/codemirror/mode/rst/rst.css +75 -0
  67. data/generators/liquid_cms/templates/public/cms/codemirror/mode/rst/rst.js +333 -0
  68. data/generators/liquid_cms/templates/public/cms/codemirror/mode/ruby/LICENSE +24 -0
  69. data/generators/liquid_cms/templates/public/cms/codemirror/mode/ruby/index.html +172 -0
  70. data/generators/liquid_cms/templates/public/cms/codemirror/mode/ruby/ruby.js +195 -0
  71. data/generators/liquid_cms/templates/public/cms/codemirror/mode/scheme/index.html +65 -0
  72. data/generators/liquid_cms/templates/public/cms/codemirror/mode/scheme/scheme.js +202 -0
  73. data/generators/liquid_cms/templates/public/cms/codemirror/mode/smalltalk/index.html +56 -0
  74. data/generators/liquid_cms/templates/public/cms/codemirror/mode/smalltalk/smalltalk.js +122 -0
  75. data/generators/liquid_cms/templates/public/cms/codemirror/mode/sparql/index.html +41 -0
  76. data/generators/liquid_cms/templates/public/cms/codemirror/mode/sparql/sparql.js +143 -0
  77. data/generators/liquid_cms/templates/public/cms/codemirror/mode/stex/index.html +96 -0
  78. data/generators/liquid_cms/templates/public/cms/codemirror/mode/stex/stex.js +167 -0
  79. data/generators/liquid_cms/templates/public/cms/codemirror/mode/velocity/index.html +103 -0
  80. data/generators/liquid_cms/templates/public/cms/codemirror/mode/velocity/velocity.js +146 -0
  81. data/generators/liquid_cms/templates/public/cms/codemirror/mode/xml/index.html +42 -0
  82. data/generators/liquid_cms/templates/public/cms/codemirror/mode/xml/xml.js +231 -0
  83. data/generators/liquid_cms/templates/public/cms/codemirror/mode/xmlpure/index.html +60 -0
  84. data/generators/liquid_cms/templates/public/cms/codemirror/mode/xmlpure/xmlpure.js +481 -0
  85. data/generators/liquid_cms/templates/public/cms/codemirror/mode/yaml/index.html +68 -0
  86. data/generators/liquid_cms/templates/public/cms/codemirror/mode/yaml/yaml.js +95 -0
  87. data/generators/liquid_cms/templates/public/cms/codemirror/theme/cobalt.css +17 -0
  88. data/generators/liquid_cms/templates/public/cms/codemirror/theme/default.css +19 -0
  89. data/generators/liquid_cms/templates/public/cms/codemirror/theme/eclipse.css +24 -0
  90. data/generators/liquid_cms/templates/public/cms/codemirror/theme/elegant.css +9 -0
  91. data/generators/liquid_cms/templates/public/cms/codemirror/theme/neat.css +8 -0
  92. data/generators/liquid_cms/templates/public/cms/codemirror/theme/night.css +20 -0
  93. data/generators/liquid_cms/templates/public/cms/javascripts/cms.js +1 -1
  94. data/generators/liquid_cms/templates/public/cms/javascripts/codemirror_custom.js +96 -0
  95. data/generators/liquid_cms/templates/public/cms/stylesheets/codemirror_changes.css +26 -0
  96. data/generators/liquid_cms/templates/public/cms/stylesheets/liquid.css +7 -0
  97. data/generators/liquid_cms/templates/public/cms/stylesheets/simple_form.css +0 -8
  98. data/lib/liquid_cms/version.rb +1 -1
  99. data/liquid_cms.gemspec +0 -1
  100. data/test/functional/assets_controller_test.rb +35 -20
  101. data/test/functional/components_controller_test.rb +15 -5
  102. data/test/functional/pages_controller_test.rb +19 -6
  103. data/test/rails_app/config/environment.rb +1 -1
  104. data/test/rails_app/config/locales/cms/en.yml +19 -4
  105. data/test/rails_app/db/migrate/20110511161859_create_liquid_cms_upgrade_rev2.rb +13 -0
  106. data/test/unit/asset_test.rb +1 -1
  107. metadata +100 -58
  108. data/generators/liquid_cms/templates/public/cms/codemirror/css/csscolors.css +0 -55
  109. data/generators/liquid_cms/templates/public/cms/codemirror/css/docs.css +0 -158
  110. data/generators/liquid_cms/templates/public/cms/codemirror/css/font.js +0 -15
  111. data/generators/liquid_cms/templates/public/cms/codemirror/css/jscolors.css +0 -59
  112. data/generators/liquid_cms/templates/public/cms/codemirror/css/sparqlcolors.css +0 -43
  113. data/generators/liquid_cms/templates/public/cms/codemirror/css/xmlcolors.css +0 -55
  114. data/generators/liquid_cms/templates/public/cms/codemirror/js/codemirror.js +0 -582
  115. data/generators/liquid_cms/templates/public/cms/codemirror/js/editor.js +0 -1671
  116. data/generators/liquid_cms/templates/public/cms/codemirror/js/highlight.js +0 -68
  117. data/generators/liquid_cms/templates/public/cms/codemirror/js/mirrorframe.js +0 -81
  118. data/generators/liquid_cms/templates/public/cms/codemirror/js/parsecss.js +0 -161
  119. data/generators/liquid_cms/templates/public/cms/codemirror/js/parsedummy.js +0 -32
  120. data/generators/liquid_cms/templates/public/cms/codemirror/js/parsehtmlmixed.js +0 -93
  121. data/generators/liquid_cms/templates/public/cms/codemirror/js/parsejavascript.js +0 -359
  122. data/generators/liquid_cms/templates/public/cms/codemirror/js/parsesparql.js +0 -162
  123. data/generators/liquid_cms/templates/public/cms/codemirror/js/parsexml.js +0 -291
  124. data/generators/liquid_cms/templates/public/cms/codemirror/js/select.js +0 -699
  125. data/generators/liquid_cms/templates/public/cms/codemirror/js/stringstream.js +0 -159
  126. data/generators/liquid_cms/templates/public/cms/codemirror/js/tokenize.js +0 -57
  127. data/generators/liquid_cms/templates/public/cms/codemirror/js/tokenizejavascript.js +0 -174
  128. data/generators/liquid_cms/templates/public/cms/codemirror/js/undo.js +0 -413
  129. data/generators/liquid_cms/templates/public/cms/codemirror/js/unittests.js +0 -44
  130. data/generators/liquid_cms/templates/public/cms/codemirror/js/util.js +0 -133
@@ -1,68 +0,0 @@
1
- // Minimal framing needed to use CodeMirror-style parsers to highlight
2
- // code. Load this along with tokenize.js, stringstream.js, and your
3
- // parser. Then call highlightText, passing a string as the first
4
- // argument, and as the second argument either a callback function
5
- // that will be called with an array of SPAN nodes for every line in
6
- // the code, or a DOM node to which to append these spans, and
7
- // optionally (not needed if you only loaded one parser) a parser
8
- // object.
9
-
10
- // Stuff from util.js that the parsers are using.
11
- var StopIteration = {toString: function() {return "StopIteration"}};
12
-
13
- var Editor = {};
14
- var indentUnit = 2;
15
-
16
- (function(){
17
- function normaliseString(string) {
18
- var tab = "";
19
- for (var i = 0; i < indentUnit; i++) tab += " ";
20
-
21
- string = string.replace(/\t/g, tab).replace(/\u00a0/g, " ").replace(/\r\n?/g, "\n");
22
- var pos = 0, parts = [], lines = string.split("\n");
23
- for (var line = 0; line < lines.length; line++) {
24
- if (line != 0) parts.push("\n");
25
- parts.push(lines[line]);
26
- }
27
-
28
- return {
29
- next: function() {
30
- if (pos < parts.length) return parts[pos++];
31
- else throw StopIteration;
32
- }
33
- };
34
- }
35
-
36
- window.highlightText = function(string, callback, parser) {
37
- parser = (parser || Editor.Parser).make(stringStream(normaliseString(string)));
38
- var line = [];
39
- if (callback.nodeType == 1) {
40
- var node = callback;
41
- callback = function(line) {
42
- for (var i = 0; i < line.length; i++)
43
- node.appendChild(line[i]);
44
- node.appendChild(document.createElement("br"));
45
- };
46
- }
47
-
48
- try {
49
- while (true) {
50
- var token = parser.next();
51
- if (token.value == "\n") {
52
- callback(line);
53
- line = [];
54
- }
55
- else {
56
- var span = document.createElement("span");
57
- span.className = token.style;
58
- span.appendChild(document.createTextNode(token.value));
59
- line.push(span);
60
- }
61
- }
62
- }
63
- catch (e) {
64
- if (e != StopIteration) throw e;
65
- }
66
- if (line.length) callback(line);
67
- }
68
- })();
@@ -1,81 +0,0 @@
1
- /* Demonstration of embedding CodeMirror in a bigger application. The
2
- * interface defined here is a mess of prompts and confirms, and
3
- * should probably not be used in a real project.
4
- */
5
-
6
- function MirrorFrame(place, options) {
7
- this.home = document.createElement("div");
8
- if (place.appendChild)
9
- place.appendChild(this.home);
10
- else
11
- place(this.home);
12
-
13
- var self = this;
14
- function makeButton(name, action) {
15
- var button = document.createElement("input");
16
- button.type = "button";
17
- button.value = name;
18
- self.home.appendChild(button);
19
- button.onclick = function(){self[action].call(self);};
20
- }
21
-
22
- makeButton("Search", "search");
23
- makeButton("Replace", "replace");
24
- makeButton("Current line", "line");
25
- makeButton("Jump to line", "jump");
26
- makeButton("Insert constructor", "macro");
27
- makeButton("Indent all", "reindent");
28
-
29
- this.mirror = new CodeMirror(this.home, options);
30
- }
31
-
32
- MirrorFrame.prototype = {
33
- search: function() {
34
- var text = prompt("Enter search term:", "");
35
- if (!text) return;
36
-
37
- var first = true;
38
- do {
39
- var cursor = this.mirror.getSearchCursor(text, first);
40
- first = false;
41
- while (cursor.findNext()) {
42
- cursor.select();
43
- if (!confirm("Search again?"))
44
- return;
45
- }
46
- } while (confirm("End of document reached. Start over?"));
47
- },
48
-
49
- replace: function() {
50
- // This is a replace-all, but it is possible to implement a
51
- // prompting replace.
52
- var from = prompt("Enter search string:", ""), to;
53
- if (from) to = prompt("What should it be replaced with?", "");
54
- if (to == null) return;
55
-
56
- var cursor = this.mirror.getSearchCursor(from, false);
57
- while (cursor.findNext())
58
- cursor.replace(to);
59
- },
60
-
61
- jump: function() {
62
- var line = prompt("Jump to line:", "");
63
- if (line && !isNaN(Number(line)))
64
- this.mirror.jumpToLine(Number(line));
65
- },
66
-
67
- line: function() {
68
- alert("The cursor is currently at line " + this.mirror.currentLine());
69
- this.mirror.focus();
70
- },
71
-
72
- macro: function() {
73
- var name = prompt("Name your constructor:", "");
74
- if (name)
75
- this.mirror.replaceSelection("function " + name + "() {\n \n}\n\n" + name + ".prototype = {\n \n};\n");
76
- },
77
-
78
- reindent: function() {
79
- this.mirror.reindent();
80
- }
81
- };
@@ -1,161 +0,0 @@
1
- /* Simple parser for CSS */
2
-
3
- var CSSParser = Editor.Parser = (function() {
4
- var tokenizeCSS = (function() {
5
- function normal(source, setState) {
6
- var ch = source.next();
7
- if (ch == "@") {
8
- source.nextWhileMatches(/\w/);
9
- return "css-at";
10
- }
11
- else if (ch == "/" && source.equals("*")) {
12
- setState(inCComment);
13
- return null;
14
- }
15
- else if (ch == "<" && source.equals("!")) {
16
- setState(inSGMLComment);
17
- return null;
18
- }
19
- else if (ch == "=") {
20
- return "css-compare";
21
- }
22
- else if (source.equals("=") && (ch == "~" || ch == "|")) {
23
- source.next();
24
- return "css-compare";
25
- }
26
- else if (ch == "\"" || ch == "'") {
27
- setState(inString(ch));
28
- return null;
29
- }
30
- else if (ch == "#") {
31
- source.nextWhileMatches(/\w/);
32
- return "css-hash";
33
- }
34
- else if (ch == "!") {
35
- source.nextWhileMatches(/[ \t]/);
36
- source.nextWhileMatches(/\w/);
37
- return "css-important";
38
- }
39
- else if (/\d/.test(ch)) {
40
- source.nextWhileMatches(/[\w.%]/);
41
- return "css-unit";
42
- }
43
- else if (/[,.+>*\/]/.test(ch)) {
44
- return "css-select-op";
45
- }
46
- else if (/[;{}:\[\]]/.test(ch)) {
47
- return "css-punctuation";
48
- }
49
- else {
50
- source.nextWhileMatches(/[\w\\\-_]/);
51
- return "css-identifier";
52
- }
53
- }
54
-
55
- function inCComment(source, setState) {
56
- var maybeEnd = false;
57
- while (!source.endOfLine()) {
58
- var ch = source.next();
59
- if (maybeEnd && ch == "/") {
60
- setState(normal);
61
- break;
62
- }
63
- maybeEnd = (ch == "*");
64
- }
65
- return "css-comment";
66
- }
67
-
68
- function inSGMLComment(source, setState) {
69
- var dashes = 0;
70
- while (!source.endOfLine()) {
71
- var ch = source.next();
72
- if (dashes >= 2 && ch == ">") {
73
- setState(normal);
74
- break;
75
- }
76
- dashes = (ch == "-") ? dashes + 1 : 0;
77
- }
78
- return "css-comment";
79
- }
80
-
81
- function inString(quote) {
82
- return function(source, setState) {
83
- var escaped = false;
84
- while (!source.endOfLine()) {
85
- var ch = source.next();
86
- if (ch == quote && !escaped)
87
- break;
88
- escaped = !escaped && ch == "\\";
89
- }
90
- if (!escaped)
91
- setState(normal);
92
- return "css-string";
93
- };
94
- }
95
-
96
- return function(source, startState) {
97
- return tokenizer(source, startState || normal);
98
- };
99
- })();
100
-
101
- function indentCSS(inBraces, inRule, base) {
102
- return function(nextChars) {
103
- if (!inBraces || /^\}/.test(nextChars)) return base;
104
- else if (inRule) return base + indentUnit * 2;
105
- else return base + indentUnit;
106
- };
107
- }
108
-
109
- // This is a very simplistic parser -- since CSS does not really
110
- // nest, it works acceptably well, but some nicer colouroing could
111
- // be provided with a more complicated parser.
112
- function parseCSS(source, basecolumn) {
113
- basecolumn = basecolumn || 0;
114
- var tokens = tokenizeCSS(source);
115
- var inBraces = false, inRule = false, inDecl = false;;
116
-
117
- var iter = {
118
- next: function() {
119
- var token = tokens.next(), style = token.style, content = token.content;
120
-
121
- if (style == "css-hash")
122
- style = token.style = inRule ? "css-colorcode" : "css-identifier";
123
- if (style == "css-identifier") {
124
- if (inRule) token.style = "css-value";
125
- else if (!inBraces && !inDecl) token.style = "css-selector";
126
- }
127
-
128
- if (content == "\n")
129
- token.indentation = indentCSS(inBraces, inRule, basecolumn);
130
-
131
- if (content == "{" && inDecl == "@media")
132
- inDecl = false;
133
- else if (content == "{")
134
- inBraces = true;
135
- else if (content == "}")
136
- inBraces = inRule = inDecl = false;
137
- else if (content == ";")
138
- inRule = inDecl = false;
139
- else if (inBraces && style != "css-comment" && style != "whitespace")
140
- inRule = true;
141
- else if (!inBraces && style == "css-at")
142
- inDecl = content;
143
-
144
- return token;
145
- },
146
-
147
- copy: function() {
148
- var _inBraces = inBraces, _inRule = inRule, _tokenState = tokens.state;
149
- return function(source) {
150
- tokens = tokenizeCSS(source, _tokenState);
151
- inBraces = _inBraces;
152
- inRule = _inRule;
153
- return iter;
154
- };
155
- }
156
- };
157
- return iter;
158
- }
159
-
160
- return {make: parseCSS, electricChars: "}"};
161
- })();
@@ -1,32 +0,0 @@
1
- var DummyParser = Editor.Parser = (function() {
2
- function tokenizeDummy(source) {
3
- while (!source.endOfLine()) source.next();
4
- return "text";
5
- }
6
- function parseDummy(source) {
7
- function indentTo(n) {return function() {return n;}}
8
- source = tokenizer(source, tokenizeDummy);
9
- var space = 0;
10
-
11
- var iter = {
12
- next: function() {
13
- var tok = source.next();
14
- if (tok.type == "whitespace") {
15
- if (tok.value == "\n") tok.indentation = indentTo(space);
16
- else space = tok.value.length;
17
- }
18
- return tok;
19
- },
20
- copy: function() {
21
- var _space = space;
22
- return function(_source) {
23
- space = _space;
24
- source = tokenizer(_source, tokenizeDummy);
25
- return iter;
26
- };
27
- }
28
- };
29
- return iter;
30
- }
31
- return {make: parseDummy};
32
- })();
@@ -1,93 +0,0 @@
1
- var HTMLMixedParser = Editor.Parser = (function() {
2
-
3
- // tags that trigger seperate parsers
4
- var triggers = {
5
- "script": "JSParser",
6
- "style": "CSSParser"
7
- };
8
-
9
- function checkDependencies() {
10
- var parsers = ['XMLParser'];
11
- for (var p in triggers) parsers.push(triggers[p]);
12
- for (var i in parsers) {
13
- if (!window[parsers[i]]) throw new Error(parsers[i] + " parser must be loaded for HTML mixed mode to work.");
14
- }
15
- XMLParser.configure({useHTMLKludges: true});
16
- }
17
-
18
- function parseMixed(stream) {
19
- checkDependencies();
20
- var htmlParser = XMLParser.make(stream), localParser = null, inTag = false;
21
- var iter = {next: top, copy: copy};
22
-
23
- function top() {
24
- var token = htmlParser.next();
25
- if (token.content == "<")
26
- inTag = true;
27
- else if (token.style == "xml-tagname" && inTag === true)
28
- inTag = token.content.toLowerCase();
29
- else if (token.content == ">") {
30
- if (triggers[inTag]) {
31
- var parser = window[triggers[inTag]];
32
- iter.next = local(parser, "</" + inTag);
33
- }
34
- inTag = false;
35
- }
36
- return token;
37
- }
38
- function local(parser, tag) {
39
- var baseIndent = htmlParser.indentation();
40
- localParser = parser.make(stream, baseIndent + indentUnit);
41
- return function() {
42
- if (stream.lookAhead(tag, false, false, true)) {
43
- localParser = null;
44
- iter.next = top;
45
- return top();
46
- }
47
-
48
- var token = localParser.next();
49
- var lt = token.value.lastIndexOf("<"), sz = Math.min(token.value.length - lt, tag.length);
50
- if (lt != -1 && token.value.slice(lt, lt + sz).toLowerCase() == tag.slice(0, sz) &&
51
- stream.lookAhead(tag.slice(sz), false, false, true)) {
52
- stream.push(token.value.slice(lt));
53
- token.value = token.value.slice(0, lt);
54
- }
55
-
56
- if (token.indentation) {
57
- var oldIndent = token.indentation;
58
- token.indentation = function(chars) {
59
- if (chars == "</")
60
- return baseIndent;
61
- else
62
- return oldIndent(chars);
63
- };
64
- }
65
-
66
- return token;
67
- };
68
- }
69
-
70
- function copy() {
71
- var _html = htmlParser.copy(), _local = localParser && localParser.copy(),
72
- _next = iter.next, _inTag = inTag;
73
- return function(_stream) {
74
- stream = _stream;
75
- htmlParser = _html(_stream);
76
- localParser = _local && _local(_stream);
77
- iter.next = _next;
78
- inTag = _inTag;
79
- return iter;
80
- };
81
- }
82
- return iter;
83
- }
84
-
85
- return {
86
- make: parseMixed,
87
- electricChars: "{}/:",
88
- configure: function(obj) {
89
- if (obj.triggers) triggers = obj.triggers;
90
- }
91
- };
92
-
93
- })();