spree_multi_slideshow 1.1.3 → 1.1.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (32) hide show
  1. data/README.md +1 -1
  2. data/app/assets/javascripts/admin/slide_settings.js +31 -0
  3. data/app/assets/javascripts/admin/spree_multi_slideshow.js +1 -2
  4. data/app/assets/stylesheets/store/spree_multi_slideshow.css +0 -4
  5. data/app/controllers/spree/admin/slide_settings_controller.rb +51 -0
  6. data/app/controllers/spree/admin/slides_controller.rb +2 -4
  7. data/app/helpers/spree/slideshow_types_helper.rb +5 -4
  8. data/app/models/spree/app_configuration_decorator.rb +8 -0
  9. data/app/models/spree/slide.rb +45 -26
  10. data/app/models/spree/slideshow_type.rb +4 -5
  11. data/app/overrides/slideshow_type_admin_tab.rb +6 -1
  12. data/app/views/spree/admin/shared/_slide_setting_configurations_menu.html.erb +4 -0
  13. data/app/views/spree/admin/shared/_slideshow_type_tabs.html.erb +1 -1
  14. data/app/views/spree/admin/slide_settings/edit.html.erb +48 -0
  15. data/app/views/spree/admin/slide_settings/show.html.erb +10 -0
  16. data/app/views/spree/admin/slides/_form.html.erb +22 -9
  17. data/app/views/spree/admin/slides/edit.html.erb +2 -2
  18. data/app/views/spree/admin/slides/index.html.erb +2 -2
  19. data/app/views/spree/admin/slideshow_types/_form.html.erb +3 -21
  20. data/app/views/spree/admin/slideshow_types/edit.html.erb +1 -1
  21. data/app/views/spree/admin/slideshow_types/index.html.erb +2 -2
  22. data/app/views/spree/admin/slideshow_types/new.html.erb +4 -22
  23. data/app/views/spree/admin/slideshow_types/new.js.erb +1 -1
  24. data/config/routes.rb +1 -0
  25. data/db/migrate/20120116081431_create_slideshow_types.rb +0 -3
  26. data/db/migrate/20120116083546_create_slides.rb +0 -1
  27. data/db/migrate/20130226082756_add_enable_to_slide.rb +8 -0
  28. data/lib/generators/spree_multi_slideshow/install/install_generator.rb +2 -13
  29. data/lib/spree_multi_slideshow.rb +0 -2
  30. metadata +11 -38
  31. data/app/assets/stylesheets/admin/spree_multi_slideshow.css +0 -17
  32. data/app/helpers/spree/slides_helper.rb +0 -4
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_multi_slideshow', '~> 1.1.3'
12
+ gem 'spree_multi_slideshow', '~> 1.1.4'
13
13
  </pre>
14
14
  2. Run `bundle install`
15
15
  3. To copy and apply migrations run:
@@ -0,0 +1,31 @@
1
+ $(document).ready(function() {
2
+
3
+ $('.destroy_slide_style').on("click", function() {
4
+ $(this).parent().remove();
5
+ });
6
+
7
+ // Handle adding new styles
8
+ var styles_hash_index = 1;
9
+ $('.add_slide_style').click(function() {
10
+ $('#styles_list').append(generate_html_for_hash("new_slide_styles", styles_hash_index));
11
+ });
12
+
13
+ // Generates html for new paperclip styles form fields
14
+ generate_html_for_hash = function(hash_name, index) {
15
+ var html = '<li>';
16
+ html += '<label for="' + hash_name + '_' + index + '_name">';
17
+ html += 'Name</label>';
18
+ html += '<input id="' + hash_name + '_' + index + '_name" name="' + hash_name + '[' + index + '][name]" type="text">';
19
+ html += '<label for="' + hash_name + '_' + index + '_value">';
20
+ html += 'Value</label>';
21
+ html += '<input id="' + hash_name + '_' + index + '_value" name="' + hash_name + '[' + index + '][value]" type="text">';
22
+ html += '<a href="#" alt="Destroy" class="destroy_style">&nbsp;x</a>';
23
+ html += '</li>';
24
+
25
+ index += 1;
26
+ return html;
27
+ };
28
+
29
+
30
+
31
+ });
@@ -1,2 +1 @@
1
- //= require admin/spree_core
2
- //= require ckeditor/init
1
+ //= require admin/slide_settings
@@ -1,7 +1,3 @@
1
- /*
2
- *= require store/spree_core
3
- */
4
-
5
1
  #slides {
6
2
  margin-bottom: 25px;
7
3
  }
