liquid_cms 0.3.1.0 → 0.3.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (136) hide show
  1. data/CHANGELOG.rdoc +10 -0
  2. data/Gemfile +0 -3
  3. data/README.rdoc +16 -2
  4. data/TODO.rdoc +0 -2
  5. data/app/controllers/cms/assets_controller.rb +20 -6
  6. data/app/controllers/cms/components_controller.rb +11 -3
  7. data/app/controllers/cms/pages_controller.rb +15 -4
  8. data/app/helpers/cms/common_helper.rb +31 -32
  9. data/app/liquid/cms_paperclip_extension.rb +75 -3
  10. data/app/liquid/tags/{data_tag.rb → cms/data_tag.rb} +0 -0
  11. data/app/models/cms/asset.rb +1 -1
  12. data/app/models/cms/component.rb +3 -3
  13. data/app/views/cms/assets/_form.html.erb +1 -2
  14. data/app/views/cms/assets/update.js.rjs +1 -0
  15. data/app/views/cms/components/update.js.rjs +1 -0
  16. data/app/views/cms/pages/_form.html.erb +3 -3
  17. data/app/views/cms/pages/update.js.rjs +1 -0
  18. data/app/views/layouts/cms.html.erb +4 -3
  19. data/config/initializers/cms/simple_form.rb +70 -12
  20. data/config/initializers/cms/simple_form_updates.rb +9 -3
  21. data/config/locales/cms/en.yml +6 -0
  22. data/lib/generators/liquid_cms/install_generator.rb +5 -1
  23. data/lib/generators/liquid_cms/templates/migration_rev2.rb +13 -0
  24. data/lib/generators/liquid_cms/templates/public/cms/codemirror/LICENSE +16 -20
  25. data/lib/generators/liquid_cms/templates/public/cms/codemirror/lib/codemirror.css +68 -0
  26. data/lib/generators/liquid_cms/templates/public/cms/codemirror/lib/codemirror.js +2197 -0
  27. data/lib/generators/liquid_cms/templates/public/cms/codemirror/lib/overlay.js +51 -0
  28. data/lib/generators/liquid_cms/templates/public/cms/codemirror/lib/runmode.js +27 -0
  29. data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/clike/clike.js +247 -0
  30. data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/clike/index.html +102 -0
  31. data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/clojure/clojure.js +207 -0
  32. data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/clojure/index.html +85 -0
  33. data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/coffeescript/LICENSE +22 -0
  34. data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/coffeescript/coffeescript.js +325 -0
  35. data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/coffeescript/index.html +722 -0
  36. data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/css/css.js +124 -0
  37. data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/css/index.html +56 -0
  38. data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/diff/diff.css +3 -0
  39. data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/diff/diff.js +13 -0
  40. data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/diff/index.html +99 -0
  41. data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/haskell/haskell.js +242 -0
  42. data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/haskell/index.html +60 -0
  43. data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/htmlmixed/htmlmixed.js +79 -0
  44. data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/htmlmixed/index.html +52 -0
  45. data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/javascript/index.html +78 -0
  46. data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/javascript/javascript.js +352 -0
  47. data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/jinja2/index.html +38 -0
  48. data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/jinja2/jinja2.js +42 -0
  49. data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/lua/index.html +72 -0
  50. data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/lua/lua.js +140 -0
  51. data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/markdown/index.html +340 -0
  52. data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/markdown/markdown.css +10 -0
  53. data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/markdown/markdown.js +230 -0
  54. data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/ntriples/index.html +33 -0
  55. data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/ntriples/ntriples.js +172 -0
  56. data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/pascal/LICENSE +7 -0
  57. data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/pascal/index.html +49 -0
  58. data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/pascal/pascal.js +138 -0
  59. data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/php/index.html +49 -0
  60. data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/php/php.js +116 -0
  61. data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/plsql/index.html +63 -0
  62. data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/plsql/plsql.js +217 -0
  63. data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/python/LICENSE.txt +21 -0
  64. data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/python/index.html +123 -0
  65. data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/python/python.js +320 -0
  66. data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/r/LICENSE +24 -0
  67. data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/r/index.html +74 -0
  68. data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/r/r.js +141 -0
  69. data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/rst/index.html +526 -0
  70. data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/rst/rst.css +75 -0
  71. data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/rst/rst.js +333 -0
  72. data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/ruby/LICENSE +24 -0
  73. data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/ruby/index.html +172 -0
  74. data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/ruby/ruby.js +195 -0
  75. data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/scheme/index.html +65 -0
  76. data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/scheme/scheme.js +202 -0
  77. data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/smalltalk/index.html +56 -0
  78. data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/smalltalk/smalltalk.js +122 -0
  79. data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/sparql/index.html +41 -0
  80. data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/sparql/sparql.js +143 -0
  81. data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/stex/index.html +96 -0
  82. data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/stex/stex.js +167 -0
  83. data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/velocity/index.html +103 -0
  84. data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/velocity/velocity.js +146 -0
  85. data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/xml/index.html +42 -0
  86. data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/xml/xml.js +231 -0
  87. data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/xmlpure/index.html +60 -0
  88. data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/xmlpure/xmlpure.js +481 -0
  89. data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/yaml/index.html +68 -0
  90. data/lib/generators/liquid_cms/templates/public/cms/codemirror/mode/yaml/yaml.js +95 -0
  91. data/lib/generators/liquid_cms/templates/public/cms/codemirror/theme/cobalt.css +17 -0
  92. data/lib/generators/liquid_cms/templates/public/cms/codemirror/theme/default.css +19 -0
  93. data/lib/generators/liquid_cms/templates/public/cms/codemirror/theme/eclipse.css +24 -0
  94. data/lib/generators/liquid_cms/templates/public/cms/codemirror/theme/elegant.css +9 -0
  95. data/lib/generators/liquid_cms/templates/public/cms/codemirror/theme/neat.css +8 -0
  96. data/lib/generators/liquid_cms/templates/public/cms/codemirror/theme/night.css +20 -0
  97. data/lib/generators/liquid_cms/templates/public/cms/javascripts/cms.js +1 -1
  98. data/lib/generators/liquid_cms/templates/public/cms/javascripts/codemirror_custom.js +96 -0
  99. data/lib/generators/liquid_cms/templates/public/cms/stylesheets/codemirror_changes.css +26 -0
  100. data/lib/generators/liquid_cms/templates/public/cms/stylesheets/liquid.css +7 -0
  101. data/lib/generators/liquid_cms/templates/public/cms/stylesheets/simple_form.css +0 -8
  102. data/lib/liquid_cms/version.rb +1 -1
  103. data/liquid_cms.gemspec +1 -1
  104. data/test/functional/assets_controller_test.rb +35 -20
  105. data/test/functional/components_controller_test.rb +15 -5
  106. data/test/functional/pages_controller_test.rb +19 -6
  107. data/test/rails_app/Gemfile +1 -2
  108. data/test/rails_app/config/locales/cms/en.yml +26 -4
  109. data/test/rails_app/db/migrate/20110511161859_create_liquid_cms_upgrade_rev2.rb +13 -0
  110. data/test/unit/asset_test.rb +1 -1
  111. data/test/unit/component_test.rb +1 -1
  112. metadata +89 -32
  113. data/generators/liquid_cms/templates/migration_rev1.rb +0 -38
  114. data/lib/generators/liquid_cms/templates/public/cms/codemirror/css/csscolors.css +0 -55
  115. data/lib/generators/liquid_cms/templates/public/cms/codemirror/css/docs.css +0 -158
  116. data/lib/generators/liquid_cms/templates/public/cms/codemirror/css/font.js +0 -15
  117. data/lib/generators/liquid_cms/templates/public/cms/codemirror/css/jscolors.css +0 -59
  118. data/lib/generators/liquid_cms/templates/public/cms/codemirror/css/sparqlcolors.css +0 -43
  119. data/lib/generators/liquid_cms/templates/public/cms/codemirror/css/xmlcolors.css +0 -55
  120. data/lib/generators/liquid_cms/templates/public/cms/codemirror/js/codemirror.js +0 -582
  121. data/lib/generators/liquid_cms/templates/public/cms/codemirror/js/editor.js +0 -1671
  122. data/lib/generators/liquid_cms/templates/public/cms/codemirror/js/highlight.js +0 -68
  123. data/lib/generators/liquid_cms/templates/public/cms/codemirror/js/mirrorframe.js +0 -81
  124. data/lib/generators/liquid_cms/templates/public/cms/codemirror/js/parsecss.js +0 -161
  125. data/lib/generators/liquid_cms/templates/public/cms/codemirror/js/parsedummy.js +0 -32
  126. data/lib/generators/liquid_cms/templates/public/cms/codemirror/js/parsehtmlmixed.js +0 -93
  127. data/lib/generators/liquid_cms/templates/public/cms/codemirror/js/parsejavascript.js +0 -359
  128. data/lib/generators/liquid_cms/templates/public/cms/codemirror/js/parsesparql.js +0 -162
  129. data/lib/generators/liquid_cms/templates/public/cms/codemirror/js/parsexml.js +0 -291
  130. data/lib/generators/liquid_cms/templates/public/cms/codemirror/js/select.js +0 -699
  131. data/lib/generators/liquid_cms/templates/public/cms/codemirror/js/stringstream.js +0 -159
  132. data/lib/generators/liquid_cms/templates/public/cms/codemirror/js/tokenize.js +0 -57
  133. data/lib/generators/liquid_cms/templates/public/cms/codemirror/js/tokenizejavascript.js +0 -174
  134. data/lib/generators/liquid_cms/templates/public/cms/codemirror/js/undo.js +0 -413
  135. data/lib/generators/liquid_cms/templates/public/cms/codemirror/js/unittests.js +0 -44
  136. data/lib/generators/liquid_cms/templates/public/cms/codemirror/js/util.js +0 -133
