spree_banner 1.1.2 → 1.1.3

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 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.1.1'
12
+ gem 'spree_banner', '~> 1.1.3'
13
13
  </pre>
14
14
  2. Run `bundle install`
15
15
  3. To copy and apply migrations run:
@@ -39,8 +39,8 @@ limits the number of banner shown to 10 (default 1)
39
39
  </pre>
40
40
  set banner class (default banner)
41
41
  <pre>
42
- <%= insert_banner(:style => "your_container") %>
42
+ <%= insert_banner(:list => true/false) %>
43
43
  </pre>
44
- set banner container (default list [possibile: div, p, ...])
44
+ set banner container (default false is DIV)
45
45
 
46
46
  Copyright (c) 2012 [Damiano Giacomello], released under the New BSD License
@@ -1,17 +1,3 @@
1
1
  /*
2
2
  *= require admin/spree_core
3
- *= require formtastic
4
3
  */
5
-
6
- .formtastic input, .formtastic textarea, .formtastic select {
7
- font-size: 100%;
8
- padding: 5px;
9
- }
10
-
11
- .formtastic button {
12
- margin: 0;
13
- padding: 0 20px 0 0;
14
- }
15
- .formtastic button:hover {
16
- text-shadow: #FFFFFF -1px -1px 0px;
17
- }
@@ -20,7 +20,7 @@ module Spree
20
20
 
21
21
  private
22
22
  def location_after_save
23
- admin_banners_url(@banner)
23
+ edit_admin_banner_url(@banner)
24
24
  end
25
25
 
26
26
  end
@@ -3,21 +3,21 @@ module Spree
3
3
 
4
4
  def insert_banner(params={})
5
5
  # max items show for list
6
- max = params[:max] || 1
6
+ params[:max] ||= 1
7
7
  # category items show
8
- category = params[:category] || ""
8
+ params[:category] ||= "home"
9
9
  # class items show
10
- cl = params[:class] || "banner"
10
+ params[:class] ||= "banner"
11
11
  # style items show
12
- style = params[:style] || "list"
13
- banner = Banner.enable(category).limit(max)
12
+ params[:list] ||= false
13
+ banner = Spree::Banner.enable(params[:category]).limit(params[:max])
14
14
  if !banner.blank?
15
15
  banner = banner.sort_by { |ban| ban.position }
16
16
 
17
- if (style == "list")
18
- content_tag(:ul, raw(banner.map do |ban| content_tag(:li, link_to(image_tag(ban.attachment.url(:custom)), ban.url), :class => cl) end.join) )
17
+ if (params[:list])
18
+ content_tag(:ul, banner.map{|ban| content_tag(:li, link_to(image_tag(ban.attachment.url(:custom)), (ban.url.blank? ? "javascript: void(0)" : ban.url)), :class => params[:class])}.join().html_safe )
19
19
  else
20
- raw(banner.map do |ban| content_tag(style.to_sym, link_to(image_tag(ban.attachment.url(:custom)), ban.url), :class => cl) end.join)
20
+ banner.map{|ban| content_tag(:div, link_to(image_tag(ban.attachment.url(:custom)), (ban.url.blank? ? "javascript: void(0)" : ban.url)), :class => params[:class])}.join().html_safe
21
21
  end
22
22
 
23
23
  end
@@ -31,12 +31,6 @@ module Spree
31
31
  Spree::Banner.attachment_definitions[:attachment][:bucket] = Spree::Config[:s3_bucket]
32
32
  Spree::Banner.attachment_definitions[:attachment][:s3_protocol] = Spree::Config[:s3_protocol] unless Spree::Config[:s3_protocol].blank?
33
33
  end
34
-
35
- Spree::Banner.attachment_definitions[:attachment][:styles] = ActiveSupport::JSON.decode(Spree::Config[:attachment_styles])
36
- Spree::Banner.attachment_definitions[:attachment][:path] = Spree::Config[:attachment_path]
37
- Spree::Banner.attachment_definitions[:attachment][:url] = Spree::Config[:attachment_url]
38
- Spree::Banner.attachment_definitions[:attachment][:default_url] = Spree::Config[:attachment_default_url]
39
- Spree::Banner.attachment_definitions[:attachment][:default_style] = Spree::Config[:attachment_default_style]
40
34
 
