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
@@ -0,0 +1,116 @@
1
+ (function() {
2
+ function keywords(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
+ function heredoc(delim) {
8
+ return function(stream, state) {
9
+ if (stream.match(delim)) state.tokenize = null;
10
+ else stream.skipToEnd();
11
+ return "string";
12
+ }
13
+ }
14
+ var phpConfig = {
15
+ name: "clike",
16
+ keywords: keywords("abstract and array as break case catch cfunction class clone const continue declare " +
17
+ "default do else elseif enddeclare endfor endforeach endif endswitch endwhile extends " +
18
+ "final for foreach function global goto if implements interface instanceof namespace " +
19
+ "new or private protected public static switch throw try use var while xor return" +
20
+ "die echo empty exit eval include include_once isset list require require_once print unset"),
21
+ blockKeywords: keywords("catch do else elseif for foreach if switch try while"),
22
+ atoms: keywords("true false null TRUE FALSE NULL"),
23
+ multiLineStrings: true,
24
+ hooks: {
25
+ "$": function(stream, state) {
26
+ stream.eatWhile(/[\w\$_]/);
27
+ return "variable-2";
28
+ },
29
+ "<": function(stream, state) {
30
+ if (stream.match(/<</)) {
31
+ stream.eatWhile(/[\w\.]/);
32
+ state.tokenize = heredoc(stream.current().slice(3));
33
+ return state.tokenize(stream, state);
34
+ }
35
+ return false;
36
+ }
37
+ }
38
+ };
39
+
40
+ CodeMirror.defineMode("php", function(config, parserConfig) {
41
+ var htmlMode = CodeMirror.getMode(config, "text/html");
42
+ var jsMode = CodeMirror.getMode(config, "text/javascript");
43
+ var cssMode = CodeMirror.getMode(config, "text/css");
44
+ var phpMode = CodeMirror.getMode(config, phpConfig);
45
+
46
+ function dispatch(stream, state) { // TODO open PHP inside text/css
47
+ if (state.curMode == htmlMode) {
48
+ var style = htmlMode.token(stream, state.curState);
49
+ if (style == "meta" && /^<\?/.test(stream.current())) {
50
+ state.curMode = phpMode;
51
+ state.curState = state.php;
52
+ state.curClose = /^\?>/;
53
+ state.mode = 'php';
54
+ }
55
+ else if (style == "tag" && stream.current() == ">" && state.curState.context) {
56
+ if (/^script$/i.test(state.curState.context.tagName)) {
57
+ state.curMode = jsMode;
58
+ state.curState = jsMode.startState(htmlMode.indent(state.curState, ""));
59
+ state.curClose = /^<\/\s*script\s*>/i;
60
+ state.mode = 'javascript';
61
+ }
62
+ else if (/^style$/i.test(state.curState.context.tagName)) {
63
+ state.curMode = cssMode;
64
+ state.curState = cssMode.startState(htmlMode.indent(state.curState, ""));
65
+ state.curClose = /^<\/\s*style\s*>/i;
66
+ state.mode = 'css';
67
+ }
68
+ }
69
+ return style;
70
+ }
71
+ else if (stream.match(state.curClose, false)) {
72
+ state.curMode = htmlMode;
73
+ state.curState = state.html;
74
+ state.curClose = null;
75
+ state.mode = 'html';
76
+ return dispatch(stream, state);
77
+ }
78
+ else return state.curMode.token(stream, state.curState);
79
+ }
80
+
81
+ return {
82
+ startState: function() {
83
+ var html = htmlMode.startState();
84
+ return {html: html,
85
+ php: phpMode.startState(),
86
+ curMode: parserConfig.startOpen ? phpMode : htmlMode,
87
+ curState: parserConfig.startOpen ? phpMode.startState() : html,
88
+ curClose: parserConfig.startOpen ? /^\?>/ : null,
89
+ mode: parserConfig.startOpen ? 'php' : 'html'}
90
+ },
91
+
92
+ copyState: function(state) {
93
+ var html = state.html, htmlNew = CodeMirror.copyState(htmlMode, html),
94
+ php = state.php, phpNew = CodeMirror.copyState(phpMode, php), cur;
95
+ if (state.curState == html) cur = htmlNew;
96
+ else if (state.curState == php) cur = phpNew;
97
+ else cur = CodeMirror.copyState(state.curMode, state.curState);
98
+ return {html: htmlNew, php: phpNew, curMode: state.curMode, curState: cur, curClose: state.curClose};
99
+ },
100
+
101
+ token: dispatch,
102
+
103
+ indent: function(state, textAfter) {
104
+ if ((state.curMode != phpMode && /^\s*<\//.test(textAfter)) ||
105
+ (state.curMode == phpMode && /^\?>/.test(textAfter)))
106
+ return htmlMode.indent(state.html, textAfter);
107
+ return state.curMode.indent(state.curState, textAfter);
108
+ },
109
+
110
+ electricChars: "/{}:"
111
+ }
112
+ });
113
+ CodeMirror.defineMIME("application/x-httpd-php", "php");
114
+ CodeMirror.defineMIME("application/x-httpd-php-open", {name: "php", startOpen: true});
115
+ CodeMirror.defineMIME("text/x-php", phpConfig);
116
+ })();
@@ -0,0 +1,63 @@
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+ <title>CodeMirror 2: Oracle PL/SQL mode</title>
5
+ <link rel="stylesheet" href="../../lib/codemirror.css">
6
+ <script src="../../lib/codemirror.js"></script>
7
+ <script src="plsql.js"></script>
8
+ <link rel="stylesheet" href="../../theme/default.css">
9
+ <link rel="stylesheet" href="../../css/docs.css">
10
+ <style>.CodeMirror {border: 2px inset #dee;}</style>
11
+ </head>
12
+ <body>
13
+ <h1>CodeMirror 2: Oracle PL/SQL mode</h1>
14
+
15
+ <form><textarea id="code" name="code">
16
+ -- Oracle PL/SQL Code Demo
17
+ /*
18
+ based on c-like mode, adapted to PL/SQL by Peter Raganitsch ( http://www.oracle-and-apex.com/ )
19
+ April 2011
20
+ */
21
+ DECLARE
22
+ vIdx NUMBER;
23
+ vString VARCHAR2(100);
24
+ cText CONSTANT VARCHAR2(100) := 'That''s it! Have fun with CodeMirror 2';
25
+ BEGIN
26
+ vIdx := 0;
27
+ --
28
+ FOR rDATA IN
29
+ ( SELECT *
30
+ FROM EMP
31
+ ORDER BY EMPNO
32
+ )
33
+ LOOP
34
+ vIdx := vIdx + 1;
35
+ vString := rDATA.EMPNO || ' - ' || rDATA.ENAME;
36
+ --
37
+ UPDATE EMP
38
+ SET SAL = SAL * 101/100
39
+ WHERE EMPNO = rDATA.EMPNO
40
+ ;
41
+ END LOOP;
42
+ --
43
+ SYS.DBMS_OUTPUT.Put_Line (cText);
44
+ END;
45
+ --
46
+ </textarea></form>
47
+
48
+ <script>
49
+ var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
50
+ lineNumbers: true,
51
+ matchBrackets: true,
52
+ indentUnit: 4,
53
+ mode: "text/x-plsql"
54
+ });
55
+ </script>
56
+
57
+ <p>
58
+ Simple mode that handles Oracle PL/SQL language (and Oracle SQL, of course).
59
+ </p>
60
+
61
+ <p><strong>MIME type defined:</strong> <code>text/x-plsql</code>
62
+ (PLSQL code)
63
+ </html>
@@ -0,0 +1,217 @@
1
+ CodeMirror.defineMode("plsql", function(config, parserConfig) {
2
+ var indentUnit = config.indentUnit,
3
+ keywords = parserConfig.keywords,
4
+ functions = parserConfig.functions,
5
+ types = parserConfig.types,
6
+ sqlplus = parserConfig.sqlplus,
7
+ multiLineStrings = parserConfig.multiLineStrings;
8
+ var isOperatorChar = /[+\-*&%=<>!?:\/|]/;
9
+ function chain(stream, state, f) {
10
+ state.tokenize = f;
11
+ return f(stream, state);
12
+ }
13
+
14
+ var type;
15
+ function ret(tp, style) {
16
+ type = tp;
17
+ return style;
18
+ }
19
+
20
+ function tokenBase(stream, state) {
21
+ var ch = stream.next();
22
+ // start of string?
23
+ if (ch == '"' || ch == "'")
24
+ return chain(stream, state, tokenString(ch));
25
+ // is it one of the special signs []{}().,;? Seperator?
26
+ else if (/[\[\]{}\(\),;\.]/.test(ch))
27
+ return ret(ch);
28
+ // start of a number value?
29
+ else if (/\d/.test(ch)) {
30
+ stream.eatWhile(/[\w\.]/);
31
+ return ret("number", "number");
32
+ }
33
+ // multi line comment or simple operator?
34
+ else if (ch == "/") {
35
+ if (stream.eat("*")) {
36
+ return chain(stream, state, tokenComment);
37
+ }
38
+ else {
39
+ stream.eatWhile(isOperatorChar);
40
+ return ret("operator", "operator");
41
+ }
42
+ }
43
+ // single line comment or simple operator?
44
+ else if (ch == "-") {
45
+ if (stream.eat("-")) {
46
+ stream.skipToEnd();
47
+ return ret("comment", "comment");
48
+ }
49
+ else {
50
+ stream.eatWhile(isOperatorChar);
51
+ return ret("operator", "operator");
52
+ }
53
+ }
54
+ // pl/sql variable?
55
+ else if (ch == "@" || ch == "$") {
56
+ stream.eatWhile(/[\w\d\$_]/);
57
+ return ret("word", "variable");
58
+ }
59
+ // is it a operator?
60
+ else if (isOperatorChar.test(ch)) {
61
+ stream.eatWhile(isOperatorChar);
62
+ return ret("operator", "operator");
63
+ }
64
+ else {
65
+ // get the whole word
66
+ stream.eatWhile(/[\w\$_]/);
67
+ // is it one of the listed keywords?
68
+ if (keywords && keywords.propertyIsEnumerable(stream.current().toLowerCase())) return ret("keyword", "keyword");
69
+ // is it one of the listed functions?
70
+ if (functions && functions.propertyIsEnumerable(stream.current().toLowerCase())) return ret("keyword", "builtin");
71
+ // is it one of the listed types?
72
+ if (types && types.propertyIsEnumerable(stream.current().toLowerCase())) return ret("keyword", "variable-2");
73
+ // is it one of the listed sqlplus keywords?
74
+ if (sqlplus && sqlplus.propertyIsEnumerable(stream.current().toLowerCase())) return ret("keyword", "variable-3");
75
+ // default: just a "word"
76
+ return ret("word", "plsql-word");
77
+ }
78
+ }
79
+
80
+ function tokenString(quote) {
81
+ return function(stream, state) {
82
+ var escaped = false, next, end = false;
83
+ while ((next = stream.next()) != null) {
84
+ if (next == quote && !escaped) {end = true; break;}
85
+ escaped = !escaped && next == "\\";
86
+ }
87
+ if (end || !(escaped || multiLineStrings))
88
+ state.tokenize = tokenBase;
89
+ return ret("string", "plsql-string");
90
+ };
91
+ }
92
+
93
+ function tokenComment(stream, state) {
94
+ var maybeEnd = false, ch;
95
+ while (ch = stream.next()) {
96
+ if (ch == "/" && maybeEnd) {
97
+ state.tokenize = tokenBase;
98
+ break;
99
+ }
100
+ maybeEnd = (ch == "*");
101
+ }
102
+ return ret("comment", "plsql-comment");
103
+ }
104
+
105
+ // Interface
106
+
107
+ return {
108
+ startState: function(basecolumn) {
109
+ return {
110
+ tokenize: tokenBase,
111
+ startOfLine: true
112
+ };
113
+ },
114
+
115
+ token: function(stream, state) {
116
+ if (stream.eatSpace()) return null;
117
+ var style = state.tokenize(stream, state);
118
+ return style;
119
+ }
120
+ };
121
+ });
122
+
123
+ (function() {
124
+ function keywords(str) {
125
+ var obj = {}, words = str.split(" ");
126
+ for (var i = 0; i < words.length; ++i) obj[words[i]] = true;
127
+ return obj;
128
+ }
129
+ var cKeywords = "abort accept access add all alter and any array arraylen as asc assert assign at attributes audit " +
130
+ "authorization avg " +
131
+ "base_table begin between binary_integer body boolean by " +
132
+ "case cast char char_base check close cluster clusters colauth column comment commit compress connect " +
133
+ "connected constant constraint crash create current currval cursor " +
134
+ "data_base database date dba deallocate debugoff debugon decimal declare default definition delay delete " +
135
+ "desc digits dispose distinct do drop " +
136
+ "else elsif enable end entry escape exception exception_init exchange exclusive exists exit external " +
137
+ "fast fetch file for force form from function " +
138
+ "generic goto grant group " +
139
+ "having " +
140
+ "identified if immediate in increment index indexes indicator initial initrans insert interface intersect " +
141
+ "into is " +
142
+ "key " +
143
+ "level library like limited local lock log logging long loop " +
144
+ "master maxextents maxtrans member minextents minus mislabel mode modify multiset " +
145
+ "new next no noaudit nocompress nologging noparallel not nowait number_base " +
146
+ "object of off offline on online only open option or order out " +
147
+ "package parallel partition pctfree pctincrease pctused pls_integer positive positiven pragma primary prior " +
148
+ "private privileges procedure public " +
149
+ "raise range raw read rebuild record ref references refresh release rename replace resource restrict return " +
150
+ "returning reverse revoke rollback row rowid rowlabel rownum rows run " +
151
+ "savepoint schema segment select separate session set share snapshot some space split sql start statement " +
152
+ "storage subtype successful synonym " +
153
+ "tabauth table tables tablespace task terminate then to trigger truncate type " +
154
+ "union unique unlimited unrecoverable unusable update use using " +
155
+ "validate value values variable view views " +
156
+ "when whenever where while with work";
157
+
158
+ var cFunctions = "abs acos add_months ascii asin atan atan2 average " +
159
+ "bfilename " +
160
+ "ceil chartorowid chr concat convert cos cosh count " +
161
+ "decode deref dual dump dup_val_on_index " +
162
+ "empty error exp " +
163
+ "false floor found " +
164
+ "glb greatest " +
165
+ "hextoraw " +
166
+ "initcap instr instrb isopen " +
167
+ "last_day least lenght lenghtb ln lower lpad ltrim lub " +
168
+ "make_ref max min mod months_between " +
169
+ "new_time next_day nextval nls_charset_decl_len nls_charset_id nls_charset_name nls_initcap nls_lower " +
170
+ "nls_sort nls_upper nlssort no_data_found notfound null nvl " +
171
+ "others " +
172
+ "power " +
173
+ "rawtohex reftohex round rowcount rowidtochar rpad rtrim " +
174
+ "sign sin sinh soundex sqlcode sqlerrm sqrt stddev substr substrb sum sysdate " +
175
+ "tan tanh to_char to_date to_label to_multi_byte to_number to_single_byte translate true trunc " +
176
+ "uid upper user userenv " +
177
+ "variance vsize";
178
+
179
+ var cTypes = "bfile blob " +
180
+ "character clob " +
181
+ "dec " +
182
+ "float " +
183
+ "int integer " +
184
+ "mlslabel " +
185
+ "natural naturaln nchar nclob number numeric nvarchar2 " +
186
+ "real rowtype " +
187
+ "signtype smallint string " +
188
+ "varchar varchar2";
189
+
190
+ var cSqlplus = "appinfo arraysize autocommit autoprint autorecovery autotrace " +
191
+ "blockterminator break btitle " +
192
+ "cmdsep colsep compatibility compute concat copycommit copytypecheck " +
193
+ "define describe " +
194
+ "echo editfile embedded escape exec execute " +
195
+ "feedback flagger flush " +
196
+ "heading headsep " +
197
+ "instance " +
198
+ "linesize lno loboffset logsource long longchunksize " +
199
+ "markup " +
200
+ "native newpage numformat numwidth " +
201
+ "pagesize pause pno " +
202
+ "recsep recsepchar release repfooter repheader " +
203
+ "serveroutput shiftinout show showmode size spool sqlblanklines sqlcase sqlcode sqlcontinue sqlnumber " +
204
+ "sqlpluscompatibility sqlprefix sqlprompt sqlterminator suffix " +
205
+ "tab term termout time timing trimout trimspool ttitle " +
206
+ "underline " +
207
+ "verify version " +
208
+ "wrap";
209
+
210
+ CodeMirror.defineMIME("text/x-plsql", {
211
+ name: "plsql",
212
+ keywords: keywords(cKeywords),
213
+ functions: keywords(cFunctions),
214
+ types: keywords(cTypes),
215
+ sqlplus: keywords(cSqlplus)
216
+ });
217
+ }());
@@ -0,0 +1,21 @@
1
+ The MIT License
2
+
3
+ Copyright (c) 2010 Timothy Farrell
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,123 @@
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+ <title>CodeMirror 2: Python mode</title>
5
+ <link rel="stylesheet" href="../../lib/codemirror.css">
6
+ <script src="../../lib/codemirror.js"></script>
7
+ <script src="python.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: Python mode</h1>
14
+
15
+ <div><textarea id="code" name="code">
16
+ # Literals
17
+ 1234
18
+ 0.0e101
19
+ .123
20
+ 0b01010011100
21
+ 0o01234567
22
+ 0x0987654321abcdef
23
+ 7
24
+ 2147483647
25
+ 3L
26
+ 79228162514264337593543950336L
27
+ 0x100000000L
28
+ 79228162514264337593543950336
29
+ 0xdeadbeef
30
+ 3.14j
31
+ 10.j
32
+ 10j
33
+ .001j
34
+ 1e100j
35
+ 3.14e-10j
36
+
37
+
38
+ # String Literals
39
+ 'For\''
40
+ "God\""
41
+ """so loved
42
+ the world"""
43
+ '''that he gave
44
+ his only begotten\' '''
45
+ 'that whosoever believeth \
46
+ in him'
47
+ ''
48
+
49
+ # Identifiers
50
+ __a__
51
+ a.b
52
+ a.b.c
53
+
54
+ # Operators
55
+ + - * / % & | ^ ~ < >
56
+ == != <= >= <> << >> // **
57
+ and or not in is
58
+
59
+ # Delimiters
60
+ () [] {} , : ` = ; @ . # Note that @ and . require the proper context.
61
+ += -= *= /= %= &= |= ^=
62
+ //= >>= <<= **=
63
+
64
+ # Keywords
65
+ as assert break class continue def del elif else except
66
+ finally for from global if import lambda pass raise
67
+ return try while with yield
68
+
69
+ # Python 2 Keywords (otherwise Identifiers)
70
+ exec print
71
+
72
+ # Python 3 Keywords (otherwise Identifiers)
73
+ nonlocal
74
+
75
+ # Types
76
+ bool classmethod complex dict enumerate float frozenset int list object
77
+ property reversed set slice staticmethod str super tuple type
78
+
79
+ # Python 2 Types (otherwise Identifiers)
80
+ basestring buffer file long unicode xrange
81
+
82
+ # Python 3 Types (otherwise Identifiers)
83
+ bytearray bytes filter map memoryview open range zip
84
+
85
+ # Some Example code
86
+ import os
87
+ from package import ParentClass
88
+
89
+ @nonsenseDecorator
90
+ def doesNothing():
91
+ pass
92
+
93
+ class ExampleClass(ParentClass):
94
+ @staticmethod
95
+ def example(inputStr):
96
+ a = list(inputStr)
97
+ a.reverse()
98
+ return ''.join(a)
99
+
100
+ def __init__(self, mixin = 'Hello'):
101
+ self.mixin = mixin
102
+
103
+ </textarea></div>
104
+ <script>
105
+ var editor = CodeMirror.fromTextArea(document.getElementById("code"), {
106
+ mode: {name: "python",
107
+ version: 2,
108
+ singleLineStringErrors: false},
109
+ lineNumbers: true,
110
+ indentUnit: 4,
111
+ tabMode: "shift",
112
+ matchBrackets: true
113
+ });
114
+ </script>
115
+ <h2>Configuration Options:</h2>
116
+ <ul>
117
+ <li>version - 2/3 - The version of Python to recognize. Default is 2.</li>
118
+ <li>singleLineStringErrors - true/false - If you have a single-line string that is not terminated at the end of the line, this will show subsequent lines as errors if true, otherwise it will consider the newline as the end of the string. Default is false.</li>
119
+ </ul>
120
+
121
+ <p><strong>MIME types defined:</strong> <code>text/x-python</code>.</p>
122
+ </body>
123
+ </html>