spree_essential_cms 0.3.0.rc1 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (69) hide show
  1. data/.gitignore +8 -0
  2. data/.travis.yml +15 -0
  3. data/Gemfile +2 -0
  4. data/LICENSE +1 -1
  5. data/README.md +64 -5
  6. data/Versionfile +8 -0
  7. data/app/controllers/spree/admin/contents_controller.rb +4 -4
  8. data/app/controllers/spree/admin/pages_controller.rb +6 -12
  9. data/app/controllers/spree/base_controller_decorator.rb +15 -0
  10. data/app/controllers/spree/home_controller_decorator.rb +23 -0
  11. data/app/controllers/spree/pages_controller.rb +2 -11
  12. data/app/models/spree/content.rb +40 -39
  13. data/app/models/spree/page.rb +21 -10
  14. data/app/models/spree/page_image.rb +10 -15
  15. data/app/views/spree/admin/contents/_form.html.erb +9 -4
  16. data/app/views/spree/admin/contents/edit.html.erb +0 -2
  17. data/app/views/spree/admin/contents/index.html.erb +22 -23
  18. data/app/views/spree/admin/contents/new.html.erb +0 -2
  19. data/app/views/spree/admin/contents/show.html.erb +0 -1
  20. data/app/views/spree/admin/page_images/edit.html.erb +1 -3
  21. data/app/views/spree/admin/page_images/index.html.erb +25 -25
  22. data/app/views/spree/admin/page_images/new.html.erb +3 -1
  23. data/app/views/spree/admin/pages/edit.html.erb +0 -2
  24. data/app/views/spree/admin/pages/index.html.erb +26 -26
  25. data/app/views/spree/admin/pages/new.html.erb +1 -1
  26. data/app/views/spree/admin/pages/show.html.erb +0 -2
  27. data/app/views/spree/pages/home.html.erb +10 -0
  28. data/app/views/spree/shared/_main_menu.html.erb +3 -7
  29. data/app/views/spree/shared/_main_menu_items.html.erb +6 -0
  30. data/config/locales/en.yml +1 -0
  31. data/config/locales/it.yml +63 -0
  32. data/config/routes.rb +10 -12
  33. data/{lib/generators/templates/db/migrate/create_pages.rb → db/migrate/20120306185628_create_pages.rb} +0 -0
  34. data/{lib/generators/templates/db/migrate/create_contents.rb → db/migrate/20120306185638_create_contents.rb} +0 -0
  35. data/{lib/generators/templates/db/migrate/add_spree_namespace.rb → db/migrate/20120306185648_add_spree_namespace.rb} +0 -0
  36. data/lib/generators/spree_essentials/cms_generator.rb +3 -8
  37. data/lib/spree_essential_cms.rb +5 -19
  38. data/lib/spree_essential_cms/engine.rb +16 -0
  39. data/lib/spree_essential_cms/version.rb +1 -1
  40. data/lib/tasks/sample.rake +9 -13
  41. data/spree_essential_cms.gemspec +34 -0
  42. data/test/dummy_hooks/after_app_generator.rb +17 -0
  43. data/test/dummy_hooks/after_migrate.rb.sample +1 -0
  44. data/test/dummy_hooks/before_migrate.rb +11 -0
  45. data/test/dummy_hooks/templates/assets/javascripts/admin/all.js +1 -0
  46. data/test/dummy_hooks/templates/assets/javascripts/store/all.js +1 -0
  47. data/test/dummy_hooks/templates/assets/stylesheets/admin/all.css +3 -0
  48. data/test/dummy_hooks/templates/assets/stylesheets/store/all.css +3 -0
  49. data/test/dummy_hooks/templates/assets/stylesheets/store/screen.css +749 -0
  50. data/test/dummy_hooks/templates/initializers/spree_user_error_fix.rb +3 -0
  51. data/test/dummy_hooks/templates/overrides/main_menu.rb +6 -0
  52. data/test/integration/spree/admin/contents_integration_test.rb +116 -0
  53. data/test/integration/spree/admin/page_images_integration_test.rb +94 -0
  54. data/test/integration/spree/admin/pages_integration_test.rb +131 -0
  55. data/test/integration/spree/home_integration_test.rb +54 -0
  56. data/test/integration/spree/pages_integration_test.rb +122 -0
  57. data/test/support/factories.rb +21 -0
  58. data/test/support/files/1.jpg +0 -0
  59. data/test/support/files/2.jpg +0 -0
  60. data/test/support/helpers.rb +13 -0
  61. data/test/test_helper.rb +19 -0
  62. data/test/unit/spree/content_test.rb +39 -0
  63. data/test/unit/spree/essential_test.rb +9 -0
  64. data/test/unit/spree/page_image_test.rb +47 -0
  65. data/test/unit/spree/page_test.rb +53 -0
  66. metadata +117 -48
  67. data/app/assets/stylesheets/essentials/cms.css +0 -39
  68. data/app/controllers/spree/page_controller.rb +0 -20
  69. data/app/controllers/spree/spree_base_controller_decorator.rb +0 -12