41
35
  def initialize(*args)
42
36
  super(*args)
@@ -1,9 +1,48 @@
1
- <%= f.inputs do %>
2
- <%= f.input :category, :required => true, :label => t("banner.category") %>
3
- <%= f.input :url, :label => t("banner.url") %>
4
- <%= f.input :position, :label => t("banner.position") %>
5
- <%= f.input :attachment_width, :required => true, :label => t("banner.attachment_width") %>
6
- <%= f.input :attachment_height, :required => true, :label => t("banner.attachment_height") %>
7
- <%= f.input :enabled, :label => t("banner.enabled") %>
8
- <%= f.input :attachment, :required => true, :as => :file, :label => t("banner.image.one").capitalize, :hint => f.object.attachment.blank? ? f.template.content_tag(:span, t("banner.no_image")) : f.template.image_tag(f.object.attachment.url(:thumbnail)) %>
9
- <% end %>
1
+ <div data-hook="admin_slideshow_form_fields">
2
+ <div class="clearfix">
3
+ <div class="left" data-hook="admin_product_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
+
16
+ <%= f.field_container :attachment do %>
17
+ <%= f.label :attachment, t(:attachment) %><br />
18
+ <%= f.file_field :attachment %>
19
+ <%= f.error_message_on :attachment %>
20
+ <% end %>
21
+ </div>
22
+ <div class="right" data-hook="admin_product_form_right">
23
+ <%= f.field_container :attachment_width do %>
24
+ <%= f.label :attachment_width, t(:attachment_width) %> <span class="required">*</span><br />
25
+ <%= f.text_field :attachment_width, :class => 'fullwidth title' %>
26
+ <%= f.error_message_on :attachment_width %>
27
+ <% end %>
28
+
29
+ <%= f.field_container :attachment_height do %>
30
+ <%= f.label :attachment_height, t(:attachment_height) %> <span class="required">*</span><br />
31
+ <%= f.text_field :attachment_height, :class => 'fullwidth title' %>
32
+ <%= f.error_message_on :attachment_height %>
33
+ <% end %>
34
+
35
+ <%= f.field_container :position do %>
36
+ <%= f.label :position, t(:position) %><br />
37
+ <%= f.text_field :position, :class => 'fullwidth title' %>
38
+ <%= f.error_message_on :position %>
39
+ <% end %>
40
+
41
+ <%= f.field_container :enabled do %>
42
+ <%= f.label :enabled, t(:enabled) %><br />
43
+ <%= f.check_box :enabled %>
44
+ <%= f.error_message_on :enabled %>
45
+ <% end %>
46
+ </div>
47
+ </div>
48
+ </div>
@@ -1,7 +1,6 @@
1
- <h1><%= t("banner.editing_banner") %></h1>
2
1
  <%= render :partial => 'spree/shared/error_messages', :locals => { :target => @banner } %>
3
2
 
4
- <%= semantic_form_for([:admin, @banner]) do |f| %>
5
- <%= render :partial => "form", :locals => { :f => f } %>
6
- <%= render :partial => 'spree/admin/shared/edit_resource_links' %>
7
- <% end %>
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,35 +1,29 @@
1
- <div class='toolbar'>
2
- <ul class='actions'>
3
- <li>
4
- <%= button_link_to t("banner.new_banner"), spree.new_admin_banner_path, :icon => 'add' %>
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
5
  </li>
6
6
  </ul>
7
7
  <br class="clear" />
8
8
  </div>
9
9
 
10
- <h1><%= t("banner.many") %></h1>
10
+ <h1><%= t(:listing_banners) %></h1>
11
11
 
