spree_banner 0.70.6 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- SpreeMultiSlideshow
1
+ SpreeBanner
2
2
  ===================
3
3
 
4
4
  Add banner for Spree Commerce Shop
@@ -9,7 +9,7 @@ Basic Installation
9
9
 
10
10
  1. Add the following to your Gemfile
11
11
  <pre>
12
- gem 'spree_banner', '~> 0.70.6'
12
+ gem 'spree_banner', :git => 'git://github.com/damianogiacomello/spree_banner'
13
13
  </pre>
14
14
  2. Run `bundle install`
15
15
  3. To copy and apply migrations run:
@@ -34,5 +34,13 @@ displays banner for which the category column, dafault is ""
34
34
  <%= insert_banner(:max => 10) %>
35
35
  </pre>
36
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(:style => "your_container") %>
43
+ </pre>
44
+ set banner container (default list[ul/li])
37
45
 
38
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
- }
@@ -0,0 +1,12 @@
1
+ module Spree
2
+ module Admin
3
+ class BannersController < ResourceController
4
+ before_filter :load_data
5
+
6
+
7
+ def load_data
8
+ @banners = Spree::Banner.all
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,27 @@
1
+ module Spree
2
+ module BannersHelper
3
+
4
+ def insert_banner(params={})
5
+ # max items show for list
6
+ max = params[:max] || 1
7
+ # category items show
8
+ category = params[:category] || ""
9
+ # class items show
10
+ cl = params[:class] || "banner"
11
+ # style items show
12
+ style = params[:style] || "list"
13
+ banner = Banner.enable(category).limit(max)
14
+ if !banner.blank?
15
+ banner = banner.sort_by { |ban| ban.position }
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) )
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)
21
+ end
22
+
23
+ end
24
+ end
25
+
26
+ end
27
+ end
@@ -0,0 +1,26 @@
1
+ module Spree
2
+ class Banner < ActiveRecord::Base
3
+
4
+ has_attached_file :attachment,
5
+ :url => "/spree/banner/:id/:style_:basename.:extension",
6
+ :path => ":rails_root/public/spree/banner/:id/:style_:basename.:extension",
7
+ #:default_url => "/missing/:style.jpg",
8
+ :styles => {
9
+ :thumbnail => "80x80#",
10
+ :custom => Proc.new { |instance| "#{instance.attachment_width}x#{instance.attachment_height}#" }
11
+ },
12
+ :convert_options => {
13
+ :thumbnail => "-gravity center"
14
+ }
15
+
16
+ #process_in_background :image UTILE MA OCCORRE ATTIVARE ANCHE LA GEMMA DELAYED-PAPERCLIP
17
+ scope :enable, lambda { |category| {:conditions => {:enabled => true, :category => category}} }
18
+
19
+ def initialize(*args)
20
+ super(*args)
21
+ last_banner = Banner.last
22
+ self.position = last_banner ? last_banner.position + 1 : 0
23
+ end
24
+
25
+ end
26
+ end
@@ -1,4 +1,5 @@
1
- Deface::Override.new(:virtual_path => "layouts/admin",
1
+ Deface::Override.new(:virtual_path => "spree/layouts/admin",
2
2
  :name => "banner_admin_tab",
3
- :insert_bottom => "[data-hook='admin_tabs']",
4
- :text => "<%= tab(:banners) %>")
3
+ :insert_bottom => "[data-hook='admin_tabs'], #admin_tabs[data-hook]",
4
+ :text => "<%= tab(:banners, :url => spree.admin_banners_path) %>",
5
+ :disabled => false)
@@ -0,0 +1,7 @@
1
+ <h1><%= t(:editing_banner) %></h1>
2
+ <%= render :partial => 'spree/shared/error_messages', :locals => { :target => @banner } %>
3
+
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 %>
@@ -1,24 +1,26 @@
1
1
  <div class='toolbar'>
