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
data/CHANGELOG.rdoc
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
== 0.2.2.0
|
2
|
+
|
3
|
+
* Enhancements
|
4
|
+
* Optimize paperclip image dimension lookup in to_liquid calls. To make use of optimized paperclip attachments in your custom to_liquid methods, add a column to your table in a migration. See the README under the customization section for more information.
|
5
|
+
* Update to codemirror v2
|
6
|
+
* Ctrl+s now uses ajax for editing pages, textual assets and textual components in order to streamline the editing process.
|
7
|
+
|
1
8
|
== 0.2.1.1
|
2
9
|
|
3
10
|
* Fixes
|
data/README.rdoc
CHANGED
@@ -29,7 +29,7 @@ Run the generator:
|
|
29
29
|
Configure the engine in config/initializers/cms/liquid_cms.rb:
|
30
30
|
|
31
31
|
If you wish to run the cms under multiple "contexts" (ie. a cms each for a company, business, customer, etc.) then you need to perform the following steps:
|
32
|
-
|
32
|
+
|
33
33
|
* Set the *context_class* attribute to your apps context class:
|
34
34
|
|
35
35
|
config.context_class = :Company
|
@@ -58,6 +58,20 @@ In order to expose data in your application in the templates, liquid filters, dr
|
|
58
58
|
|
59
59
|
A set of filters, drops and tags are provided in addition to the defaults provided by liquid. The documentation link accessible in the CMS provides additional details.
|
60
60
|
|
61
|
+
If you're using paperclip images in any models and exposing them via to_liquid, you can add an addtional column to your table to optimize dimension lookup.
|
62
|
+
|
63
|
+
class Customer
|
64
|
+
has_attached :photo
|
65
|
+
|
66
|
+
def to_liquid
|
67
|
+
photo.to_liquid
|
68
|
+
end
|
69
|
+
end
|
70
|
+
|
71
|
+
change_table :customers do |t|
|
72
|
+
t.text :cms_photo_dimensions # field name must be named after the paperclip name. ie. :cms_{paperclip name}_dimensions
|
73
|
+
end
|
74
|
+
|
61
75
|
= Upgrading
|
62
76
|
|
63
77
|
To upgrade the liquid_cms engine once you've installed a newer gem, simply re-run the liquid_cms generator. If any differences are found in files, you'll be prompted to overwrite or compare versions.
|
data/TODO.rdoc
CHANGED
@@ -1,8 +1,6 @@
|
|
1
1
|
* Implement a cleaner, more functional UI.
|
2
|
-
* Vestal versions is used, but not exposed via the UI currently to go back to previous versions.
|
3
2
|
* No functions are currently limited to specific user roles. All CMS users can perform the same actions.
|
4
3
|
* Implement caching and expiration logic.
|
5
4
|
* Provide example apache/nginx/etc. conf files that properly scope cms assets for each context.
|
6
5
|
* Generate CMS documentation from rdoc comments in source files?
|
7
|
-
* Search functions. Find templates based on search text.
|
8
6
|
* Missing tests... add more coverage.
|
@@ -30,10 +30,21 @@ class Cms::AssetsController < Cms::MainController
|
|
30
30
|
@asset.assign_ordered_attributes params[:cms_asset]
|
31
31
|
|
32
32
|
if @asset.save
|
33
|
-
|
34
|
-
|
33
|
+
respond_to do |format|
|
34
|
+
format.html {
|
35
|
+
redirect_to edit_cms_asset_path(@asset), :notice => t('assets.flash.updated')
|
36
|
+
}
|
37
|
+
format.js {
|
38
|
+
flash.now[:notice] = t('assets.flash.updated')
|
39
|
+
}
|
40
|
+
end
|
35
41
|
else
|
36
|
-
|
42
|
+
respond_to do |format|
|
43
|
+
format.html {
|
44
|
+
render :action => 'edit'
|
45
|
+
}
|
46
|
+
format.js
|
47
|
+
end
|
37
48
|
end
|
38
49
|
end
|
39
50
|
|
@@ -42,7 +53,7 @@ class Cms::AssetsController < Cms::MainController
|
|
42
53
|
@asset.destroy
|
43
54
|
|
44
55
|
flash[:notice] = t('assets.flash.deleted')
|
45
|
-
|
56
|
+
|
46
57
|
respond_to do |format|
|
47
58
|
format.html { redirect_to cms_root_path }
|
48
59
|
end
|
@@ -62,10 +73,13 @@ protected
|
|
62
73
|
# remove meta values since we only want the key names
|
63
74
|
# new values will be provided for the new asset
|
64
75
|
asset.meta_data = meta_asset.meta_data.collect{|m| {:name => m[:name], :value => ''}}
|
76
|
+
end
|
65
77
|
|
78
|
+
dims_asset = @context.assets.tagged_with(curr_tag).first :conditions => 'custom_width is not null and custom_height is not null'
|
79
|
+
if dims_asset
|
66
80
|
# assign custom dims
|
67
|
-
asset.custom_width =
|
68
|
-
asset.custom_height =
|
81
|
+
asset.custom_width = dims_asset.custom_width
|
82
|
+
asset.custom_height = dims_asset.custom_height
|
69
83
|
end
|
70
84
|
|
71
85
|
asset
|
@@ -13,15 +13,23 @@ class Cms::ComponentsController < Cms::MainController
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def update
|
16
|
+
edit_url = {:controller => 'cms/components', :action => 'edit', :url => @path}
|
17
|
+
|
16
18
|
if Cms::Component.editable?(@path)
|
17
19
|
@component = Cms::Component.new(@context, @path)
|
18
20
|
@component.write params[:file_content]
|
19
21
|
|
20
|
-
|
21
|
-
|
22
|
+
respond_to do |format|
|
23
|
+
format.html {
|
24
|
+
redirect_to edit_url, :notice => t('components.flash.updated')
|
25
|
+
}
|
26
|
+
format.js {
|
27
|
+
flash.now[:notice] = t('components.flash.updated')
|
28
|
+
}
|
29
|
+
end
|
22
30
|
else
|
23
31
|
flash[:error] = "Not an editable component."
|
24
|
-
redirect_to
|
32
|
+
redirect_to edit_url
|
25
33
|
end
|
26
34
|
end
|
27
35
|
|
@@ -26,10 +26,21 @@ class Cms::PagesController < Cms::MainController
|
|
26
26
|
def update
|
27
27
|
@page = @context.pages.find params[:id]
|
28
28
|
if @page.update_attributes(params[:cms_page])
|
29
|
-
|
30
|
-
|
29
|
+
respond_to do |format|
|
30
|
+
format.html {
|
31
|
+
redirect_to edit_cms_page_path(@page), :notice => t('pages.flash.updated')
|
32
|
+
}
|
33
|
+
format.js {
|
34
|
+
flash.now[:notice] = t('pages.flash.updated')
|
35
|
+
}
|
36
|
+
end
|
31
37
|
else
|
32
|
-
|
38
|
+
respond_to do |format|
|
39
|
+
format.html {
|
40
|
+
render :action => 'edit'
|
41
|
+
}
|
42
|
+
format.js
|
43
|
+
end
|
33
44
|
end
|
34
45
|
end
|
35
46
|
|
@@ -38,7 +49,7 @@ class Cms::PagesController < Cms::MainController
|
|
38
49
|
@page.destroy
|
39
50
|
|
40
51
|
flash[:notice] = t('pages.flash.deleted')
|
41
|
-
|
52
|
+
|
42
53
|
respond_to do |format|
|
43
54
|
format.html { redirect_to cms_root_path }
|
44
55
|
format.js
|
@@ -13,48 +13,48 @@ module Cms::CommonHelper
|
|
13
13
|
|
14
14
|
def cms_flash_message
|
15
15
|
type = (flash[:error] ? :error : :notice)
|
16
|
-
|
16
|
+
flash[type].present? ? "humanMsg.displayMsg('#{escape_javascript(flash[type])}', '#{type}')" : nil
|
17
|
+
end
|
18
|
+
|
19
|
+
def load_cms_flash_message
|
20
|
+
msg = cms_flash_message
|
21
|
+
msg.present? ? javascript_tag("document.observe('dom:loaded', function(){ #{msg} })") : nil
|
17
22
|
end
|
18
23
|
|
19
24
|
def cms_row_class
|
20
25
|
cycle 'dark', 'light'
|
21
26
|
end
|
22
27
|
|
23
|
-
def
|
24
|
-
|
28
|
+
def cms_ajax_update_form(page, object, path)
|
29
|
+
if object.errors.empty?
|
30
|
+
page << cms_flash_message
|
31
|
+
else
|
32
|
+
page.replace_html 'content', :file => "cms/#{path}/edit.html.erb"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def codemirror_edit(content_type, form, content_id, use_ajax = true, liquid_support = false)
|
37
|
+
mode = nil
|
38
|
+
|
39
|
+
case content_type
|
25
40
|
when "text/css"
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
41
|
+
mode = 'css'
|
42
|
+
content_for :cms_styles do
|
43
|
+
javascript_include_tag '/cms/codemirror/mode/css/css'
|
44
|
+
end
|
30
45
|
when "text/javascript"
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
46
|
+
mode = 'javascript'
|
47
|
+
content_for :cms_styles do
|
48
|
+
javascript_include_tag '/cms/codemirror/mode/javascript/javascript'
|
49
|
+
end
|
35
50
|
else
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
51
|
+
mode = 'htmlmixed'
|
52
|
+
content_for :cms_styles do
|
53
|
+
javascript_include_tag '/cms/codemirror/mode/htmlmixed/htmlmixed'
|
54
|
+
end
|
40
55
|
end
|
41
56
|
|
42
|
-
javascript_tag
|
43
|
-
<<-JS
|
44
|
-
var editor = CodeMirror.fromTextArea("#{content_id}", {
|
45
|
-
#{js_options}
|
46
|
-
path: "/cms/codemirror/js/",
|
47
|
-
textWrapping: false,
|
48
|
-
height: '600px',
|
49
|
-
width: '89%',
|
50
|
-
saveFunction: function() {
|
51
|
-
var form = $$('#{form}').first();
|
52
|
-
$('#{content_id}').setValue(editor.getCode());
|
53
|
-
form.submit();
|
54
|
-
}
|
55
|
-
});
|
56
|
-
JS
|
57
|
-
end
|
57
|
+
javascript_tag %(initCodemirror('#{mode}', $$('#{form}').first(), $('#{content_id}'), #{use_ajax}, #{liquid_support}))
|
58
58
|
end
|
59
59
|
|
60
60
|
def file_type_icon(file_name)
|
@@ -3,14 +3,86 @@ module Paperclip
|
|
3
3
|
extend ActiveSupport::Memoizable
|
4
4
|
|
5
5
|
def to_liquid
|
6
|
-
{}
|
6
|
+
style_hash = {}
|
7
|
+
|
8
|
+
style_hash.tap do |h|
|
7
9
|
all_styles = self.styles.keys + ['original']
|
8
10
|
all_styles.each do |style|
|
9
|
-
|
10
|
-
h[style.to_s]
|
11
|
+
h[style.to_s] = find_geometry_dims(style)
|
12
|
+
h[style.to_s]['url'] = self.url(style) if h[style.to_s].present?
|
11
13
|
end
|
12
14
|
end
|
15
|
+
|
16
|
+
save_geometry_dims style_hash
|
17
|
+
|
18
|
+
style_hash
|
13
19
|
end
|
14
20
|
memoize :to_liquid
|
21
|
+
|
22
|
+
# clear out the dimension attribute when post processing
|
23
|
+
# it'll be updated on the next render via to_liquid
|
24
|
+
def post_process_with_dimension_attribute_clear
|
25
|
+
key = dimension_key
|
26
|
+
|
27
|
+
if instance.has_attribute?(key)
|
28
|
+
instance.send("#{key}=", nil)
|
29
|
+
end
|
30
|
+
|
31
|
+
post_process_without_dimension_attribute_clear
|
32
|
+
end
|
33
|
+
|
34
|
+
alias_method_chain :post_process, :dimension_attribute_clear
|
35
|
+
|
36
|
+
protected
|
37
|
+
def dimension_key
|
38
|
+
"cms_#{name}_dimensions"
|
39
|
+
end
|
40
|
+
|
41
|
+
def find_geometry_dims(style)
|
42
|
+
key = dimension_key
|
43
|
+
|
44
|
+
if instance.has_attribute?(key)
|
45
|
+
# dimension attr found
|
46
|
+
values = YAML::load(instance.send(key) || '{}')
|
47
|
+
if values.blank?
|
48
|
+
# no saved entry
|
49
|
+
geometry_dims(style)
|
50
|
+
else
|
51
|
+
# saved entry
|
52
|
+
dimensions = values[style.to_s]
|
53
|
+
if dimensions.blank?
|
54
|
+
# empty dimensions for the given style
|
55
|
+
geometry_dims(style)
|
56
|
+
else
|
57
|
+
# valid dimensions for the given style
|
58
|
+
{'width' => dimensions['width'].to_i, 'height' => dimensions['height'].to_i}
|
59
|
+
end
|
60
|
+
end
|
61
|
+
else
|
62
|
+
log %{To optimize image data in your liquid templates, add a text column named "#{key}" to your "#{instance.class.table_name}" table.}
|
63
|
+
# no dimensions found
|
64
|
+
geometry_dims(style)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
def save_geometry_dims(style_hash)
|
69
|
+
key = dimension_key
|
70
|
+
|
71
|
+
if instance.has_attribute?(key) && YAML::load(instance.send(key) || '{}').all?{|k,v| v.blank?} && style_hash.present?
|
72
|
+
# deep copy hash
|
73
|
+
temp_hash = Marshal.load(Marshal.dump(style_hash))
|
74
|
+
# remove blank styles
|
75
|
+
temp_hash.delete_if{|k,v| v.blank?}
|
76
|
+
# and remove the urls
|
77
|
+
temp_hash.each{|k,v| v.delete_if{|k2,v2| k2 == 'url'}}
|
78
|
+
|
79
|
+
instance.update_attribute key, temp_hash.to_yaml if temp_hash.present?
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def geometry_dims(style)
|
84
|
+
g = Paperclip::Geometry.from_file(self.path(style)) rescue nil
|
85
|
+
g.nil? ? {} : {'width' => g.width.to_i, 'height' => g.height.to_i}
|
86
|
+
end
|
15
87
|
end
|
16
88
|
end
|
data/app/models/cms/asset.rb
CHANGED
data/app/models/cms/component.rb
CHANGED
@@ -2,7 +2,7 @@ require 'zip/zip'
|
|
2
2
|
|
3
3
|
class Cms::Component
|
4
4
|
attr_reader :path
|
5
|
-
|
5
|
+
|
6
6
|
def initialize(context, path = nil)
|
7
7
|
@context = context
|
8
8
|
@path = self.class.clean_path(path) if path
|
@@ -67,7 +67,7 @@ class Cms::Component
|
|
67
67
|
end if exist
|
68
68
|
end
|
69
69
|
end
|
70
|
-
|
70
|
+
|
71
71
|
def delete
|
72
72
|
return false if @path.blank?
|
73
73
|
|
@@ -78,7 +78,7 @@ class Cms::Component
|
|
78
78
|
end
|
79
79
|
|
80
80
|
def self.editable?(file)
|
81
|
-
Cms.editable_component_exts.include?(File.extname(file).downcase)
|
81
|
+
file.present? && Cms.editable_component_exts.include?(File.extname(file).downcase)
|
82
82
|
end
|
83
83
|
|
84
84
|
protected
|
@@ -25,7 +25,7 @@
|
|
25
25
|
<%= f.input :file_content, :as => :text, :input_html => {:rows => 40, :cols => nil} %>
|
26
26
|
</div>
|
27
27
|
|
28
|
-
<%= codemirror_edit Cms::Editable::content_type(@asset.asset_file_name), 'form.simple_form', 'cms_asset_file_content' %>
|
28
|
+
<%= codemirror_edit Cms::Editable::content_type(@asset.asset_file_name), 'form.simple_form', 'cms_asset_file_content', !@asset.new_record? %>
|
29
29
|
<% end %>
|
30
30
|
|
31
31
|
<div class="dimensions">
|
@@ -0,0 +1 @@
|
|
1
|
+
cms_ajax_update_form page, @asset, 'assets'
|
@@ -0,0 +1 @@
|
|
1
|
+
page << cms_flash_message
|
@@ -0,0 +1 @@
|
|
1
|
+
cms_ajax_update_form page, @page, 'pages'
|
@@ -6,7 +6,8 @@
|
|
6
6
|
<title><%= t 'pages.layout.title' %></title>
|
7
7
|
<%= javascript_include_tag 'prototype', 'effects' %>
|
8
8
|
<%= javascript_include_tag '/cms/javascripts/humanmsg', '/cms/javascripts/cookiejar', '/cms/javascripts/cms', '/cms/javascripts/livepipe', '/cms/javascripts/tabs', :cache => 'cms_scripts' %>
|
9
|
-
<%= javascript_include_tag '/cms/codemirror/
|
9
|
+
<%= javascript_include_tag '/cms/codemirror/lib/codemirror', '/cms/codemirror/mode/javascript/javascript', '/cms/codemirror/mode/css/css', '/cms/codemirror/mode/xml/xml', '/cms/codemirror/lib/overlay', '/cms/javascripts/codemirror_custom', :cache => 'codemirror_scripts' %>
|
10
|
+
<%= stylesheet_link_tag '/cms/codemirror/lib/codemirror', '/cms/codemirror/theme/default', '/cms/stylesheets/codemirror_changes', :cache => 'codemirror_styles' %>
|
10
11
|
<%= stylesheet_link_tag '/cms/stylesheets/simple_form' %>
|
11
12
|
<%= stylesheet_link_tag '/cms/stylesheets/clearfix', '/cms/stylesheets/humanmsg', '/cms/stylesheets/styles', '/cms/stylesheets/sidebar', :cache => 'cms_styles' %>
|
12
13
|
<%= stylesheet_link_tag '/cms/stylesheets/themes/dark' %>
|
@@ -26,11 +27,11 @@
|
|
26
27
|
<div id="outer-container" class="clearfix">
|
27
28
|
<div id="sidebar" class="shadow curved">
|
28
29
|
<%= render 'cms/shared/sidebar' %>
|
29
|
-
</div>
|
30
|
+
</div>
|
30
31
|
|
31
32
|
<div id="content">
|
32
33
|
<%= yield %>
|
33
|
-
<%=
|
34
|
+
<%= load_cms_flash_message %>
|
34
35
|
</div>
|
35
36
|
</div>
|
36
37
|
</body>
|
@@ -6,6 +6,7 @@ class LiquidCmsGenerator < Rails::Generator::Base
|
|
6
6
|
# migrations
|
7
7
|
m.migration_template 'migration.rb', File.join('db', 'migrate'), :migration_file_name => 'create_liquid_cms_setup'
|
8
8
|
m.migration_template 'migration_rev1.rb', File.join('db', 'migrate'), :migration_file_name => 'create_liquid_cms_upgrade_rev1'
|
9
|
+
m.migration_template 'migration_rev2.rb', File.join('db', 'migrate'), :migration_file_name => 'create_liquid_cms_upgrade_rev2'
|
9
10
|
|
10
11
|
# initializers
|
11
12
|
m.directory File.join('config', 'initializers', 'cms')
|
@@ -39,6 +39,8 @@ en:
|
|
39
39
|
index:
|
40
40
|
title: 'Components'
|
41
41
|
none: 'There are currently no components.'
|
42
|
+
flash:
|
43
|
+
updated: 'The component file has been updated.'
|
42
44
|
|
43
45
|
simple_form:
|
44
46
|
"yes": 'Yes'
|
@@ -68,6 +70,8 @@ en:
|
|
68
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.'
|
69
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'
|
70
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.'
|
71
75
|
cms_component:
|
72
76
|
file_content: '<em>No liquid support for editing components.</em> Use ctrl+s to save.'
|
73
77
|
cms_asset:
|
@@ -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
|
@@ -1,23 +1,19 @@
|
|
1
|
-
|
1
|
+
Copyright (C) 2011 by Marijn Haverbeke <marijnh@gmail.com>
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
4
|
+
of this software and associated documentation files (the "Software"), to deal
|
5
|
+
in the Software without restriction, including without limitation the rights
|
6
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
7
|
+
copies of the Software, and to permit persons to whom the Software is
|
8
|
+
furnished to do so, subject to the following conditions:
|
6
9
|
|
7
|
-
|
8
|
-
|
9
|
-
redistribute it freely, subject to the following restrictions:
|
10
|
+
The above copyright notice and this permission notice shall be included in
|
11
|
+
all copies or substantial portions of the Software.
|
10
12
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
3. This notice may not be removed or altered from any source
|
20
|
-
distribution.
|
21
|
-
|
22
|
-
Marijn Haverbeke
|
23
|
-
marijnh@gmail.com
|
13
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
14
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
15
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
16
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
17
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
18
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
19
|
+
THE SOFTWARE.
|
@@ -0,0 +1,68 @@
|
|
1
|
+
.CodeMirror {
|
2
|
+
line-height: 1em;
|
3
|
+
font-family: monospace;
|
4
|
+
}
|
5
|
+
|
6
|
+
.CodeMirror-scroll {
|
7
|
+
overflow: auto;
|
8
|
+
height: 300px;
|
9
|
+
/* This is needed to prevent an IE[67] bug where the scrolled content
|
10
|
+
is visible outside of the scrolling box. */
|
11
|
+
position: relative;
|
12
|
+
}
|
13
|
+
|
14
|
+
.CodeMirror-gutter {
|
15
|
+
position: absolute; left: 0; top: 0;
|
16
|
+
z-index: 10;
|
17
|
+
background-color: #f7f7f7;
|
18
|
+
border-right: 1px solid #eee;
|
19
|
+
min-width: 2em;
|
20
|
+
height: 100%;
|
21
|
+
}
|
22
|
+
.CodeMirror-gutter-text {
|
23
|
+
color: #aaa;
|
24
|
+
text-align: right;
|
25
|
+
padding: .4em .2em .4em .4em;
|
26
|
+
}
|
27
|
+
.CodeMirror-lines {
|
28
|
+
padding: .4em;
|
29
|
+
}
|
30
|
+
|
31
|
+
.CodeMirror pre {
|
32
|
+
-moz-border-radius: 0;
|
33
|
+
-webkit-border-radius: 0;
|
34
|
+
-o-border-radius: 0;
|
35
|
+
border-radius: 0;
|
36
|
+
border-width: 0; margin: 0; padding: 0; background: transparent;
|
37
|
+
font-family: inherit;
|
38
|
+
font-size: inherit;
|
39
|
+
padding: 0; margin: 0;
|
40
|
+
white-space: pre;
|
41
|
+
word-wrap: normal;
|
42
|
+
}
|
43
|
+
|
44
|
+
.CodeMirror textarea {
|
45
|
+
font-family: inherit !important;
|
46
|
+
font-size: inherit !important;
|
47
|
+
}
|
48
|
+
|
49
|
+
.CodeMirror-cursor {
|
50
|
+
z-index: 10;
|
51
|
+
position: absolute;
|
52
|
+
visibility: hidden;
|
53
|
+
border-left: 1px solid black !important;
|
54
|
+
}
|
55
|
+
.CodeMirror-focused .CodeMirror-cursor {
|
56
|
+
visibility: visible;
|
57
|
+
}
|
58
|
+
|
59
|
+
span.CodeMirror-selected {
|
60
|
+
background: #ccc !important;
|
61
|
+
color: HighlightText !important;
|
62
|
+
}
|
63
|
+
.CodeMirror-focused span.CodeMirror-selected {
|
64
|
+
background: Highlight !important;
|
65
|
+
}
|
66
|
+
|
67
|
+
.CodeMirror-matchingbracket {color: #0f0 !important;}
|
68
|
+
.CodeMirror-nonmatchingbracket {color: #f22 !important;}
|