@@ -1,15 +1,19 @@
1
1
  class Spree::PageImage < Spree::Asset
2
2
 
3
- validate :no_attachement_errors
3
+ attr_accessible :viewable, :attachment, :alt
4
4
 
5
+ validates_attachment_presence :attachment
6
+
5
7
  has_attached_file :attachment,
6
8
  :styles => Proc.new{ |clip| clip.instance.attachment_sizes },
7
- :default_style => :medium
8
-
9
+ :default_style => :medium,
10
+ :url => '/spree/pages/:id/:style/:basename.:extension',
11
+ :path => ':rails_root/public/spree/pages/:id/:style/:basename.:extension'
12
+
9
13
  def image_content?
10
- attachment_content_type.match(/\/(jpeg|png|gif|tiff|x-photoshop)/)
14
+ attachment_content_type.to_s.match(/\/(jpeg|png|gif|tiff|x-photoshop)/)
11
15
  end
12
-
16
+
13
17
  def attachment_sizes
14
18
  sizes = {}
15
19
  if image_content?
@@ -18,14 +22,5 @@ class Spree::PageImage < Spree::Asset
18
22
  end
19
23
  sizes
20
24
  end
21
-
22
- def no_attachement_errors
23
- unless attachment.errors.empty?
24
- # uncomment this to get rid of the less-than-useful interrim messages
25
- errors.clear
26
- errors.add :attachment, "Paperclip returned errors for file '#{attachment_file_name}' - check ImageMagick installation or image source file."
27
- false
28
- end
29
- end
30
-
25
+
31
26
  end
@@ -32,7 +32,14 @@
32
32
  <%= error_message_on :content, :attachment %>
33
33
  <% end %>
34
34
 
35
- <% if @content.has_image? %>
35
+ <% if @content.attachment.exists?(:mini) %>
36
+ <%= form.field_container :delete_attachment do %>
37
+ <%= form.check_box :delete_attachment %>
38
+ <%= form.label :delete_attachment, t('content.delete_attachment') %><br />
39
+ <% end %>
40
+ <% end %>
41
+
42
+ <% if @content.attachment.exists?(:mini) %>
36
43
  <p><%= image_tag @content.attachment.url(:mini) %></p>
37
44
  <% end %>
38
45
 
@@ -57,8 +64,6 @@
57
64
  </div>
58
65
 
59
66
  <% content_for :head do %>
60
- <%= stylesheet_link_tag "markitup.css" %>
61
- <%= javascript_include_tag 'jquery.markitup.js', 'markdown.set.js' %>
62
67
  <script type="text/javascript">
63
68
  //<![CDATA[
64
69
  $(document).ready(function() {
@@ -71,4 +76,4 @@
71
76
  });
72
77
  //]]>
73
78
  </script>
74
- <% end %>
79
+ <% end %>
@@ -1,5 +1,3 @@
1
- <%= render :partial => 'spree/admin/shared/contents_sub_menu' %>
2
-
3
1
  <%= render :partial => 'spree/admin/shared/page_tabs', :locals => {:current => 'Contents'} %>