2
- <ul class='actions'>
3
- <li id="new_product_link">
4
- <%= button_link_to t("banner.new_page"), new_admin_banner_url, {:icon => 'add'} %>
5
- </li>
6
- </ul>
7
- <br class='clear' />
2
+ <ul class='actions'>
3
+ <li>
4
+ <%= button_link_to t(:new_banner), spree.new_admin_banner_path, :icon => 'add' %>
5
+ </li>
6
+ </ul>
7
+ <br class="clear" />
8
8
  </div>
9
9
 
10
- <h1><%= t("banner.many") %></h1>
10
+ <h1><%= t(:banner) %></h1>
11
11
 
12
12
  <table class="index">
13
13
  <tr>
14
- <th><%= t("banner.category") %></th>
15
- <th><%= t("banner.enable") %></th>
16
- <th><%= t("action") %></th>
14
+ <th><%= t(:category) %></th>
15
+ <th><%= t(:position) %></th>
16
+ <th><%= t(:enable) %></th>
17
+ <th><%= t(:action) %></th>
17
18
  </tr>
18
19
  <tbody>
19
20
  <% @banners.each do |banner| %>
20
21
  <tr class="<%= cycle('even', 'odd') %>" id="<%= dom_id banner %>">
21
22
  <td><%= banner.category %></td>
23
+ <td><%= banner.position %></td>
22
24
  <td><%= icon('tick') if banner.enabled %></td>
23
25
  <td>
24
26
  <%= link_to_edit banner %> &nbsp;
@@ -0,0 +1,7 @@
1
+ <h1><%= t(:new_banner) %></h1>
2
+ <%= render :partial => 'spree/shared/error_messages', :locals => { :target => @banner } %>
3
+
4
+ <%= semantic_form_for([:admin, @banner], :html => { :enctype => "multipart/form-data" }) do |f| %>
5
+ <%= render :partial => "form", :locals => { :f => f } %>
6
+ <%= render :partial => 'spree/admin/shared/new_resource_links' %>
7
+ <% end %>
@@ -1,18 +1,8 @@
1
1
  module SpreeBanner
2
2
  module Generators
3
3
  class InstallGenerator < Rails::Generators::Base
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
-
4
+
14
5
  def add_stylesheets
15
- inject_into_file "app/assets/stylesheets/admin/all.css", " *= require admin/spree_banner\n", :before => /\*\//, :verbose => true
16
6
  inject_into_file "app/assets/stylesheets/store/all.css", " *= require store/spree_banner\n", :before => /\*\//, :verbose => true
17
7
  end
18
8
 
data/lib/spree_banner.rb CHANGED
@@ -1,3 +1,2 @@
1
1
  require 'spree_core'
2
- require 'formtastic'
3
2
  require 'spree_banner/engine'
metadata CHANGED
@@ -1,86 +1,103 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: spree_banner
3
- version: !ruby/object:Gem::Version
4
- version: 0.70.6
3
+ version: !ruby/object:Gem::Version
4
+ hash: 23
5
5
  prerelease:
6
+ segments:
7
+ - 1
8
+ - 0
9
+ - 0
10
+ version: 1.0.0
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Damiano Giacomello
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
- date: 2012-07-22 00:00:00.000000000 Z
13
- dependencies:
14
- - !ruby/object:Gem::Dependency
17
+
18
+ date: 2012-03-15 00:00:00 Z
19
+ dependencies:
20
+ - !ruby/object:Gem::Dependency
15
21
  name: spree_core
16
- requirement: !ruby/object:Gem::Requirement
22
+ prerelease: false
23
+ requirement: &id001 !ruby/object:Gem::Requirement
17
24
  none: false
18
- requirements:
19
- - - ! '>='
20
- - !ruby/object:Gem::Version
21
- version: '0'
25
+ requirements:
26
+ - - ">="
27
+ - !ruby/object:Gem::Version
28
+ hash: 3
29
+ segments:
30
+ - 0
31
+ version: "0"
22
32
  type: :runtime
33
+ version_requirements: *id001
34
+ - !ruby/object:Gem::Dependency
35
+ name: spree_auth
23
36
  prerelease: false