12
- <table class="index sortable" data-hook data-sortable-link="<%= update_positions_admin_banners_url %>">
13
- <tr>
14
- <th><%= t("banner.category") %></th>
15
- <th><%= t("banner.position") %></th>
16
- <th><%= t("banner.enable") %></th>
17
- <th><%= t(:action) %></th>
18
- </tr>
19
- <tbody>
20
- <% @banners.each do |banner| %>
21
- <tr class="<%= cycle('even', 'odd') %>" id="<%= dom_id banner %>">
22
- <td>
23
- <span class="handle"></span>
24
- <%= banner.category %>
25
- </td>
26
- <td><%= banner.position %></td>
27
- <td><%= icon('tick') if banner.enabled %></td>
28
- <td>
29
- <%= link_to_edit banner %> &nbsp;
30
- <%= link_to_delete banner %>
31
- </td>
32
- </tr>
33
- <% end %>
34
- </tbody>
35
- </table>
12
+ <div id="new_banner" data-hook></div>
13
+
14
+ <table class="index" id="listing_banners">
15
+ <tr data-hook="admin_banners_index_headers">
16
+ <th><%= t(:category) %></th>
17
+ <th><%= t(:enable) %></th>
18
+ <th data-hook="admin_banners_index_header_actions"></th>
19
+ </tr>
20
+ <% @banners.each do |banner| %>
21
+ <tr id="<%= spree_dom_id banner %>" data-hook="admin_banners_index_rows">
22
+ <td><%= banner.category %></td>
23
+ <td><%= icon('tick') if banner.enabled %></td>
24
+ <td class="actions" data-hook="admin_banners_index_row_actions">
25
+ <%= link_to_edit banner, :class => 'edit' %>&nbsp;<%= link_to_delete banner %>
26
+ </td>
27
+ </tr>
28
+ <% end %>
29
+ </table>
@@ -4,4 +4,58 @@
4
4
  <%= semantic_form_for([:admin, @banner], :html => { :enctype => "multipart/form-data" }) do |f| %>
5
5
  <%= render :partial => "form", :locals => { :f => f } %>
6
6
  <%= render :partial => 'spree/admin/shared/new_resource_links' %>
7
+ <% end %>
8
+
9
+ <%= render :partial => 'spree/shared/error_messages', :locals => { :target => @banner } %>
10
+
11
+ <%= form_for [:admin, @banner], :html => { :multipart => true } do |f| %>
12
+ <fieldset data-hook="new_slideshow_type">
13
+ <div class="clearfix" data-hook="new_product_attrs">
14
+ <div class="left">
15
+ <%= f.field_container :category do %>
16
+ <%= f.label :category, t(:category) %> <span class="required">*</span><br />
17
+ <%= f.text_field :category, :class => 'fullwidth title' %>
18
+ <%= f.error_message_on :category %>
19
+ <% end %>
20
+
21
+ <%= f.field_container :url do %>
22
+ <%= f.label :url, t(:url) %><br />
23
+ <%= f.text_field :url, :class => 'fullwidth title' %>
24
+ <%= f.error_message_on :url %>
25
+ <% end %>
26
+
27
+ <%= f.field_container :attachment do %>
28
+ <%= f.label :attachment, t(:attachment) %><br />
29
+ <%= f.file_field :attachment %>
30
+ <%= f.error_message_on :attachment %>
31
+ <% end %>
32
+ </div>
33
+ <div class="right">
34
+ <%= f.field_container :attachment_width do %>
35
+ <%= f.label :attachment_width, t(:attachment_width) %> <span class="required">*</span><br />
36
+ <%= f.text_field :attachment_width, :class => 'fullwidth title' %>
37
+ <%= f.error_message_on :attachment_width %>
38
+ <% end %>
39
+
40
+ <%= f.field_container :attachment_height do %>
41
+ <%= f.label :attachment_height, t(:attachment_height) %> <span class="required">*</span><br />
42
+ <%= f.text_field :attachment_height, :class => 'fullwidth title' %>
43
+ <%= f.error_message_on :attachment_height %>
44
+ <% end %>
45
+
46
+ <%= f.field_container :position do %>
47
+ <%= f.label :position, t(:position) %><br />
48
+ <%= f.text_field :position, :class => 'fullwidth title' %>
49
+ <%= f.error_message_on :position %>
50
+ <% end %>
51
+
52
+ <%= f.field_container :enabled do %>
53
+ <%= f.label :enabled, t(:enabled) %><br />
54
+ <%= f.check_box :enabled %>
55
+ <%= f.error_message_on :enabled %>
56
+ <% end %>
57
+ </div>
58
+ </div>
59
+ <%= render :partial => 'spree/admin/shared/new_resource_links' %>
60
+ </fieldset>
7
61
  <% end %>
