spree_home_page_features 1.2.2 → 1.2.3

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- spree_home_page_features (1.2.1)
4
+ spree_home_page_features (1.2.2)
5
5
  spree_core (~> 1.2)
6
6
 
7
7
  GEM
@@ -64,7 +64,7 @@ GEM
64
64
  xpath (~> 0.1.4)
65
65
  childprocess (0.3.5)
66
66
  ffi (~> 1.0, >= 1.0.6)
67
- cocaine (0.3.0)
67
+ cocaine (0.4.0)
68
68
  columnize (0.3.6)
69
69
  debugger (1.2.0)
70
70
  columnize (>= 0.3.1)
@@ -89,7 +89,7 @@ GEM
89
89
  multi_xml
90
90
  i18n (0.6.1)
91
91
  journey (1.0.4)
92
- jquery-rails (2.1.2)
92
+ jquery-rails (2.1.3)
93
93
  railties (>= 3.1.0, < 5.0)
94
94
  thor (~> 0.14)
95
95
  json (1.7.5)
@@ -112,7 +112,7 @@ GEM
112
112
  activerecord (>= 3.0.0)
113
113
  railties (>= 3.0.0)
114
114
  nokogiri (1.5.5)
115
- paperclip (2.7.0)
115
+ paperclip (2.8.0)
116
116
  activerecord (>= 2.3.0)
117
117
  activesupport (>= 2.3.2)
118
118
  cocaine (>= 0.0.2)
@@ -197,7 +197,7 @@ GEM
197
197
  stringex (1.3.3)
198
198
  thor (0.16.0)
199
199
  tilt (1.3.3)
200
- treetop (1.4.10)
200
+ treetop (1.4.11)
201
201
  polyglot
202
202
  polyglot (>= 0.3.1)
203
203
  tzinfo (0.3.33)
data/README.md CHANGED
@@ -1,21 +1,36 @@
1
- SpreeHomePageFeatures
2
- =====================
1
+ Spree Home Page Features
2
+ ========================
3
3
 
4
- Introduction goes here.
4
+ This adds a section to your spree home page where you can include 'features', which are basically news items.
5
5
 
6
6
 
7
- Example
8
- =======
7
+ Installation
8
+ ============
9
9
 
10
- Example goes here.
10
+ First add the reference to your gem file...
11
11
 
12
- Testing
13
- -------
12
+ # ./Gemfile
13
+ gem 'spree_home_page_features', '~> 1.2.2'
14
14
 
15
- Be sure to bundle your dependencies and then create a dummy test app for the specs to run against.
16
15
 
17
- $ bundle
18
- $ bundle exec rake test_app
19
- $ bundle exec rspec spec
16
+ Then from your console bundle it & install the migration...
20
17
 
21
- Copyright (c) 2012 [name of extension creator], released under the New BSD License
18
+ $ bundle install
19
+ $ bundle exec rake spree_home_page_features:install:migrations
20
+ $ bundle exec rake db:migrate
21
+
22
+
23
+ Styles
24
+ ======
25
+
26
+ When you create a feature in the backend, you have the option of setting a style. This will add the style as class to the feature div. I intended this to be used to allow the site administrator select a backdrop for the article they are writing. To set the available styles in the dropdown, simply add the list of styles you would like available to a decorator in your models directory...
27
+
28
+ # ./app/models/spree/home_page_feature_decorator.rb
29
+ Spree::HomePageFeature.styles = ["style1", "style2", "etc"]
30
+
31
+ You can then define a css file in your assets folder which define the styles...
32
+
33
+ # ./app/assets/stylesheets/store/home_page_feature_styles.css
34
+ li.feature.style1 { background-color: blue }
35
+ li.feature.style2 { background-color: green }
36
+ li.feature.etc { background-color: orange }
@@ -1,17 +1,32 @@
1
1
  module Spree
2
2
  class HomePageFeature < ActiveRecord::Base
3
3
  self.table_name = 'home_page_features'
4
- attr_accessible :title, :body, :publish, :style
4
+ attr_accessible :title, :body, :publish, :style, :image
5
5
 
6
6
  validates :title,
7
7
  presence: true,
8
8
  length: { minimum: 1 }
9
9
  validates :body,
10
10
  presence: true,
11
- length: { minimum: 1 }
11
+ length: { minimum: 1 },
12
+ unless: :image
13
+ validates_attachment_presence :image, unless: :body
12
14
 
13
15
  scope :published, where(publish: true)
14
16
 