4
2
 
5
3
  <% if @content.try(:errors).present? %>
@@ -1,5 +1,3 @@
1
- <%= render :partial => 'spree/admin/shared/contents_sub_menu' %>
2
-
3
1
  <div class='toolbar'>
4
2
  <ul class='actions'>
5
3
  <li>
@@ -13,13 +11,13 @@
13
11
 
14
12
  <h2><%= t('.listing_contents') %></h2>
15
13
 
16
- <table class="index sortable">
14
+ <table class="index sortable" data-sortable-link="<%= update_positions_admin_page_contents_url(@page) -%>">
17
15
  <thead>
18
- <tr>
19
- <th><%= sort_link @search, :title, t("content.title") %></th>
20
- <th><%= sort_link @search, :context, t("content.context") %></th>
21
- <th><%= t("action") %></th>
22
- </tr>
16
+ <tr>
17
+ <th><%= sort_link @search, :title, t("content.title") %></th>
18
+ <th><%= sort_link @search, :context, t("content.context") %></th>
19
+ <th><%= t("action") %></th>
20
+ </tr>
23
21
  </thead>
24
22
  <tbody>
25
23
  <%- @collection.each do |content|%>
@@ -27,8 +25,8 @@
27
25
  <td><span class="handle">&nbsp;</span>&nbsp; <%= link_to content.title, object_url(content) %></td>
28
26
  <td><%= content.context %>
29
27
  <td>
30
- <%= link_to_edit content %> &nbsp;
31
- <%= link_to_delete content %>
28
+ <%= link_to_edit content %> &nbsp;
29
+ <%= link_to_delete content %>
32
30
  </td>
33
31
  </tr>
34
32
  <% end %>
@@ -38,17 +36,18 @@
38
36
  <%= paginate @collection %>
39
37
 
40
38
  <% content_for :sidebar do %>
41
-
42
- <div class="box">
43
- <h3><%= t(:search) %></h3>
44
-
45
- <% @content = Spree::Content.metasearch %>
46
- <%= form_for [:admin, @page, @content] do |f| %>
47
- <p>
48
- <label><%= t('content.title') %></label><br />
49
- <%= f.text_field :title_like, :size => 25 %>
50
- </p>
51
- <p><%= button t("search") %></p>
52
- <% end %>
53
- </div>
39
+ <div class="box">
40
+ <h3><%= t(:search) %></h3>
41
+ <%= search_form_for [:admin, @page, @search] do |f| %>
42
+ <p>
43
+ <%= f.label :title_cont, t('content.title') %><br />
44
+ <%= f.text_field :title_cont, :size => 25 %>
45
+ </p>
46
+ <p>
47
+ <%= f.label :context_cont, t('content.context') %><br />
48
+ <%= f.text_field :context_cont, :size => 25 %>
49
+ </p>
50
+ <p><%= button t("search") %></p>
51
+ <% end %>
52
+ </div>
54
53
  <% end %>
@@ -1,5 +1,3 @@
1
- <%= render :partial => 'spree/admin/shared/contents_sub_menu' %>
2
-
3
1
  <%= render :partial => 'spree/admin/shared/page_tabs', :locals => {:current => 'Contents'} %>
4
2
 
5
3
  <% if @content.try(:errors).present? %>
@@ -1,4 +1,3 @@
1
- <%= render :partial => 'spree/admin/shared/contents_sub_menu' %>
2
1
  <%= render :partial => 'spree/admin/shared/page_tabs', :locals => {:current => 'Contents'} %>
3
2
 
4
3
  <h2>Content: <%= h @content.title %></h2>
@@ -1,5 +1,3 @@
1
- <%= render :partial => 'spree/admin/shared/contents_sub_menu' %>
2
-
3
1
  <%= render :partial => 'spree/admin/shared/page_tabs', :locals => {:current => "Images"} %>
4
2
 
5
3
  <% if @page_image.try(:errors).present? %>
@@ -17,4 +15,4 @@
17
15
  <%= button t("update") %>