@@ -0,0 +1,2 @@
1
+ $("#new_banner").html('<%= escape_javascript(render :template => "spree/admin/banners/new", :formats => [:html], :handlers => [:erb]) %>');
2
+ $("#admin_new_banner").parent().hide();
@@ -59,21 +59,20 @@ en:
59
59
  one: Banner
60
60
  many: Banners
61
61
 
62
- banner:
63
- one: Banner
64
- many: Banners
65
- enable: Enable?
66
- enabled: Enable?
67
- category: Category
68
- no_image: No Image Yet
69
- attachment_width: Width image
70
- attachment_height: Height image
71
- position: Position (if there are other banners with the same category)
72
- url: Link to product or taxonomy or to external website
73
- image:
74
- one: Image
75
- many: Images
76
- banner_desc: Manage banner.
77
- new_banner: New banner
78
- editing_banner: Edit banner
79
- confirm_delete: Are you sure?
62
+ banner: "Banner"
63
+ banners: "Banners"
64
+ enable: Enable?
65
+ enabled: Enable?
66
+ category: Category
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?
@@ -59,21 +59,21 @@ it:
59
59
  one: Banner
60
60
  many: Banners
61
61
 
62
- banner:
63
- one: Banner
64
- many: Banners
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?
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?
@@ -10,7 +10,6 @@ class CreateBanners < ActiveRecord::Migration
10
10
  t.datetime :attachment_updated_at
11
11
  t.integer :attachment_width, :attachment_height, :default => 100
12
12
  t.integer :attachment_size
13
- t.string :type, :limit => 75
14
13
 
15
14
  t.timestamps
16
15
  end
@@ -2,15 +2,6 @@ module SpreeBanner
2
2
  module Generators
3
3
  class InstallGenerator < Rails::Generators::Base
4
4
 
5
- def add_formtastic
6
- res = ask "Would you like to run the formtastic install now? [Y/n]"
7
- if res == "" || res.downcase == "y"
8
- run 'rails generate formtastic:install'
9
- else
10
- puts "Skiping rails generate formtastic:install, don't forget to run it!"
11
- end
12
- end
13
-
14
5
  def add_stylesheets
15
6
  inject_into_file "app/assets/stylesheets/admin/all.css", " *= require admin/spree_banner\n", :before => /\*\//, :verbose => true
16
7
  inject_into_file "app/assets/stylesheets/store/all.css", " *= require store/spree_banner\n", :before => /\*\//, :verbose => true
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.1.2
4
+ version: 1.1.3
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-01-08 00:00:00.000000000 Z
12
+ date: 2013-01-22 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: spree_core
@@ -27,22 +27,6 @@ dependencies:
27
27
  - - ! '>='
28
28
  - !ruby/object:Gem::Version
29
29
  version: '0'
30
- - !ruby/object:Gem::Dependency
31
- name: formtastic
32
- requirement: !ruby/object:Gem::Requirement
33
- none: false
34
- requirements:
35
- - - ! '>='
36
- - !ruby/object:Gem::Version
37
- version: '0'
38
- type: :runtime
39
- prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ! '>='
44
- - !ruby/object:Gem::Version
45
- version: '0'
46
30
  - !ruby/object:Gem::Dependency
47
31
  name: paperclip
48
32
  requirement: !ruby/object:Gem::Requirement
@@ -114,6 +98,7 @@ files:
114
98
  - app/views/spree/admin/banners/edit.html.erb
115
99
  - app/views/spree/admin/banners/index.html.erb
116
100
  - app/views/spree/admin/banners/new.html.erb
101
+ - app/views/spree/admin/banners/new.js.erb
117
102
  - db/migrate/20120116204313_create_banners.rb
118
103
  - db/migrate/20120323174800_banner_namespace.rb
119
104
  - config/locales/en.yml