@@ -0,0 +1,51 @@
1
+ module Spree
2
+ module Admin
3
+ class SlideSettingsController < Spree::Admin::BaseController
4
+ def show
5
+ styles = ActiveSupport::JSON.decode(Spree::Config[:slide_styles])
6
+ @styles_list = styles.collect { |k, v| k }.join(", ")
7
+ end
8
+
9
+ def edit
10
+ @styles = ActiveSupport::JSON.decode(Spree::Config[:slide_styles])
11
+ @headers = ActiveSupport::JSON.decode(Spree::Config[:s3_headers])
12
+ end
13
+
14
+ def update
15
+ update_styles(params)
16
+
17
+ Spree::Config.set(params[:preferences])
18
+ update_paperclip_settings
19
+
20
+ respond_to do |format|
21
+ format.html {
22
+ flash[:notice] = t(:slide_settings_updated)
23
+ redirect_to admin_slide_settings_path
24
+ }
25
+ end
26
+ end
27
+
28
+
29
+ private
30
+
31
+ def update_styles(params)
32
+ params[:new_slide_styles].each do |index, style|
33
+ params[:slide_styles][style[:name]] = style[:value] unless style[:value].empty?
34
+ end if params[:new_slide_styles].present?
35
+
36
+ styles = params[:slide_styles]
37
+
38
+ Spree::Config[:slide_styles] = ActiveSupport::JSON.encode(styles) unless styles.nil?
39
+ end
40
+
41
+ def update_paperclip_settings
42
+
43
+ Spree::Slide.attachment_definitions[:attachment][:styles] = ActiveSupport::JSON.decode(Spree::Config[:slide_styles])
44
+ Spree::Slide.attachment_definitions[:attachment][:path] = Spree::Config[:slide_path]
45
+ Spree::Slide.attachment_definitions[:attachment][:default_url] = Spree::Config[:slide_default_url]
46
+ Spree::Slide.attachment_definitions[:attachment][:default_style] = Spree::Config[:slide_default_style]
47
+ end
48
+ end
49
+ end
50
+ end
51
+
@@ -5,24 +5,22 @@ module Spree
5
5
 
6
6
  def update_positions
7
7
  params[:positions].each do |id, index|
8
- Spree::Slide.update_all(['position=?', index], ['id=?', id])
8
+ Spree::Slide.where(:id => id).update_all(:position => index)
9
9
  end
10
10
 
11
11
  respond_to do |format|
12
- format.html { redirect_to admin_slideshow_type_slides_url(@slideshow_type) }
13
12
  format.js { render :text => 'Ok' }
14
13
  end
15
14
  end
16
15
 
17
16
  protected
18
17
  def location_after_save
19
- edit_admin_slideshow_type_url(@slideshow_type)
18
+ admin_slideshow_type_slides_url(@slideshow_type)
20
19
  end
21
20
 
22
21
  def load_data
23
22
  @slideshow_type = Spree::SlideshowType.find(params[:slideshow_type_id])
24
23
  end
25
-
26
24
  end
27
25
  end
28
26
  end
@@ -7,7 +7,8 @@ module Spree
7
7
  params[:id] ||= "slides"
8
8
  params[:class] ||= "my_slide"
9
9
  params[:category] ||= "home"
10
- @@slideshow = Spree::SlideshowType.enable.find_by_category(params[:category])
10
+ logger.info("#{params[:category]}")
11
+ @@slideshow = Spree::SlideshowType.enable(params[:category]).try(:first)
11
12
  if @@slideshow.blank? || (!@@slideshow.blank? && @@slideshow.slides.empty?)
12
13
  return ''
13
14
  end
@@ -33,10 +34,10 @@ module Spree
33
34
  end
34
35
 
35
36
  def slide_images(params, slideshow)
36
- params[:style] ||= "custom"
37
+ params[:style] ||= "medium"
37
38
  params[:show_content] ||= false
38
- max = slideshow.slide_number || slideshow.slides.count
39
- slides = slideshow.slides.limit(max).sort_by { |slide| slide.position }
39
+ max = slideshow.slides.enable.count
40
+ slides = slideshow.slides.enable.limit(max).sort_by { |slide| slide.position }
40
41
 
41
42
  slides.map do |slide|
42
43
  content_tag(:div, :class => "slide_list") do
@@ -0,0 +1,8 @@
1
+ Spree::AppConfiguration.class_eval do
2
+ # Preferences related to slide settings
3
+ preference :slide_default_url, :string, :default => '/spree/slides/:id/:style/:basename.:extension'
4
+ preference :slide_path, :string, :default => ':rails_root/public/spree/slides/:id/:style/:basename.:extension'
5
+ preference :slide_url, :string, :default => '/spree/slides/:id/:style/:basename.:extension'
6
+ preference :slide_styles, :string, :default => "{\"mini\":\"100x33#\",\"small\":\"300x100#\",\"medium\":\"600x200#\",\"large\":\"900x300#\"}"
7
+ preference :slide_default_style, :string, :default => 'medium'
8
+ end
@@ -1,27 +1,28 @@
1
1
  module Spree
2
2
  class Slide < ActiveRecord::Base
