spree_banner 1.1.6 → 1.3.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.
- data/README.md +5 -16
- data/app/assets/javascripts/admin/banner_settings.js +27 -17
- data/app/assets/javascripts/store/spree_banner.js +1 -1
- data/app/assets/stylesheets/admin/spree_banner.css +0 -3
- data/app/controllers/spree/admin/{banner_settings_controller.rb → banner_box_settings_controller.rb} +8 -8
- data/app/controllers/spree/admin/banner_boxes_controller.rb +44 -0
- data/app/helpers/spree/banner_boxes_helper.rb +24 -0
- data/app/models/spree/app_configuration_decorator.rb +17 -0
- data/app/models/spree/banner_box.rb +65 -0
- data/app/overrides/banner_admin_tab.rb +6 -7
- data/app/views/spree/admin/banner_box_settings/edit.html.erb +72 -0
- data/app/views/spree/admin/banner_boxes/_form.html.erb +47 -0
- data/app/views/spree/admin/banner_boxes/edit.html.erb +17 -0
- data/app/views/spree/admin/banner_boxes/index.html.erb +63 -0
- data/app/views/spree/admin/{banners → banner_boxes}/new.html.erb +14 -6
- data/app/views/spree/admin/banner_boxes/new.js.erb +2 -0
- data/app/views/spree/admin/shared/_banner_box_sub_menu.html.erb +6 -0
- data/config/locales/en.yml +31 -74
- data/config/locales/it.yml +30 -74
- data/config/routes.rb +7 -3
- data/db/migrate/20120116204313_create_banners.rb +2 -2
- data/db/migrate/20120323174800_banner_namespace.rb +1 -1
- metadata +15 -16
- data/app/controllers/spree/admin/banners_controller.rb +0 -26
- data/app/helpers/spree/banners_helper.rb +0 -24
- data/app/models/spree/banner.rb +0 -51
- data/app/views/spree/admin/banner_settings/edit.html.erb +0 -48
- data/app/views/spree/admin/banner_settings/show.html.erb +0 -10
- data/app/views/spree/admin/banners/_form.html.erb +0 -30
- data/app/views/spree/admin/banners/edit.html.erb +0 -6
- data/app/views/spree/admin/banners/index.html.erb +0 -36
- data/app/views/spree/admin/banners/new.js.erb +0 -2
- data/app/views/spree/admin/shared/_banner_setting_configurations_menu.html.erb +0 -4
data/README.md
CHANGED
@@ -9,7 +9,7 @@ Basic Installation
|
|
9
9
|
|
10
10
|
1. Add the following to your Gemfile
|
11
11
|
<pre>
|
12
|
-
gem 'spree_banner', '~> 1.
|
12
|
+
gem 'spree_banner', '~> 1.3.0'
|
13
13
|
</pre>
|
14
14
|
2. Run `bundle install`
|
15
15
|
3. To copy and apply migrations run:
|
@@ -22,25 +22,14 @@ Example
|
|
22
22
|
|
23
23
|
1. add banner helper method in your view:
|
24
24
|
<pre>
|
25
|
-
<%=
|
25
|
+
<%= insert_banner_box(:category => "my_category") %>
|
26
26
|
</pre>
|
27
27
|
and add banner in the admin section
|
28
28
|
2. Additional options:
|
29
29
|
<pre>
|
30
|
-
|
30
|
+
:class => "my_class"
|
31
|
+
:style => "my_style"
|
32
|
+
:list = true|false
|
31
33
|
</pre>
|
32
|
-
displays banner for which the category column, dafault is ""
|
33
|
-
<pre>
|
34
|
-
<%= insert_banner(:max => 10) %>
|
35
|
-
</pre>
|
36
|
-
limits the number of banner shown to 10 (default 1)
|
37
|
-
<pre>
|
38
|
-
<%= insert_banner(:class => "your_class") %>
|
39
|
-
</pre>
|
40
|
-
set banner class (default banner)
|
41
|
-
<pre>
|
42
|
-
<%= insert_banner(:list => true/false) %>
|
43
|
-
</pre>
|
44
|
-
set banner container (default false is DIV)
|
45
34
|
|
46
35
|
Copyright (c) 2012 [Damiano Giacomello], released under the New BSD License
|
@@ -1,29 +1,39 @@
|
|
1
1
|
$(document).ready(function() {
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
3
|
+
$('.destroy_banner_style').live("click", function(e) {
|
4
|
+
e.preventDefault();
|
5
|
+
$(this).parent().remove();
|
6
|
+
});
|
7
|
+
|
8
|
+
$('.destroy_new_banner_styles').live("click", function(e) {
|
9
|
+
e.preventDefault();
|
10
|
+
$(this).closest('.new_banner_styles').remove();
|
11
|
+
});
|
6
12
|
|
7
13
|
// Handle adding new styles
|
8
14
|
var styles_hash_index = 1;
|
9
|
-
$('.
|
10
|
-
|
15
|
+
$('.add_new_banner_style').live("click", function(e) {
|
16
|
+
e.preventDefault();
|
17
|
+
$('#new-banner-styles').append(generate_html_for_hash("new_banner_styles", styles_hash_index));
|
11
18
|
});
|
12
19
|
|
13
20
|
// Generates html for new paperclip styles form fields
|
14
21
|
generate_html_for_hash = function(hash_name, index) {
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
22
|
+
var html = '<div class="' + hash_name + ' row"><div class="field">';
|
23
|
+
html += '<div class="five columns">';
|
24
|
+
html += '<label for="' + hash_name + '_' + index + '_name">';
|
25
|
+
html += Spree.translations.name + '</label>';
|
26
|
+
html += '<input id="' + hash_name + '_' + index + '_name" name="' + hash_name + '[' + index + '][name]" type="text" class="fullwidth"><br>';
|
27
|
+
html += '</div><div class="five columns">'
|
28
|
+
html += '<label for="' + hash_name + '_' + index + '_value">';
|
29
|
+
html += Spree.translations.value + '</label>';
|
30
|
+
html += '<input id="' + hash_name + '_' + index + '_value" name="' + hash_name + '[' + index + '][value]" type="text" class="fullwidth">';
|
31
|
+
html += '</div><div class="two columns">'
|
32
|
+
html += '<a href="#" title="' + Spree.translations.destroy + '" class="destroy_' + hash_name + ' with-tip button" style="margin-top: 19px;"><i class="icon-trash"></i> ' + Spree.translations.destroy + '</a>';
|
33
|
+
html += '</div></div></div>';
|
34
|
+
|
35
|
+
index += 1;
|
36
|
+
return html;
|
27
37
|
};
|
28
38
|
|
29
39
|
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
|
data/app/controllers/spree/admin/{banner_settings_controller.rb → banner_box_settings_controller.rb}
RENAMED
@@ -1,9 +1,9 @@
|
|
1
1
|
module Spree
|
2
2
|
module Admin
|
3
|
-
class
|
3
|
+
class BannerBoxSettingsController < Spree::Admin::BaseController
|
4
|
+
|
4
5
|
def show
|
5
|
-
|
6
|
-
@styles_list = styles.collect { |k, v| k }.join(", ")
|
6
|
+
redirect_to( :action => :edit )
|
7
7
|
end
|
8
8
|
|
9
9
|
def edit
|
@@ -19,7 +19,7 @@ module Spree
|
|
19
19
|
respond_to do |format|
|
20
20
|
format.html {
|
21
21
|
flash[:notice] = t(:banner_settings_updated)
|
22
|
-
redirect_to
|
22
|
+
redirect_to edit_admin_banner_box_settings_path
|
23
23
|
}
|
24
24
|
end
|
25
25
|
end
|
@@ -38,10 +38,10 @@ module Spree
|
|
38
38
|
end
|
39
39
|
|
40
40
|
def update_paperclip_settings
|
41
|
-
Spree::
|
42
|
-
Spree::
|
43
|
-
Spree::
|
44
|
-
Spree::
|
41
|
+
Spree::BannerBox.attachment_definitions[:attachment][:styles] = ActiveSupport::JSON.decode(Spree::Config[:banner_styles])
|
42
|
+
Spree::BannerBox.attachment_definitions[:attachment][:path] = Spree::Config[:banner_path]
|
43
|
+
Spree::BannerBox.attachment_definitions[:attachment][:default_url] = Spree::Config[:banner_default_url]
|
44
|
+
Spree::BannerBox.attachment_definitions[:attachment][:default_style] = Spree::Config[:banner_default_style]
|
45
45
|
end
|
46
46
|
end
|
47
47
|
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
module Spree
|
2
|
+
module Admin
|
3
|
+
class BannerBoxesController < ResourceController
|
4
|
+
|
5
|
+
def index
|
6
|
+
respond_with(@collection)
|
7
|
+
end
|
8
|
+
|
9
|
+
def show
|
10
|
+
redirect_to( :action => :edit )
|
11
|
+
end
|
12
|
+
|
13
|
+
def clone
|
14
|
+
@new = @banner_box.duplicate
|
15
|
+
|
16
|
+
if @new.save
|
17
|
+
flash.notice = I18n.t('notice_messages.banner_box_cloned')
|
18
|
+
else
|
19
|
+
flash.notice = I18n.t('notice_messages.banner_box_not_cloned')
|
20
|
+
end
|
21
|
+
|
22
|
+
respond_with(@new) { |format| format.html { redirect_to edit_admin_banner_box_url(@new) } }
|
23
|
+
end
|
24
|
+
|
25
|
+
protected
|
26
|
+
def find_resource
|
27
|
+
Spree::BannerBox.find(params[:id])
|
28
|
+
end
|
29
|
+
|
30
|
+
def location_after_save
|
31
|
+
edit_admin_banner_box_url(@banner_box)
|
32
|
+
end
|
33
|
+
|
34
|
+
def collection
|
35
|
+
return @collection if @collection.present?
|
36
|
+
params[:q] ||= {}
|
37
|
+
params[:q][:s] ||= "title asc"
|
38
|
+
|
39
|
+
@search = super.ransack(params[:q])
|
40
|
+
@collection = @search.result.page(params[:page]).per(Spree::Config[:admin_products_per_page])
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Spree
|
2
|
+
module BannerBoxesHelper
|
3
|
+
|
4
|
+
def insert_banner_box(params={})
|
5
|
+
params[:category] ||= "home"
|
6
|
+
params[:class] ||= "banner"
|
7
|
+
params[:style] ||= "small"
|
8
|
+
params[:list] ||= false
|
9
|
+
@@banner = Spree::BannerBox.enable(params[:category])
|
10
|
+
if @@banner.blank?
|
11
|
+
return ''
|
12
|
+
end
|
13
|
+
res = []
|
14
|
+
banner = @@banner.sort_by { |ban| ban.position }
|
15
|
+
|
16
|
+
if (params[:list])
|
17
|
+
content_tag(:ul, banner.map{|ban| content_tag(:li, link_to(image_tag(ban.attachment.url(params[:style].to_sym)), (ban.url.blank? ? "javascript: void(0)" : ban.url)), :class => params[:class])}.join().html_safe )
|
18
|
+
else
|
19
|
+
banner.map{|ban| content_tag(:div, link_to(image_tag(ban.attachment.url(params[:style].to_sym)), (ban.url.blank? ? "javascript: void(0)" : ban.url)), :class => params[:class])}.join().html_safe
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
24
|
+
end
|
@@ -1,3 +1,20 @@
|
|
1
|
+
# This is the primary location for defining spree preferences
|
2
|
+
#
|
3
|
+
# The expectation is that this is created once and stored in
|
4
|
+
# the spree environment
|
5
|
+
#
|
6
|
+
# setters:
|
7
|
+
# a.color = :blue
|
8
|
+
# a[:color] = :blue
|
9
|
+
# a.set :color = :blue
|
10
|
+
# a.preferred_color = :blue
|
11
|
+
#
|
12
|
+
# getters:
|
13
|
+
# a.color
|
14
|
+
# a[:color]
|
15
|
+
# a.get :color
|
16
|
+
# a.preferred_color
|
17
|
+
#
|
1
18
|
Spree::AppConfiguration.class_eval do
|
2
19
|
# Preferences related to banner settings
|
3
20
|
preference :banner_default_url, :string, :default => '/spree/banners/:id/:style/:basename.:extension'
|
@@ -0,0 +1,65 @@
|
|
1
|
+
module Spree
|
2
|
+
class BannerBox < ActiveRecord::Base
|
3
|
+
attr_accessible :presentation, :url, :category, :position, :enabled, :attachment
|
4
|
+
|
5
|
+
has_attached_file :attachment,
|
6
|
+
:url => "/spree/banners/:id/:style_:basename.:extension",
|
7
|
+
:path => ":rails_root/public/spree/banners/:id/:style_:basename.:extension",
|
8
|
+
:styles => lambda {|a|{
|
9
|
+
:mini => "80x80#",
|
10
|
+
:small => "120x120#",
|
11
|
+
:custom => "#{a.instance.attachment_width}x#{a.instance.attachment_height}#"
|
12
|
+
}},
|
13
|
+
:convert_options => { :all => '-strip -auto-orient' }
|
14
|
+
# save the w,h of the original image (from which others can be calculated)
|
15
|
+
# we need to look at the write-queue for images which have not been saved yet
|
16
|
+
after_post_process :find_dimensions
|
17
|
+
|
18
|
+
validates_presence_of :category
|
19
|
+
validates_attachment_presence :attachment
|
20
|
+
validates_attachment_content_type :attachment, :content_type => ['image/jpeg', 'image/png', 'image/gif', 'image/jpg', 'image/x-png', 'image/pjpeg'], :message => I18n.t(:images_only)
|
21
|
+
|
22
|
+
scope :enable, lambda { |category| {:conditions => {:enabled => true, :category => category}} }
|
23
|
+
|
24
|
+
# Load user defined paperclip settings
|
25
|
+
include Spree::Core::S3Support
|
26
|
+
supports_s3 :attachment
|
27
|
+
|
28
|
+
Spree::BannerBox.attachment_definitions[:attachment][:styles] = ActiveSupport::JSON.decode(Spree::Config[:banner_styles])
|
29
|
+
Spree::BannerBox.attachment_definitions[:attachment][:path] = Spree::Config[:banner_path]
|
30
|
+
Spree::BannerBox.attachment_definitions[:attachment][:url] = Spree::Config[:banner_url]
|
31
|
+
Spree::BannerBox.attachment_definitions[:attachment][:default_url] = Spree::Config[:banner_default_url]
|
32
|
+
Spree::BannerBox.attachment_definitions[:attachment][:default_style] = Spree::Config[:banner_default_style]
|
33
|
+
|
34
|
+
def initialize(*args)
|
35
|
+
super(*args)
|
36
|
+
last_banner = BannerBox.last
|
37
|
+
self.position = last_banner ? last_banner.position + 1 : 0
|
38
|
+
end
|
39
|
+
|
40
|
+
# for adding banner_boxes which are closely related to existing ones
|
41
|
+
# define "duplicate_extra" for site-specific actions, eg for additional fields
|
42
|
+
def duplicate
|
43
|
+
p = self.dup
|
44
|
+
p.category = 'COPY OF ' + category
|
45
|
+
p.created_at = p.updated_at = nil
|
46
|
+
p.url = url
|
47
|
+
p.attachment = attachment
|
48
|
+
|
49
|
+
# allow site to do some customization
|
50
|
+
p.send(:duplicate_extra, self) if p.respond_to?(:duplicate_extra)
|
51
|
+
p.save!
|
52
|
+
p
|
53
|
+
end
|
54
|
+
|
55
|
+
def find_dimensions
|
56
|
+
temporary = attachment.queued_for_write[:original]
|
57
|
+
filename = temporary.path unless temporary.nil?
|
58
|
+
filename = attachment.path if filename.blank?
|
59
|
+
geometry = Paperclip::Geometry.from_file(filename)
|
60
|
+
self.attachment_width = geometry.width
|
61
|
+
self.attachment_height = geometry.height
|
62
|
+
end
|
63
|
+
|
64
|
+
end
|
65
|
+
end
|
@@ -1,10 +1,9 @@
|
|
1
1
|
Deface::Override.new(:virtual_path => "spree/layouts/admin",
|
2
|
-
:name => "
|
2
|
+
:name => "banner_box_admin_tab",
|
3
3
|
:insert_bottom => "[data-hook='admin_tabs'], #admin_tabs[data-hook]",
|
4
|
-
:text => "<%= tab(:
|
5
|
-
:disabled => false)
|
4
|
+
:text => "<%= tab(:banner_boxes, :icon => 'icon-bookmark') %>")
|
6
5
|
|
7
|
-
Deface::Override.new(:virtual_path => "spree/admin/
|
8
|
-
:name => "
|
9
|
-
:insert_bottom => "[data-hook='
|
10
|
-
:
|
6
|
+
Deface::Override.new(:virtual_path => "spree/admin/shared/_configuration_menu",
|
7
|
+
:name => "add_banner_box_settings",
|
8
|
+
:insert_bottom => "[data-hook='admin_configurations_sidebar_menu'], #admin_configurations_sidebar_menu[data-hook]",
|
9
|
+
:text => "<%= configurations_sidebar_menu_item(:banner_box_settings, edit_admin_banner_box_settings_url) %>")
|
@@ -0,0 +1,72 @@
|
|
1
|
+
<%= render :partial => 'spree/admin/shared/configuration_menu' %>
|
2
|
+
|
3
|
+
<% content_for :page_title do %>
|
4
|
+
<%= t(:banner_box_settings) %>
|
5
|
+
<% end %>
|
6
|
+
|
7
|
+
<%= render :partial => 'spree/admin/shared/banner_box_sub_menu' %>
|
8
|
+
|
9
|
+
<%= form_tag admin_banner_box_settings_path, :method => :put do %>
|
10
|
+
|
11
|
+
<fieldset class="no-border-top">
|
12
|
+
<fieldset class="no-border-bottom">
|
13
|
+
<legend align="center"><%= t(:general_settings)%></legend>
|
14
|
+
|
15
|
+
<div class="field">
|
16
|
+
<div class="warning note"><%= t(:banner_box_settings_warning) %></div>
|
17
|
+
</div>
|
18
|
+
|
19
|
+
<div data-hook="attachment_path" class="field">
|
20
|
+
<%= label_tag 'preferences[attachment_path]', t(:banner_path) %>
|
21
|
+
<%= preference_field_tag 'preferences[banner_path]', Spree::Config[:banner_path], :type => :string %>
|
22
|
+
</div>
|
23
|
+
|
24
|
+
<div class="alpha eight columns">
|
25
|
+
<div data-hook="attachment_default_url" class="field">
|
26
|
+
<%= label_tag 'preferences[attachment_default_url]', t(:banner_default_url) %>
|
27
|
+
<%= preference_field_tag 'preferences[banner_default_url]', Spree::Config[:banner_default_url], :type => :string %>
|
28
|
+
</div>
|
29
|
+
</div>
|
30
|
+
|
31
|
+
<div class="alpha eight columns">
|
32
|
+
<div data-hook="attachment_url" class="field">
|
33
|
+
<%= label_tag 'preferences[attachment_url]', t(:banner_url) %>
|
34
|
+
<%= preference_field_tag 'preferences[banner_url]', Spree::Config[:banner_url], :type => :string %>
|
35
|
+
</div>
|
36
|
+
</div>
|
37
|
+
|
38
|
+
<div class="omega four columns">
|
39
|
+
<div data-hook="attachment_default_style" class="field">
|
40
|
+
<%= label_tag 'preferences[attachment_default_style]', t(:banner_default_style) %>
|
41
|
+
<%= collection_select 'preferences', 'banner_default_style', @styles, :first, :first, {:selected => Spree::Config[:banner_default_style] }, :class => 'select2 fullwidth' %>
|
42
|
+
</div>
|
43
|
+
</div>
|
44
|
+
|
45
|
+
</fieldset>
|
46
|
+
|
47
|
+
<fieldset class="no-border-bottom" id="attachment_styles" data-hook="banner_styles">
|
48
|
+
<legend align="center"><%= t(:banner_styles) %></legend>
|
49
|
+
|
50
|
+
<div id="banner_styles_list" class="row frameless">
|
51
|
+
<% @styles.each_with_index do |(style_name, style_value), index| %>
|
52
|
+
<div class="field three columns">
|
53
|
+
<%= label_tag "banner_styles[#{style_name}]", style_name %>
|
54
|
+
<a href='#' alt="<%= t(:destroy)%>" title="<%= t(:destroy)%>" class='destroy_banner_style with-tip'><i class='icon-trash'></i></a>
|
55
|
+
<%= text_field_tag "banner_styles[#{style_name}]", style_value, :class => 'fullwidth' %>
|
56
|
+
</div>
|
57
|
+
<% end %>
|
58
|
+
</div>
|
59
|
+
|
60
|
+
<div id="new-banner-styles" class="row frameless"></div>
|
61
|
+
|
62
|
+
<div class="field">
|
63
|
+
<%= link_to_with_icon 'icon-plus', t(:add_new_banner_style), '#', :class => 'add_new_banner_style button' %>
|
64
|
+
</div>
|
65
|
+
</fieldset>
|
66
|
+
|
67
|
+
<div class="form-buttons filter-actions actions" data-hook="buttons">
|
68
|
+
<%= button t(:update), 'icon-refresh' %>
|
69
|
+
</div>
|
70
|
+
</fieldset>
|
71
|
+
|
72
|
+
<% end %>
|
@@ -0,0 +1,47 @@
|
|
1
|
+
<div data-hook="admin_banner_box_form_fields">
|
2
|
+
|
3
|
+
<div class="left eight columns alpha" data-hook="admin_banner_box_form_left">
|
4
|
+
<%= f.field_container :category do %>
|
5
|
+
<%= f.label :category, raw(t(:category) + content_tag(:span, ' *', :class => 'required')) %>
|
6
|
+
<%= f.text_field :category, :class => 'fullwidth title' %>
|
7
|
+
<%= f.error_message_on :category %>
|
8
|
+
<% end %>
|
9
|
+
|
10
|
+
<%= f.field_container :url do %>
|
11
|
+
<%= f.label :url, raw(t(:url)) %>
|
12
|
+
<%= f.text_field :url, :class => 'fullwidth title' %>
|
13
|
+
<%= f.error_message_on :url %>
|
14
|
+
<% end %>
|
15
|
+
|
16
|
+
<%= f.field_container :presentation do %>
|
17
|
+
<%= f.label :presentation, t(:alt_text) %>
|
18
|
+
<%= f.text_field :presentation, :class => 'fullwidth' %>
|
19
|
+
<%= f.error_message_on :presentation %>
|
20
|
+
<% end %>
|
21
|
+
</div>
|
22
|
+
|
23
|
+
<div class="right seven columns omega" data-hook="admin_banner_box_form_right">
|
24
|
+
<div data-hook="thumbnail" class="field alpha six columns align-center">
|
25
|
+
<%= f.label t(:thumbnail) %><br>
|
26
|
+
<%= link_to image_tag(@banner_box.attachment.url(:mini)), @banner_box.attachment.url(:small) %>
|
27
|
+
</div>
|
28
|
+
|
29
|
+
<%= f.field_container :attachment do %>
|
30
|
+
<%= f.label :attachment, t(:attachment) %><br />
|
31
|
+
<%= f.file_field :attachment %>
|
32
|
+
<%= f.error_message_on :attachment %>
|
33
|
+
<% end %>
|
34
|
+
|
35
|
+
<%= f.field_container :enabled do %>
|
36
|
+
<%= f.label :enabled, t(:enabled) %><br />
|
37
|
+
<%= f.check_box :enabled %>
|
38
|
+
<%= f.error_message_on :enabled %>
|
39
|
+
<% end %>
|
40
|
+
</div>
|
41
|
+
|
42
|
+
<div class="clear"></div>
|
43
|
+
|
44
|
+
<div data-hook="admin_banner_box_form_additional_fields"></div>
|
45
|
+
|
46
|
+
<div class="clear"></div>
|
47
|
+
</div>
|
@@ -0,0 +1,17 @@
|
|
1
|
+
<%= render :partial => 'spree/admin/shared/banner_box_sub_menu' %>
|
2
|
+
|
3
|
+
<% content_for :page_actions do %>
|
4
|
+
<li><%= button_link_to t(:back_to_banner_boxes_list), admin_banner_boxes_url, :icon => 'icon-arrow-left' %></li>
|
5
|
+
<li id="new_banner_box_link">
|
6
|
+
<%= button_link_to t(:new_banner_box), new_object_url, { :remote => true, :icon => 'icon-plus', :id => 'admin_new_banner_box' } %>
|
7
|
+
</li>
|
8
|
+
<% end %>
|
9
|
+
|
10
|
+
<%= render :partial => 'spree/shared/error_messages', :locals => { :target => @banner_box } %>
|
11
|
+
|
12
|
+
<%= form_for [:admin, @banner_box], :method => :put, :html => { :multipart => true } do |f| %>
|
13
|
+
<fieldset class="no-border-top">
|
14
|
+
<%= render :partial => 'form', :locals => { :f => f } %>
|
15
|
+
<%= render :partial => 'spree/admin/shared/edit_resource_links' %>
|
16
|
+
</fieldset>
|
17
|
+
<% end %>
|
@@ -0,0 +1,63 @@
|
|
1
|
+
<% content_for :page_title do %>
|
2
|
+
<%= t(:listing_banner_boxes) %>
|
3
|
+
<% end %>
|
4
|
+
|
5
|
+
<% content_for :page_actions do %>
|
6
|
+
<div class="toolbar" data-hook="toolbar">
|
7
|
+
<ul class="actions header-action-links inline-menu">
|
8
|
+
<li id="new_banner_box_link">
|
9
|
+
<%= button_link_to t(:new_banner_box), new_object_url, { :remote => true, :icon => 'icon-plus', :id => 'admin_new_banner_box' } %>
|
10
|
+
</li>
|
11
|
+
</ul>
|
12
|
+
</div>
|
13
|
+
<% end %>
|
14
|
+
|
15
|
+
<%= render :partial => 'spree/admin/shared/banner_box_sub_menu' %>
|
16
|
+
|
17
|
+
<div id="new_banner_box" data-hook></div>
|
18
|
+
|
19
|
+
<% if @collection.any? %>
|
20
|
+
<table class="index sortable" id="listing_banner_boxes" data-sortable-link="<%= update_positions_admin_banner_boxes_url() %>">
|
21
|
+
<colgroup>
|
22
|
+
<col style="width: 5%">
|
23
|
+
<col style="width: 15%;">
|
24
|
+
<col style="width: 10%;">
|
25
|
+
<col style="width: 10%;">
|
26
|
+
<col style="width: 17%;">
|
27
|
+
</colgroup>
|
28
|
+
<thead>
|
29
|
+
<tr data-hook="admin_products_index_headers">
|
30
|
+
<th colspan="2"><%= t(:thumbnail) %></th>
|
31
|
+
<th><%= t(:category) %></th>
|
32
|
+
<th><%= t(:url) %></th>
|
33
|
+
<th data-hook="admin_products_index_header_actions" class="actions"></th>
|
34
|
+
</tr>
|
35
|
+
</thead>
|
36
|
+
<tbody>
|
37
|
+
<% @collection.each do |banner_box| %>
|
38
|
+
<tr id="<%= spree_dom_id banner_box %>" data-hook="admin_banner_boxes_index_rows" class="<%= cycle('odd', 'even') %>">
|
39
|
+
<td class="no-border">
|
40
|
+
<span class="handle"></span>
|
41
|
+
</td>
|
42
|
+
<td class="align-center"><%= image_tag(banner_box.attachment(:mini)) %></td>
|
43
|
+
<td class="align-center"><%= banner_box.category rescue '' %></td>
|
44
|
+
<td class="align-center"><%= banner_box.url rescue '' %></td>
|
45
|
+
<td class="actions" data-hook="admin_products_index_row_actions">
|
46
|
+
<%= link_to_edit banner_box, :no_text => true, :class => 'edit' %>
|
47
|
+
|
48
|
+
<%= link_to_with_icon 'icon-copy', t(:clone), clone_admin_banner_box_url(banner_box), :no_text => true, :class => 'clone' %>
|
49
|
+
|
50
|
+
<%= link_to_delete banner_box, :no_text => true %>
|
51
|
+
</td>
|
52
|
+
</tr>
|
53
|
+
<% end %>
|
54
|
+
</tbody>
|
55
|
+
</table>
|
56
|
+
<% else %>
|
57
|
+
<div class="no-objects-found">
|
58
|
+
<%= t(:no_results) %>
|
59
|
+
</div>
|
60
|
+
<% end %>
|
61
|
+
|
62
|
+
<%= paginate @collection %>
|
63
|
+
|
@@ -1,9 +1,10 @@
|
|
1
|
-
<%= render :partial => 'spree/shared/error_messages', :locals => { :target => @
|
1
|
+
<%= render :partial => 'spree/shared/error_messages', :locals => { :target => @banner_box } %>
|
2
2
|
|
3
|
-
<%= form_for [:admin, @
|
4
|
-
<fieldset data-hook="
|
5
|
-
<
|
6
|
-
|
3
|
+
<%= form_for [:admin, @banner_box], :html => { :multipart => true } do |f| %>
|
4
|
+
<fieldset data-hook="new_banner_box">
|
5
|
+
<legend align="center"><%= t(:new_banner_box) %></legend>
|
6
|
+
<div data-hook="new_banner_box_attrs" class="row">
|
7
|
+
<div class="left alpha eight columns">
|
7
8
|
<%= f.field_container :category do %>
|
8
9
|
<%= f.label :category, t(:category) %> <span class="required">*</span><br />
|
9
10
|
<%= f.text_field :category, :class => 'fullwidth title' %>
|
@@ -16,12 +17,19 @@
|
|
16
17
|
<%= f.error_message_on :url %>
|
17
18
|
<% end %>
|
18
19
|
</div>
|
19
|
-
|
20
|
+
|
21
|
+
<div class="right omega four columns">
|
20
22
|
<%= f.field_container :attachment do %>
|
21
23
|
<%= f.label :attachment, t(:attachment) %><br />
|
22
24
|
<%= f.file_field :attachment %>
|
23
25
|
<%= f.error_message_on :attachment %>
|
24
26
|
<% end %>
|
27
|
+
|
28
|
+
<%= f.field_container :presentation do %>
|
29
|
+
<%= f.label :presentation, t(:alt_text) %><br />
|
30
|
+
<%= f.text_field :presentation, :class => 'fullwidth' %>
|
31
|
+
<%= f.error_message_on :presentation %>
|
32
|
+
<% end %>
|
25
33
|
|
26
34
|
<%= f.field_container :enabled do %>
|
27
35
|
<%= f.label :enabled, t(:enabled) %><br />
|
data/config/locales/en.yml
CHANGED
@@ -1,78 +1,35 @@
|
|
1
|
-
---
|
2
1
|
en:
|
2
|
+
images_only: "deve essere JPG, JPEG, PNG o GIF"
|
3
|
+
banner_box_settings: Banner Setting
|
4
|
+
add_new_banner_style: "Add New Banner Style"
|
5
|
+
banner_box_settings_warning: "You will need to regenerate thumbnails if you update the paperclip styles. Use rake paperclip:refresh:thumbnails CLASS=Spree::Banner to do this."
|
6
|
+
banner_settings_description: "Banner Settings Description"
|
7
|
+
banner_settings_updated: "Banner Settings successfully updated."
|
8
|
+
banner_default_style: "Banner Default Path"
|
9
|
+
banner_default_url: "Banner Default URL"
|
10
|
+
banner_path: "Banner Path"
|
11
|
+
banner_styles: "Paperclip Styles Banner"
|
12
|
+
banner_url: "Banner URL"
|
13
|
+
back_to_banner_boxes_list: "Back To Banner List"
|
14
|
+
new_banner_box: "New Banner"
|
15
|
+
listing_banner_boxes: "Listing Banners"
|
16
|
+
enabled: Enabled?
|
17
|
+
url: Link url
|
18
|
+
attachment: Attachment
|
19
|
+
category: Category
|
20
|
+
banner_boxes: Banners
|
21
|
+
banner_box: Banner
|
22
|
+
notice_messages:
|
23
|
+
banner_box_cloned: "Banner has been cloned"
|
24
|
+
banner_box_not_cloned: "Banner could not be cloned"
|
3
25
|
activerecord:
|
4
|
-
errors: &errors
|
5
|
-
format: "%{attribute} %{message}\n"
|
6
|
-
|
7
|
-
messages: &errors_messages
|
8
|
-
inclusion: "is not included in the list"
|
9
|
-
exclusion: "is reserved"
|
10
|
-
invalid: "is invalid"
|
11
|
-
confirmation: "doesn't match confirmation"
|
12
|
-
record_invalid: "Validation failed: %{errors}"
|
13
|
-
taken: has already been taken
|
14
|
-
accepted: "must be accepted"
|
15
|
-
empty: "can't be empty"
|
16
|
-
blank: "can't be blank"
|
17
|
-
too_long:
|
18
|
-
one: "is too long (maximum is 1 character)"
|
19
|
-
other: "is too long (maximum is %{count} characters)"
|
20
|
-
too_short:
|
21
|
-
one: "is too short (minimum is 1 character)"
|
22
|
-
other: "is too short (minimum is %{count} characters)"
|
23
|
-
wrong_length:
|
24
|
-
one: "is the wrong length (should be 1 character)"
|
25
|
-
other: "is the wrong length (should be %{count} characters)"
|
26
|
-
not_a_number: "is not a number"
|
27
|
-
not_an_integer: "must be an integer"
|
28
|
-
greater_than: "must be greater than %{count}"
|
29
|
-
greater_than_or_equal_to: "must be greater than or equal to %{count}"
|
30
|
-
equal_to: "must be equal to %{count}"
|
31
|
-
less_than: "must be less than %{count}"
|
32
|
-
less_than_or_equal_to: "must be less than or equal to %{count}"
|
33
|
-
odd: "must be odd"
|
34
|
-
even: "must be even"
|
35
|
-
|
36
|
-
models:
|
37
|
-
banner:
|
38
|
-
attributes:
|
39
|
-
banner:
|
40
|
-
category: Category
|
41
|
-
enabled: Enable?
|
42
|
-
url: Link to product or taxonomy or to external website
|
43
|
-
attachment_width: Width image
|
44
|
-
attachment_height: Height image
|
45
|
-
attachment: Image
|
46
|
-
attachment_file_name: Image Name
|
47
|
-
position: Position (if there are other banners with the same category)
|
48
|
-
attributes:
|
49
|
-
banner:
|
50
|
-
category: Category
|
51
|
-
enabled: Enable?
|
52
|
-
url: Link to product or taxonomy or to external website
|
53
|
-
attachment_width: Width image
|
54
|
-
attachment_height: Height image
|
55
|
-
attachment: Image
|
56
|
-
position: Position (if there are other banners with the same category)
|
57
26
|
models:
|
58
|
-
|
27
|
+
banner_box:
|
59
28
|
one: Banner
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
no_image: No Image Yet
|
68
|
-
attachment_width: Width image
|
69
|
-
attachment_height: Height image
|
70
|
-
position: Position (if there are other banners with the same category)
|
71
|
-
url: Link to product or taxonomy or to external website
|
72
|
-
image:
|
73
|
-
one: Image
|
74
|
-
many: Images
|
75
|
-
banner_desc: Manage banner.
|
76
|
-
new_banner: New banner
|
77
|
-
editing_banner: Edit banner
|
78
|
-
confirm_delete: Are you sure?
|
29
|
+
other: Banners
|
30
|
+
attributes:
|
31
|
+
banner_box:
|
32
|
+
category: Category
|
33
|
+
updated_at: Updated At
|
34
|
+
created_at: Created At
|
35
|
+
enabled: Enabled?
|
data/config/locales/it.yml
CHANGED
@@ -1,79 +1,35 @@
|
|
1
|
-
---
|
2
1
|
it:
|
2
|
+
images_only: "deve essere JPG, JPEG, PNG o GIF"
|
3
|
+
banner_box_settings: Impostazioni Banner
|
4
|
+
add_new_banner_style: "Aggiungi nuovo stile dei Banner"
|
5
|
+
banner_box_settings_warning: "Sarà necessario rigenerare le miniature dopo aver aggiornato gli stili di paperclip delle Slide, col comando rake paperclip:refresh:thumbnails CLASS=Spree::Banner"
|
6
|
+
banner_settings_description: "Descrizione Impostazioni Banner"
|
7
|
+
banner_settings_updated: "Impostazioni Banner aggiornate con successo."
|
8
|
+
banner_default_style: "Stile di Default dell'allegato dei Banner"
|
9
|
+
banner_default_url: "URL di Default dell'allegato dei Banner"
|
10
|
+
banner_path: "Percorso dell'allegato dei Banner"
|
11
|
+
banner_styles: "Stili di Paperclip dei Banner"
|
12
|
+
banner_url: "URL dell'allegato dei Banner"
|
13
|
+
back_to_banner_boxes_list: "Torna all'elenco Banner"
|
14
|
+
new_banner_box: "Nuova Banner"
|
15
|
+
listing_banner_boxes: "Elenco Banner"
|
16
|
+
enabled: Attivo?
|
17
|
+
url: Link url
|
18
|
+
attachment: Immagine
|
19
|
+
category: Categoria
|
20
|
+
banner_boxes: Banners
|
21
|
+
banner_box: Banner
|
22
|
+
notice_messages:
|
23
|
+
banner_box_cloned: "Banner Duplicato"
|
24
|
+
banner_box_not_cloned: "Impossibili Duplicare il Banner"
|
3
25
|
activerecord:
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
inclusion: "non è incluso nella lista"
|
9
|
-
exclusion: "è riservato"
|
10
|
-
invalid: "non è valido"
|
11
|
-
confirmation: "non coincide con la conferma"
|
12
|
-
record_invalid: "Validazione fallita: %{errors}"
|
13
|
-
taken: è già in uso
|
14
|
-
accepted: "deve essere accettata"
|
15
|
-
empty: "non può essere vuoto"
|
16
|
-
blank: "non può essere lasciato in bianco"
|
17
|
-
too_long:
|
18
|
-
one: "è troppo lungo (il massimo è 1 carattere)"
|
19
|
-
other: "è troppo lungo (il massimo è %{count} caratteri)"
|
20
|
-
too_short:
|
21
|
-
one: "è troppo corto (il minimo è 1 carattere)"
|
22
|
-
other: "è troppo corto (il minimo è %{count} caratteri)"
|
23
|
-
wrong_length:
|
24
|
-
one: "è della lunghezza sbagliata (deve essere di 1 carattere)"
|
25
|
-
other: "è della lunghezza sbagliata (deve essere di %{count} caratteri)"
|
26
|
-
not_a_number: "non è un numero"
|
27
|
-
not_an_integer: "non è un intero"
|
28
|
-
greater_than: "deve essere superiore a %{count}"
|
29
|
-
greater_than_or_equal_to: "deve essere superiore o uguale a %{count}"
|
30
|
-
equal_to: "deve essere uguale a %{count}"
|
31
|
-
less_than: "deve essere meno di %{count}"
|
32
|
-
less_than_or_equal_to: "deve essere meno o uguale a %{count}"
|
33
|
-
odd: "deve essere dispari"
|
34
|
-
even: "deve essere pari"
|
35
|
-
|
36
|
-
models:
|
37
|
-
banner:
|
38
|
-
attributes:
|
39
|
-
banner:
|
40
|
-
category: Categoria
|
41
|
-
enabled: Attivo?
|
42
|
-
url: Link a prodotto o tassonomia o a sito esterno
|
43
|
-
attachment_width: Larghezza immagine
|
44
|
-
attachment_height: Altezza immagine
|
45
|
-
attachment: Immagine
|
46
|
-
attachment_file_name: Nome immagine
|
47
|
-
position: Posizione (se esistono altri banner con la stessa categoria)
|
26
|
+
models:
|
27
|
+
banner_box:
|
28
|
+
one: Banner
|
29
|
+
other: Banners
|
48
30
|
attributes:
|
49
|
-
|
31
|
+
banner_box:
|
50
32
|
category: Categoria
|
33
|
+
updated_at: Aggiornata il
|
34
|
+
created_at: Creata il
|
51
35
|
enabled: Attivo?
|
52
|
-
url: Link a prodotto o tassonomia o a sito esterno
|
53
|
-
attachment_width: Larghezza immagine
|
54
|
-
attachment_height: Altezza immagine
|
55
|
-
attachment: Immagine
|
56
|
-
position: Posizione (se esistono altri banner con la stessa categoria)
|
57
|
-
models:
|
58
|
-
banner:
|
59
|
-
one: Banner
|
60
|
-
many: Banners
|
61
|
-
|
62
|
-
banner: "Banner"
|
63
|
-
banners: "Banners"
|
64
|
-
new_banner: "Nuovo Banner"
|
65
|
-
enable: Attivo?
|
66
|
-
category: Categoria
|
67
|
-
no_image: Nessuna immagine caricata
|
68
|
-
attachment_width: Larghezza immagine banner
|
69
|
-
attachment_height: Altezza immagine banner
|
70
|
-
position: Posizione (se esistono altri banner con la stessa categoria)
|
71
|
-
enabled: Attivo?
|
72
|
-
url: Link a prodotto o tassonomia o a sito esterno
|
73
|
-
image:
|
74
|
-
one: Immagine
|
75
|
-
many: Immagini
|
76
|
-
banner_desc: Gestione banner.
|
77
|
-
new_banner: Nuovo banner
|
78
|
-
editing_banner: Modifica banner
|
79
|
-
confirm_delete: Sei sicuro?
|
data/config/routes.rb
CHANGED
@@ -1,10 +1,14 @@
|
|
1
|
-
Spree::Core::Engine.routes.
|
1
|
+
Spree::Core::Engine.routes.draw do
|
2
|
+
|
2
3
|
namespace :admin do
|
3
|
-
resources :
|
4
|
+
resources :banner_boxes do
|
4
5
|
collection do
|
5
6
|
post :update_positions
|
6
7
|
end
|
8
|
+
member do
|
9
|
+
get :clone
|
10
|
+
end
|
7
11
|
end
|
8
|
-
resource :
|
12
|
+
resource :banner_box_settings
|
9
13
|
end
|
10
14
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
class CreateBanners < ActiveRecord::Migration
|
2
2
|
def change
|
3
3
|
create_table :banners do |t|
|
4
|
-
t.string :
|
4
|
+
t.string :presentation, :url
|
5
5
|
t.string :category
|
6
6
|
t.integer :position
|
7
|
-
t.boolean :enabled
|
7
|
+
t.boolean :enabled, :default => false
|
8
8
|
|
9
9
|
t.string :attachment_content_type, :attachment_file_name
|
10
10
|
t.datetime :attachment_updated_at
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: spree_banner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-03-
|
12
|
+
date: 2013-03-13 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: spree_core
|
@@ -18,7 +18,7 @@ dependencies:
|
|
18
18
|
requirements:
|
19
19
|
- - ! '>='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version: 1.
|
21
|
+
version: 1.3.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -26,7 +26,7 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ! '>='
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: 1.
|
29
|
+
version: 1.3.0
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: paperclip
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -75,20 +75,19 @@ files:
|
|
75
75
|
- app/assets/javascripts/store/spree_banner.js
|
76
76
|
- app/assets/stylesheets/admin/spree_banner.css
|
77
77
|
- app/assets/stylesheets/store/spree_banner.css
|
78
|
-
- app/controllers/spree/admin/
|
79
|
-
- app/controllers/spree/admin/
|
80
|
-
- app/helpers/spree/
|
78
|
+
- app/controllers/spree/admin/banner_box_settings_controller.rb
|
79
|
+
- app/controllers/spree/admin/banner_boxes_controller.rb
|
80
|
+
- app/helpers/spree/banner_boxes_helper.rb
|
81
81
|
- app/models/spree/app_configuration_decorator.rb
|
82
|
-
- app/models/spree/
|
82
|
+
- app/models/spree/banner_box.rb
|
83
83
|
- app/overrides/banner_admin_tab.rb
|
84
|
-
- app/views/spree/admin/
|
85
|
-
- app/views/spree/admin/
|
86
|
-
- app/views/spree/admin/
|
87
|
-
- app/views/spree/admin/
|
88
|
-
- app/views/spree/admin/
|
89
|
-
- app/views/spree/admin/
|
90
|
-
- app/views/spree/admin/
|
91
|
-
- app/views/spree/admin/shared/_banner_setting_configurations_menu.html.erb
|
84
|
+
- app/views/spree/admin/banner_box_settings/edit.html.erb
|
85
|
+
- app/views/spree/admin/banner_boxes/_form.html.erb
|
86
|
+
- app/views/spree/admin/banner_boxes/edit.html.erb
|
87
|
+
- app/views/spree/admin/banner_boxes/index.html.erb
|
88
|
+
- app/views/spree/admin/banner_boxes/new.html.erb
|
89
|
+
- app/views/spree/admin/banner_boxes/new.js.erb
|
90
|
+
- app/views/spree/admin/shared/_banner_box_sub_menu.html.erb
|
92
91
|
- db/migrate/20120116204313_create_banners.rb
|
93
92
|
- db/migrate/20120323174800_banner_namespace.rb
|
94
93
|
- config/locales/en.yml
|
@@ -1,26 +0,0 @@
|
|
1
|
-
module Spree
|
2
|
-
module Admin
|
3
|
-
class BannersController < ResourceController
|
4
|
-
|
5
|
-
def show
|
6
|
-
redirect_to(:action => :edit)
|
7
|
-
end
|
8
|
-
|
9
|
-
def update_positions
|
10
|
-
params[:positions].each do |id, index|
|
11
|
-
Spree::Banner.where(:id => id).update_all(:position => index)
|
12
|
-
end
|
13
|
-
|
14
|
-
respond_to do |format|
|
15
|
-
format.js { render :text => 'Ok' }
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
private
|
20
|
-
def location_after_save
|
21
|
-
edit_admin_banner_url(@banner)
|
22
|
-
end
|
23
|
-
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
@@ -1,24 +0,0 @@
|
|
1
|
-
module Spree
|
2
|
-
module BannersHelper
|
3
|
-
|
4
|
-
def insert_banner(params={})
|
5
|
-
params[:max] ||= 1
|
6
|
-
params[:category] ||= "home"
|
7
|
-
params[:class] ||= "banner"
|
8
|
-
params[:style] ||= "small"
|
9
|
-
params[:list] ||= false
|
10
|
-
banner = Spree::Banner.enable(params[:category]).limit(params[:max])
|
11
|
-
if !banner.blank?
|
12
|
-
banner = banner.sort_by { |ban| ban.position }
|
13
|
-
|
14
|
-
if (params[:list])
|
15
|
-
content_tag(:ul, banner.map{|ban| content_tag(:li, link_to(image_tag(ban.attachment.url(params[:style].to_sym)), (ban.url.blank? ? "javascript: void(0)" : ban.url)), :class => params[:class])}.join().html_safe )
|
16
|
-
else
|
17
|
-
banner.map{|ban| content_tag(:div, link_to(image_tag(ban.attachment.url(params[:style].to_sym)), (ban.url.blank? ? "javascript: void(0)" : ban.url)), :class => params[:class])}.join().html_safe
|
18
|
-
end
|
19
|
-
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
end
|
24
|
-
end
|
data/app/models/spree/banner.rb
DELETED
@@ -1,51 +0,0 @@
|
|
1
|
-
module Spree
|
2
|
-
class Banner < ActiveRecord::Base
|
3
|
-
attr_accessible :title, :url, :category, :position, :enabled, :attachment
|
4
|
-
|
5
|
-
has_attached_file :attachment,
|
6
|
-
:styles => { :mini => '80x80#', :small => '120x120#' },
|
7
|
-
:url => "/spree/banners/:id/:style_:basename.:extension",
|
8
|
-
:path => ":rails_root/public/spree/banners/:id/:style_:basename.:extension",
|
9
|
-
:convert_options => { :all => '-strip' }
|
10
|
-
|
11
|
-
after_post_process :find_dimensions
|
12
|
-
|
13
|
-
validates_presence_of :category
|
14
|
-
validates_attachment_presence :attachment
|
15
|
-
validates_attachment_content_type :attachment, :content_type => ['image/jpeg', 'image/png', 'image/gif', 'image/jpg', 'image/x-png', 'image/pjpeg'], :message => "deve essere JPG, JPEG, PNG o GIF"
|
16
|
-
|
17
|
-
scope :enable, lambda { |category| {:conditions => {:enabled => true, :category => category}} }
|
18
|
-
|
19
|
-
# Load user defined paperclip settings
|
20
|
-
if Spree::Config[:use_s3]
|
21
|
-
s3_creds = { :access_key_id => Spree::Config[:s3_access_key], :secret_access_key => Spree::Config[:s3_secret], :bucket => Spree::Config[:s3_bucket] }
|
22
|
-
Spree::Banner.attachment_definitions[:attachment][:storage] = :s3
|
23
|
-
Spree::Banner.attachment_definitions[:attachment][:s3_credentials] = s3_creds
|
24
|
-
Spree::Banner.attachment_definitions[:attachment][:s3_headers] = ActiveSupport::JSON.decode(Spree::Config[:s3_headers])
|
25
|
-
Spree::Banner.attachment_definitions[:attachment][:bucket] = Spree::Config[:s3_bucket]
|
26
|
-
Spree::Banner.attachment_definitions[:attachment][:s3_protocol] = Spree::Config[:s3_protocol] unless Spree::Config[:s3_protocol].blank?
|
27
|
-
end
|
28
|
-
|
29
|
-
Spree::Banner.attachment_definitions[:attachment][:styles] = ActiveSupport::JSON.decode(Spree::Config[:banner_styles])
|
30
|
-
Spree::Banner.attachment_definitions[:attachment][:path] = Spree::Config[:banner_path]
|
31
|
-
Spree::Banner.attachment_definitions[:attachment][:url] = Spree::Config[:banner_url]
|
32
|
-
Spree::Banner.attachment_definitions[:attachment][:default_url] = Spree::Config[:banner_default_url]
|
33
|
-
Spree::Banner.attachment_definitions[:attachment][:default_style] = Spree::Config[:banner_default_style]
|
34
|
-
|
35
|
-
def initialize(*args)
|
36
|
-
super(*args)
|
37
|
-
last_banner = Banner.last
|
38
|
-
self.position = last_banner ? last_banner.position + 1 : 0
|
39
|
-
end
|
40
|
-
|
41
|
-
def find_dimensions
|
42
|
-
temporary = attachment.queued_for_write[:original]
|
43
|
-
filename = temporary.path unless temporary.nil?
|
44
|
-
filename = attachment.path if filename.blank?
|
45
|
-
geometry = Paperclip::Geometry.from_file(filename)
|
46
|
-
self.attachment_width = geometry.width
|
47
|
-
self.attachment_height = geometry.height
|
48
|
-
end
|
49
|
-
|
50
|
-
end
|
51
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
<%= render :partial => 'spree/admin/shared/configuration_menu' %>
|
2
|
-
|
3
|
-
<h1><%= t(:banner_settings) %></h1>
|
4
|
-
|
5
|
-
<p><span class="warning"><%= t(:banner_settings_warning) %></span></p>
|
6
|
-
|
7
|
-
<%= form_tag admin_banner_settings_path, :method => :put do %>
|
8
|
-
|
9
|
-
<p data-hook="banner_path">
|
10
|
-
<label>
|
11
|
-
<%= label_tag 'preferences[banner_path]', t(:banner_path) %>
|
12
|
-
<%= preference_field_tag 'preferences[banner_path]', Spree::Config[:banner_path], :type => :string %>
|
13
|
-
</label>
|
14
|
-
</p>
|
15
|
-
|
16
|
-
<p data-hook="banner_default_url">
|
17
|
-
<label>
|
18
|
-
<%= label_tag 'preferences[banner_default_url]', t(:banner_default_url) %>
|
19
|
-
<%= preference_field_tag 'preferences[banner_default_url]', Spree::Config[:banner_default_url], :type => :string %>
|
20
|
-
</label>
|
21
|
-
</p>
|
22
|
-
|
23
|
-
<p data-hook="banner_default_style">
|
24
|
-
<label>
|
25
|
-
<%= label_tag 'preferences[banner_default_style]', t(:banner_default_style) %>
|
26
|
-
<%= collection_select 'preferences', 'banner_default_style', @styles, :first, :first, {:selected => Spree::Config[:banner_default_style] } %>
|
27
|
-
</label>
|
28
|
-
</p>
|
29
|
-
|
30
|
-
<div id="banner_styles" data-hook="banner_styles">
|
31
|
-
<h2><%= t(:banner_styles) %></h2>
|
32
|
-
<ul id="styles_list">
|
33
|
-
<% @styles.each do |style_name, style_value| %>
|
34
|
-
<li>
|
35
|
-
<%= label_tag "banner_styles[#{style_name}]", style_name %>
|
36
|
-
<%= text_field_tag "banner_styles[#{style_name}]", style_value %>
|
37
|
-
<a href="#" alt="Destroy" class="destroy_banner_style">x</a>
|
38
|
-
</li>
|
39
|
-
<% end %>
|
40
|
-
</ul>
|
41
|
-
<p><a href="#" alt="Add Style" class="add_banner_style"><%= t(:add_new_style) %></a></p>
|
42
|
-
</div>
|
43
|
-
|
44
|
-
<p class="form-buttons" data-hook="buttons">
|
45
|
-
<%= button t(:update) %>
|
46
|
-
</p>
|
47
|
-
|
48
|
-
<% end %>
|
@@ -1,10 +0,0 @@
|
|
1
|
-
<%= render :partial => 'spree/admin/shared/configuration_menu' %>
|
2
|
-
|
3
|
-
<h1><%= t(:banner_settings) %></h1>
|
4
|
-
|
5
|
-
<h4><%= t(:banner_path) %>: <%= Spree::Config[:banner_path] %></h4>
|
6
|
-
<h4><%= t(:banner_default_url) %>: <%= Spree::Config[:banner_default_url] %></h4>
|
7
|
-
<h4><%= t(:banner_default_style) %>: <%= Spree::Config[:banner_default_style] %></h4>
|
8
|
-
<h4><%= t(:defined_paperclip_styles) %>: <%= @styles_list %></h4>
|
9
|
-
|
10
|
-
<%= link_to_with_icon 'edit', t(:edit), edit_admin_banner_settings_path, :id => 'admin_banner_settings_link' %>
|
@@ -1,30 +0,0 @@
|
|
1
|
-
<div data-hook="admin_banner_form_fields">
|
2
|
-
<div class="clearfix">
|
3
|
-
<div class="left" data-hook="admin_banner_form_left">
|
4
|
-
<%= f.field_container :category do %>
|
5
|
-
<%= f.label :category, t(:category) %> <span class="required">*</span><br />
|
6
|
-
<%= f.text_field :category, :class => 'fullwidth title' %>
|
7
|
-
<%= f.error_message_on :category %>
|
8
|
-
<% end %>
|
9
|
-
|
10
|
-
<%= f.field_container :url do %>
|
11
|
-
<%= f.label :url, t(:url) %><br />
|
12
|
-
<%= f.text_field :url, :class => 'fullwidth title' %>
|
13
|
-
<%= f.error_message_on :url %>
|
14
|
-
<% end %>
|
15
|
-
</div>
|
16
|
-
<div class="right" data-hook="admin_banner_form_right">
|
17
|
-
<%= f.field_container :attachment do %>
|
18
|
-
<%= f.label :attachment, t(:attachment) %><br />
|
19
|
-
<%= f.file_field :attachment %>
|
20
|
-
<%= f.error_message_on :attachment %>
|
21
|
-
<% end %>
|
22
|
-
|
23
|
-
<%= f.field_container :enabled do %>
|
24
|
-
<%= f.label :enabled, t(:enabled) %><br />
|
25
|
-
<%= f.check_box :enabled %>
|
26
|
-
<%= f.error_message_on :enabled %>
|
27
|
-
<% end %>
|
28
|
-
</div>
|
29
|
-
</div>
|
30
|
-
</div>
|
@@ -1,6 +0,0 @@
|
|
1
|
-
<%= render :partial => 'spree/shared/error_messages', :locals => { :target => @banner } %>
|
2
|
-
|
3
|
-
<%= form_for([:admin, @banner], :html => { :multipart => true }) do |f| %>
|
4
|
-
<%= render :partial => 'form', :locals => { :f => f } %>
|
5
|
-
<%= render :partial => 'spree/admin/shared/edit_resource_links' %>
|
6
|
-
<% end %>
|
@@ -1,36 +0,0 @@
|
|
1
|
-
<div class="toolbar" data-hook="toolbar">
|
2
|
-
<ul class="actions">
|
3
|
-
<li id="new_banner_link">
|
4
|
-
<%= button_link_to t(:new_banner), new_object_url, {:remote => true, :icon => 'add', :id => 'admin_new_banner'} %>
|
5
|
-
</li>
|
6
|
-
</ul>
|
7
|
-
<br class="clear" />
|
8
|
-
</div>
|
9
|
-
|
10
|
-
<h1><%= t(:listing_banners) %></h1>
|
11
|
-
|
12
|
-
<div id="new_banner" data-hook></div>
|
13
|
-
|
14
|
-
<table class="index sortable" data-hook="listing_banners" data-sortable-link="<%= update_positions_admin_banners_url() %>">
|
15
|
-
<tr data-hook="admin_banners_index_headers">
|
16
|
-
<th><%= t(:thumbnail) %></th>
|
17
|
-
<th><%= t(:category) %></th>
|
18
|
-
<th><%= t(:enable) %></th>
|
19
|
-
<th data-hook="admin_banners_index_header_actions"></th>
|
20
|
-
</tr>
|
21
|
-
<% @banners.each do |banner| %>
|
22
|
-
<tr id="<%= spree_dom_id banner %>" data-hook="admin_banners_index_rows">
|
23
|
-
<td>
|
24
|
-
<span class="handle"></span>
|
25
|
-
<%= link_to image_tag(banner.attachment.url(:mini)), banner.attachment.url(:small) %>
|
26
|
-
</td>
|
27
|
-
<td><%= banner.category %></td>
|
28
|
-
<td><%= icon('tick') if banner.enabled %></td>
|
29
|
-
<td class="actions" data-hook="admin_banners_index_row_actions">
|
30
|
-
<%= link_to_edit banner, :class => 'edit' %>
|
31
|
-
|
32
|
-
<%= link_to_delete banner %>
|
33
|
-
</td>
|
34
|
-
</tr>
|
35
|
-
<% end %>
|
36
|
-
</table>
|