17
+ has_attached_file :image,
18
+ :url => '/spree/home_page_features/:id/:style/:basename.:extension',
19
+ :path => ':rails_root/public/spree/home_page_features/:id/:style/:basename.:extension'
20
+
21
+ if Spree::Config[:use_s3]
22
+ s3_creds = { :access_key_id => Spree::Config[:s3_access_key], :secret_access_key => Spree::Config[:s3_secret], :bucket => Spree::Config[:s3_bucket] }
23
+ Spree::HomePageFeature.attachment_definitions[:image][:storage] = :s3
24
+ Spree::HomePageFeature.attachment_definitions[:image][:s3_credentials] = s3_creds
25
+ Spree::HomePageFeature.attachment_definitions[:image][:s3_headers] = ActiveSupport::JSON.decode(Spree::Config[:s3_headers])
26
+ Spree::HomePageFeature.attachment_definitions[:image][:bucket] = Spree::Config[:s3_bucket]
27
+ Spree::HomePageFeature.attachment_definitions[:image][:s3_protocol] = Spree::Config[:s3_protocol] unless Spree::Config[:s3_protocol].blank?
28
+ end
29
+
15
30
  class << self
16
31
  def styles
17
32
  @styles ||= []
@@ -8,6 +8,10 @@
8
8
  <%= f.label :body, t(:body, :scope => scope) %><br />
9
9
  <%= f.text_area :body %>
10
10
  <% end %>
11
+ <%= f.field_container :image do %>
12
+ <%= f.label :image, t(:image, :scope => scope) %><br />
13
+ <%= f.file_field :image %>
14
+ <% end %>
11
15
  <%= f.field_container :style do %>
12
16
  <%= f.label :style, t(:style, :scope => scope) %><br />
13
17
  <%= f.select :style, Spree::HomePageFeature.styles_dropdown %>
@@ -4,7 +4,7 @@
4
4
 
5
5
  <%= render :partial => 'spree/shared/error_messages', :locals => { :target => @home_page_feature } %>
6
6
 
7
- <%= form_for [:admin, @home_page_feature], url: spree.admin_home_page_feature_path(@home_page_feature) do |f| %>
7
+ <%= form_for [:admin, @home_page_feature], url: spree.admin_home_page_feature_path(@home_page_feature), html: { multipart: true } do |f| %>
8
8
  <%= render :partial => 'form', :locals => { :f => f } %>
9
9
  <%= render :partial => 'spree/admin/shared/edit_resource_links' %>
10
10
  <% end %>
@@ -4,7 +4,7 @@
4
4
 
5
5
  <%= render :partial => 'spree/shared/error_messages', :locals => { :target => @home_page_feature } %>
6
6
 
7
- <%= form_for [:admin, @home_page_feature], url: spree.admin_home_page_features_path do |f| %>
7
+ <%= form_for [:admin, @home_page_feature], url: spree.admin_home_page_features_path, html: { multipart: true } do |f| %>
8
8
  <%= render :partial => 'form', :locals => { :f => f } %>
9
9
  <%= render :partial => 'spree/admin/shared/new_resource_links', locals: { collection_url: spree.admin_home_page_features_path } %>
10
10
  <% end %>
@@ -2,10 +2,16 @@
2
2
  <ul class="slides">
3
3
  <% Spree::HomePageFeature.published.each do |feature| %>
4
4
  <li class="feature <%= feature.style? ? feature.style : "" %>">
5
- <div class="hero padded vertical-margin">
6
- <h4><%= feature.title %></h4>
7
- <div><%= feature.body %></div>
8
- </div>
5
+ <% if feature.image %>
6
+ <div class="feture-image-container">
7
+ <%= image_tag feature.image.url %>
8
+ </div>
9
+ <% else %>
10
+ <div class="hero padded vertical-margin">
11
+ <h4><%= feature.title %></h4>
12
+ <div><%= feature.body %></div>
13
+ </div>
14
+ <% end %>
9
15
  </li>
10
16
  <% end %>
11
17
  </ul>
@@ -0,0 +1,8 @@
1
+ class AddImageToHomePageFeatures < ActiveRecord::Migration
2
+ def change
3
+ add_column :home_page_features, :image_file_name, :string
4
+ add_column :home_page_features, :image_file_size, :integer
5
+ add_column :home_page_features, :image_content_type, :string
6
+ add_column :home_page_features, :image_updated_at, :datetime
7
+ end
8
+ end
@@ -2,7 +2,7 @@
2
2
  Gem::Specification.new do |s|