3
3
  belongs_to :slideshow_type
4
+ validate :no_attachment_errors
4
5
 
5
6
  attr_accessor :attachment_width, :attachment_height
6
- attr_accessible :title, :url, :attachment_width, :attachment_height, :content, :slideshow_type_id, :attachment
7
+ attr_accessible :title, :url, :attachment_width, :attachment_height, :content, :slideshow_type_id, :attachment, :enable
7
8
 
8
9
  has_attached_file :attachment,
9
10
  :url => "/spree/slides/:id/:style_:basename.:extension",
10
11
  :path => ":rails_root/public/spree/slides/:id/:style_:basename.:extension",
11
12
  :styles => lambda {|a|
12
13
  {
13
- :thumbnail => "100x33#",
14
+ :mini => "100x33#",
14
15
  :small => "300x100#",
15
16
  :medium => "600x200#",
16
- :slide => "900x300#",
17
+ :large => "900x300#",
17
18
  :custom => "#{a.instance.attachment_width}x#{a.instance.attachment_height}#"
18
19
  }
19
20
  },
20
21
  :convert_options => {
21
- :thumbnail => "-gravity center",
22
+ :mini => "-gravity center",
22
23
  :small => "-gravity center",
23
24
  :medium => "-gravity center",
24
- :slide => "-gravity center",
25
+ :large => "-gravity center",
25
26
  :custom => "-gravity center"
26
27
  }
27
28
 
@@ -30,33 +31,51 @@ module Spree
30
31
  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"
31
32
 
32
33
  default_scope order("position ASC")
34
+ scope :enable, {:conditions => {:enabled => true}}
35
+ after_post_process :find_dimensions
33
36
 
34
- # Load S3 settings
35
- if ( FileTest.exist?(Rails.root.join('config', 's3.yml')) && !YAML.load_file(Rails.root.join('config', 's3.yml'))[Rails.env].blank?)
36
- S3_OPTIONS = {
37
- :storage => 's3',
38
- :s3_credentials => Rails.root.join('config', 's3.yml')
39
- }
40
- elsif (FileTest.exist?(Rails.root.join('config', 's3.yml')) &&!ENV['S3_KEY'].blank? && !ENV['S3_SECRET'].blank? && !ENV['S3_BUCKET'].blank?)
41
- S3_OPTIONS = {
42
- :storage => 's3',
43
- :s3_credentials => {
44
- :access_key_id => ENV['S3_KEY'],
45
- :secret_access_key => ENV['S3_SECRET']
46
- },
47
- :bucket => ENV['S3_BUCKET']
48
- }
49
- else
50
- S3_OPTIONS = { :storage => 'filesystem' }
37
+ # Load user defined paperclip settings
38
+ if Spree::Config[:use_s3]
39
+ s3_creds = { :access_key_id => Spree::Config[:s3_access_key], :secret_access_key => Spree::Config[:s3_secret], :bucket => Spree::Config[:s3_bucket] }
40
+ Spree::Slide.attachment_definitions[:attachment][:storage] = :s3
41
+ Spree::Slide.attachment_definitions[:attachment][:s3_credentials] = s3_creds
42
+ Spree::Slide.attachment_definitions[:attachment][:s3_headers] = ActiveSupport::JSON.decode(Spree::Config[:s3_headers])
43
+ Spree::Slide.attachment_definitions[:attachment][:bucket] = Spree::Config[:s3_bucket]
44
+ Spree::Slide.attachment_definitions[:attachment][:s3_protocol] = Spree::Config[:s3_protocol] unless Spree::Config[:s3_protocol].blank?
45
+ Spree::Slide.attachment_definitions[:attachment][:s3_host_alias] = Spree::Config[:s3_host_alias] unless Spree::Config[:s3_host_alias].blank?
51
46
  end
52
-
53
- attachment_definitions[:attachment] = (attachment_definitions[:attachment] || {}).merge(S3_OPTIONS)
47
+
48
+ Spree::Slide.attachment_definitions[:attachment][:styles] = ActiveSupport::JSON.decode(Spree::Config[:slide_styles])
49
+ Spree::Slide.attachment_definitions[:attachment][:path] = Spree::Config[:slide_path]
50
+ Spree::Slide.attachment_definitions[:attachment][:url] = Spree::Config[:slide_url]
51
+ Spree::Slide.attachment_definitions[:attachment][:default_url] = Spree::Config[:slide_default_url]
52
+ Spree::Slide.attachment_definitions[:attachment][:default_style] = Spree::Config[:slide_default_style]
54
53
 
55
54
  def initialize(*args)
56
55
  super(*args)
57
- last_slide = Slide.last
56
+ last_slide = Spree::Slide.last
58
57
  self.position = last_slide ? last_slide.position + 1 : 0
59
58
  end