18
16
  or <%= link_to t("cancel"), admin_page_images_url(@page), :id => "cancel_link" %>
19
17
  </p>
20
- <% end %>
18
+ <% end %>
@@ -1,26 +1,26 @@
1
- <%= render :partial => 'spree/admin/shared/contents_sub_menu' %>
2
-
3
1
  <%= render :partial => 'spree/admin/shared/page_tabs', :locals => {:current => "Images"} %>
4
2
 
5
- <table class="index sortable">
6
- <tr>
7
- <th><%= t("thumbnail") %></th>
8
- <th><%= t("alt_text") %></th>
9
- <th><%= t("action") %></th>
10
- </tr>
11
-
12
- <% @page.images.each do |image| %>
13
- <tr id="<%= dom_id(image).sub('page_', '') %>">
14
- <td><span class="handle">&nbsp;</span>&nbsp; <%= link_to(image_tag(image.attachment.url(:mini)), image.attachment.url(:large)) %></td>
15
- <td><%= image.alt %></td>
16
- <td class="actions">
17
- <%= link_to_with_icon('edit', t("edit"), edit_admin_page_image_url(@page, image)) %>
18
- &nbsp;
19
- <%= link_to_delete image, {:url => admin_page_image_url(@page, image) }%>
20
- </td>
3
+ <table class="index sortable" data-sortable-link="<%= update_positions_admin_page_images_url(@page) -%>">
4
+ <thead>
5
+ <tr>
6
+ <th><%= t("thumbnail") %></th>
7
+ <th><%= t("alt_text") %></th>
8
+ <th><%= t("action") %></th>
21
9
  </tr>
22
- <% end %>
23
-
10
+ </thead>
11
+ <tbody>
12
+ <% @page.images.each do |image| %>
13
+ <tr id="<%= dom_id(image) %>">
14
+ <td><span class="handle">&nbsp;</span>&nbsp; <%= link_to(image_tag(image.attachment.url(:mini)), image.attachment.url(:large)) %></td>
15
+ <td><%= image.alt %></td>
16
+ <td class="actions">
17
+ <%= link_to_with_icon('edit', t("edit"), edit_admin_page_image_url(@page, image)) %>
18
+ &nbsp;
19
+ <%= link_to_delete image, {:url => admin_page_image_url(@page, image) }%>
20
+ </td>
21
+ </tr>
22
+ <% end %>
23
+ </tbody>
24
24
  </table>
25
25
 
26
26
  <div id="images"></div>
@@ -31,14 +31,14 @@
31
31
 
32
32
  <% content_for :head do %>
33
33
  <script type="text/javascript">