3
3
  s.platform = Gem::Platform::RUBY
4
4
  s.name = 'spree_home_page_features'
5
- s.version = '1.2.2'
5
+ s.version = '1.2.3'
6
6
  s.summary = 'Adds feature articles to the spree home page'
7
7
  s.description = 'Allows you to edit articles in the spree admin, which will be displayed on your homepage'
8
8
  s.required_ruby_version = '>= 1.9.2'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_home_page_features
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.2
4
+ version: 1.2.3
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-04 00:00:00.000000000Z
12
+ date: 2012-10-15 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: spree_core
16
- requirement: &70284200408480 !ruby/object:Gem::Requirement
16
+ requirement: !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ~>
@@ -21,21 +21,31 @@ dependencies:
21
21
  version: '1.2'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70284200408480
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: '1.2'
25
30
  - !ruby/object:Gem::Dependency
26
31
  name: capybara
27
- requirement: &70284200408020 !ruby/object:Gem::Requirement
32
+ requirement: !ruby/object:Gem::Requirement
28
33
  none: false
29
34
  requirements:
30
- - - =
35
+ - - '='
31
36
  - !ruby/object:Gem::Version
32
37
  version: 1.0.1
33
38
  type: :development
34
39
  prerelease: false
35
- version_requirements: *70284200408020
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - '='
44
+ - !ruby/object:Gem::Version
45
+ version: 1.0.1
36
46
  - !ruby/object:Gem::Dependency
37
47
  name: factory_girl
38
- requirement: &70284200407560 !ruby/object:Gem::Requirement
48
+ requirement: !ruby/object:Gem::Requirement
39
49
  none: false
40
50
  requirements:
41
51
  - - ~>
@@ -43,10 +53,15 @@ dependencies:
43
53
  version: 2.6.4
44
54
  type: :development
45
55
  prerelease: false
46
- version_requirements: *70284200407560
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ~>
60
+ - !ruby/object:Gem::Version
61
+ version: 2.6.4
47
62
  - !ruby/object:Gem::Dependency
48
63
  name: ffaker
49
- requirement: &70284200407180 !ruby/object:Gem::Requirement
64
+ requirement: !ruby/object:Gem::Requirement
50
65
  none: false
51
66
  requirements:
52
67
  - - ! '>='
@@ -54,10 +69,15 @@ dependencies:
54
69
  version: '0'
55
70
  type: :development
56
71
  prerelease: false
57
- version_requirements: *70284200407180
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
58
78
  - !ruby/object:Gem::Dependency
59
79
  name: rspec-rails
60
- requirement: &70284200406640 !ruby/object:Gem::Requirement
80
+ requirement: !ruby/object:Gem::Requirement
61
81
  none: false
62
82
  requirements:
63
83
  - - ~>
@@ -65,10 +85,15 @@ dependencies:
65
85
  version: '2.9'
66
86
  type: :development
67
87
  prerelease: false
68
- version_requirements: *70284200406640
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ~>
92
+ - !ruby/object:Gem::Version
93
+ version: '2.9'
69
94
  - !ruby/object:Gem::Dependency
70
95
  name: sqlite3
71
- requirement: &70284200406220 !ruby/object:Gem::Requirement
96
+ requirement: !ruby/object:Gem::Requirement
72
97
  none: false
73
98
  requirements:
74
99
  - - ! '>='
@@ -76,7 +101,12 @@ dependencies:
76
101
  version: '0'
77
102
  type: :development
78
103
  prerelease: false
79
- version_requirements: *70284200406220
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
80
110
  description: Allows you to edit articles in the spree admin, which will be displayed
81
111
  on your homepage
82
112
  email: robertoles@me.com
@@ -110,6 +140,7 @@ files:
110
140
  - config/locales/hu.yml
111
141
  - config/routes.rb
112
142
  - db/migrate/20120711073050_create_home_page_features.rb
143
+ - db/migrate/20121015104853_add_image_to_home_page_features.rb
113
144
  - lib/assets/images/bg_direction_nav.png
114
145
  - lib/assets/javascripts/jquery.flexslider-min.js
115
146
  - lib/assets/stylesheets/flexslider.css
@@ -140,7 +171,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
140
171
  requirements:
141
172
  - none
142
173
  rubyforge_project:
143
- rubygems_version: 1.8.11
174
+ rubygems_version: 1.8.24
144
175
  signing_key:
145
176
  specification_version: 3
146
177
  summary: Adds feature articles to the spree home page