60
-
59
+
60
+ def find_dimensions
61
+ if self.attachment_width.blank? && self.attachment_height.blank?
62
+ temporary = attachment.queued_for_write[:original]
63
+ filename = temporary.path unless temporary.nil?
64
+ filename = attachment.path if filename.blank?
65
+ geometry = Paperclip::Geometry.from_file(filename)
66
+ self.attachment_width = geometry.width
67
+ self.attachment_height = geometry.height
68
+ end
69
+ end
70
+
71
+ # if there are errors from the plugin, then add a more meaningful message
72
+ def no_attachment_errors
73
+ unless attachment.errors.empty?
74
+ # uncomment this to get rid of the less-than-useful interrim messages
75
+ # errors.clear
76
+ errors.add :attachment, "Paperclip returned errors for file '#{attachment_file_name}' - check ImageMagick installation or image source file."
77
+ false
78
+ end
79
+ end
61
80
  end
62
81
  end
@@ -2,12 +2,11 @@ module Spree
2
2
  class SlideshowType < ActiveRecord::Base
3
3
  has_many :slides
4
4
 
5
- attr_accessible :category, :slide_width, :slide_height, :slide_number, :enable_navigation, :enabled, :enable_pagination
5
+ attr_accessible :category, :enable_navigation, :enabled, :enable_pagination
6
6
 
7
- validates :slide_number, :slide_width, :slide_height, :presence => true
7
+ validates :category, :presence => true
8
8
  validates_uniqueness_of :category
9
- validates_numericality_of :slide_number, :only_integer => true
10
-
11
- scope :enable, where("enabled IS NOT NULL AND enabled = 1")
9
+
10
+ scope :enable, lambda { |category| {:conditions => {:enabled => true, :category => category}} }
12
11
  end
13
12
  end
@@ -1,4 +1,9 @@
1
1
  Deface::Override.new(:virtual_path => "spree/layouts/admin",
2
2
  :name => "slideshow_type_admin_tab",
3
3
  :insert_bottom => "[data-hook='admin_tabs']",
4
- :text => "<%= tab(:slideshow_types) %>")
4
+ :text => "<%= tab(:slideshow_types) %>")
5
+
6
+ Deface::Override.new(:virtual_path => "spree/admin/configurations/index",
7
+ :name => "add_slide_setting_to_configuration_menu",
8
+ :insert_bottom => "[data-hook='admin_configurations_menu']",
9
+ :partial => "spree/admin/shared/slide_setting_configurations_menu")
@@ -0,0 +1,4 @@
1
+ <tr>
2
+ <td><%= link_to t(:slide_settings), admin_slide_settings_path %></td>
3
+ <td><%= t(:slide_settings_description) %></td>
4
+ </tr>
@@ -9,7 +9,7 @@
9
9
  <li<%== ' class="active"' if current == 'Slideshow_type Details' %>>
10
10
  <%= link_to t(:slideshow_type_details), edit_admin_slideshow_type_url(@slideshow_type) %>
11
11
  </li>
12
- <li<%== ' class="active"' if current == 'Slide Images' %>>
12
+ <li<%== ' class="active"' if current == 'Slides' %>>
13
13
  <%= link_to t(:slides), admin_slideshow_type_slides_path(@slideshow_type) %>
14
14
  </li>
15
15
  </ul>
