camaleon_cms 0.1.6 → 0.1.7
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.
Potentially problematic release.
This version of camaleon_cms might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/app/helpers/uploader_helper.rb +72 -13
- data/app/views/admin/plugins/_plugins_list.html.erb +2 -23
- data/config/initializers/fix_ssl.rb +9 -3
- data/config/initializers/sass.rb +42 -0
- data/lib/camaleon_cms/version.rb +1 -1
- data/lib/generators/cplugin_generator.rb +4 -2
- data/lib/generators/ctheme_generator.rb +4 -2
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d108ac8f32bb33eae1fb694f6162c5cee33ff093
|
4
|
+
data.tar.gz: 599fa7428f1fe9b7fba9414a96e286573a3c2860
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a7d641d8afce4af8bd65a3de03e860580e12d67bf83820aecc1cbad5b7cf7962d2d6fa07ef2d2b225f31e1aaf5123a3b228d27d87b4aed6b6a4a1689061ec12
|
7
|
+
data.tar.gz: 2a5762b637a1f4f7afd0e3e41f5be720125ebb979933cee3a4e676ddc24ad74e92f98fc060fa4757c52435cde034195c05e30cbc73eeb27221cb0b02b2b3a68b
|
@@ -37,7 +37,7 @@ module UploaderHelper
|
|
37
37
|
settings[:folder] = settings[:folder].to_s
|
38
38
|
if settings[:create_folder] && !File.directory?(settings[:folder])
|
39
39
|
FileUtils.mkdir_p(settings[:folder])
|
40
|
-
FileUtils.chmod(
|
40
|
+
FileUtils.chmod(0777, settings[:folder])
|
41
41
|
end
|
42
42
|
|
43
43
|
# folder validation
|
@@ -87,20 +87,22 @@ module UploaderHelper
|
|
87
87
|
|
88
88
|
# check for destroy the file in the future
|
89
89
|
if settings[:temporal_time] > 0
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
"name"=> File.basename(file_path),
|
95
|
-
"size"=> File.size(file_path),
|
96
|
-
"url"=> file_path_to_url(file_path),
|
97
|
-
"type"=> uploaded_io.content_type,
|
98
|
-
"deleteUrl"=> ""
|
99
|
-
}
|
100
|
-
else
|
101
|
-
Rails.logger.error " ******************** Camaleon: This version of rails doesn't support active job, please install a gem or manage your file destroy manually."
|
90
|
+
Thread.new do
|
91
|
+
sleep(settings[:temporal_time])
|
92
|
+
FileUtils.rm_rf(file_path) if File.exist?(file_path) && !File.directory?(file_path)
|
93
|
+
ActiveRecord::Base.connection.close
|
102
94
|
end
|
103
95
|
end
|
96
|
+
|
97
|
+
# returning data
|
98
|
+
{
|
99
|
+
"file" => file_path,
|
100
|
+
"name"=> File.basename(file_path),
|
101
|
+
"size"=> File.size(file_path),
|
102
|
+
"url"=> file_path_to_url(file_path),
|
103
|
+
"type"=> uploaded_io.content_type,
|
104
|
+
"deleteUrl"=> ""
|
105
|
+
}
|
104
106
|
end
|
105
107
|
|
106
108
|
# helper to find an available filename for file_path in that directory
|
@@ -148,4 +150,61 @@ module UploaderHelper
|
|
148
150
|
file.gsub(ext, "_crop#{ext}")
|
149
151
|
end
|
150
152
|
|
153
|
+
# resize and crop a file
|
154
|
+
# Params:
|
155
|
+
# file: (String) File path
|
156
|
+
# w: (Integer) width
|
157
|
+
# h: (Integer) height
|
158
|
+
# gravity: (Sym, default :north_east) Crop position: :north_west, :north, :north_east, :east, :south_east, :south, :south_west, :west, :center
|
159
|
+
# overwrite: (Boolean, default true) true for overwrite current image with resized resolutions, false: create other file called with prefix "crop_"
|
160
|
+
# Return: (String) file path where saved this cropped
|
161
|
+
def cama_resize_and_crop(file, w, h, settings = {})
|
162
|
+
settings = {gravity: :north_east, overwrite: true}.merge(settings)
|
163
|
+
img = MiniMagick::Image.open(file)
|
164
|
+
w_original, h_original = [img[:width].to_f, img[:height].to_f]
|
165
|
+
|
166
|
+
# check proportions
|
167
|
+
if w_original * h < h_original * w
|
168
|
+
op_resize = "#{w.to_i}x"
|
169
|
+
w_result = w
|
170
|
+
h_result = (h_original * w / w_original)
|
171
|
+
else
|
172
|
+
op_resize = "x#{h.to_i}"
|
173
|
+
w_result = (w_original * h / h_original)
|
174
|
+
h_result = h
|
175
|
+
end
|
176
|
+
|
177
|
+
w_offset, h_offset = cama_crop_offsets_by_gravity(settings[:gravity], [w_result, h_result], [ w, h])
|
178
|
+
img.combine_options do |i|
|
179
|
+
i.resize(op_resize)
|
180
|
+
i.gravity(settings[:gravity])
|
181
|
+
i.crop "#{w.to_i}x#{h.to_i}+#{w_offset}+#{h_offset}!"
|
182
|
+
end
|
183
|
+
|
184
|
+
img.write(file) if settings[:overwrite]
|
185
|
+
img.write(file = uploader_verify_name(File.join(File.dirname(file), "crop_#{File.basename(file)}"))) unless settings[:overwrite]
|
186
|
+
file
|
187
|
+
end
|
188
|
+
|
189
|
+
private
|
190
|
+
# helper for resize and crop method
|
191
|
+
def cama_crop_offsets_by_gravity(gravity, original_dimensions, cropped_dimensions)
|
192
|
+
original_width, original_height = original_dimensions
|
193
|
+
cropped_width, cropped_height = cropped_dimensions
|
194
|
+
|
195
|
+
vertical_offset = case gravity
|
196
|
+
when :north_west, :north, :north_east then 0
|
197
|
+
when :center, :east, :west then [ ((original_height - cropped_height) / 2.0).to_i, 0 ].max
|
198
|
+
when :south_west, :south, :south_east then (original_height - cropped_height).to_i
|
199
|
+
end
|
200
|
+
|
201
|
+
horizontal_offset = case gravity
|
202
|
+
when :north_west, :west, :south_west then 0
|
203
|
+
when :center, :north, :south then [ ((original_width - cropped_width) / 2.0).to_i, 0 ].max
|
204
|
+
when :north_east, :east, :south_east then (original_width - cropped_width).to_i
|
205
|
+
end
|
206
|
+
|
207
|
+
return [ horizontal_offset, vertical_offset ]
|
208
|
+
end
|
209
|
+
|
151
210
|
end
|
@@ -18,7 +18,7 @@
|
|
18
18
|
<td>
|
19
19
|
<%= plugin["title"] %>
|
20
20
|
<br>
|
21
|
-
<% r[:links] << (link_to("#{t('admin.sidebar.information')}",
|
21
|
+
<% r[:links] << (link_to("#{t('admin.sidebar.information')}", "http://camaleon.tuzitio.com/store/plugins/info/#{plugin["key"]}", target: "_blank", title: "#{plugin["title"]}")) %>
|
22
22
|
<% hook_run(plugin, "plugin_options", r) if status %>
|
23
23
|
<%= raw r[:links].join(" | ") %>
|
24
24
|
</td>
|
@@ -27,8 +27,6 @@
|
|
27
27
|
<td><%= t("admin.plugins.status_#{status}") %></td>
|
28
28
|
<td>
|
29
29
|
<%= link_to raw("<i class='fa fa-#{status ? "check-square" : "square"}'></i>"), {action: :toggle, id: plugin["key"], status: status }, class: "btn btn-default btn-xs", title: "#{status ? t('admin.button.disable_plugin') : t('admin.button.activate_plugin') }" %>
|
30
|
-
<%#= link_to raw('<i class="fa fa-times"></i>'), { action: :destroy, id: plugin["key"] },
|
31
|
-
method: :delete, data: { confirm: t('admin.message.delete_item') }, class: "btn btn-danger btn-xs", title: "#{t('admin.button.delete')}" if plugin_can_be_deleted?(plugin["key"]) %>
|
32
30
|
</td>
|
33
31
|
</tr>
|
34
32
|
<% end %>
|
@@ -37,23 +35,4 @@
|
|
37
35
|
</table>
|
38
36
|
<%= content_tag("div", raw(t('admin.message.data_found_list')), class: "alert alert-warning") if plugins.empty? %>
|
39
37
|
</div>
|
40
|
-
|
41
|
-
</div>
|
42
|
-
|
43
|
-
<script type="text/javascript" charset="utf-8">
|
44
|
-
function do_modal_plugin(ele, url_asset){
|
45
|
-
$.get($(ele).attr("href"), function(res){
|
46
|
-
var template = $('<div class="modal" id="modal_large" tabindex="-1" role="dialog" aria-labelledby="largeModalHead" aria-hidden="true"> <div class="modal-dialog modal-lg"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button> <h4 class="modal-title" id="largeModalHead">Large Modal</h4> </div> <div class="modal-body"></div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">'+lang.close+'</button> </div> </div> </div> </div>');
|
47
|
-
template.find(".modal-body").html(res.replace(/src=\"/g, 'src="'+url_asset));
|
48
|
-
template.find("#largeModalHead").html($(ele).attr("title"));
|
49
|
-
template.modal();
|
50
|
-
});
|
51
|
-
}
|
52
|
-
|
53
|
-
function do_modal_plugin2(item, title){
|
54
|
-
var title = 'Plugin '+ title;
|
55
|
-
var template = $('<div class="modal" id="modal_large" tabindex="-1" role="dialog" aria-labelledby="largeModalHead" aria-hidden="true"> <div class="modal-dialog modal-lg"> <div class="modal-content"> <div class="modal-header"> <button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">×</span><span class="sr-only">Close</span></button> <h4 class="modal-title" id="largeModalHead">'+title+'</h4> </div> <div class="modal-body"></div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal">'+lang.close+'</button> </div> </div> </div> </div>');
|
56
|
-
template.find(".modal-body").html('<iframe src="'+$(item).attr("href")+'" width="100%" height="500px" frameborder=0></iframe>');
|
57
|
-
template.modal();
|
58
|
-
}
|
59
|
-
</script>
|
38
|
+
</div>
|
@@ -8,12 +8,18 @@ module Net
|
|
8
8
|
# fix ssl for facebook connection
|
9
9
|
def use_ssl=(flag)
|
10
10
|
if @address.include?("facebook.com")
|
11
|
-
self.ca_file =
|
11
|
+
self.ca_file = File.join($camaleon_engine_dir, 'lib/ca-bundle.crt').to_s
|
12
12
|
self.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
13
13
|
self.original_use_ssl = flag
|
14
|
-
|
15
|
-
|
14
|
+
|
15
|
+
else # original method
|
16
|
+
flag = flag ? true : false
|
17
|
+
if started? and @use_ssl != flag
|
18
|
+
raise IOError, "use_ssl value changed, but session already started"
|
19
|
+
end
|
20
|
+
@use_ssl = flag
|
16
21
|
end
|
22
|
+
|
17
23
|
end
|
18
24
|
end
|
19
25
|
end
|
@@ -0,0 +1,42 @@
|
|
1
|
+
module Sass::Script::Functions
|
2
|
+
# similar to asset_path with prefix for current theme asset
|
3
|
+
# def theme_path(path, options = {})
|
4
|
+
# asset_path("#{get_theme_prefix}#{path}", options)
|
5
|
+
# end
|
6
|
+
|
7
|
+
# similar to asset_url with prefix for current theme asset
|
8
|
+
def theme_asset(path, options = {})
|
9
|
+
asset_url("#{get_theme_prefix}#{path}", options)
|
10
|
+
end
|
11
|
+
|
12
|
+
# # similar to asset_path with prefix for current plugin asset
|
13
|
+
# def plugin_path(path, options = {})
|
14
|
+
# asset_path("#{get_plugin_prefix}#{path}", options)
|
15
|
+
# end
|
16
|
+
|
17
|
+
# similar to asset_url with prefix for current plugin asset
|
18
|
+
def plugin_asset(path, options = {})
|
19
|
+
asset_url("#{get_plugin_prefix}#{path}", options)
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
# get plugin asset prefix
|
24
|
+
def get_plugin_prefix
|
25
|
+
file = sprockets_context.filename
|
26
|
+
res = ""
|
27
|
+
if file.include?("/app/apps/plugins/")
|
28
|
+
res = "themes/#{file.split("/app/apps/plugins/").last.split("/").first}/assets/"
|
29
|
+
end
|
30
|
+
res
|
31
|
+
end
|
32
|
+
|
33
|
+
# get theme asset prefix
|
34
|
+
def get_theme_prefix
|
35
|
+
file = sprockets_context.filename
|
36
|
+
res = ""
|
37
|
+
if file.include?("/app/apps/themes/")
|
38
|
+
res = "themes/#{file.split("/app/apps/themes/").last.split("/").first}/assets/"
|
39
|
+
end
|
40
|
+
res
|
41
|
+
end
|
42
|
+
end
|
data/lib/camaleon_cms/version.rb
CHANGED
@@ -20,11 +20,13 @@ class CpluginGenerator < Rails::Generators::Base
|
|
20
20
|
else
|
21
21
|
|
22
22
|
# helpers + controllers
|
23
|
-
plugin_app =
|
23
|
+
plugin_app = File.join($camaleon_engine_dir, "lib", "generators", "cplugin_template", "app_#{get_plugin_name}")
|
24
24
|
plugin_folder = File.join(plugin_app, "apps", "plugins", get_plugin_name)
|
25
25
|
|
26
|
+
FileUtils.rm_r(plugin_app) if Dir.exist?(plugin_app)
|
27
|
+
|
26
28
|
# tmp copy
|
27
|
-
FileUtils.cp_r(
|
29
|
+
FileUtils.cp_r(File.join($camaleon_engine_dir, "lib", "generators", "cplugin_template", "app"), plugin_app)
|
28
30
|
FileUtils.mv(File.join(plugin_app, "apps", "plugins", "my_plugin"), plugin_folder) rescue nil
|
29
31
|
|
30
32
|
# configuration
|
@@ -19,11 +19,13 @@ class CthemeGenerator < Rails::Generators::Base
|
|
19
19
|
else
|
20
20
|
|
21
21
|
# helpers + controllers
|
22
|
-
plugin_app =
|
22
|
+
plugin_app = File.join($camaleon_engine_dir, "lib", "generators", "ctheme_template", "app_#{get_theme_name}")
|
23
23
|
plugin_folder = File.join(plugin_app, "apps", "themes", get_theme_name)
|
24
24
|
|
25
|
+
FileUtils.rm_r(plugin_app) if Dir.exist?(plugin_app)
|
26
|
+
|
25
27
|
# tmp copy
|
26
|
-
FileUtils.cp_r(
|
28
|
+
FileUtils.cp_r(File.join($camaleon_engine_dir, "lib", "generators", "ctheme_template", "app"), plugin_app)
|
27
29
|
FileUtils.mv(File.join(plugin_app, "apps", "themes", "my_theme"), plugin_folder) rescue nil
|
28
30
|
|
29
31
|
# configuration
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: camaleon_cms
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.7
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Owen Peredo Diaz
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-09-01 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Camaleon CMS is a dynamic and advanced content management system based
|
14
14
|
on Ruby on Rails 4 as an alternative to Wordpress.
|
@@ -596,6 +596,7 @@ files:
|
|
596
596
|
- config/initializers/mobu.rb
|
597
597
|
- config/initializers/page_caching.rb
|
598
598
|
- config/initializers/rufus_cron.rb
|
599
|
+
- config/initializers/sass.rb
|
599
600
|
- config/locales/admin/en.yml
|
600
601
|
- config/locales/admin/es.yml
|
601
602
|
- config/locales/ar.yml
|