solidus_slider 1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (64) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +12 -0
  3. data/.rspec +1 -0
  4. data/.rvmrc +1 -0
  5. data/Gemfile +26 -0
  6. data/LICENSE +26 -0
  7. data/README.md +61 -0
  8. data/README.textile +71 -0
  9. data/Rakefile +21 -0
  10. data/Versionfile +5 -0
  11. data/app/assets/javascripts/spree/backend/slide_location_picker.js +53 -0
  12. data/app/assets/javascripts/spree/backend/solidus_slider.js +1 -0
  13. data/app/controllers/spree/admin/slide_locations_controller.rb +19 -0
  14. data/app/controllers/spree/admin/slides_controller.rb +57 -0
  15. data/app/models/spree/product_decorator.rb +8 -0
  16. data/app/models/spree/slide.rb +49 -0
  17. data/app/models/spree/slide_location.rb +8 -0
  18. data/app/models/spree/slide_slide_location.rb +8 -0
  19. data/app/overrides/spree/admin/configurations/index/add_slides_to_admin_configurations_menu.html.erb.deface +11 -0
  20. data/app/overrides/spree/admin/shared/_configuration_menu/add_slide_locations_to_admin_configurations_sidebar_menu.html.erb.deface +3 -0
  21. data/app/overrides/spree/admin/shared/_configuration_menu/add_slides_to_admin_configurations_sidebar_menu.html.erb.deface +3 -0
  22. data/app/overrides/spree/home/index/add_slider.html.erb.deface +5 -0
  23. data/app/overrides/spree/shared/_header/add_slider.html.erb.deface +3 -0
  24. data/app/views/spree/admin/slide_locations/_form.html.erb +10 -0
  25. data/app/views/spree/admin/slide_locations/edit.html.erb +18 -0
  26. data/app/views/spree/admin/slide_locations/index.html.erb +40 -0
  27. data/app/views/spree/admin/slide_locations/new.html.erb +16 -0
  28. data/app/views/spree/admin/slide_locations/search.json.jbuilder +4 -0
  29. data/app/views/spree/admin/slides/_form.html.erb +70 -0
  30. data/app/views/spree/admin/slides/edit.html.erb +23 -0
  31. data/app/views/spree/admin/slides/index.html.erb +50 -0
  32. data/app/views/spree/admin/slides/new.html.erb +18 -0
  33. data/app/views/spree/admin/slides/show.html.erb +54 -0
  34. data/app/views/spree/shared/_slider.html.erb +19 -0
  35. data/bin/rails +7 -0
  36. data/config/locales/de.yml +27 -0
  37. data/config/locales/en.yml +28 -0
  38. data/config/locales/es-MX.yml +33 -0
  39. data/config/locales/es.yml +27 -0
  40. data/config/locales/nl-NL.yml +27 -0
  41. data/config/locales/nl.yml +27 -0
  42. data/config/locales/pl.yml +29 -0
  43. data/config/locales/pt-BR.yml +36 -0
  44. data/config/locales/ru.yml +27 -0
  45. data/config/routes.rb +15 -0
  46. data/db/migrate/20120222184238_create_slides.rb +16 -0
  47. data/db/migrate/20120816192758_add_position_to_slides.rb +5 -0
  48. data/db/migrate/20121219124126_add_product_id_to_slides.rb +5 -0
  49. data/db/migrate/20150611113500_create_slider_location.rb +8 -0
  50. data/db/migrate/20160214061128_add_show_caption_to_slides.rb +5 -0
  51. data/db/migrate/20180113010348_create_spree_slide_slide_locations_table.rb +10 -0
  52. data/lib/generators/solidus_slider/install/install_generator.rb +24 -0
  53. data/lib/generators/solidus_slider/install_anything_generator.rb +31 -0
  54. data/lib/generators/solidus_slider/install_nivo_generator.rb +34 -0
  55. data/lib/generators/solidus_slider/install_simple_carousel_generator.rb +30 -0
  56. data/lib/generators/solidus_slider/templates/anything_slider.html.erb +23 -0
  57. data/lib/generators/solidus_slider/templates/nivo_slider.html.erb +37 -0
  58. data/lib/generators/solidus_slider/templates/simple_carousel_slider.html.erb +15 -0
  59. data/lib/solidus_slider.rb +4 -0
  60. data/lib/solidus_slider/engine.rb +22 -0
  61. data/lib/solidus_slider/version.rb +3 -0
  62. data/solidus_slider.gemspec +55 -0
  63. data/spec/spec_helper.rb +21 -0
  64. metadata +550 -0