@@ -0,0 +1,48 @@
1
+ <%= render :partial => 'spree/admin/shared/configuration_menu' %>
2
+
3
+ <h1><%= t(:slide_settings) %></h1>
4
+
5
+ <p><span class="warning"><%= t(:slide_settings_warning) %></span></p>
6
+
7
+ <%= form_tag admin_slide_settings_path, :method => :put do %>
8
+
9
+ <p data-hook="slide_path">
10
+ <label>
11
+ <%= label_tag 'preferences[slide_path]', t(:slide_path) %>
12
+ <%= preference_field_tag 'preferences[slide_path]', Spree::Config[:slide_path], :type => :string %>
13
+ </label>
14
+ </p>
15
+
16
+ <p data-hook="slide_default_url">
17
+ <label>
18
+ <%= label_tag 'preferences[slide_default_url]', t(:slide_default_url) %>
19
+ <%= preference_field_tag 'preferences[slide_default_url]', Spree::Config[:slide_default_url], :type => :string %>
20
+ </label>
21
+ </p>
22
+
23
+ <p data-hook="slide_default_style">
24
+ <label>
25
+ <%= label_tag 'preferences[slide_default_style]', t(:slide_default_style) %>
26
+ <%= collection_select 'preferences', 'slide_default_style', @styles, :first, :first, {:selected => Spree::Config[:slide_default_style] } %>
27
+ </label>
28
+ </p>
29
+
30
+ <div id="slide_styles" data-hook="slide_styles">
31
+ <h2><%= t(:slide_styles) %></h2>
32
+ <ul id="styles_list">
33
+ <% @styles.each do |style_name, style_value| %>
34
+ <li>
35
+ <%= label_tag "slide_styles[#{style_name}]", style_name %>
36
+ <%= text_field_tag "slide_styles[#{style_name}]", style_value %>
37
+ <a href="#" alt="Destroy" class="destroy_slide_style">x</a>
38
+ </li>
39
+ <% end %>
40
+ </ul>
41
+ <p><a href="#" alt="Add Style" class="add_slide_style"><%= t(:add_new_style) %></a></p>
42
+ </div>
43
+
44
+ <p class="form-buttons" data-hook="buttons">
45
+ <%= button t(:update) %>
46
+ </p>
47
+
48
+ <% end %>
@@ -0,0 +1,10 @@
1
+ <%= render :partial => 'spree/admin/shared/configuration_menu' %>
2
+
3
+ <h1><%= t(:slide_settings) %></h1>
4
+
5
+ <h4><%= t(:slide_path) %>: <%= Spree::Config[:slide_path] %></h4>
6
+ <h4><%= t(:slide_default_url) %>: <%= Spree::Config[:slide_default_url] %></h4>
7
+ <h4><%= t(:slide_default_style) %>: <%= Spree::Config[:slide_default_style] %></h4>
8
+ <h4><%= t(:defined_paperclip_styles) %>: <%= @styles_list %></h4>
9
+
10
+ <%= link_to_with_icon 'edit', t(:edit), edit_admin_slide_settings_path, :id => 'admin_slide_settings_link' %>
@@ -1,9 +1,22 @@
1
- <%= f.inputs do %>
2
- <%= f.input :title %>
3
- <%= f.input :url %>
4
- <%= f.input :attachment_width, :input_html => { :value => @slideshow_type.slide_width}, :as => :hidden %>
5
- <%= f.input :attachment_height, :input_html => { :value => @slideshow_type.slide_height}, :as => :hidden %>
6
- <%= f.cktext_area :content, :input_html => { :value => @slide.content }, :label => t("slideshow_type.slide.content") %>
7
- <%= f.input :attachment, :as => :file, :label => I18n.t("slideshow_type.slide.image.one").capitalize, :hint => f.object.attachment.blank? ? f.template.content_tag(:span, "No Image Yet") : f.template.image_tag(f.object.attachment.url(:thumbnail)) %>
8
- <%= f.input :slideshow_type_id, :as => :hidden, :value => params[:slideshow_type_id] %>
9
- <% end %>
1
+ <div data-hook="admin_slide_form_fields">
2
+ <tr data-hook="file">
3
+ <td><%= t(:filename) %>:</td>
4
+ <td><%= f.file_field :attachment %></td>
5
+ </tr>
6
+ <tr data-hook="title">
7
+ <td><%= t(:title) %>:</td>
8
+ <td><%= f.text_field :title %></td>
9
+ </tr>
10
+ <tr data-hook="url">
11
+ <td><%= t(:url) %>:</td>
12
+ <td><%= f.text_field :url %></td>
13
+ </tr>
14
+ <tr data-hook="content">
15
+ <td><%= t(:content) %>:</td>
16
+ <td><%= f.text_area :content %></td>
17
+ </tr>
18
+ <tr data-hook="enable">
19
+ <td><%= t(:enable) %>:</td>
20
+ <td><%= f.check_box :enable %></td>
21
+ </tr>
22
+ </div>
@@ -1,5 +1,5 @@
1
- <%= render :partial => 'spree/admin/shared/slideshow_type_tabs', :locals => {:current => 'Slide Image'} %>
2
- <h1><%= t("slideshow_type.slide.editing_page") %></h1>
1
+ <%= render :partial => 'spree/admin/shared/slideshow_type_tabs', :locals => {:current => 'Slides'} %>
2
+
3
3
  <%= render 'spree/shared/error_messages', :target => @slide %>
4
4
 
5
5
  <%= form_for [:admin, @slideshow_type, @slide], :html => { :multipart => true } do |f| %>
@@ -1,4 +1,4 @@
1
- <%= render :partial => 'spree/admin/shared/slideshow_type_tabs', :locals => {:current => 'Slide Images'} %>
1
+ <%= render :partial => 'spree/admin/shared/slideshow_type_tabs', :locals => {:current => 'Slides'} %>
2
2
 
3
3
  <table class="index sortable" data-hook="slide_table" data-sortable-link="<%= update_positions_admin_slideshow_type_slides_url(@slideshow_type) %>">
4
4
  <tr data-hook="images_header">
@@ -13,7 +13,7 @@
13
13
  <tr id="<%= spree_dom_id slide %>" data-hook="images_row">
14
14
  <td>
15
15
  <span class="handle"></span>
