liquid_cms 0.2.1.1 → 0.2.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.rdoc +7 -0
- data/README.rdoc +15 -1
- data/TODO.rdoc +0 -2
- data/app/controllers/cms/assets_controller.rb +20 -6
- data/app/controllers/cms/components_controller.rb +11 -3
- data/app/controllers/cms/pages_controller.rb +15 -4
- data/app/helpers/cms/common_helper.rb +31 -31
- data/app/liquid/cms_paperclip_extension.rb +75 -3
- data/app/models/cms/asset.rb +1 -1
- data/app/models/cms/component.rb +3 -3
- data/app/views/cms/assets/_form.html.erb +1 -1
- data/app/views/cms/assets/update.js.rjs +1 -0
- data/app/views/cms/components/update.js.rjs +1 -0
- data/app/views/cms/pages/_form.html.erb +1 -1
- data/app/views/cms/pages/update.js.rjs +1 -0
- data/app/views/layouts/cms.html.erb +4 -3
- data/generators/liquid_cms/liquid_cms_generator.rb +1 -0
- data/generators/liquid_cms/templates/config/locales/cms/en.yml +4 -0
- data/generators/liquid_cms/templates/migration_rev2.rb +13 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/LICENSE +16 -20
- data/generators/liquid_cms/templates/public/cms/codemirror/lib/codemirror.css +68 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/lib/codemirror.js +2197 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/lib/overlay.js +51 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/lib/runmode.js +27 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/clike/clike.js +247 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/clike/index.html +102 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/clojure/clojure.js +207 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/clojure/index.html +85 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/coffeescript/LICENSE +22 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/coffeescript/coffeescript.js +325 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/coffeescript/index.html +722 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/css/css.js +124 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/css/index.html +56 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/diff/diff.css +3 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/diff/diff.js +13 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/diff/index.html +99 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/haskell/haskell.js +242 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/haskell/index.html +60 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/htmlmixed/htmlmixed.js +79 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/htmlmixed/index.html +52 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/javascript/index.html +78 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/javascript/javascript.js +352 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/jinja2/index.html +38 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/jinja2/jinja2.js +42 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/lua/index.html +72 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/lua/lua.js +140 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/markdown/index.html +340 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/markdown/markdown.css +10 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/markdown/markdown.js +230 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/ntriples/index.html +33 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/ntriples/ntriples.js +172 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/pascal/LICENSE +7 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/pascal/index.html +49 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/pascal/pascal.js +138 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/php/index.html +49 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/php/php.js +116 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/plsql/index.html +63 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/plsql/plsql.js +217 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/python/LICENSE.txt +21 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/python/index.html +123 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/python/python.js +320 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/r/LICENSE +24 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/r/index.html +74 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/r/r.js +141 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/rst/index.html +526 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/rst/rst.css +75 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/rst/rst.js +333 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/ruby/LICENSE +24 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/ruby/index.html +172 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/ruby/ruby.js +195 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/scheme/index.html +65 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/scheme/scheme.js +202 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/smalltalk/index.html +56 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/smalltalk/smalltalk.js +122 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/sparql/index.html +41 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/sparql/sparql.js +143 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/stex/index.html +96 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/stex/stex.js +167 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/velocity/index.html +103 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/velocity/velocity.js +146 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/xml/index.html +42 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/xml/xml.js +231 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/xmlpure/index.html +60 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/xmlpure/xmlpure.js +481 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/yaml/index.html +68 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/mode/yaml/yaml.js +95 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/theme/cobalt.css +17 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/theme/default.css +19 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/theme/eclipse.css +24 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/theme/elegant.css +9 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/theme/neat.css +8 -0
- data/generators/liquid_cms/templates/public/cms/codemirror/theme/night.css +20 -0
- data/generators/liquid_cms/templates/public/cms/javascripts/cms.js +1 -1
- data/generators/liquid_cms/templates/public/cms/javascripts/codemirror_custom.js +96 -0
- data/generators/liquid_cms/templates/public/cms/stylesheets/codemirror_changes.css +26 -0
- data/generators/liquid_cms/templates/public/cms/stylesheets/liquid.css +7 -0
- data/generators/liquid_cms/templates/public/cms/stylesheets/simple_form.css +0 -8
- data/lib/liquid_cms/version.rb +1 -1
- data/liquid_cms.gemspec +0 -1
- data/test/functional/assets_controller_test.rb +35 -20
- data/test/functional/components_controller_test.rb +15 -5
- data/test/functional/pages_controller_test.rb +19 -6
- data/test/rails_app/config/environment.rb +1 -1
- data/test/rails_app/config/locales/cms/en.yml +19 -4
- data/test/rails_app/db/migrate/20110511161859_create_liquid_cms_upgrade_rev2.rb +13 -0
- data/test/unit/asset_test.rb +1 -1
- metadata +100 -58
- data/generators/liquid_cms/templates/public/cms/codemirror/css/csscolors.css +0 -55
- data/generators/liquid_cms/templates/public/cms/codemirror/css/docs.css +0 -158
- data/generators/liquid_cms/templates/public/cms/codemirror/css/font.js +0 -15
- data/generators/liquid_cms/templates/public/cms/codemirror/css/jscolors.css +0 -59
- data/generators/liquid_cms/templates/public/cms/codemirror/css/sparqlcolors.css +0 -43
- data/generators/liquid_cms/templates/public/cms/codemirror/css/xmlcolors.css +0 -55
- data/generators/liquid_cms/templates/public/cms/codemirror/js/codemirror.js +0 -582
- data/generators/liquid_cms/templates/public/cms/codemirror/js/editor.js +0 -1671
- data/generators/liquid_cms/templates/public/cms/codemirror/js/highlight.js +0 -68
- data/generators/liquid_cms/templates/public/cms/codemirror/js/mirrorframe.js +0 -81
- data/generators/liquid_cms/templates/public/cms/codemirror/js/parsecss.js +0 -161
- data/generators/liquid_cms/templates/public/cms/codemirror/js/parsedummy.js +0 -32
- data/generators/liquid_cms/templates/public/cms/codemirror/js/parsehtmlmixed.js +0 -93
- data/generators/liquid_cms/templates/public/cms/codemirror/js/parsejavascript.js +0 -359
- data/generators/liquid_cms/templates/public/cms/codemirror/js/parsesparql.js +0 -162
- data/generators/liquid_cms/templates/public/cms/codemirror/js/parsexml.js +0 -291
- data/generators/liquid_cms/templates/public/cms/codemirror/js/select.js +0 -699
- data/generators/liquid_cms/templates/public/cms/codemirror/js/stringstream.js +0 -159
- data/generators/liquid_cms/templates/public/cms/codemirror/js/tokenize.js +0 -57
- data/generators/liquid_cms/templates/public/cms/codemirror/js/tokenizejavascript.js +0 -174
- data/generators/liquid_cms/templates/public/cms/codemirror/js/undo.js +0 -413
- data/generators/liquid_cms/templates/public/cms/codemirror/js/unittests.js +0 -44
- data/generators/liquid_cms/templates/public/cms/codemirror/js/util.js +0 -133
@@ -0,0 +1,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; }
|
@@ -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
|
+
}
|
@@ -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
|
}
|
data/lib/liquid_cms/version.rb
CHANGED
data/liquid_cms.gemspec
CHANGED
@@ -19,7 +19,6 @@ Gem::Specification.new do |s|
|
|
19
19
|
|
20
20
|
s.add_dependency 'rails', '~> 2.3.5'
|
21
21
|
s.add_dependency 'paperclip', '~> 2.3.1'
|
22
|
-
s.add_dependency 'vestal_versions', '~> 1.0.1'
|
23
22
|
s.add_dependency 'simple_form', '1.0.4'
|
24
23
|
s.add_dependency 'rubyzip', '~> 0.9.1'
|
25
24
|
s.add_dependency 'will_paginate', '~> 2.3.12'
|
@@ -119,7 +119,8 @@ class Cms::AssetsControllerTest < ActionController::TestCase
|
|
119
119
|
|
120
120
|
put :update, :id => asset, :cms_asset => {:asset => ActionController::TestUploadedFile.new(new_asset_file)}
|
121
121
|
assert_response :redirect
|
122
|
-
assert_redirected_to
|
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
|
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
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
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
|
|
@@ -27,11 +27,21 @@ class Cms::ComponentsControllerTest < ActionController::TestCase
|
|
27
27
|
assert_template 'edit'
|
28
28
|
end
|
29
29
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
30
|
+
context "update" do
|
31
|
+
should "update via HTTP" do
|
32
|
+
put :update, :url => [@file], :file_content => 'new content'
|
33
|
+
assert_response :redirect
|
34
|
+
assert_redirected_to :controller => 'cms/components', :action => 'edit', :url => @file
|
35
|
+
assert_equal "The component file has been updated.", flash[:notice]
|
36
|
+
assert_equal "new content\n", File.read(Cms::Component.full_path(@context).join(@file))
|
37
|
+
end
|
38
|
+
|
39
|
+
should "update via XHR" do
|
40
|
+
xhr :put, :update, :url => [@file], :file_content => 'new content'
|
41
|
+
assert_response :success
|
42
|
+
assert_equal "The component file has been updated.", flash[:notice]
|
43
|
+
assert_equal "new content\n", File.read(Cms::Component.full_path(@context).join(@file))
|
44
|
+
end
|
35
45
|
end
|
36
46
|
|
37
47
|
should "valid destroy" do
|
@@ -70,12 +70,25 @@ class Cms::PagesControllerTest < ActionController::TestCase
|
|
70
70
|
assert_template 'edit'
|
71
71
|
end
|
72
72
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
73
|
+
context "update" do
|
74
|
+
setup do
|
75
|
+
@page = @company.pages.first
|
76
|
+
end
|
77
|
+
|
78
|
+
should "update via HTTP" do
|
79
|
+
put :update, :id => @page.id, :cms_page => {:slug => '', :published => false}
|
80
|
+
assert_response :redirect
|
81
|
+
assert_equal true, assigns(:page).errors.empty?
|
82
|
+
assert_redirected_to edit_cms_page_path(@page)
|
83
|
+
assert_equal 'The page has been updated.', flash[:notice]
|
84
|
+
end
|
85
|
+
|
86
|
+
should "update via XHR" do
|
87
|
+
xhr :put, :update, :id => @page.id, :cms_page => {:slug => '', :published => false}
|
88
|
+
assert_response :success
|
89
|
+
assert_equal true, assigns(:page).errors.empty?
|
90
|
+
assert_equal 'The page has been updated.', flash[:notice]
|
91
|
+
end
|
79
92
|
end
|
80
93
|
|
81
94
|
should "destroy a page via HTML :DELETE" do
|
@@ -1,7 +1,7 @@
|
|
1
1
|
# Be sure to restart your server when you modify this file
|
2
2
|
|
3
3
|
# Specifies gem version of Rails to use when vendor/rails is not present
|
4
|
-
RAILS_GEM_VERSION = '2.3.
|
4
|
+
RAILS_GEM_VERSION = '2.3.14' unless defined? RAILS_GEM_VERSION
|
5
5
|
|
6
6
|
# Bootstrap the Rails environment, frameworks, and default configuration
|
7
7
|
require File.join(File.dirname(__FILE__), 'boot')
|
@@ -1,14 +1,19 @@
|
|
1
1
|
en:
|
2
2
|
pages:
|
3
|
+
layout:
|
4
|
+
title: 'Liquid CMS'
|
3
5
|
actions:
|
4
6
|
index:
|
5
|
-
title: '
|
7
|
+
title: 'Pages'
|
6
8
|
none: 'There are currently no pages.'
|
7
|
-
|
9
|
+
new: 'Create a new page'
|
10
|
+
search: 'Search'
|
8
11
|
new:
|
9
12
|
title: 'New Page'
|
10
13
|
edit:
|
11
14
|
title: 'Editing Page'
|
15
|
+
search:
|
16
|
+
title: 'Page Search'
|
12
17
|
flash:
|
13
18
|
created: 'The page has been saved.'
|
14
19
|
updated: 'The page has been updated.'
|
@@ -17,9 +22,9 @@ en:
|
|
17
22
|
assets:
|
18
23
|
actions:
|
19
24
|
index:
|
20
|
-
title: '
|
25
|
+
title: 'Assets'
|
21
26
|
none: 'There are currently no assets.'
|
22
|
-
|
27
|
+
new: 'Upload a new asset'
|
23
28
|
new:
|
24
29
|
title: 'New Asset'
|
25
30
|
edit:
|
@@ -33,6 +38,9 @@ en:
|
|
33
38
|
actions:
|
34
39
|
index:
|
35
40
|
title: 'Components'
|
41
|
+
none: 'There are currently no components.'
|
42
|
+
flash:
|
43
|
+
updated: 'The component file has been updated.'
|
36
44
|
|
37
45
|
simple_form:
|
38
46
|
"yes": 'Yes'
|
@@ -55,16 +63,23 @@ en:
|
|
55
63
|
root: 'Home Page'
|
56
64
|
cms_asset:
|
57
65
|
asset_file_name: 'File'
|
66
|
+
tag_list: 'Tags'
|
58
67
|
hints:
|
59
68
|
cms_page:
|
60
69
|
name: 'The name must contain no whitespace or any other special characters. Letters, numbers, hyphens, underscores and periods are valid.<br/>The extensions <em>.css</em>, <em>.js</em>, <em>.xml</em>, <em>.json</em> and <em>.txt</em> can used to auto-identify the content-type. If no extension is provided, html is the default type.'
|
61
70
|
content: 'To create a layout page, add the <em>{{ content_for_layout }}</em> tag which will act as a placeholder for the contents of another page. Use ctrl+s to save.'
|
62
71
|
slug: 'The url path that will be used to access this page. Defaults to the page name if not provided. ie. /name.<br/> Ex. /home_page'
|
63
72
|
layout_page_id: 'Optional page that will be used as this pages layout. Ie. This pages content will be inserted into the layout page where the <em>{{ content_for_layout }}</em> tag is specified.'
|
73
|
+
published: 'Make this page accessible via the pages name or url path?'
|
74
|
+
root: 'Make this page the sites root path (/)? Only one page can have this designation.'
|
64
75
|
cms_component:
|
65
76
|
file_content: '<em>No liquid support for editing components.</em> Use ctrl+s to save.'
|
66
77
|
cms_asset:
|
67
78
|
asset: 'Upload an asset file.'
|
79
|
+
tag_list: 'Seperate tags with commas.'
|
80
|
+
dimensions: 'Specify custom dimensions in pixels as width x height. The aspect ratio will be maintained, so actual dimensions may differ. Applies to image assets only.'
|
81
|
+
meta:
|
82
|
+
name: 'The name must begin with a letter and consist only of lowercase letters, numbers and underscores.'
|
68
83
|
file_content: '<em>No liquid support for editing assets.</em> Use ctrl+s to save.'
|
69
84
|
edit:
|
70
85
|
asset: 'An existing file has been uploaded. Upload a new file to replace it.'
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class CreateLiquidCmsUpgradeRev2 < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
change_table :cms_assets do |t|
|
4
|
+
t.text :cms_asset_dimensions # serialized yaml
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
def self.down
|
9
|
+
change_table :cms_assets do |t|
|
10
|
+
t.remove :cms_asset_dimensions
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
data/test/unit/asset_test.rb
CHANGED
@@ -122,7 +122,7 @@ class Cms::AssetTest < ActiveSupport::TestCase
|
|
122
122
|
|
123
123
|
context "javascript" do
|
124
124
|
setup do
|
125
|
-
@asset.
|
125
|
+
@asset.update_attributes :asset_content_type => 'text/javascript', :asset_file_name => 'test.js'
|
126
126
|
setup_asset @asset.asset.path(:original)
|
127
127
|
end
|
128
128
|
|