@@ -0,0 +1,68 @@
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+ <title>CodeMirror 2: YAML mode</title>
5
+ <link rel="stylesheet" href="../../lib/codemirror.css">
6
+ <script src="../../lib/codemirror.js"></script>
7
+ <script src="yaml.js"></script>
8
+ <link rel="stylesheet" href="../../theme/default.css">
9
+ <style>.CodeMirror { border-top: 1px solid #ddd; border-bottom: 1px solid #ddd; }</style>
10
+ <link rel="stylesheet" href="../../css/docs.css">
11
+ </head>
12
+ <body>
13
+ <h1>CodeMirror 2: YAML mode</h1>
14
+ <form><textarea id="code" name="code">
15
+ --- # Favorite movies
16
+ - Casablanca
17
+ - North by Northwest
18
+ - The Man Who Wasn't There
19
+ --- # Shopping list
20
+ [milk, pumpkin pie, eggs, juice]
21
+ --- # Indented Blocks, common in YAML data files, use indentation and new lines to separate the key: value pairs
22
+ name: John Smith
23
+ age: 33
24
+ --- # Inline Blocks, common in YAML data streams, use commas to separate the key: value pairs between braces
25
+ {name: John Smith, age: 33}
26
+ ---
27
+ receipt: Oz-Ware Purchase Invoice
28
+ date: 2007-08-06
29
+ customer:
30
+ given: Dorothy
31
+ family: Gale
32
+
33
+ items:
34
+ - part_no: A4786
35
+ descrip: Water Bucket (Filled)
36
+ price: 1.47
37
+ quantity: 4
38
+
39
+ - part_no: E1628
40
+ descrip: High Heeled "Ruby" Slippers
41
+ size: 8
42
+ price: 100.27
43
+ quantity: 1
44
+
45
+ bill-to: &id001
46
+ street: |
47
+ 123 Tornado Alley
48
+ Suite 16
49
+ city: East Centerville
50
+ state: KS
51
+
52
+ ship-to: *id001
53
+
54
+ specialDelivery: >
55
+ Follow the Yellow Brick
56
+ Road to the Emerald City.
57
+ Pay no attention to the
58
+ man behind the curtain.
59
+ ...
60
+ </textarea></form>
61
+ <script>
62
+ var editor = CodeMirror.fromTextArea(document.getElementById("code"), {});
63
+ </script>
64
+
65
+ <p><strong>MIME types defined:</strong> <code>text/x-yaml</code>.</p>
66
+
67
+ </body>
68
+ </html>
@@ -0,0 +1,95 @@
1
+ CodeMirror.defineMode("yaml", function() {
2
+
3
+ var cons = ['true', 'false', 'on', 'off', 'yes', 'no'];
4
+ var keywordRegex = new RegExp("\\b(("+cons.join(")|(")+"))$", 'i');
5
+
6
+ return {
7
+ token: function(stream, state) {
8
+ var ch = stream.peek();
9
+ var esc = state.escaped;
10
+ state.escaped = false;
11
+ /* comments */
12
+ if (ch == "#") { stream.skipToEnd(); return "comment"; }
13
+ if (state.literal && stream.indentation() > state.keyCol) {
14
+ stream.skipToEnd(); return "string";
15
+ } else if (state.literal) { state.literal = false; }
16
+ if (stream.sol()) {
17
+ state.keyCol = 0;
18
+ state.pair = false;
19
+ state.pairStart = false;
20
+ /* document start */
21
+ if(stream.match(/---/)) { return "def"; }
22
+ /* document end */
23
+ if (stream.match(/\.\.\./)) { return "def"; }
24
+ /* array list item */
25
+ if (stream.match(/\s*-\s+/)) { return 'meta'; }
26
+ }
27
+ /* pairs (associative arrays) -> key */
28
+ if (!state.pair && stream.match(/^\s*([a-z0-9\._-])+(?=\s*:)/i)) {
29
+ state.pair = true;
30
+ state.keyCol = stream.indentation();
31
+ return "atom";
32
+ }
33
+ if (state.pair && stream.match(/^:\s*/)) { state.pairStart = true; return 'meta'; }
34
+
35
+ /* inline pairs/lists */
36
+ if (stream.match(/^(\{|\}|\[|\])/)) {
37
+ if (ch == '{')
38
+ state.inlinePairs++;
39
+ else if (ch == '}')
40
+ state.inlinePairs--;
41
+ else if (ch == '[')
42
+ state.inlineList++;
43
+ else
44
+ state.inlineList--;
45
+ return 'meta';
46
+ }
47
+
48
+ /* list seperator */
49
+ if (state.inlineList > 0 && !esc && ch == ',') {
50
+ stream.next();
51
+ return 'meta';
52
+ }
53
+ /* pairs seperator */
54
+ if (state.inlinePairs > 0 && !esc && ch == ',') {
55
+ state.keyCol = 0;
56
+ state.pair = false;
57
+ state.pairStart = false;
58
+ stream.next();
59
+ return 'meta';
60
+ }
61
+
62
+ /* start of value of a pair */
63
+ if (state.pairStart) {
64
+ /* block literals */
65
+ if (stream.match(/^\s*(\||\>)\s*/)) { state.literal = true; return 'meta'; };
66
+ /* references */
67
+ if (stream.match(/^\s*(\&|\*)[a-z0-9\._-]+\b/i)) { return 'variable-2'; }
68
+ /* numbers */
69
+ if (state.inlinePairs == 0 && stream.match(/^\s*-?[0-9\.\,]+\s?$/)) { return 'number'; }
70
+ if (state.inlinePairs > 0 && stream.match(/^\s*-?[0-9\.\,]+\s?(?=(,|}))/)) { return 'number'; }
71
+ /* keywords */
72
+ if (stream.match(keywordRegex)) { return 'keyword'; }
73
+ }
74
+
75
+ /* nothing found, continue */
76
+ state.pairStart = false;
77
+ state.escaped = (ch == '\\');
78
+ stream.next();
79
+ return null;
80
+ },
81
+ startState: function() {
82
+ return {
83
+ pair: false,
84
+ pairStart: false,
85
+ keyCol: 0,
86
+ inlinePairs: 0,
87
+ inlineList: 0,
88
+ literal: false,
89
+ escaped: false
90
+ };
91
+ }
92
+ };
93
+ });
94
+
95
+ CodeMirror.defineMIME("text/x-yaml", "yaml");
@@ -0,0 +1,17 @@
1
+ .cm-s-cobalt { background: #002240; color: white; }
2
+ .cm-s-cobalt span.CodeMirror-selected { background: #b36539 !important; }
3
+ .cm-s-cobalt .CodeMirror-gutter { background: #002240; border-right: 1px solid #aaa; }
4
+ .cm-s-cobalt .CodeMirror-gutter-text { color: #d0d0d0; }
5
+ .cm-s-cobalt .CodeMirror-cursor { border-left: 1px solid white !important; }
6
+
7
+ .cm-s-cobalt span.cm-comment { color: #08f; }
8
+ .cm-s-cobalt span.cm-atom { color: #845dc4; }
9
+ .cm-s-cobalt span.cm-number, .cm-s-cobalt span.cm-attribute { color: #ff80e1; }
10
+ .cm-s-cobalt span.cm-keyword { color: #ffee80; }
11
+ .cm-s-cobalt span.cm-string { color: #3ad900; }
12
+ .cm-s-cobalt span.cm-meta { color: #ff9d00; }
13
+ .cm-s-cobalt span.cm-variable-2, .cm-s-cobalt span.cm-tag { color: #9effff; }
14
+ .cm-s-cobalt span.cm-variable-3, .cm-s-cobalt span.cm-def { color: white; }
15
+ .cm-s-cobalt span.cm-error { color: #9d1e15; }
16
+ .cm-s-cobalt span.cm-bracket { color: #d8d8d8; }
17
+ .cm-s-cobalt span.cm-builtin, .cm-s-cobalt span.cm-special { color: #ff9e59; }
@@ -0,0 +1,19 @@
1
+ .cm-s-default span.cm-keyword {color: #708;}
2
+ .cm-s-default span.cm-atom {color: #219;}
3
+ .cm-s-default span.cm-number {color: #164;}
4
+ .cm-s-default span.cm-def {color: #00f;}
5
+ .cm-s-default span.cm-variable {color: black;}
6
+ .cm-s-default span.cm-variable-2 {color: #05a;}
7
+ .cm-s-default span.cm-variable-3 {color: #0a5;}
8
+ .cm-s-default span.cm-property {color: black;}
9
+ .cm-s-default span.cm-operator {color: black;}
10
+ .cm-s-default span.cm-comment {color: #a50;}
11
+ .cm-s-default span.cm-string {color: #a11;}
12
+ .cm-s-default span.cm-string-2 {color: #f50;}
13
+ .cm-s-default span.cm-meta {color: #555;}
14
+ .cm-s-default span.cm-error {color: #f00;}
15
+ .cm-s-default span.cm-qualifier {color: #555;}
16
+ .cm-s-default span.cm-builtin {color: #30a;}
17
+ .cm-s-default span.cm-bracket {color: #cc7;}
18
+ .cm-s-default span.cm-tag {color: #170;}
19
+ .cm-s-default span.cm-attribute {color: #00c;}
@@ -0,0 +1,24 @@
1
+ .cm-s-eclipse span.cm-meta {color: #FF1717;}
2
+ .cm-s-eclipse span.cm-keyword { font-weight: bold; color: #7F0055; }
3
+ .cm-s-eclipse span.cm-atom {color: #219;}
4
+ .cm-s-eclipse span.cm-number {color: #164;}
5
+ .cm-s-eclipse span.cm-def {color: #00f;}
6
+ .cm-s-eclipse span.cm-variable {color: black;}
7
+ .cm-s-eclipse span.cm-variable-2 {color: #0000C0;}
8
+ .cm-s-eclipse span.cm-variable-3 {color: #0000C0;}
9
+ .cm-s-eclipse span.cm-property {color: black;}
10
+ .cm-s-eclipse span.cm-operator {color: black;}
11
+ .cm-s-eclipse span.cm-comment {color: #3F7F5F;}
12
+ .cm-s-eclipse span.cm-string {color: #2A00FF;}
13
+ .cm-s-eclipse span.cm-string-2 {color: #f50;}
14
+ .cm-s-eclipse span.cm-error {color: #f00;}
15
+ .cm-s-eclipse span.cm-qualifier {color: #555;}
16
+ .cm-s-eclipse span.cm-builtin {color: #30a;}
17
+ .cm-s-eclipse span.cm-bracket {color: #cc7;}
18
+ .cm-s-eclipse span.cm-tag {color: #170;}
19
+ .cm-s-eclipse span.cm-attribute {color: #00c;}
20
+
21
+ .CodeMirror-matchingbracket{
22
+ border:1px solid grey;
23
+ color:black !important;;
24
+ }
@@ -0,0 +1,9 @@
1
+ .cm-s-elegant span.cm-number, .cm-s-elegant span.cm-string, .cm-s-elegant span.cm-atom {color: #762;}
2
+ .cm-s-elegant span.cm-comment {color: #262;font-style: italic;}
3
+ .cm-s-elegant span.cm-meta {color: #555;font-style: italic;}
4
+ .cm-s-elegant span.cm-variable {color: black;}
5
+ .cm-s-elegant span.cm-variable-2 {color: #b11;}
6
+ .cm-s-elegant span.cm-qualifier {color: #555;}
7
+ .cm-s-elegant span.cm-keyword {color: #730;}
8
+ .cm-s-elegant span.cm-builtin {color: #30a;}
9
+ .cm-s-elegant span.cm-error {background-color: #fdd;}
@@ -0,0 +1,8 @@
1
+ .cm-s-neat span.cm-comment { color: #a86; }
2
+ .cm-s-neat span.cm-keyword { font-weight: bold; color: blue; }
3
+ .cm-s-neat span.cm-string { color: #a22; }
4
+ .cm-s-neat span.cm-builtin { font-weight: bold; color: #077; }
5
+ .cm-s-neat span.cm-special { font-weight: bold; color: #0aa; }
6
+ .cm-s-neat span.cm-variable { color: black; }
7
+ .cm-s-neat span.cm-number, .cm-s-neat span.cm-atom { color: #3a3; }
8
+ .cm-s-neat span.cm-meta {color: #555;}
@@ -0,0 +1,20 @@
1
+ /* Loosely based on the Midnight Textmate theme */
2
+
3
+ .cm-s-night { background: #0a001f; color: #f8f8f8; }
4
+ .cm-s-night span.CodeMirror-selected { background: #a8f !important; }
5
+ .cm-s-night .CodeMirror-gutter { background: #0a001f; border-right: 1px solid #aaa; }
6
+ .cm-s-night .CodeMirror-gutter-text { color: #f8f8f8; }
7
+ .cm-s-night .CodeMirror-cursor { border-left: 1px solid white !important; }
8
+
9
+ .cm-s-night span.cm-comment { color: #6900a1; }
10
+ .cm-s-night span.cm-atom { color: #845dc4; }
11
+ .cm-s-night span.cm-number, .cm-s-night span.cm-attribute { color: #ffd500; }
12
+ .cm-s-night span.cm-keyword { color: #599eff; }
13
+ .cm-s-night span.cm-string { color: #37f14a; }
14
+ .cm-s-night span.cm-meta { color: #7678e2; }
15
+ .cm-s-night span.cm-variable-2, .cm-s-night span.cm-tag { color: #99b2ff; }
16
+ .cm-s-night span.cm-variable-3, .cm-s-night span.cm-def { color: white; }
17
+ .cm-s-night span.cm-error { color: #9d1e15; }
18
+ .cm-s-night span.cm-bracket { color: #8da6ce; }
19
+ .cm-s-night span.cm-comment { color: #6900a1; }
20
+ .cm-s-night span.cm-builtin, .cm-s-night span.cm-special { color: #ff9e59; }
@@ -2,7 +2,7 @@
2
2
  function set_component_view_state(elem) {
3
3
  var key = elem.getAttribute('id');
4
4
  var current_folders = jar.get('component_folders') || {};
5
-
5
+
6
6
  if (elem.next('ul').visible())
7
7
  current_folders[key] = true;
8
8
  else
@@ -0,0 +1,96 @@
1
+ function codemirrorToggleFullscreenEditing()
2
+ {
3
+ var editorDiv = $$('.CodeMirror-scroll').first();
4
+
5
+ if (!editorDiv.hasClassName('fullscreen')) {
6
+ var height = document.viewport.getHeight()+document.viewport.getScrollOffsets()[1];
7
+
8
+ toggleFullscreenEditing.beforeFullscreen = { height: editorDiv.getHeight(), width: editorDiv.getWidth() }
9
+ editorDiv.addClassName('fullscreen');
10
+ editorDiv.setStyle({height:height+'px', width:'100%'});
11
+ editor.refresh();
12
+ }
13
+ else {
14
+ editorDiv.removeClassName('fullscreen');
15
+ editorDiv.setStyle({
16
+ height:toggleFullscreenEditing.beforeFullscreen.height,
17
+ width:toggleFullscreenEditing.beforeFullscreen.width
18
+ });
19
+ editor.refresh();
20
+ }
21
+ }
22
+
23
+ function codemirrorSave(editor, form, use_ajax) {
24
+ editor.save();
25
+
26
+ if (!use_ajax) {
27
+ form.submit();
28
+ return;
29
+ }
30
+
31
+ var has_indicator = $('indicator');
32
+
33
+ if (has_indicator)
34
+ Element.show('indicator');
35
+
36
+ new Ajax.Request(form.action, {asynchronous:true, evalScripts:true, onComplete:
37
+ function(request){
38
+ if (has_indicator)
39
+ Element.hide('indicator');
40
+
41
+ form.enable();
42
+ },
43
+ parameters:form.serialize()}
44
+ );
45
+
46
+ form.disable();
47
+ }
48
+
49
+ CodeMirror.defineMode("liquid", function(config, parserConfig) {
50
+ var liquidOverlay = {
51
+ token: function(stream, state) {
52
+ if (stream.match("{{", false)) {
53
+ stream.match("{{");
54
+ while ((ch = stream.next()) != null)
55
+ if (ch == "}" && stream.next() == "}") break;
56
+ return "liquid-control";
57
+ }
58
+
59
+ if (stream.match("{%", false)) {
60
+ stream.match("{%");
61
+ while ((ch = stream.next()) != null)
62
+ if (ch == "%" && stream.next() == "}") break;
63
+ return "liquid-output";
64
+ }
65
+
66
+ while (stream.next() != null && !stream.match("{{", false) && !stream.match("{%", false)) {}
67
+ return null;
68
+ }
69
+ };
70
+
71
+ return CodeMirror.overlayParser(CodeMirror.getMode(config, parserConfig.backdrop || "text/html"), liquidOverlay);
72
+ });
73
+
74
+ function initCodemirror(mode, form, textarea, use_ajax, liquid_support) {
75
+ var codeMirrorOptions = {
76
+ mode : mode,
77
+ onKeyEvent : function(instance, event){
78
+ if (event.type == 'keydown') {
79
+ if (event.ctrlKey && (event.which == 83 || event.keyCode == 83)) {
80
+ event.stop();
81
+ codemirrorSave(instance, form, use_ajax);
82
+ }
83
+ // Hook into F11
84
+ //else if (event.keyCode == 122 || event.keyCode == 27) {
85
+ // event.stop();
86
+ // codemirrorToggleFullscreenEditing();
87
+ //}
88
+ }
89
+ }
90
+ }
91
+
92
+ //if (liquid_support)
93
+ // codeMirrorOptions.mode = 'liquid';
94
+
95
+ var editor = CodeMirror.fromTextArea(textarea, codeMirrorOptions);
96
+ }
@@ -0,0 +1,26 @@
1
+ .CodeMirror {
2
+ background-color: white;
3
+ border: 1px solid #BBBBBB;
4
+ display: inline-block;
5
+ width: 89%;
6
+ }
7
+ .CodeMirror-scroll {
8
+ height: auto;
9
+ max-height: 800px;
10
+ min-height: 350px;
11
+ }
12
+
13
+ .fullscreen {
14
+ background-color: white;
15
+ display: block;
16
+ position: absolute;
17
+ top: 0;
18
+ left: 0;
19
+ width: 100%;
20
+ height: 100%;
21
+ z-index: 9999;
22
+ margin: 0;
23
+ padding: 0;
24
+ border: 0px solid #BBBBBB;
25
+ opacity: 1;
26
+ }
@@ -0,0 +1,7 @@
1
+ span.cm-liquid-control {
2
+ }
3
+ span.cm-liquid-output {
4
+ }
5
+ span.cm-liquid-control, span.cm-liquid-output {
6
+ color: purple;
7
+ }
@@ -104,14 +104,6 @@ form.simple_form .details .label {
104
104
  float: none;
105
105
  }
106
106
 
107
- .CodeMirror-wrapping {
108
- display: inline-block;
109
- }
110
- .CodeMirror-wrapping iframe {
111
- background-color: white;
112
- border: 1px solid #BBBBBB !important;
113
- }
114
-
115
107
  div.dimensions {
116
108
  margin-bottom: 1.3em;
117
109
  }
@@ -1,3 +1,3 @@
1
1
  module Cms
2
- VERSION = "0.3.1.0"
2
+ VERSION = "0.3.2.0"
3
3
  end
@@ -21,7 +21,7 @@ Gem::Specification.new do |s|
21
21
  s.add_dependency 'rails', '~> 3.0.0'
22
22
  s.add_dependency 'paperclip', '~> 2.3.1'
23
23
  #s.add_dependency 'vestal_versions', '~> 1.2.1'
24
- s.add_dependency 'simple_form', '~> 1.2.0'
24
+ s.add_dependency 'simple_form', '~> 1.5.2'
25
25
  s.add_dependency 'rubyzip', '~> 0.9.1'
26
26
  s.add_dependency 'will_paginate', '~> 2.3.12'
27
27
  s.add_dependency 'formatize'
@@ -119,7 +119,8 @@ class Cms::AssetsControllerTest < ActionController::TestCase
119
119
 
120
120
  put :update, :id => asset, :cms_asset => {:asset => fixture_file_upload(File.join('assets', File.basename(new_asset_file)))}
121
121
  assert_response :redirect
122
- assert_redirected_to cms_root_path
122
+ assert_redirected_to edit_cms_asset_path(asset)
123
+ assert_equal 'The asset has been updated.', flash[:notice]
123
124
 
124
125
  # check that the file name updated
125
126
  assert_equal File.basename(new_asset_file), asset.reload.asset_file_name
@@ -131,27 +132,41 @@ class Cms::AssetsControllerTest < ActionController::TestCase
131
132
  # file contents are ignored for non-editable assets
132
133
  put :update, :id => asset, :cms_asset => {:file_content => 'new content'}
133
134
  assert_response :redirect
134
- assert_redirected_to cms_root_path
135
+ assert_redirected_to edit_cms_asset_path(asset)
136
+ assert_equal 'The asset has been updated.', flash[:notice]
135
137
  end
136
138
 
137
- should "modify the contents of an editable asset file and it's meta data" do
138
- asset = Factory(:js_asset, :context => @company)
139
- assert_nil asset.meta_data
140
- assert_equal 0, asset.meta.length
141
-
142
- asset_file = asset_file(asset.asset_file_name)
143
- setup_asset asset_file
144
-
145
- Cms::Asset.any_instance.stubs(:asset => stub(:path => asset_file))
146
- Cms::Asset.any_instance.expects(:file_content=).with('new content').returns('new content')
147
-
148
- put :update, :id => asset, :cms_asset => {:file_content => 'new content', :meta => {'new_0' => {:name => 'key_a', :value => 'test'}, 'new_1' => {:name => 'key_b', :value => 'test'}}}
149
- assert_response :redirect
150
- assert_redirected_to cms_root_path
151
-
152
- asset.reload
153
- assert_not_nil asset.meta_data
154
- assert_equal 2, asset.meta.length
139
+ context "update editable content" do
140
+ setup do
141
+ @asset = Factory(:js_asset, :context => @company)
142
+
143
+ asset_file = asset_file(@asset.asset_file_name)
144
+ setup_asset asset_file
145
+
146
+ Cms::Asset.any_instance.stubs(:asset => stub(:path => asset_file))
147
+ Cms::Asset.any_instance.expects(:file_content=).with('new content').returns('new content')
148
+ end
149
+
150
+ teardown do
151
+ assert_equal 'The asset has been updated.', flash[:notice]
152
+ @asset.reload
153
+ assert_not_nil @asset.meta_data
154
+ assert_equal 2, @asset.meta.length
155
+ end
156
+
157
+ should "modify the contents of an editable asset file and it's meta data" do
158
+ assert_nil @asset.meta_data
159
+ assert_equal 0, @asset.meta.length
160
+
161
+ put :update, :id => @asset, :cms_asset => {:file_content => 'new content', :meta => {'new_0' => {:name => 'key_a', :value => 'test'}, 'new_1' => {:name => 'key_b', :value => 'test'}}}
162
+ assert_response :redirect
163
+ assert_redirected_to edit_cms_asset_path(@asset)
164
+ end
165
+
166
+ should "update via XHR" do
167
+ xhr :put, :update, :id => @asset, :cms_asset => {:file_content => 'new content', :meta => {'new_0' => {:name => 'key_a', :value => 'test'}, 'new_1' => {:name => 'key_b', :value => 'test'}}}
168
+ assert_response :success
169
+ end
155
170
  end
156
171
  end
157
172