24
- version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
- requirements:
27
- - - ! '>='
28
- - !ruby/object:Gem::Version
29
- version: '0'
30
- - !ruby/object:Gem::Dependency
31
- name: formtastic
32
- requirement: !ruby/object:Gem::Requirement
37
+ requirement: &id002 !ruby/object:Gem::Requirement
33
38
  none: false
34
- requirements:
35
- - - ! '>='
36
- - !ruby/object:Gem::Version
37
- version: '0'
39
+ requirements:
40
+ - - ">="
41
+ - !ruby/object:Gem::Version
42
+ hash: 3
43
+ segments:
44
+ - 0
45
+ version: "0"
38
46
  type: :runtime
47
+ version_requirements: *id002
48
+ - !ruby/object:Gem::Dependency
49
+ name: formtastic
39
50
  prerelease: false
40
- version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
- requirements:
43
- - - ! '>='
44
- - !ruby/object:Gem::Version
45
- version: '0'
46
- - !ruby/object:Gem::Dependency
47
- name: paperclip
48
- requirement: !ruby/object:Gem::Requirement
51
+ requirement: &id003 !ruby/object:Gem::Requirement
49
52
  none: false
50
- requirements:
51
- - - ! '>='
52
- - !ruby/object:Gem::Version
53
- version: 2.5.0
53
+ requirements:
54
+ - - ">="
55
+ - !ruby/object:Gem::Version
56
+ hash: 3
57
+ segments:
58
+ - 0
59
+ version: "0"
54
60
  type: :runtime
61
+ version_requirements: *id003
62
+ - !ruby/object:Gem::Dependency
63
+ name: paperclip
55
64
  prerelease: false
56
- version_requirements: !ruby/object:Gem::Requirement
65
+ requirement: &id004 !ruby/object:Gem::Requirement
57
66
  none: false
58
- requirements:
59
- - - ! '>='
60
- - !ruby/object:Gem::Version
67
+ requirements:
68
+ - - ">="
69
+ - !ruby/object:Gem::Version
70
+ hash: 27
71
+ segments:
72
+ - 2
73
+ - 5
74
+ - 0
61
75
  version: 2.5.0
62
- - !ruby/object:Gem::Dependency
76
+ type: :runtime
77
+ version_requirements: *id004
78
+ - !ruby/object:Gem::Dependency
63
79
  name: rspec-rails
64
- requirement: !ruby/object:Gem::Requirement
65
- none: false
66
- requirements:
67
- - - ! '>='
68
- - !ruby/object:Gem::Version
69
- version: '0'
70
- type: :development
71
80
  prerelease: false
72
- version_requirements: !ruby/object:Gem::Requirement
81
+ requirement: &id005 !ruby/object:Gem::Requirement
73
82
  none: false
74
- requirements:
75
- - - ! '>='
76
- - !ruby/object:Gem::Version
77
- version: '0'
83
+ requirements:
84
+ - - ">="
85
+ - !ruby/object:Gem::Version
86
+ hash: 3
87
+ segments:
88
+ - 0
89
+ version: "0"
90
+ type: :development
91
+ version_requirements: *id005
78
92
  description:
79
93
  email: damiano.giacomello@diginess.it
80
94
  executables: []
95
+
81
96
  extensions: []
97
+
82
98
  extra_rdoc_files: []
83
- files:
99
+
100
+ files:
84
101
  - README.md
85
102
  - LICENSE
86
103
  - lib/generators/spree_banner/install/install_generator.rb
@@ -90,41 +107,48 @@ files:
90
107
  - app/assets/javascripts/store/spree_banner.js
91
108
  - app/assets/stylesheets/admin/spree_banner.css
92
109
  - app/assets/stylesheets/store/spree_banner.css
93
- - app/controllers/admin/banners_controller.rb
94
- - app/helpers/banners_helper.rb
95
- - app/models/banner.rb
110
+ - app/controllers/spree/admin/banners_controller.rb
111
+ - app/helpers/spree/banners_helper.rb
112
+ - app/models/spree/banner.rb
96
113
  - app/overrides/banner_admin_tab.rb
