Skip to content

Commit

Permalink
- fixed ssl for facebook
Browse files Browse the repository at this point in the history
- changed plugins list for documentation link
- added crop and resize function
  • Loading branch information
owen2345 committed Sep 1, 2015
1 parent fc02c45 commit c8c6cdd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 30 deletions.
8 changes: 4 additions & 4 deletions app/helpers/uploader_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ def upload_file(uploaded_io, settings = {})
settings[:folder] = settings[:folder].to_s
if settings[:create_folder] && !File.directory?(settings[:folder])
FileUtils.mkdir_p(settings[:folder])
FileUtils.chmod(0655, settings[:folder])
FileUtils.chmod(0777, settings[:folder])
end

# folder validation
Expand Down Expand Up @@ -157,7 +157,7 @@ def crop_image(file, w, h, w_offset, h_offset, resize = nil )
# h: (Integer) height
# gravity: (Sym, default :north_east) Crop position: :north_west, :north, :north_east, :east, :south_east, :south, :south_west, :west, :center
# overwrite: (Boolean, default true) true for overwrite current image with resized resolutions, false: create other file called with prefix "crop_"
# Return: Image object
# Return: (String) file path where saved this cropped
def cama_resize_and_crop(file, w, h, settings = {})
settings = {gravity: :north_east, overwrite: true}.merge(settings)
img = MiniMagick::Image.open(file)
Expand All @@ -182,8 +182,8 @@ def cama_resize_and_crop(file, w, h, settings = {})
end

img.write(file) if settings[:overwrite]
img.write(uploader_verify_name(File.join(File.dirname(file), "crop_#{File.basename(file)}"))) unless settings[:overwrite]
img
img.write(file = uploader_verify_name(File.join(File.dirname(file), "crop_#{File.basename(file)}"))) unless settings[:overwrite]
file
end

private
Expand Down
25 changes: 2 additions & 23 deletions app/views/admin/plugins/_plugins_list.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<td>
<%= plugin["title"] %>
<br>
<% r[:links] << (link_to("#{t('admin.sidebar.information')}", plugin_asset_path(plugin["key"], "docs/index.html"), onclick: "do_modal_plugin2(this, '#{plugin["title"]}'); return false;", title: "#{plugin["title"]}")) if File.exist?(File.join(plugin["path"], "assets", "docs/index.html")) %>
<% r[:links] << (link_to("#{t('admin.sidebar.information')}", "http://camaleon.tuzitio.com/store/plugins/info/#{plugin["key"]}", target: "_blank", title: "#{plugin["title"]}")) %>
<% hook_run(plugin, "plugin_options", r) if status %>
<%= raw r[:links].join(" | ") %>
</td>
Expand All @@ -27,8 +27,6 @@
<td><%= t("admin.plugins.status_#{status}") %></td>
<td>
<%= 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') }" %>
<%#= link_to raw('<i class="fa fa-times"></i>'), { action: :destroy, id: plugin["key"] },
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"]) %>
</td>
</tr>
<% end %>
Expand All @@ -37,23 +35,4 @@
</table>
<%= content_tag("div", raw(t('admin.message.data_found_list')), class: "alert alert-warning") if plugins.empty? %>
</div>

</div>

<script type="text/javascript" charset="utf-8">
function do_modal_plugin(ele, url_asset){
$.get($(ele).attr("href"), function(res){
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">&times;</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>');
template.find(".modal-body").html(res.replace(/src=\"/g, 'src="'+url_asset));
template.find("#largeModalHead").html($(ele).attr("title"));
template.modal();
});
}

function do_modal_plugin2(item, title){
var title = 'Plugin '+ title;
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">&times;</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>');
template.find(".modal-body").html('<iframe src="'+$(item).attr("href")+'" width="100%" height="500px" frameborder=0></iframe>');
template.modal();
}
</script>
</div>
12 changes: 9 additions & 3 deletions config/initializers/fix_ssl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,18 @@ class HTTP
# fix ssl for facebook connection
def use_ssl=(flag)
if @address.include?("facebook.com")
self.ca_file = Rails.root.join('lib/ca-bundle.crt').to_s
self.ca_file = File.join($camaleon_engine_dir, 'lib/ca-bundle.crt').to_s
self.verify_mode = OpenSSL::SSL::VERIFY_PEER
self.original_use_ssl = flag
else
super

else # original method
flag = flag ? true : false
if started? and @use_ssl != flag
raise IOError, "use_ssl value changed, but session already started"
end
@use_ssl = flag
end

end
end
end

0 comments on commit c8c6cdd

Please sign in to comment.