spree_banner 0.70.3
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +26 -0
- data/README.md +38 -0
- data/app/assets/javascripts/admin/spree_banner.js +1 -0
- data/app/assets/javascripts/store/spree_banner.js +1 -0
- data/app/assets/stylesheets/admin/spree_banner.css +3 -0
- data/app/assets/stylesheets/store/spree_banner.css +26 -0
- data/app/controllers/admin/banners_controller.rb +2 -0
- data/app/helpers/banners_helper.rb +14 -0
- data/app/models/banner.rb +25 -0
- data/app/overrides/banner_admin_tab.rb +4 -0
- data/app/views/admin/banners/_form.html.erb +9 -0
- data/app/views/admin/banners/edit.html.erb +10 -0
- data/app/views/admin/banners/index.html.erb +30 -0
- data/app/views/admin/banners/new.html.erb +10 -0
- data/lib/generators/spree_banner/install/install_generator.rb +23 -0
- data/lib/spree_banner/engine.rb +24 -0
- data/lib/spree_banner.rb +2 -0
- metadata +154 -0
data/LICENSE
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
Copyright (c) 2012 [name of plugin creator]
|
2
|
+
All rights reserved.
|
3
|
+
|
4
|
+
Redistribution and use in source and binary forms, with or without modification,
|
5
|
+
are permitted provided that the following conditions are met:
|
6
|
+
|
7
|
+
* Redistributions of source code must retain the above copyright notice,
|
8
|
+
this list of conditions and the following disclaimer.
|
9
|
+
* Redistributions in binary form must reproduce the above copyright notice,
|
10
|
+
this list of conditions and the following disclaimer in the documentation
|
11
|
+
and/or other materials provided with the distribution.
|
12
|
+
* Neither the name Spree nor the names of its contributors may be used to
|
13
|
+
endorse or promote products derived from this software without specific
|
14
|
+
prior written permission.
|
15
|
+
|
16
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
17
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
18
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
19
|
+
A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
20
|
+
CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
21
|
+
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
22
|
+
PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
23
|
+
PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
24
|
+
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
25
|
+
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
26
|
+
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
data/README.md
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
SpreeMultiSlideshow
|
2
|
+
===================
|
3
|
+
|
4
|
+
Add banner for Spree Commerce Shop
|
5
|
+
|
6
|
+
|
7
|
+
Basic Installation
|
8
|
+
------------------
|
9
|
+
|
10
|
+
1. Add the following to your Gemfile
|
11
|
+
<pre>
|
12
|
+
gem 'spree_banner', :git => 'git://github.com/damianogiacomello/spree_banner'
|
13
|
+
</pre>
|
14
|
+
2. Run `bundle install`
|
15
|
+
3. To copy and apply migrations run:
|
16
|
+
<pre>
|
17
|
+
rails g spree_banner:install
|
18
|
+
</pre>
|
19
|
+
|
20
|
+
Example
|
21
|
+
=======
|
22
|
+
|
23
|
+
1. add banner helper method in your view:
|
24
|
+
<pre>
|
25
|
+
<%= insert_banner %>
|
26
|
+
</pre>
|
27
|
+
and add banner in the admin section
|
28
|
+
2. Additional options:
|
29
|
+
<pre>
|
30
|
+
<%= insert_banner(:category => "my_category") %>
|
31
|
+
</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
|
+
|
38
|
+
Copyright (c) 2012 [Damiano Giacomello], released under the New BSD License
|
@@ -0,0 +1 @@
|
|
1
|
+
//= require admin/spree_core
|
@@ -0,0 +1 @@
|
|
1
|
+
//= require store/spree_core
|
@@ -0,0 +1,26 @@
|
|
1
|
+
/*
|
2
|
+
*= require store/spree_core
|
3
|
+
*/
|
4
|
+
|
5
|
+
.banner {
|
6
|
+
background: none;
|
7
|
+
}
|
8
|
+
|
9
|
+
.banner ul {
|
10
|
+
margin: 0px;
|
11
|
+
padding: 0px;
|
12
|
+
list-style-type: none;
|
13
|
+
}
|
14
|
+
|
15
|
+
.banner ul li {
|
16
|
+
float: left;
|
17
|
+
background: none;
|
18
|
+
margin: 2px;
|
19
|
+
}
|
20
|
+
|
21
|
+
.banner img {
|
22
|
+
border: 0;
|
23
|
+
-webkit-box-shadow: 1px 2px 5px 0.6px #C1C5C8;
|
24
|
+
-moz-box-shadow: 1px 2px 5px 0.6px #C1C5C8;
|
25
|
+
box-shadow: 1px 2px 5px 0.6px #C1C5C8;
|
26
|
+
}
|
@@ -0,0 +1,14 @@
|
|
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
|
@@ -0,0 +1,25 @@
|
|
1
|
+
class Banner < ActiveRecord::Base
|
2
|
+
|
3
|
+
has_attached_file :attachment,
|
4
|
+
:url => "/spree/banner/:id/:style_:basename.:extension",
|
5
|
+
:path => ":rails_root/public/spree/banner/:id/:style_:basename.:extension",
|
6
|
+
#:default_url => "/missing/:style.jpg",
|
7
|
+
:styles => {
|
8
|
+
:thumbnail => "80x80#",
|
9
|
+
:custom => Proc.new { |instance| "#{instance.attachment_width}x#{instance.attachment_height}#" }
|
10
|
+
},
|
11
|
+
:convert_options => {
|
12
|
+
:thumbnail => "-gravity center",
|
13
|
+
:custom => "-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
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<%= f.inputs do %>
|
2
|
+
<%= f.input :category %>
|
3
|
+
<%= f.input :url %>
|
4
|
+
<%= f.input :position %>
|
5
|
+
<%= f.input :attachment_width %>
|
6
|
+
<%= f.input :attachment_height %>
|
7
|
+
<%= f.input :enabled %>
|
8
|
+
<%= f.input :attachment, :as => :file, :label => I18n.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 %>
|
@@ -0,0 +1,10 @@
|
|
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 %>
|
@@ -0,0 +1,30 @@
|
|
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' />
|
8
|
+
</div>
|
9
|
+
|
10
|
+
<h1><%= t("banner.many") %></h1>
|
11
|
+
|
12
|
+
<table class="index">
|
13
|
+
<tr>
|
14
|
+
<th><%= t("banner.category") %></th>
|
15
|
+
<th><%= t("banner.enable") %></th>
|
16
|
+
<th><%= t("action") %></th>
|
17
|
+
</tr>
|
18
|
+
<tbody>
|
19
|
+
<% @banners.each do |banner| %>
|
20
|
+
<tr class="<%= cycle('even', 'odd') %>" id="<%= dom_id banner %>">
|
21
|
+
<td><%= banner.category %></td>
|
22
|
+
<td><%= icon('tick') if banner.enabled %></td>
|
23
|
+
<td>
|
24
|
+
<%= link_to_edit banner %>
|
25
|
+
<%= link_to_delete banner %>
|
26
|
+
</td>
|
27
|
+
</tr>
|
28
|
+
<% end %>
|
29
|
+
</tbody>
|
30
|
+
</table>
|
@@ -0,0 +1,10 @@
|
|
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 %>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module SpreeBanner
|
2
|
+
module Generators
|
3
|
+
class InstallGenerator < Rails::Generators::Base
|
4
|
+
|
5
|
+
def add_stylesheets
|
6
|
+
inject_into_file "app/assets/stylesheets/store/all.css", " *= require store/spree_banner\n", :before => /\*\//, :verbose => true
|
7
|
+
end
|
8
|
+
|
9
|
+
def add_migrations
|
10
|
+
run 'bundle exec rake railties:install:migrations FROM=spree_banner'
|
11
|
+
end
|
12
|
+
|
13
|
+
def run_migrations
|
14
|
+
res = ask "Would you like to run the migrations now? [Y/n]"
|
15
|
+
if res == "" || res.downcase == "y"
|
16
|
+
run 'bundle exec rake db:migrate'
|
17
|
+
else
|
18
|
+
puts "Skiping rake db:migrate, don't forget to run it!"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module SpreeBanner
|
2
|
+
class Engine < Rails::Engine
|
3
|
+
engine_name 'spree_banner'
|
4
|
+
|
5
|
+
config.autoload_paths += %W(#{config.root}/lib)
|
6
|
+
|
7
|
+
# use rspec for tests
|
8
|
+
config.generators do |g|
|
9
|
+
g.test_framework :rspec
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.activate
|
13
|
+
Dir.glob(File.join(File.dirname(__FILE__), "../../app/**/*_decorator*.rb")) do |c|
|
14
|
+
Rails.application.config.cache_classes ? require(c) : load(c)
|
15
|
+
end
|
16
|
+
|
17
|
+
Dir.glob(File.join(File.dirname(__FILE__), "../../app/overrides/*.rb")) do |c|
|
18
|
+
Rails.application.config.cache_classes ? require(c) : load(c)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
config.to_prepare &method(:activate).to_proc
|
23
|
+
end
|
24
|
+
end
|
data/lib/spree_banner.rb
ADDED
metadata
ADDED
@@ -0,0 +1,154 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: spree_banner
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 257
|
5
|
+
prerelease:
|
6
|
+
segments:
|
7
|
+
- 0
|
8
|
+
- 70
|
9
|
+
- 3
|
10
|
+
version: 0.70.3
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Damiano Giacomello
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2012-03-15 00:00:00 Z
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: spree_core
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
none: false
|
25
|
+
requirements:
|
26
|
+
- - ">="
|
27
|
+
- !ruby/object:Gem::Version
|
28
|
+
hash: 3
|
29
|
+
segments:
|
30
|
+
- 0
|
31
|
+
version: "0"
|
32
|
+
type: :runtime
|
33
|
+
version_requirements: *id001
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
name: spree_auth
|
36
|
+
prerelease: false
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
38
|
+
none: false
|
39
|
+
requirements:
|
40
|
+
- - ">="
|
41
|
+
- !ruby/object:Gem::Version
|
42
|
+
hash: 3
|
43
|
+
segments:
|
44
|
+
- 0
|
45
|
+
version: "0"
|
46
|
+
type: :runtime
|
47
|
+
version_requirements: *id002
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: formtastic
|
50
|
+
prerelease: false
|
51
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
52
|
+
none: false
|
53
|
+
requirements:
|
54
|
+
- - ">="
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
hash: 3
|
57
|
+
segments:
|
58
|
+
- 0
|
59
|
+
version: "0"
|
60
|
+
type: :runtime
|
61
|
+
version_requirements: *id003
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: paperclip
|
64
|
+
prerelease: false
|
65
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ">="
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
hash: 27
|
71
|
+
segments:
|
72
|
+
- 2
|
73
|
+
- 5
|
74
|
+
- 0
|
75
|
+
version: 2.5.0
|
76
|
+
type: :runtime
|
77
|
+
version_requirements: *id004
|
78
|
+
- !ruby/object:Gem::Dependency
|
79
|
+
name: rspec-rails
|
80
|
+
prerelease: false
|
81
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
82
|
+
none: false
|
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
|
92
|
+
description:
|
93
|
+
email: damiano.giacomello@diginess.it
|
94
|
+
executables: []
|
95
|
+
|
96
|
+
extensions: []
|
97
|
+
|
98
|
+
extra_rdoc_files: []
|
99
|
+
|
100
|
+
files:
|
101
|
+
- README.md
|
102
|
+
- LICENSE
|
103
|
+
- lib/generators/spree_banner/install/install_generator.rb
|
104
|
+
- lib/spree_banner/engine.rb
|
105
|
+
- lib/spree_banner.rb
|
106
|
+
- app/assets/javascripts/admin/spree_banner.js
|
107
|
+
- app/assets/javascripts/store/spree_banner.js
|
108
|
+
- app/assets/stylesheets/admin/spree_banner.css
|
109
|
+
- app/assets/stylesheets/store/spree_banner.css
|
110
|
+
- app/controllers/admin/banners_controller.rb
|
111
|
+
- app/helpers/banners_helper.rb
|
112
|
+
- app/models/banner.rb
|
113
|
+
- app/overrides/banner_admin_tab.rb
|
114
|
+
- app/views/admin/banners/_form.html.erb
|
115
|
+
- app/views/admin/banners/edit.html.erb
|
116
|
+
- app/views/admin/banners/index.html.erb
|
117
|
+
- app/views/admin/banners/new.html.erb
|
118
|
+
homepage:
|
119
|
+
licenses: []
|
120
|
+
|
121
|
+
post_install_message:
|
122
|
+
rdoc_options: []
|
123
|
+
|
124
|
+
require_paths:
|
125
|
+
- lib
|
126
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
127
|
+
none: false
|
128
|
+
requirements:
|
129
|
+
- - ">="
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
hash: 57
|
132
|
+
segments:
|
133
|
+
- 1
|
134
|
+
- 8
|
135
|
+
- 7
|
136
|
+
version: 1.8.7
|
137
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
138
|
+
none: false
|
139
|
+
requirements:
|
140
|
+
- - ">="
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
hash: 3
|
143
|
+
segments:
|
144
|
+
- 0
|
145
|
+
version: "0"
|
146
|
+
requirements:
|
147
|
+
- none
|
148
|
+
rubyforge_project:
|
149
|
+
rubygems_version: 1.8.10
|
150
|
+
signing_key:
|
151
|
+
specification_version: 3
|
152
|
+
summary: Extension to manage banner for you Spree Shop
|
153
|
+
test_files: []
|
154
|
+
|