97
- - app/views/admin/banners/_form.html.erb
98
- - app/views/admin/banners/edit.html.erb
99
- - app/views/admin/banners/index.html.erb
100
- - app/views/admin/banners/new.html.erb
101
- - db/migrate/20120116204313_create_banners.rb
102
- - config/locales/en.yml
103
- - config/locales/it.yml
104
- - config/routes.rb
114
+ - app/views/spree/admin/banners/_form.html.erb
115
+ - app/views/spree/admin/banners/edit.html.erb
116
+ - app/views/spree/admin/banners/index.html.erb
117
+ - app/views/spree/admin/banners/new.html.erb
105
118
  homepage:
106
119
  licenses: []
120
+
107
121
  post_install_message:
108
122
  rdoc_options: []
109
- require_paths:
123
+
124
+ require_paths:
110
125
  - lib
111
- required_ruby_version: !ruby/object:Gem::Requirement
126
+ required_ruby_version: !ruby/object:Gem::Requirement
112
127
  none: false
113
- requirements:
114
- - - ! '>='
115
- - !ruby/object:Gem::Version
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ hash: 57
132
+ segments:
133
+ - 1
134
+ - 8
135
+ - 7
116
136
  version: 1.8.7
117
- required_rubygems_version: !ruby/object:Gem::Requirement
137
+ required_rubygems_version: !ruby/object:Gem::Requirement
118
138
  none: false
119
- requirements:
120
- - - ! '>='
121
- - !ruby/object:Gem::Version
122
- version: '0'
123
- requirements:
139
+ requirements:
140
+ - - ">="
141
+ - !ruby/object:Gem::Version
142
+ hash: 3
143
+ segments:
144
+ - 0
145
+ version: "0"
146
+ requirements:
124
147
  - none
125
148
  rubyforge_project:
126
- rubygems_version: 1.8.22
149
+ rubygems_version: 1.8.10
127
150
  signing_key:
128
151
  specification_version: 3
129
152
  summary: Extension to manage banner for you Spree Shop
130
153
  test_files: []