@@ -0,0 +1,8 @@
1
+ module Spree
2
+ class SlideLocation < ActiveRecord::Base
3
+ has_one :slide_slide_locations
4
+ has_one :slide, through: :slide_slide_locations
5
+
6
+ validates :name, presence: true
7
+ end
8
+ end
@@ -0,0 +1,8 @@
1
+ module Spree
2
+ class SlideSlideLocation < ActiveRecord::Base
3
+ self.table_name = 'spree_slide_slide_locations'
4
+
5
+ belongs_to :slide
6
+ belongs_to :slide_location
7
+ end
8
+ end
@@ -0,0 +1,11 @@
1
+ <!-- insert_bottom "[data-hook='admin_configurations_menu']" -->
2
+
3
+ <tr>
4
+ <td><%= link_to Spree.t('slider.config_name'), admin_slides_path %></td>
5
+ <td><%= Spree.t('slider.config_description') %></td>
6
+ </tr>
7
+
8
+ <tr>
9
+ <td><%= link_to Spree.t('slider_locations.config_name'), admin_slide_locations_path %></td>
10
+ <td><%= Spree.t('slider_locations.config_description') %></td>
11
+ </tr>
@@ -0,0 +1,3 @@
1
+ <!-- insert_bottom "[data-hook='admin_configurations_sidebar_menu']" -->
2
+
3
+ <%= settings_tab_item Spree.t('slider_locations.config_name'), admin_slide_locations_path %>
@@ -0,0 +1,3 @@
1
+ <!-- insert_bottom "[data-hook='admin_configurations_sidebar_menu']" -->
2
+
3
+ <%= settings_tab_item Spree.t('slider.config_name'), admin_slides_path %>
@@ -0,0 +1,5 @@
1
+ <!-- insert_before '[data-hook="homepage_products"]' -->
2
+
3
+ <% content_for :solidus_slider do %>
4
+ <%= render 'spree/shared/slider' %>
5
+ <% end %>
@@ -0,0 +1,3 @@
1
+ <!-- insert_after '#header[data-hook]' -->
2
+
3
+ <%= yield :solidus_slider %>
@@ -0,0 +1,10 @@
1
+ <div data-hook='admin_slide_location_form_fields'>
2
+ <div class='row'>
3
+ <div class='col-12'>
4
+ <%= f.field_container :name do %>
5
+ <%= f.label :name, Spree.t(:name) %><br>
6
+ <%= f.text_field :name, class: 'form-control fullwidth' %>
7
+ <% end %>
8
+ </div>
9
+ </div>
10
+ </div>
@@ -0,0 +1,18 @@
1
+ <%= render partial: 'spree/admin/shared/configuration_menu' %>
2
+
3
+ <% content_for :page_title do %>
4
+ <%= Spree.t('slider_locations.editing_location') %>
5
+ <% end %>
6
+
7
+ <% content_for :page_actions do %>
8
+ <%= button_link_to Spree.t('slider_locations.back_to_locations'), spree.admin_slide_locations_path %>
9
+ <% end %>
10
+
11
+ <%= render 'spree/shared/error_messages', target: @slide_location %>
12
+
13
+ <%= form_for [:admin, @slide_location] do |f| %>
14
+ <%= render partial: 'form', locals: { f: f } %>
15
+ <div class="form-actions" data-hook="buttons">
16
+ <%= render partial: 'spree/admin/shared/edit_resource_links' %>
17
+ </div>
18
+ <% end %>
@@ -0,0 +1,40 @@
1
+ <%= render partial: 'spree/admin/shared/configuration_menu' %>
2
+
3
+ <% content_for :page_actions do %>
4
+ <%= button_link_to Spree.t('slider_locations.new_location'), new_object_url, { id: 'admin_new_slide_link' } %>
5
+ <% end %>
6
+
7
+ <% content_for :page_title do %>
8
+ <%= Spree.t('slider_locations.title') %>
9
+ <% end %>
10
+
11
+ <% if @slide_locations %>
12
+ <table class='table' id='listing_slide_locations' data-hook>
13
+ <thead>
14
+ <tr data-hook='admin_slides_index_headers'>
15
+ <th><%= Spree.t(:name) %></th>
16
+ <th data-hook='admin_slides_index_header_actions' class='actions'></th>
17
+ </tr>
18
+ </thead>
19
+
20
+ <tbody>
21
+ <% @slide_locations.each do |location|%>
22
+ <tr>
23
+ <td class='align-left'><%= location.name %></td>
24
+ <td data-hook='admin_slide_locations_index_row_actions' class='actions'>
25
+ <%= link_to_edit location, no_text: true, class: 'edit' if can?(:edit, location) %>
26
+ <%= link_to_delete location, no_text: true if can?(:delete, location) %>
27
+ </td>
28
+ </tr>
29
+ <% end %>
30
+ </tbody>
31
+ </table>
32
+ <% else %>
33
+ <div class='no-objects-found'>
34
+ <%= render 'spree/admin/shared/no_objects_found',
35
+ resource: Spree::SlideLocation,
36
+ new_resource_url: new_object_url %>
37
+ </div>
38
+ <% end %>
39
+
40
+
@@ -0,0 +1,16 @@
1
+ <%= render partial: 'spree/admin/shared/configuration_menu' %>
2
+
3
+ <% content_for :page_title do %>
4
+ <%= Spree.t('slider_locations.new_location') %>
5
+ <% end %>
6
+
7
+ <% content_for :page_actions do %>
8
+ <%= button_link_to Spree.t('slider_locations.back_to_locations'), spree.admin_slide_locations_path %>
9
+ <% end %>
10
+
11
+ <%= render 'spree/shared/error_messages', target: @slide_location %>
12
+
13
+ <%= form_for [:admin, @slide_location] do |f| %>
14
+ <%= render partial: 'form', locals: { f: f } %>
15
+ <%= render partial: 'spree/admin/shared/new_resource_links' %>
16
+ <% end %>
@@ -0,0 +1,4 @@
1
+ json.slide_locations(@slide_locations) do |slide_location|
2
+ json.id slide_location.id
3
+ json.name slide_location.name
4
+ end
@@ -0,0 +1,70 @@
1
+ <div data-hook='admin_slide_form_fields'>
2
+ <div class='row'>
3
+ <div class='left col-2'>
4
+ <%= f.field_container :position do %>
5
+ <%= f.label :position, Spree.t(:position) %>
6
+ <%= f.number_field :position, class: 'fullwidth' %>
7
+ <% end %>
8
+ </div>
9
+
10
+ <div class='col-5'>
11
+ <%= f.field_container :product_id do %>
12
+ <%= label_tag :product_id, Spree.t(:product) %><br />
13
+ <%= hidden_field_tag 'slide[product_id]', f.object.product_id.to_s, class: 'product_picker fullwidth' %>
14
+ <% end %>
15
+ </div>
16
+
17
+ <div class='col-5'>
18
+ <%= f.field_container :name do %>
19
+ <%= f.label :name, Spree.t(:name) %><br />
20
+ <%= f.text_field :name, class: 'fullwidth', placeholder: Spree.t('slider.placeholder_name') %>
21
+ <% end %>
22
+ </div>
23
+
24
+ <div class='col-2'>
25
+ <div class='field checkbox'>
26
+ <label>
27
+ <%= f.check_box :published %>
28
+ <%= Spree.t(:published) %>
29
+ </label>
30
+ </div>
31
+ </div>
32
+
33
+ <div class='col-5'>
34
+ <%= f.field_container :link_url do %>
35
+ <%= f.label :link_url, Spree.t(:link_url) %><br />
36
+ <%= f.text_field :link_url, class: 'fullwidth', placeholder: Spree.t('slider.placeholder_link_url') %>
37
+ <% end %>
38
+ </div>
39
+
40
+ <div class='col-5'>
41
+ <%= f.field_container :body do %>
42
+ <%= f.label :body, Spree.t(:body) %><br />
43
+ <%= f.text_area :body, { cols: 60, rows: 4, class: 'fullwidth'} %>
44
+ <% end %>
45
+ </div>
46
+
47
+ <div class='col-5'>
48
+ <%= f.field_container :slide_locations do %>
49
+ <%= label_tag :slide_location_ids, Spree.t(:location) %><br />
50
+ <%= hidden_field_tag 'slide[slide_location_ids]', f.object.slide_location_ids.join(','), class: 'slide_location_picker fullwidth' %>
51
+ <% end %>
52
+ </div>
53
+
54
+ <div class='col-4'>
55
+ <%= f.field_container :image do %>
56
+ <%= f.label :image, Spree.t(:image) %> <i>(<%= Spree.t('slider.image_tip') %>)</i><br />
57
+ <%= f.file_field :image %>
58
+ <% end %>
59
+ </div>
60
+
61
+ <div class='col-2'>
62
+ <%= f.field_container :image do %>
63
+ <% if f.object.image? %>
64
+ <p><%= image_tag f.object.image, style: 'max-width: 100%; height: auto;' %></p>
65
+ <% end %>
66
+ <% end %>
67
+ </div>
68
+
69
+ </div>
70
+ </div>
@@ -0,0 +1,23 @@
1
+ <%= render partial: 'spree/admin/shared/configuration_menu' %>
2
+
3
+ <% content_for :page_title do %>
4
+ <%= Spree.t('slider.editing_slide') %>
5
+ <% end %>
6
+
7
+ <% content_for :page_actions do %>
8
+ <li>
9
+ <%= button_link_to Spree.t('slider.back_to_slides'), new_object_url, { id: 'admin_new_slide' } %>
10
+ </li>
11
+ <li>
12
+ <%= button_link_to Spree.t('slider_locations.new_location'), admin_slide_locations_path, { id: 'admin_new_slide_location' } %>
13
+ </li>
14
+ <% end %>
15
+
16
+ <%= render 'spree/shared/error_messages', target: @slide %>
17
+
18
+ <%= form_for [:admin, @slide], html: { multipart: true } do |f| %>
19
+ <%= render partial: 'form', locals: { f: f } %>
20
+ <div class="form-actions" data-hook="buttons">
21
+ <%= render partial: 'spree/admin/shared/edit_resource_links' %>
22
+ </div>
23
+ <% end %>
@@ -0,0 +1,50 @@
1
+ <%= render partial: 'spree/admin/shared/configuration_menu' %>
2
+
3
+ <% content_for :page_actions do %>
4
+ <li>
5
+ <%= button_link_to Spree.t(:'slider.new_slide'), new_object_url, id: 'admin_new_slide_link' %>
6
+ </li>
7
+ <% end %>
8
+
9
+ <% content_for :page_title do %>
10
+ <%= Spree.t('slider.title') %>
11
+ <% end %>
12
+
13
+ <% if @slides %>
14
+ <table class='index sortable' id='listing_slides' data-hook data-sortable-link='<%= update_positions_admin_slides_url %>' >
15
+ <thead>
16
+ <tr data-hook='admin_slides_index_headers'>
17
+ <th colspan='2'><%= Spree.t(:image) %></th>
18
+ <th><%= Spree.t(:name) %></th>
19
+ <th><%= Spree.t(:product) %></th>
20
+ <th><%= Spree.t(:published) %></th>
21
+ <th data-hook='admin_slides_index_header_actions' class='actions'></th>
22
+ </tr>
23
+ </thead>
24
+
25
+ <tbody>
26
+ <% @slides.each do |slide|%>
27
+ <tr id='<%= spree_dom_id slide %>' data-hook='admin_slides_index_rows'>
28
+ <td class='no-border'><span class='handle'></span></td>
29
+ <td class='align-left'><%= image_tag slide.slide_image, style: 'width: 120px; height: auto;' %></td>
30
+ <td class='align-left'><%= link_to slide.name, object_url(slide) %></td>
31
+ <td class='align-left'><%= link_to slide.product.name, object_url(slide) unless slide.product_id.blank? %></td>
32
+ <td class='align-center'><%= slide.published ? Spree.t(:say_yes) : Spree.t(:say_no) %></td>
33
+ <td data-hook='admin_slides_index_row_actions' class='actions'>
34
+ <%= link_to_edit slide, no_text: true, class: 'edit' if can?(:edit, slide) %>
35
+ &nbsp;
36
+ <%= link_to_delete slide, no_text: true if can?(:delete, slide) %>
37
+ </td>
38
+ </tr>
39
+ <% end %>
40
+ </tbody>
41
+ </table>
42
+ <% else %>
43
+ <div class='no-objects-found'>
44
+ <%= render 'spree/admin/shared/no_objects_found',
45
+ resource: Spree::Slide,
46
+ new_resource_url: new_object_url %>
47
+ </div>
48
+ <% end %>
49
+
50
+ <%= paginate @slides, theme: 'solidus_admin' %>
@@ -0,0 +1,18 @@
1
+ <%= render partial: 'spree/admin/shared/configuration_menu' %>
2
+
3
+ <% content_for :page_title do %>
4
+ <%= Spree.t('slider.new_slide') %>
5
+ <% end %>
6
+
7
+ <% content_for :page_actions do %>
8
+ <li>
9
+ <%= button_link_to Spree.t('slider.back_to_slides'), spree.admin_slides_path %>
10
+ </li>
11
+ <% end %>
12
+
13
+ <%= render 'spree/shared/error_messages', target: @slide %>
14
+
15
+ <%= form_for [:admin, @slide] , html: { multipart: true } do |f| %>
16
+ <%= render :partial => 'form', locals: { f: f } %>
17
+ <%= render partial: 'spree/admin/shared/new_resource_links' %>
18
+ <% end %>
@@ -0,0 +1,54 @@
1
+ <h1><%= t(:slide) %></h1>
2
+ <%= render partial: 'spree/admin/shared/configuration_menu' %>
3
+
4
+ <h1><%= Spree.t(:slide) %></h1>
5
+
6
+ <table class="table">
7
+ <tr data-hook="product_id">
8
+ <th><%= Spree.t(:product) %></th>
9
+ <td>
10
+ <%= @slide.product.name unless @slide.product_id.blank? %>
11
+ </td>
12
+ </tr>
13
+ <tr data-hook="name">
14
+ <th><%= Spree.t(:name) %></th>
15
+ <td>
16
+ <%= @slide.name %>
17
+ </td>
18
+ </tr>
19
+ <tr data-hook="body">
20
+ <th><%= Spree.t(:body) %></th>
21
+ <td>
22
+ <%= @slide.body %>
23
+ </td>
24
+ </tr>
25
+ <tr data-hook="link_url">
26
+ <th><%= Spree.t(:link_url) %></th>
27
+ <td>
28
+ <%= @slide.link_url %>
29
+ </td>
30
+ </tr>
31
+ <tr data-hook="published">
32
+ <th><%= Spree.t(:published) %></th>
33
+ <td>
34
+ <%= @slide.published ? Spree.t(:y) : Spree.t(:n) %>
35
+ </td>
36
+ </tr>
37
+ <tr data-hook="image_file_name">
38
+ <th><%= Spree.t(:image_file_name) %></th>
39
+ <td>
40
+ <%= @slide.image_file_name %>
41
+ </td>
42
+ </tr>
43
+ <tr data-hook="position">
44
+ <th><%= Spree.t(:position) %></th>
45
+ <td>
46
+ <%= @slide.position %>
47
+ </td>
48
+ </tr>
49
+ </table>
50
+
51
+ <p>
52
+ <%= link_to_edit @slide, class: 'edit_slide' %> <%= Spree.t(:or) %>
53
+ <%= link_to Spree.t(:back), collection_url %>
54
+ </p>
@@ -0,0 +1,19 @@
1
+ <% if slider.size > 0 %>
2
+ <slick slides-to-show="1" ng-if="true" settings="{arrows:false,centerMode:false,centerPadding:'0',autoplay: true,autoplaySpeed: 5000,fade:true}">
3
+ <% slider.each_with_index do |slide, index| %>
4
+ <div class="item">
5
+ <%= link_to image_tag(slide.slide_image.url, alt: slide.slide_caption, class:'img-responsive'), url_for(slide.slide_link) %>
6
+
7
+ <div>
8
+ <% if slide.show_caption? %>
9
+ <h3><%= slide.slide_caption %></h3>
10
+ <% end %>
11
+
12
+ <% unless slide.body.blank? %>
13
+ <p><%= slide.body %><p>
14
+ <% end %>
15
+ </div>
16
+ </div>
17
+ <% end %>
18
+ </slick>
19
+ <% end %>
data/bin/rails ADDED
@@ -0,0 +1,7 @@
1
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
2
+
3
+ ENGINE_ROOT = File.expand_path('../..', __FILE__)
4
+ ENGINE_PATH = File.expand_path('../../lib/solidus_slider/engine', __FILE__)
5
+
6
+ require 'rails/all'
7
+ require 'rails/engine/commands'
@@ -0,0 +1,27 @@
1
+ de:
2
+ activerecord:
3
+ models:
4
+ spree/slide: "Slide"
5
+
6
+ spree:
7
+ next: "Nächste"
8
+ previous: "Vorhergehend"
9
+ name: "Name"
10
+ body: "Körper"
11
+ link_url: "Link URL"
12
+ image: "Bild"
13
+ image_file_name: "Name der Bilddatei"
14
+ published: "Veröffentlicht"
15
+ position: "Position"
16
+ y: "Ja"
17
+ n: "Nein"
18
+
19
+ slider:
20
+ config_name: "Spree Slides"
21
+ config_description: "Verwalten Spree Slider Inhalt"
22
+ title: "Slides"
23
+ new_slide: "Neue Slide"
24
+ editing_slide: "Bearbeiten Slide"
25
+ placeholder_name: "Leer lassen, um Produkt-Namen verwenden"
26
+ placeholder_link_url: "Leer lassen, um Produkt-URL verwenden"
27
+ image_tip: "Standard ersten product image"
@@ -0,0 +1,28 @@
1
+ en:
2
+ activerecord:
3
+ models:
4
+ spree/slide: "Slide"
5
+
6
+ spree:
7
+ next: "Next"
8
+ previous: "Previous"
9
+ name: "Name"
10
+ body: "Body"
11
+ link_url: "Link URL"
12
+ image: "Image"
13
+ image_file_name: "Image file name"
14
+ published: "Published"
15
+ position: "Position"
16
+ y: "Yes"
17
+ n: "No"
18
+
19
+ slider:
20
+ config_name: "Spree Slider"
21
+ config_description: "Manage Spree Slider contents"
22
+ title: "Slides"
23
+ new_slide: "New Slide"
24
+ editing_slide: "Editing Slide"
25
+ back_to_slides: "Back to Slides"
26
+ placeholder_name: "Leave blank to use product name"
27
+ placeholder_link_url: "Leave blank to use product url"
28
+ image_tip: "Default first product image"