16
- <%= link_to image_tag(slide.attachment.url(:thumbnail)), slide.attachment.url(:medium) %>
16
+ <%= link_to image_tag(slide.attachment.url(:mini)), slide.attachment.url(:medium) %>
17
17
  </td>
18
18
  <td><%= slide.title %></td>
19
19
  <td><%= slide.url %></td>
@@ -1,37 +1,19 @@
1
1
  <div data-hook="admin_slideshow_form_fields">
2
2
  <div class="clearfix">
3
- <div class="left" data-hook="admin_product_form_left">
3
+ <div class="left" data-hook="admin_slideshow_form_left">
4
4
  <%= f.field_container :category do %>
5
5
  <%= f.label :category, t(:category) %> <span class="required">*</span><br />
6
6
  <%= f.text_field :category, :class => 'fullwidth title' %>
7
7
  <%= f.error_message_on :category %>
8
8
  <% end %>
9
9
 
10
- <%= f.field_container :slide_width do %>
11
- <%= f.label :slide_width, t(:slide_width) %> <span class="required">*</span><br />
12
- <%= f.text_field :slide_width, :class => 'fullwidth title' %>
13
- <%= f.error_message_on :slide_width %>
14
- <% end %>
15
-
16
- <%= f.field_container :slide_height do %>
17
- <%= f.label :slide_height, t(:slide_height) %><br />
18
- <%= f.text_field :slide_height, :class => 'fullwidth title' %>
19
- <%= f.error_message_on :slide_height %>
20
- <% end %>
21
- </div>
22
- <div class="right" data-hook="admin_product_form_right">
23
- <%= f.field_container :slide_number do %>
24
- <%= f.label :slide_number, t(:slide_number) %> <span class="required">*</span><br />
25
- <%= f.text_field :slide_number, :class => 'fullwidth title' %>
26
- <%= f.error_message_on :slide_number %>
27
- <% end %>
28
-
29
10
  <%= f.field_container :enable_navigation do %>
30
11
  <%= f.label :enable_navigation, t(:enable_navigation) %><br />
31
12
  <%= f.check_box :enable_navigation %>
32
13
  <%= f.error_message_on :enable_navigation %>
33
14
  <% end %>
34
-
15
+ </div>
16
+ <div class="right" data-hook="admin_slideshow_form_right">
35
17
  <%= f.field_container :enable_pagination do %>
36
18
  <%= f.label :enable_pagination, t(:enable_pagination) %><br />
37
19
  <%= f.check_box :enable_pagination %>
@@ -1,5 +1,5 @@
1
1
  <%= render :partial => 'spree/admin/shared/slideshow_type_tabs', :locals => { :current => 'Slideshow_type Details' } %>
2
- <%= render :partial => 'spree/shared/error_messages', :locals => { :target => @product } %>
2
+ <%= render :partial => 'spree/shared/error_messages', :locals => { :target => @slideshow_type } %>
3
3
 
4
4
  <%= form_for([:admin, @slideshow_type], :html => { :multipart => true }) do |f| %>
5
5
  <%= render :partial => 'form', :locals => { :f => f } %>
@@ -12,7 +12,7 @@
12
12
  <div id="new_slideshow" data-hook></div>
13
13
 
14
14
  <table class="index" id="listing_products">
15
- <tr data-hook="admin_products_index_headers">
15
+ <tr data-hook="admin_slideshows_index_headers">
16
16
  <th><%= t(:category) %></th>
17
17
  <th><%= t(:enable) %></th>
18
18
  <th><%= t(:slide_number) %></th>
@@ -23,7 +23,7 @@
23
23
  <td><%= slideshow_type.category %></td>
24
24
  <td><%= icon('tick') if slideshow_type.enabled %></td>
25
25
  <td><%= slideshow_type.slide_number %></td>
26
- <td class="actions" data-hook="admin_products_index_row_actions">
26
+ <td class="actions" data-hook="admin_slideshows_index_row_actions">
27
27
  <%= link_to_edit slideshow_type, :class => 'edit' %>
28
28
  &nbsp;
29
29
  <%= link_to_delete slideshow_type %>
@@ -2,39 +2,21 @@
2
2
 
3
3
  <%= form_for [:admin, @slideshow_type], :html => { :multipart => true } do |f| %>
4
4
  <fieldset data-hook="new_slideshow_type">
5
- <div class="clearfix" data-hook="new_product_attrs">
5
+ <div class="clearfix" data-hook="new_slideshow_type_attrs">
6
6
  <div class="left">
7
7
  <%= f.field_container :category do %>
8
8
  <%= f.label :category, t(:category) %> <span class="required">*</span><br />
9
9
  <%= f.text_field :category, :class => 'fullwidth title' %>
10
10
  <%= f.error_message_on :category %>
11
11
  <% end %>