34
- jQuery(document).ready(function(){
35
-
36
- jQuery('#new_image_link').click(function (event) {
34
+ jQuery(document).ready(function(){
35
+
36
+ jQuery('#new_image_link').click(function (event) {
37
37
  event.preventDefault();
38
38
  jQuery(this).hide();
39
39
  jQuery.ajax({type: 'GET', url: this.href, data: ({authenticity_token: AUTH_TOKEN}), success: function(r){ jQuery('#images').html(r);} });
40
40
  });
41
-
41
+
42
42
  });
43
43
  </script>
44
- <% end %>
44
+ <% end %>
@@ -1,3 +1,5 @@
1
+ <%= render :partial => 'spree/admin/shared/page_tabs', :locals => {:current => "Images"} unless request.xhr? %>
2
+
1
3
  <h3><%= t("new_image") %></h3>
2
4
 
3
5
  <%= render 'spree/shared/error_messages', :target => @page_image %>
@@ -17,4 +19,4 @@
17
19
  jQuery('#new_image_link').show();
18
20
  jQuery('#images').html('');
19
21
  });
20
- </script>
22
+ </script>
@@ -1,5 +1,3 @@
1
- <%= render :partial => 'spree/admin/shared/contents_sub_menu' %>
2
-
3
1
  <%= render :partial => 'spree/admin/shared/page_tabs', :locals => {:current => 'Page Details'} %>
4
2
 
5
3
  <% if @page.try(:errors).present? %>
@@ -1,5 +1,3 @@
1
- <%= render :partial => 'spree/admin/shared/contents_sub_menu' %>
2
-
3
1
  <div class='toolbar'>
4
2
  <ul class='actions'>
5
3
  <li>
@@ -11,15 +9,15 @@
11
9
 
12
10
  <h1><%= t('.listing_pages') %></h1>
13
11
 
14
- <table class="index sortable">
12
+ <table class="index sortable" data-sortable-link="<%= update_positions_admin_pages_url -%>">
15
13
  <thead>
16
- <tr>
17
- <th><%= sort_link @search, :title, t("page.title") %></th>
18
- <th><%= sort_link @search, :path, t("page.path") %></th>
19
- <th><%= sort_link @search, :accessible, t("page.accessible") %></th>
20
- <th><%= sort_link @search, :visible, t("page.visible") %></th>
21
- <th><%= t("action") %></th>
22
- </tr>
14
+ <tr>
15
+ <th><%= sort_link @search, :title, t("page.title") %></th>
16
+ <th><%= sort_link @search, :path, t("page.path") %></th>
17
+ <th><%= sort_link @search, :accessible, t("page.accessible") %></th>
18
+ <th><%= sort_link @search, :visible, t("page.visible") %></th>
19
+ <th><%= t("action") %></th>
20
+ </tr>
23
21
  </thead>
24
22
  <tbody>
25
23
  <%- @collection.each do |page|%>
@@ -29,10 +27,10 @@
29
27
  <td><%= page.accessible %></td>
30
28
  <td><%= page.visible %></td>
31
29
  <td>
32
- <%= link_to_with_icon :accept, t('preview'), page.path, :onclick => 'window.open(this.href);return false;' %> &nbsp;
33
- <%= link_to_with_icon :pages, t('page.contents'), admin_page_contents_path(page) %> &nbsp;
34
- <%= link_to_edit page %> &nbsp;
35
- <%= link_to_delete page %>
30
+ <%= link_to_with_icon :accept, t('preview'), page.path, :onclick => 'window.open(this.href);return false;' %> &nbsp;
31
+ <%= link_to_with_icon :pages, t('page.contents'), admin_page_contents_path(page) %> &nbsp;
32
+ <%= link_to_edit page %> &nbsp;
33
+ <%= link_to_delete page %>
36
34
  </td>
37
35
  </tr>
38
36
  <% end %>
@@ -42,16 +40,18 @@
42
40
  <%= paginate @collection %>
43
41
 
44
42
  <% content_for :sidebar do %>
45
- <div class="box">
46
- <h3><%= t(:search) %></h3>
47
-
48
- <% @page = Spree::Page.metasearch %>
49
- <%= form_for [:admin, @page] do |f| %>
50
- <p>
51
- <label><%= t '.title_contains' %></label><br />
52
- <%= f.text_field :title_contains, :size => 25 %>
53
- </p>
54
- <p><%= button t("search") %></p>
55
- <% end %>
56
- </div>
43
+ <div class="box">
44
+ <h3><%= t(:search) %></h3>
45
+ <%= search_form_for [:admin, @search] do |f| %>
46
+ <p>
47
+ <%= f.label :title_cont, t('page.title') %><br />
48
+ <%= f.text_field :title_cont, :size => 25 %>
49
+ </p>
50
+ <p>
51
+ <%= f.label :path_cont, t('page.path') %><br />
52
+ <%= f.text_field :path_cont, :size => 25 %>
53
+ </p>
54
+ <p><%= button t("search") %></p>
55
+ <% end %>
56
+ </div>
57
57
  <% end %>
@@ -1,4 +1,4 @@
1
- <%= render :partial => 'spree/admin/shared/contents_sub_menu' %>
1
+ <%#= render :partial => 'spree/admin/shared/contents_sub_menu' %>
2
2
 
3
3
  <% if @page.try(:errors).present? %>
4
4
  <%= render 'spree/shared/error_messages', :target => @page %>
@@ -1,5 +1,3 @@
1
- <%= render :partial => 'spree/admin/shared/contents_sub_menu' %>
2
-
3
1
  <%= render :partial => 'spree/admin/shared/page_tabs', :locals => {:current => "Page Details"} %>
4
2
 
5
3
  <h3>Meta Data:</h3>
@@ -26,3 +26,13 @@
26
26
  </div>
27
27
  <% end %>
28
28
  </div>
29
+
30
+ <% content_for :sidebar do %>
31
+ <div data-hook="homepage_sidebar_navigation">
32
+ <%= render :partial => 'spree/shared/taxonomies' %>
33
+ </div>
34
+ <% end %>
35
+
36
+ <div data-hook="homepage_products">
37
+ <%= render :partial => 'spree/shared/products', :locals => { :products => @products } %>
38
+ </div>
@@ -1,7 +1,3 @@
1
- <% if @pages %>
2
- <ul id="main-menu">
3
- <% @pages.each do |page| %>
4
- <li<%= ' class="active"'.html_safe if page.matches?(request.path) %>><%= link_to page.nav_title, page.path %></li>
5
- <% end %>
6
- </ul>
7
- <% end %>
1
+ <ul id="main-menu">
2
+ <%= render "spree/shared/main_menu_items" %>
3
+ </ul>
@@ -0,0 +1,6 @@
1
+ <% unless @pages.blank? %>
2
+ <% @pages.each do |page| %>
3
+ <% next if page.root? || !page.visible? %>
4
+ <%= content_tag(:li, link_to(page.nav_title, page.path), :class => page.matches?(request.path) ? "active" : nil) %>
5
+ <% end %>
6
+ <% end %>
@@ -24,6 +24,7 @@ en:
24
24
  link_text: Link Text
25
25
  context: Context
26
26
  hide_title: Hide Title
27
+ delete_attachment: Delete current attachment
27
28
 
28
29
  pages: Pages
29
30
 
@@ -0,0 +1,63 @@
1
+ it:
2
+ page:
3
+ model_name: Pagina
4
+ contents: Contenuti
5
+ title: Titolo
6
+ nav_title: Titolo navigazione
7
+ path: Percorso
8
+ meta_title: Titolo (metadato)
9
+ meta_description: Descrizione (metadato)
10
+ meta_keywords: Parole chiave (metadato)
11
+ accessible: Accessibile
12
+ visible: Visibile
13
+ explain_accessible: le pagine non accessibili devono essere messe in un controller personalizzato
14
+ explain_visible: le pagine visibili verranno mostrate nel menù principale
15
+
16
+ content:
17
+ model_name: Contenuto
18
+ page_title: Titolo pagina
19
+ page: Pagina
20
+ title: Titolo
21
+ body: Corpo
22
+ attachment: Allegato
23
+ link: URL del collegamento
24
+ link_text: Testo del collegamento
25
+ context: Contesto
26
+ hide_title: Nascondi titolo
27
+ delete_attachment: Cancella gli allegati correnti
28
+
29
+ pages: Pagine
30
+
31
+ spree:
32
+ admin:
33
+ subnav:
34
+ pages: Pagine
35
+ shared:
36
+ contents_tab:
37
+ content: Contenuto
38
+ page_tabs:
39
+ editing_page: Modifica pagina
40
+ page_details: Dettagli della pagina
41
+ contents: Contenuti
42
+ images: Immagini
43
+ pages:
44
+ index:
45
+ title: Titolo
46
+ listing_pages: Elenco pagine
47
+ new_page: Nuova pagina
48
+ title_contains: Titolo
49
+ new:
50
+ new_page: Nuova pagina
51
+
52
+ contents:
53
+ index:
54
+ new_content: Nuovo contenuto
55
+ listing_contents: Elenca contenuti
56
+ new:
57
+ new_content: Nuovo contenuto
58
+ edit:
59
+ edit_content: Modifica contenuto
60
+
61
+ uploads:
62
+ index:
63
+ new_upload: Carica un nuovo allegato