Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
...
  • 11 commits
  • 17 files changed
  • 0 commit comments
  • 2 contributors
View
71 README.md
@@ -1,35 +1,56 @@
-SpreeBanner
-===================
+Spree Banner
+============
-Add banner for Spree Commerce Shop [compatible with Amazon S3]
+Adds a way to manage banners to Spree Commerce [compatible with Amazon S3]
-Basic Installation
-------------------
+Installation
+------------
1. Add the following to your Gemfile
-<pre>
- gem 'spree_banner', '~> 2.0.0'
-</pre>
+
+```ruby
+gem 'spree_banner', '~> 2.0.0'
+```
+
2. Run `bundle install`
+
3. To copy and apply migrations run:
-<pre>
- rails g spree_banner:install
-</pre>
-
-Example
-=======
-
-1. add banner helper method in your view:
-<pre>
- <%= insert_banner_box(:category => "my_category") %>
-</pre>
-and add banner in the admin section
+
+```
+rails g spree_banner:install
+```
+
+
+Configuration
+-------------
+
+Preferences can be updated within the admin panel under "Configuration" then "Banner box settings".
+Or you may set them with an initializer within your application:
+
+```ruby
+SpreeBanner::Config.tap do |config|
+ config.banner_styles = {"mini" => "48x48>", "small" => "100x100>", "large" => "800x200#"}.to_json.to_s
+ config.banner_default_style = 'small'
+end
+```
+
+
+Banner use example
+------------------
+
+1. Add banner helper method in your view:
+
+```erb
+<%= insert_banner_box(category: "my_category") %>
+```
+
2. Additional options:
-<pre>
- :class => "my_class"
- :style => "my_style"
- :list = true|false
-</pre>
+
+```ruby
+ :class => "my_class"
+ :style => "my_style"
+ :list = true|false
+```
Copyright (c) 2012 [Damiano Giacomello], released under the New BSD License
View
19 app/controllers/spree/admin/banner_box_settings_controller.rb
@@ -1,25 +1,25 @@
module Spree
module Admin
class BannerBoxSettingsController < Spree::Admin::BaseController
-
+
def show
redirect_to( :action => :edit )
end
def create
update_paperclip_settings
- @styles = ActiveSupport::JSON.decode(Spree::Config[:banner_styles])
+ @styles = ActiveSupport::JSON.decode(SpreeBanner::Config[:banner_styles])
super
end
def edit
- @styles = ActiveSupport::JSON.decode(Spree::Config[:banner_styles])
+ @styles = ActiveSupport::JSON.decode(SpreeBanner::Config[:banner_styles])
end
def update
update_styles(params)
- Spree::Config.set(params[:preferences])
+ SpreeBanner::Config.set(params[:preferences])
update_paperclip_settings
respond_to do |format|
@@ -40,20 +40,19 @@ def update_styles(params)
styles = params[:banner_styles]
- Spree::Config[:banner_styles] = ActiveSupport::JSON.encode(styles) unless styles.nil?
+ SpreeBanner::Config[:banner_styles] = ActiveSupport::JSON.encode(styles) unless styles.nil?
end
def update_paperclip_settings
extended_hash = {}
- ActiveSupport::JSON.decode(Spree::Config[:banner_styles]).each do |key,value|
+ ActiveSupport::JSON.decode(SpreeBanner::Config[:banner_styles]).each do |key,value|
extended_hash[:"#{key}"] = value
end
Spree::BannerBox.attachment_definitions[:attachment][:styles] = extended_hash
- Spree::BannerBox.attachment_definitions[:attachment][:path] = Spree::Config[:banner_path]
- Spree::BannerBox.attachment_definitions[:attachment][:default_url] = Spree::Config[:banner_default_url]
- Spree::BannerBox.attachment_definitions[:attachment][:default_style] = Spree::Config[:banner_default_style]
+ Spree::BannerBox.attachment_definitions[:attachment][:path] = SpreeBanner::Config[:banner_path]
+ Spree::BannerBox.attachment_definitions[:attachment][:default_url] = SpreeBanner::Config[:banner_default_url]
+ Spree::BannerBox.attachment_definitions[:attachment][:default_style] = SpreeBanner::Config[:banner_default_style]
end
end
end
end
-
View
2  app/controllers/spree/admin/banner_boxes_controller.rb
@@ -39,7 +39,7 @@ def location_after_save
def collection
return @collection if @collection.present?
params[:q] ||= {}
- params[:q][:s] ||= "title asc"
+ params[:q][:s] ||= "category, position asc"
@search = super.ransack(params[:q])
@collection = @search.result.page(params[:page]).per(Spree::Config[:admin_products_per_page])
View
36 app/helpers/spree/banner_boxes_helper.rb
@@ -4,21 +4,33 @@ module BannerBoxesHelper
def insert_banner_box(params={})
params[:category] ||= "home"
params[:class] ||= "banner"
- params[:style] ||= "small"
+ params[:style] ||= SpreeBanner::Config[:banner_default_style]
params[:list] ||= false
- @@banner = Spree::BannerBox.enable(params[:category])
- if @@banner.blank?
- return ''
- end
- res = []
- banner = @@banner.sort_by { |ban| ban.position }
-
- if (params[:list])
- 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 )
+ banners = Spree::BannerBox.enabled(params[:category]).order(:position)
+ return '' if banners.empty?
+
+ if params[:list]
+ content_tag :ul do
+ banners.map do |ban|
+ content_tag :li, :class => params[:class] do
+ link_to (ban.url.blank? ? "javascript: void(0)" : ban.url) do
+ src = ban.attachment.url(params[:style].to_sym)
+ image_tag(src, :alt => ban.alt_text.presence || image_alt(src))
+ end
+ end
+ end.join.html_safe
+ end
else
- 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
+ banners.map do |ban|
+ content_tag :div, :class => params[:class] do
+ link_to (ban.url.blank? ? "javascript: void(0)" : ban.url) do
+ src = ban.attachment.url(params[:style].to_sym)
+ image_tag(ban.attachment.url(params[:style].to_sym), :alt => ban.alt_text.presence || image_alt(src))
+ end
+ end
+ end.join.html_safe
end
end
-
+
end
end
View
25 app/models/spree/app_configuration_decorator.rb
@@ -1,25 +0,0 @@
-# This is the primary location for defining spree preferences
-#
-# The expectation is that this is created once and stored in
-# the spree environment
-#
-# setters:
-# a.color = :blue
-# a[:color] = :blue
-# a.set :color = :blue
-# a.preferred_color = :blue
-#
-# getters:
-# a.color
-# a[:color]
-# a.get :color
-# a.preferred_color
-#
-Spree::AppConfiguration.class_eval do
- # Preferences related to banner settings
- preference :banner_default_url, :string, :default => '/spree/banners/:id/:style/:basename.:extension'
- preference :banner_path, :string, :default => ':rails_root/public/spree/banners/:id/:style/:basename.:extension'
- preference :banner_url, :string, :default => '/spree/banners/:id/:style/:basename.:extension'
- preference :banner_styles, :string, :default => "{\":mini\":\"48x48>\",\":small\":\"100x100>\",\":large\":\"800x200#\"}"
- preference :banner_default_style, :string, :default => 'small'
-end
View
52 app/models/spree/banner_box.rb
@@ -1,7 +1,7 @@
module Spree
class BannerBox < ActiveRecord::Base
- attr_accessible :presentation, :url, :category, :position, :enabled, :attachment
-
+ attr_accessible :alt_text, :url, :category, :position, :enabled, :attachment
+
has_attached_file :attachment,
:url => "/spree/banners/:id/:style_:basename.:extension",
:path => ":rails_root/public/spree/banners/:id/:style_:basename.:extension",
@@ -15,30 +15,36 @@ class BannerBox < ActiveRecord::Base
# save the w,h of the original image (from which others can be calculated)
# we need to look at the write-queue for images which have not been saved yet
after_post_process :find_dimensions
-
+
validates_presence_of :category
validates_attachment_presence :attachment
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)
-
- scope :enable, lambda { |category| {:conditions => {:enabled => true, :category => category}} }
-
+
+ scope :enabled, lambda { |*categories|
+ if categories.empty?
+ where(:enabled => true)
+ else
+ where(:enabled => true).where(:category => categories)
+ end
+ }
+
# Load user defined paperclip settings
include Spree::Core::S3Support
supports_s3 :attachment
-
- Spree::BannerBox.attachment_definitions[:attachment][:styles] = ActiveSupport::JSON.decode(Spree::Config[:banner_styles])
- Spree::BannerBox.attachment_definitions[:attachment][:path] = Spree::Config[:banner_path]
- Spree::BannerBox.attachment_definitions[:attachment][:url] = Spree::Config[:banner_url]
- Spree::BannerBox.attachment_definitions[:attachment][:default_url] = Spree::Config[:banner_default_url]
- Spree::BannerBox.attachment_definitions[:attachment][:default_style] = Spree::Config[:banner_default_style]
-
+
+ Spree::BannerBox.attachment_definitions[:attachment][:styles] = ActiveSupport::JSON.decode(SpreeBanner::Config[:banner_styles]).symbolize_keys!
+ Spree::BannerBox.attachment_definitions[:attachment][:path] = SpreeBanner::Config[:banner_path]
+ Spree::BannerBox.attachment_definitions[:attachment][:url] = SpreeBanner::Config[:banner_url]
+ Spree::BannerBox.attachment_definitions[:attachment][:default_url] = SpreeBanner::Config[:banner_default_url]
+ Spree::BannerBox.attachment_definitions[:attachment][:default_style] = SpreeBanner::Config[:banner_default_style].to_sym
+
def initialize(*args)
super(*args)
last_banner = BannerBox.last
self.position = last_banner ? last_banner.position + 1 : 0
enhance_settings
end
-
+
# for adding banner_boxes which are closely related to existing ones
# define "duplicate_extra" for site-specific actions, eg for additional fields
def duplicate
@@ -54,7 +60,7 @@ def duplicate
p.save!
p
end
-
+
def find_dimensions
temporary = attachment.queued_for_write[:original]
filename = temporary.path unless temporary.nil?
@@ -66,15 +72,19 @@ def find_dimensions
def enhance_settings
extended_hash = {}
- ActiveSupport::JSON.decode(Spree::Config[:banner_styles]).each do |key,value|
+ ActiveSupport::JSON.decode(SpreeBanner::Config[:banner_styles]).each do |key,value|
extended_hash[:"#{key}"] = value
end
Spree::BannerBox.attachment_definitions[:attachment][:styles] = extended_hash
- Spree::BannerBox.attachment_definitions[:attachment][:path] = Spree::Config[:banner_path]
- Spree::BannerBox.attachment_definitions[:attachment][:url] = Spree::Config[:banner_url]
- Spree::BannerBox.attachment_definitions[:attachment][:default_url] = Spree::Config[:banner_default_url]
- Spree::BannerBox.attachment_definitions[:attachment][:default_style] = Spree::Config[:banner_default_style]
+ Spree::BannerBox.attachment_definitions[:attachment][:path] = SpreeBanner::Config[:banner_path]
+ Spree::BannerBox.attachment_definitions[:attachment][:url] = SpreeBanner::Config[:banner_url]
+ Spree::BannerBox.attachment_definitions[:attachment][:default_url] = SpreeBanner::Config[:banner_default_url]
+ Spree::BannerBox.attachment_definitions[:attachment][:default_style] = SpreeBanner::Config[:banner_default_style]
end
-
+
+ def self.categories_for_select
+ unscoped.pluck(:category).uniq.sort
+ end
+
end
end
View
9 app/models/spree/banner_configuration.rb
@@ -0,0 +1,9 @@
+module Spree
+ class BannerConfiguration < Preferences::Configuration
+ preference :banner_default_url, :string, default: '/spree/banners/:id/:style/:basename.:extension'
+ preference :banner_path, :string, default: ':rails_root/public/spree/banners/:id/:style/:basename.:extension'
+ preference :banner_url, :string, default: '/spree/banners/:id/:style/:basename.:extension'
+ preference :banner_styles, :string, default: "{\"mini\":\"48x48>\",\"small\":\"100x100>\",\"large\":\"800x200#\"}"
+ preference :banner_default_style, :string, default: 'small'
+ end
+end
View
2  app/overrides/banner_admin_tab.rb
@@ -6,4 +6,4 @@
Deface::Override.new(:virtual_path => "spree/admin/shared/_configuration_menu",
:name => "add_banner_box_settings",
:insert_bottom => "[data-hook='admin_configurations_sidebar_menu'], #admin_configurations_sidebar_menu[data-hook]",
- :text => "<%= configurations_sidebar_menu_item(:banner_box_settings, edit_admin_banner_box_settings_url) %>")
+ :text => "<%= configurations_sidebar_menu_item(Spree.t(:banner_box_settings), edit_admin_banner_box_settings_url) %>")
View
8 app/views/spree/admin/banner_box_settings/edit.html.erb
@@ -18,27 +18,27 @@
<div data-hook="attachment_path" class="field">
<%= label_tag 'preferences[attachment_path]', t(:banner_path) %>
- <%= preference_field_tag 'preferences[banner_path]', Spree::Config[:banner_path], :type => :string %>
+ <%= preference_field_tag 'preferences[banner_path]', SpreeBanner::Config[:banner_path], :type => :string %>
</div>
<div class="alpha eight columns">
<div data-hook="attachment_default_url" class="field">
<%= label_tag 'preferences[attachment_default_url]', t(:banner_default_url) %>
- <%= preference_field_tag 'preferences[banner_default_url]', Spree::Config[:banner_default_url], :type => :string %>
+ <%= preference_field_tag 'preferences[banner_default_url]', SpreeBanner::Config[:banner_default_url], :type => :string %>
</div>
</div>
<div class="alpha eight columns">
<div data-hook="attachment_url" class="field">
<%= label_tag 'preferences[attachment_url]', t(:banner_url) %>
- <%= preference_field_tag 'preferences[banner_url]', Spree::Config[:banner_url], :type => :string %>
+ <%= preference_field_tag 'preferences[banner_url]', SpreeBanner::Config[:banner_url], :type => :string %>
</div>
</div>
<div class="omega four columns">
<div data-hook="attachment_default_style" class="field">
<%= label_tag 'preferences[attachment_default_style]', t(:banner_default_style) %>
- <%= collection_select 'preferences', 'banner_default_style', @styles, :first, :first, {:selected => Spree::Config[:banner_default_style] }, :class => 'select2 fullwidth' %>
+ <%= collection_select 'preferences', 'banner_default_style', @styles, :first, :first, {:selected => SpreeBanner::Config[:banner_default_style] }, :class => 'select2 fullwidth' %>
</div>
</div>
View
95 app/views/spree/admin/banner_boxes/_form.html.erb
@@ -1,47 +1,50 @@
-<div data-hook="admin_banner_box_form_fields">
-
- <div class="left eight columns alpha" data-hook="admin_banner_box_form_left">
- <%= f.field_container :category do %>
- <%= f.label :category, raw(t(:category) + content_tag(:span, ' *', :class => 'required')) %>
- <%= f.text_field :category, :class => 'fullwidth title' %>
- <%= f.error_message_on :category %>
- <% end %>
-
- <%= f.field_container :url do %>
- <%= f.label :url, raw(t(:url)) %>
- <%= f.text_field :url, :class => 'fullwidth title' %>
- <%= f.error_message_on :url %>
- <% end %>
-
- <%= f.field_container :presentation do %>
- <%= f.label :presentation, t(:alt_text) %>
- <%= f.text_field :presentation, :class => 'fullwidth' %>
- <%= f.error_message_on :presentation %>
- <% end %>
- </div>
-
- <div class="right seven columns omega" data-hook="admin_banner_box_form_right">
- <div data-hook="thumbnail" class="field alpha six columns align-center">
- <%= f.label t(:thumbnail) %><br>
- <%= link_to image_tag(@banner_box.attachment.url(:mini)), @banner_box.attachment.url(:small) %>
- </div>
-
- <%= f.field_container :attachment do %>
- <%= f.label :attachment, t(:attachment) %><br />
- <%= f.file_field :attachment %>
- <%= f.error_message_on :attachment %>
- <% end %>
-
- <%= f.field_container :enabled do %>
- <%= f.label :enabled, t(:enabled) %><br />
- <%= f.check_box :enabled %>
- <%= f.error_message_on :enabled %>
- <% end %>
- </div>
-
- <div class="clear"></div>
-
- <div data-hook="admin_banner_box_form_additional_fields"></div>
-
- <div class="clear"></div>
+<div data-hook="admin_banner_box_form_fields" class="row">
+
+ <div class="left eight columns alpha" data-hook="admin_banner_box_form_left">
+ <%= f.field_container :category do %>
+ <%= f.label :category, raw(t(:category) + content_tag(:span, ' *', :class => 'required')) %>
+ <%= f.text_field :category, :class => 'fullwidth title' %>
+ <%= f.error_message_on :category %>
+ <% end %>
+
+ <%= f.field_container :url do %>
+ <%= f.label :url, raw(t(:url)) %>
+ <%= f.text_field :url, :class => 'fullwidth title' %>
+ <%= f.error_message_on :url %>
+ <% end %>
+ </div>
+
+ <div class="right eight columns omega" data-hook="admin_banner_box_form_right">
+ <% unless f.object.new_record? %>
+ <div data-hook="thumbnail" class="field alpha two columns">
+ <%= f.label t(:thumbnail) %><br>
+ <%= link_to image_tag(@banner_box.attachment.url(:mini)), @banner_box.attachment.url(:small) %>
+ </div>
+ <% end %>
+
+ <%= f.field_container :attachment do %>
+ <%= f.label :attachment, t(:attachment) %><br />
+ <%= f.file_field :attachment %>
+ <%= f.error_message_on :attachment %>
+ <% end %>
+ <div class="clear"></div>
+
+ <%= f.field_container :alt_text do %>
+ <%= f.label :alt_text, t(:alt_text) %>
+ <%= f.text_field :alt_text, :class => 'fullwidth' %>
+ <%= f.error_message_on :alt_text %>
+ <% end %>
+
+ <%= f.field_container :enabled do %>
+ <%= f.label :enabled, t(:enabled) %><br />
+ <%= f.check_box :enabled %>
+ <%= f.error_message_on :enabled %>
+ <% end %>
+ </div>
+
+ <div class="clear"></div>
+
+ <div data-hook="admin_banner_box_form_additional_fields"></div>
+
+ <div class="clear"></div>
</div>
View
2  app/views/spree/admin/banner_boxes/edit.html.erb
@@ -3,7 +3,7 @@
<% content_for :page_actions do %>
<li><%= button_link_to t(:back_to_banner_boxes_list), admin_banner_boxes_url, :icon => 'icon-arrow-left' %></li>
<li id="new_banner_box_link">
- <%= button_link_to t(:new_banner_box), new_object_url, { :remote => true, :icon => 'icon-plus', :id => 'admin_new_banner_box' } %>
+ <%= button_link_to t(:new_banner_box), new_object_url, { :icon => 'icon-plus', :id => 'admin_new_banner_box' } %>
</li>
<% end %>
View
118 app/views/spree/admin/banner_boxes/index.html.erb
@@ -1,63 +1,103 @@
<% content_for :page_title do %>
- <%= t(:listing_banner_boxes) %>
+ <%= t(:listing_banner_boxes) %>
<% end %>
<% content_for :page_actions do %>
- <div class="toolbar" data-hook="toolbar">
- <ul class="actions header-action-links inline-menu">
- <li id="new_banner_box_link">
- <%= button_link_to t(:new_banner_box), new_object_url, { :remote => true, :icon => 'icon-plus', :id => 'admin_new_banner_box' } %>
- </li>
- </ul>
- </div>
+ <div class="toolbar" data-hook="toolbar">
+ <ul class="actions header-action-links inline-menu">
+ <li id="new_banner_box_link">
+ <%= button_link_to t(:new_banner_box), new_object_url, { :remote => true, :icon => 'icon-plus', :id => 'admin_new_banner_box' } %>
+ </li>
+ </ul>
+ </div>
<% end %>
<%= render :partial => 'spree/admin/shared/banner_box_sub_menu' %>
+<% content_for :table_filter_title do %>
+ <%= Spree.t(:search) %>
+<% end %>
+
+<% content_for :table_filter do %>
+ <div data-hook="admin_banner_sidebar">
+
+ <%= search_form_for [:admin, @search] do |f| %>
+ <%- locals = {:f => f} %>
+ <div data-hook="admin_banner_index_search">
+ <div class="alpha four columns">
+ <div class="field">
+ <%= f.label :category_eq, Spree.t(:category) %>
+ <%= f.select :category_eq, Spree::BannerBox.categories_for_select, {:include_blank => true}, {:class => 'select2 fullwidth'} %>
+ </div>
+ </div>
+ <div class="eight columns">
+ <div class="field">
+ <%= f.label :url_cont, Spree.t(:url) %>
+ <%= f.text_field :url_cont, :size => 15 %>
+ </div>
+ </div>
+ <div class="three columns omega">
+ <div class="field checkbox">
+ <label>
+ <%= f.check_box :enabled_true %>
+ <%= Spree.t(:show_only_enabled) %>
+ </label>
+ </div>
+ </div>
+
+ <div class="clear"></div>
+
+ <div class="form-buttons actions filter-actions" data-hook="admin_banner_index_search_buttons">
+ <%= button Spree.t(:search), 'icon-search' %>
+ </div>
+ <% end %>
+ </div>
+<% end %>
+
+
<div id="new_banner_box" data-hook></div>
<% if @collection.any? %>
<table class="index sortable" id="listing_banner_boxes" data-sortable-link="<%= update_positions_admin_banner_boxes_url() %>">
- <colgroup>
- <col style="width: 5%">
- <col style="width: 15%;">
- <col style="width: 10%;">
- <col style="width: 10%;">
- <col style="width: 17%;">
+ <colgroup>
+ <col style="width: 5%">
+ <col style="width: 15%;">
+ <col style="width: 10%;">
+ <col style="width: 10%;">
+ <col style="width: 17%;">
</colgroup>
<thead>
- <tr data-hook="admin_products_index_headers">
- <th colspan="2"><%= t(:thumbnail) %></th>
- <th><%= t(:category) %></th>
- <th><%= t(:url) %></th>
- <th data-hook="admin_products_index_header_actions" class="actions"></th>
- </tr>
-</thead>
+ <tr data-hook="admin_banner_index_headers">
+ <th colspan="2"><%= t(:thumbnail) %></th>
+ <th><%= t(:category) %></th>
+ <th><%= t(:url) %></th>
+ <th data-hook="admin_banner_index_header_actions" class="actions"></th>
+ </tr>
+</thead>
<tbody>
- <% @collection.each do |banner_box| %>
- <tr id="<%= spree_dom_id banner_box %>" data-hook="admin_banner_boxes_index_rows" class="<%= cycle('odd', 'even') %>">
- <td class="no-border">
- <span class="handle"></span>
- </td>
- <td class="align-center"><%= image_tag(banner_box.attachment(:mini)) %></td>
- <td class="align-center"><%= banner_box.category rescue '' %></td>
- <td class="align-center"><%= banner_box.url rescue '' %></td>
- <td class="actions" data-hook="admin_products_index_row_actions">
- <%= link_to_edit banner_box, :no_text => true, :class => 'edit' %>
- &nbsp;
- <%= link_to_with_icon 'icon-copy', t(:clone), clone_admin_banner_box_url(banner_box), :no_text => true, :class => 'clone' %>
+ <% @collection.each do |banner_box| %>
+ <tr id="<%= spree_dom_id banner_box %>" data-hook="admin_banner_boxes_index_rows" class="<%= cycle('odd', 'even') %>">
+ <td class="no-border">
+ <span class="handle"></span>
+ </td>
+ <td class="align-center"><%= image_tag(banner_box.attachment(:mini)) %></td>
+ <td class="align-center"><%= banner_box.category rescue '' %></td>
+ <td class="align-center"><%= banner_box.url rescue '' %></td>
+ <td class="actions" data-hook="admin_banner_index_row_actions">
+ <%= link_to_edit banner_box, :no_text => true, :class => 'edit' %>
+ &nbsp;
+ <%= link_to_with_icon 'icon-copy', t(:clone), clone_admin_banner_box_url(banner_box), :no_text => true, :class => 'clone' %>
&nbsp;
- <%= link_to_delete banner_box, :no_text => true %>
- </td>
- </tr>
- <% end %>
+ <%= link_to_delete banner_box, :no_text => true %>
+ </td>
+ </tr>
+ <% end %>
</tbody>
</table>
<% else %>
<div class="no-objects-found">
- <%= t(:no_results) %>
+ <%= t(:no_results) %>
</div>
<% end %>
<%= paginate @collection %>
-
View
46 app/views/spree/admin/banner_boxes/new.html.erb
@@ -1,43 +1,9 @@
<%= render :partial => 'spree/shared/error_messages', :locals => { :target => @banner_box } %>
<%= form_for [:admin, @banner_box], :html => { :multipart => true } do |f| %>
-<fieldset data-hook="new_banner_box">
- <legend align="center"><%= t(:new_banner_box) %></legend>
- <div data-hook="new_banner_box_attrs" class="row">
- <div class="left alpha eight columns">
- <%= f.field_container :category do %>
- <%= f.label :category, t(:category) %> <span class="required">*</span><br />
- <%= f.text_field :category, :class => 'fullwidth title' %>
- <%= f.error_message_on :category %>
- <% end %>
-
- <%= f.field_container :url do %>
- <%= f.label :url, t(:url) %><br />
- <%= f.text_field :url, :class => 'fullwidth title' %>
- <%= f.error_message_on :url %>
- <% end %>
- </div>
-
- <div class="right omega four columns">
- <%= f.field_container :attachment do %>
- <%= f.label :attachment, t(:attachment) %><br />
- <%= f.file_field :attachment %>
- <%= f.error_message_on :attachment %>
- <% end %>
-
- <%= f.field_container :presentation do %>
- <%= f.label :presentation, t(:alt_text) %><br />
- <%= f.text_field :presentation, :class => 'fullwidth' %>
- <%= f.error_message_on :presentation %>
- <% end %>
-
- <%= f.field_container :enabled do %>
- <%= f.label :enabled, t(:enabled) %><br />
- <%= f.check_box :enabled %>
- <%= f.error_message_on :enabled %>
- <% end %>
- </div>
- </div>
- <%= render :partial => 'spree/admin/shared/new_resource_links' %>
-</fieldset>
-<% end %>
+ <fieldset data-hook="new_banner_box">
+ <legend align="center"><%= t(:new_banner_box) %></legend>
+ <%= render :partial => 'form', :locals => { :f => f } %>
+ <%= render :partial => 'spree/admin/shared/new_resource_links' %>
+ </fieldset>
+<% end %>
View
5 config/locales/en.yml
@@ -1,11 +1,11 @@
en:
images_only: "deve essere JPG, JPEG, PNG o GIF"
- banner_box_settings: Banner Setting
+ banner_box_settings: "Banner Settings"
add_new_banner_style: "Add New Banner Style"
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."
banner_settings_description: "Banner Settings Description"
banner_settings_updated: "Banner Settings successfully updated."
- banner_default_style: "Banner Default Path"
+ banner_default_style: "Banner Default Style"
banner_default_url: "Banner Default URL"
banner_path: "Banner Path"
banner_styles: "Paperclip Styles Banner"
@@ -19,6 +19,7 @@ en:
category: Category
banner_boxes: Banners
banner_box: Banner
+ show_only_enabled: "Show only enabled"
notice_messages:
banner_box_cloned: "Banner has been cloned"
banner_box_not_cloned: "Banner could not be cloned"
View
1  config/locales/it.yml
@@ -19,6 +19,7 @@ it:
category: Categoria
banner_boxes: Banners
banner_box: Banner
+ show_only_enabled: "Mostra solo attivi"
notice_messages:
banner_box_cloned: "Banner Duplicato"
banner_box_not_cloned: "Impossibili Duplicare il Banner"
View
5 db/migrate/20131001104524_rename_presentation_to_alt_text.rb
@@ -0,0 +1,5 @@
+class RenamePresentationToAltText < ActiveRecord::Migration
+ def change
+ rename_column :spree_banner_boxes, :presentation, :alt_text
+ end
+end
View
8 lib/spree_banner/engine.rb
@@ -2,13 +2,17 @@ module SpreeBanner
class Engine < Rails::Engine
engine_name 'spree_banner'
- config.autoload_paths += %W(#{config.root}/lib)
-
# use rspec for tests
config.generators do |g|
g.test_framework :rspec
end
+ initializer "spree_banner.preferences", :before => :load_config_initializers do |app|
+ SpreeBanner::Config = Spree::BannerConfiguration.new
+ end
+
+ config.autoload_paths += %W(#{config.root}/lib)
+
def self.activate
Dir.glob(File.join(File.dirname(__FILE__), "../../app/**/*_decorator*.rb")) do |c|
Rails.application.config.cache_classes ? require(c) : load(c)

No commit comments for this range

Something went wrong with that request. Please try again.