12
-
13
- <%= f.field_container :slide_width do %>
14
- <%= f.label :slide_width, t(:slide_width) %> <span class="required">*</span><br />
15
- <%= f.text_field :slide_width, :class => 'fullwidth title' %>
16
- <%= f.error_message_on :slide_width %>
17
- <% end %>
18
-
19
- <%= f.field_container :slide_height do %>
20
- <%= f.label :slide_height, t(:slide_height) %><br />
21
- <%= f.text_field :slide_height, :class => 'fullwidth title' %>
22
- <%= f.error_message_on :slide_height %>
23
- <% end %>
24
- </div>
25
- <div class="right">
26
- <%= f.field_container :slide_number do %>
27
- <%= f.label :slide_number, t(:slide_number) %> <span class="required">*</span><br />
28
- <%= f.text_field :slide_number, :class => 'fullwidth title' %>
29
- <%= f.error_message_on :slide_number %>
30
- <% end %>
31
-
12
+
32
13
  <%= f.field_container :enable_navigation do %>
33
14
  <%= f.label :enable_navigation, t(:enable_navigation) %><br />
34
15
  <%= f.check_box :enable_navigation %>
35
16
  <%= f.error_message_on :enable_navigation %>
36
17
  <% end %>
37
-
18
+ </div>
19
+ <div class="right">
38
20
  <%= f.field_container :enable_pagination do %>
39
21
  <%= f.label :enable_pagination, t(:enable_pagination) %><br />
40
22
  <%= f.check_box :enable_pagination %>
@@ -1,2 +1,2 @@
1
1
  $("#new_slideshow").html('<%= escape_javascript(render :template => "spree/admin/slideshow_types/new", :formats => [:html], :handlers => [:erb]) %>');
2
- $("#admin_new_slideshow").parent().hide();
2
+ $("#admin_new_slideshow").parent().hide();
data/config/routes.rb CHANGED
@@ -8,6 +8,7 @@ Spree::Core::Engine.routes.draw do
8
8
  end
9
9
  end
10
10
  end
11
+ resource :slide_settings
11
12
  end
12
13
 
13
14
  end
@@ -3,9 +3,6 @@ class CreateSlideshowTypes < ActiveRecord::Migration
3
3
  create_table :slideshow_types do |t|
4
4
  t.string :category
5
5
  t.boolean :enabled, :default => false
6
- t.integer :slide_height, :default => 400
7
- t.integer :slide_width, :default => 900
8
- t.integer :slide_number, :default => 4
9
6
  t.boolean :enable_navigation, :default => false
10
7
 
11
8
  t.timestamps
@@ -7,7 +7,6 @@ class CreateSlides < ActiveRecord::Migration
7
7
  t.string :attachment_content_type, :attachment_file_name
8
8
  t.datetime :attachment_updated_at
9
9
  t.integer :attachment_size, :position
10
- t.string :type, :limit => 75
11
10
 
12
11
  t.references :slideshow_type
13
12
 
@@ -0,0 +1,8 @@
1
+ class AddEnableToSlide < ActiveRecord::Migration
2
+ def change
3
+ add_column :spree_slides, :enable, :boolean, :default => true, :after => :content
4
+ remove_column :spree_slideshow_types, :slide_number
5
+ remove_column :spree_slideshow_types, :slide_width
6
+ remove_column :spree_slideshow_types, :slide_height
7
+ end
8
+ end
@@ -4,12 +4,11 @@ module SpreeMultiSlideshow
4
4
 
5
5
  def add_javascripts
6
6
  append_file "app/assets/javascripts/store/all.js", "//= require store/spree_multi_slideshow\n"
7
- #append_file "app/assets/javascripts/admin/all.js", "//= require admin/spree_multi_slideshow\n"
7
+ append_file "app/assets/javascripts/admin/all.js", "//= require admin/spree_multi_slideshow\n"
8
8
  end
9
9
 
10
10
  def add_stylesheets
11
11
  inject_into_file "app/assets/stylesheets/store/all.css", " *= require store/spree_multi_slideshow\n", :before => /\*\//, :verbose => true
12
- inject_into_file "app/assets/stylesheets/admin/all.css", " *= require admin/spree_multi_slideshow\n", :before => /\*\//, :verbose => true
13
12
  end
14
13
 
15
14
  def add_migrations
@@ -23,17 +22,7 @@ module SpreeMultiSlideshow
23
22
  else
24
23
  puts "Skiping rake db:migrate, don't forget to run it!"
25
24
  end
26
- end
27
-
28
- def add_ckeditor
29
- res = ask "Would you like to run the ckeditor generator now? [Y/n]"
30
- if res == "" || res.downcase == "y"
31
- run 'rails generate ckeditor:install --orm=active_record --backend=paperclip'
32
- else
33
- puts "Skiping rails generate ckeditor:install --orm=active_record --backend=paperclip, don't forget to run it!"
34
- end
35
- end
36
-
25
+ end
37
26
  end
38
27
  end