154
+
@@ -1,2 +0,0 @@
1
- class Admin::BannersController < Admin::ResourceController
2
- end
@@ -1,14 +0,0 @@
1
- module BannersHelper
2
-
3
- def insert_banner(params={})
4
- max = params[:max] || 1
5
- category = params[:category] || ""
6
- banner = Banner.enable(category).limit(max)
7
- if !banner.blank?
8
- banner = banner.sort_by { |ban| ban.position }
9
-
10
- content_tag(:div, content_tag(:ul, raw(banner.map do |ban| content_tag(:li, link_to(image_tag(ban.attachment.url(:custom)), ban.url) ) end.join) ), :class => "banner")
11
- end
12
- end
13
-
14
- end
data/app/models/banner.rb DELETED
@@ -1,40 +0,0 @@
1
- class Banner < ActiveRecord::Base
2
-
3
- attr_accessible :category, :url, :position, :attachment_width, :attachment_height, :enabled, :attachment
4
-
5
- has_attached_file :attachment,
6
- :url => "/spree/banner/:id/:style_:basename.:extension",
7
- :path => ":rails_root/public/spree/banner/:id/:style_:basename.:extension",
8
- #:default_url => "/missing/:style.jpg",
9
- :styles => {
10
- :thumbnail => "80x80#",
11
- :custom => Proc.new { |instance| "#{instance.attachment_width}x#{instance.attachment_height}#" }
12
- },
13
- :convert_options => {
14
- :thumbnail => "-gravity center",
15
- :custom => "-gravity center"
16
- }
17
-
18
-
19
- after_post_process :find_dimensions
20
- validates_presence_of :category, :attachment_width, :attachment_height
21
- validates_attachment_presence :attachment
22
- 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"
23
-
24
- scope :enable, lambda { |category| {:conditions => {:enabled => true, :category => category}} }
25
-
26
- def initialize(*args)
27
- super(*args)
28
- last_banner = Banner.last
29
- self.position = last_banner ? last_banner.position + 1 : 0
30
- end
31
-
32
- def find_dimensions
33
- temporary = attachment.queued_for_write[:original]
34
- filename = temporary.path unless temporary.nil?
35
- filename = attachment.path if filename.blank?
36
- geometry = Paperclip::Geometry.from_file(filename)
37
- self.attachment_width = geometry.width
38
- self.attachment_height = geometry.height
39
- end
40
- end
@@ -1,10 +0,0 @@
1
- <h1><%= t("banner.editing_page") %></h1>
2
- <%= render "shared/error_messages", :target => @banner %>
3
-
4
- <%= semantic_form_for([:admin, @banner]) do |f| %>
5
- <%= render :partial => "form", :locals => { :f => f } %>
6
- <p class="form-buttons">
7
- <%= button t("actions.create"), nil, 'submit' %>
8
- <%= t("or") %> <%= link_to t("actions.cancel"), admin_banners_path %>
9
- </p>
10
- <% end %>
@@ -1,10 +0,0 @@
1
- <h1><%= t("banner.new_page") %></h1>
2
- <%= render "shared/error_messages", :target => @banner %>
3
-
4
- <%= semantic_form_for([:admin, @banner], :html => { :enctype => "multipart/form-data" }) do |f| %>
5
- <%= render :partial => "form", :locals => { :f => f } %>
6
- <p class="form-buttons">
7
- <%= button t("actions.create"), nil, 'submit' %>
8
- <%= t("or") %> <%= link_to t("actions.cancel"), admin_banners_path %>
9
- </p>
10
- <% end %>
@@ -1,30 +0,0 @@
1
- ---
2
- it:
3
- activerecord:
4
- attributes:
5
- banner:
6
- category: Category
7
- enabled: Enable?
8
- url: Link to product or taxonomy or to external website
9
- attachment_width: Width
10
- attachment_height: Height
11
- attachment: Image
12
- position: Position (if there are other banners with the same category)
13
- models:
14
- banner:
15
- one: Banner
16
- many: Banners
17
-
18
- banner:
19
- one: Banner
20
- many: Banners
21
- enable: Enable?
22
- category: Category
23
- no_image: No Image Yet
24
- image:
25
- one: Image
26
- many: Images
27
- banner_desc: Manage banner.
28
- new_page: New banner
29
- editing_page: Edit banner
30
- confirm_delete: Are you sure?
@@ -1,30 +0,0 @@
1
- ---
2
- it:
3
- activerecord:
4
- attributes:
5
- banner:
6
- category: Categoria
7
- enabled: Attivo?
8
- url: Link a prodotto o tassonomia o a sito esterno
9
- attachment_width: Larghezza
10
- attachment_height: Altezza
11
- attachment: Immagine
12
- position: Posizione (se esistono altri banner con la stessa categoria)
13
- models:
14
- banner:
15
- one: Banner
16
- many: Banners
17
-
18
- banner:
19
- one: Banner
20
- many: Banners
21
- enable: Attivo?
22
- category: Categoria
23
- no_image: Nessuna immagine caricata
24
- image:
25
- one: Immagine
26
- many: Immagini
27
- banner_desc: Gestione banner.
28
- new_page: Nuovo banner
29
- editing_page: Modifica banner
30
- confirm_delete: Sei sicuro?
data/config/routes.rb DELETED
@@ -1,7 +0,0 @@
1
- Rails.application.routes.draw do
2
-
3
- namespace :admin do
4
- resources :banners
5
- end
6
-
7
- end
@@ -1,18 +0,0 @@
1
- class CreateBanners < ActiveRecord::Migration
2
- def change
3
- create_table :banners do |t|
4
- t.string :title, :url
5
- t.string :category
6
- t.integer :position
7
- t.boolean :enabled
8
-
9
- t.string :attachment_content_type, :attachment_file_name, :attachment_content_type
10
- t.datetime :attachment_updated_at
11
- t.integer :attachment_width, :attachment_height, :default => 100
12
- t.integer :attachment_size, :position
13
- t.string :type, :limit => 75
14
-
15
- t.timestamps
16
- end
17
- end
18
- end