39
28
  end
@@ -1,4 +1,2 @@
1
1
  require 'spree_core'
2
- require 'ckeditor'
3
- require 'formtastic'
4
2
  require 'spree_multi_slideshow/engine'
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: spree_multi_slideshow
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.3
4
+ version: 1.1.4
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-22 00:00:00.000000000 Z
12
+ date: 2013-02-26 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: spree_core
@@ -18,7 +18,7 @@ dependencies:
18
18
  requirements:
19
19
  - - ! '>='
20
20
  - !ruby/object:Gem::Version
21
- version: '0'
21
+ version: 1.1.3
22
22
  type: :runtime
23
23
  prerelease: false
24
24
  version_requirements: !ruby/object:Gem::Requirement
@@ -26,7 +26,7 @@ dependencies:
26
26
  requirements:
27
27
  - - ! '>='
28
28
  - !ruby/object:Gem::Version
29
- version: '0'
29
+ version: 1.1.3
30
30
  - !ruby/object:Gem::Dependency
31
31
  name: aws-sdk
32
32
  requirement: !ruby/object:Gem::Requirement
@@ -59,38 +59,6 @@ dependencies:
59
59
  - - ! '>='
60
60
  - !ruby/object:Gem::Version
61
61
  version: '0'
62
- - !ruby/object:Gem::Dependency
63
- name: ckeditor
64
- requirement: !ruby/object:Gem::Requirement
65
- none: false
66
- requirements:
67
- - - ! '>='
68
- - !ruby/object:Gem::Version
69
- version: '0'
70
- type: :runtime
71
- prerelease: false
72
- version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
- requirements:
75
- - - ! '>='
76
- - !ruby/object:Gem::Version
77
- version: '0'
78
- - !ruby/object:Gem::Dependency
79
- name: rspec-rails
80
- requirement: !ruby/object:Gem::Requirement
81
- none: false
82
- requirements:
83
- - - ! '>='
84
- - !ruby/object:Gem::Version
85
- version: '0'
86
- type: :development
87
- prerelease: false
88
- version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
- requirements:
91
- - - ! '>='
92
- - !ruby/object:Gem::Version
93
- version: '0'
94
62
  description:
95
63
  email: damiano.giacomello@diginess.it
96
64
  executables: []
@@ -104,20 +72,24 @@ files:
104
72
  - lib/spree_multi_slideshow.rb
105
73
  - app/assets/images/store/slides/pagination.png
106
74
  - app/assets/images/store/slides/sprite01.png
75
+ - app/assets/javascripts/admin/slide_settings.js
107
76
  - app/assets/javascripts/admin/slides/index.js
108
77
  - app/assets/javascripts/admin/slides/new.js
109
78
  - app/assets/javascripts/admin/spree_multi_slideshow.js
110
79
  - app/assets/javascripts/store/spree_multi_slideshow.js
111
- - app/assets/stylesheets/admin/spree_multi_slideshow.css
112
80
  - app/assets/stylesheets/store/spree_multi_slideshow.css
81
+ - app/controllers/spree/admin/slide_settings_controller.rb
113
82
  - app/controllers/spree/admin/slides_controller.rb
114
83
  - app/controllers/spree/admin/slideshow_types_controller.rb
115
- - app/helpers/spree/slides_helper.rb
116
84
  - app/helpers/spree/slideshow_types_helper.rb
85
+ - app/models/spree/app_configuration_decorator.rb
117
86
  - app/models/spree/slide.rb
118
87
  - app/models/spree/slideshow_type.rb
119
88
  - app/overrides/slideshow_type_admin_tab.rb
89
+ - app/views/spree/admin/shared/_slide_setting_configurations_menu.html.erb
120
90
  - app/views/spree/admin/shared/_slideshow_type_tabs.html.erb
91
+ - app/views/spree/admin/slide_settings/edit.html.erb
92
+ - app/views/spree/admin/slide_settings/show.html.erb
121
93
  - app/views/spree/admin/slides/_form.html.erb
122
94
  - app/views/spree/admin/slides/edit.html.erb
123
95
  - app/views/spree/admin/slides/index.html.erb
@@ -131,6 +103,7 @@ files:
131
103
  - db/migrate/20120116083546_create_slides.rb
132
104
  - db/migrate/20120323164044_multi_slideshow_namespace.rb
133
105
  - db/migrate/20130114150224_add_enable_pagination.rb
106
+ - db/migrate/20130226082756_add_enable_to_slide.rb
134
107
  - config/locales/en.yml
135
108
  - config/locales/it.yml
136
109
  - config/routes.rb
@@ -1,17 +0,0 @@
1
- /*
2
- *= require admin/spree_core
3
- *= require formtastic
4
- */
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
- }
@@ -1,4 +0,0 @@
1
- module Spree
2
- module SlidesHelper
3
- end
4
- end