spree_essential_cms 0.1.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 (44) hide show
  1. data/LICENSE +23 -0
  2. data/README.md +78 -0
  3. data/Rakefile +21 -0
  4. data/app/controllers/admin/contents_controller.rb +41 -0
  5. data/app/controllers/admin/page_images_controller.rb +37 -0
  6. data/app/controllers/admin/pages_controller.rb +38 -0
  7. data/app/controllers/page_controller.rb +19 -0
  8. data/app/controllers/pages_controller.rb +28 -0
  9. data/app/controllers/spree_base_controller_decorator.rb +11 -0
  10. data/app/models/content.rb +82 -0
  11. data/app/models/page.rb +61 -0
  12. data/app/models/page_image.rb +40 -0
  13. data/app/views/admin/contents/_form.html.erb +74 -0
  14. data/app/views/admin/contents/edit.html.erb +16 -0
  15. data/app/views/admin/contents/index.html.erb +59 -0
  16. data/app/views/admin/contents/new.html.erb +18 -0
  17. data/app/views/admin/contents/show.html.erb +11 -0
  18. data/app/views/admin/page_images/_form.html.erb +8 -0
  19. data/app/views/admin/page_images/edit.html.erb +20 -0
  20. data/app/views/admin/page_images/index.html.erb +42 -0
  21. data/app/views/admin/page_images/new.html.erb +20 -0
  22. data/app/views/admin/pages/_form.html.erb +73 -0
  23. data/app/views/admin/pages/edit.html.erb +14 -0
  24. data/app/views/admin/pages/index.html.erb +62 -0
  25. data/app/views/admin/pages/new.html.erb +16 -0
  26. data/app/views/admin/pages/show.html.erb +23 -0
  27. data/app/views/admin/shared/_page_tabs.html.erb +23 -0
  28. data/app/views/pages/home.html.erb +28 -0
  29. data/app/views/pages/show.html.erb +3 -0
  30. data/app/views/shared/_content.html.erb +33 -0
  31. data/app/views/shared/_main_menu.html.erb +7 -0
  32. data/app/views/shared/_slideshow.html.erb +8 -0
  33. data/config/locales/en.yml +55 -0
  34. data/config/routes.rb +38 -0
  35. data/lib/dummy_hooks/after_migrate.rb +1 -0
  36. data/lib/dummy_hooks/after_migrate.rb.sample +1 -0
  37. data/lib/dummy_hooks/before_migrate.rb +6 -0
  38. data/lib/generators/essentials_base.rb +23 -0
  39. data/lib/generators/spree_essentials/cms_generator.rb +17 -0
  40. data/lib/generators/templates/db/migrate/create_contents.rb +27 -0
  41. data/lib/generators/templates/db/migrate/create_pages.rb +24 -0
  42. data/lib/spree_essential_cms/version.rb +3 -0
  43. data/lib/spree_essential_cms.rb +43 -0
  44. metadata +236 -0
@@ -0,0 +1,20 @@
1
+ <%= render :partial => 'admin/shared/contents_sub_menu' %>
2
+
3
+ <%= render :partial => 'admin/shared/page_tabs', :locals => {:current => "Images"} %>
4
+
5
+ <% if @page_image.try(:errors).present? %>
6
+ <%= render 'shared/error_messages', :target => @page_image %>
7
+ <% end %>
8
+
9
+ <%= form_for([:admin, @page.id, @page_image], :url => admin_page_image_url(@page, @page_image), :html => { :multipart => true }) do |f| %>
10
+ <p>
11
+ <%= label_tag ("thumbnail") %>:<br/>
12
+ <%= link_to(image_tag(@page_image.attachment.url(:mini)), @page_image.attachment.url(:product)) %>
13
+ </p>
14
+ <%= render "form", :form => f %>
15
+ </table>
16
+ <p class="form-buttons">
17
+ <%= button t("update") %>
18
+ or <%= link_to t("cancel"), admin_page_images_url(@page), :id => "cancel_link" %>
19
+ </p>
20
+ <% end %>
@@ -0,0 +1,42 @@
1
+ <%= render :partial => 'admin/shared/page_tabs', :locals => {:current => "Images"} %>
2
+
3
+ <table class="index sortable">
4
+ <tr>
5
+ <th><%= t("thumbnail") %></th>
6
+ <th><%= t("alt_text") %></th>
7
+ <th><%= t("action") %></th>
8
+ </tr>
9
+
10
+ <% @page.images.each do |image| %>
11
+ <tr id="<%= dom_id(image).sub('page_', '') %>">
12
+ <td><span class="handle">&nbsp;</span>&nbsp; <%= link_to(image_tag(image.attachment.url(:mini)), image.attachment.url(:large)) %></td>
13
+ <td><%= image.alt %></td>
14
+ <td class="actions">
15
+ <%= link_to_with_icon('edit', t("edit"), edit_admin_page_image_url(@page, image)) %>
16
+ &nbsp;
17
+ <%= link_to_delete image, {:url => admin_page_image_url(@page, image) }%>
18
+ </td>
19
+ </tr>
20
+ <% end %>
21
+
22
+ </table>
23
+
24
+ <div id="images"></div>
25
+ <br/>
26
+ <p>
27
+ <%= link_to icon('add') + ' ' + t("new_image"), new_admin_page_image_url(@page), :id => "new_image_link" %>
28
+ </p>
29
+
30
+ <% content_for :head do %>
31
+ <script type="text/javascript">
32
+ jQuery(document).ready(function(){
33
+
34
+ jQuery('#new_image_link').click(function (event) {
35
+ event.preventDefault();
36
+ jQuery(this).hide();
37
+ jQuery.ajax({type: 'GET', url: this.href, data: ({authenticity_token: AUTH_TOKEN}), success: function(r){ jQuery('#images').html(r);} });
38
+ });
39
+
40
+ });
41
+ </script>
42
+ <% end %>
@@ -0,0 +1,20 @@
1
+ <h3><%= t("new_image") %></h3>
2
+
3
+ <%= render 'shared/error_messages', :target => @page_image %>
4
+
5
+ <%= form_for(@page_image, :url => admin_page_images_path(@page), :html => { :multipart => true }) do |form| %>
6
+ <table class="basic-table">
7
+ <%= render "form", :form => form %>
8
+ </table>
9
+ <p class="form-buttons">
10
+ <%= button t("create") %>
11
+ or <%= link_to t("cancel"), "#", :id => "cancel_link" %>
12
+ </p>
13
+ <% end %>
14
+
15
+ <script type="text/javascript">
16
+ jQuery('#cancel_link').click(function (event) {
17
+ jQuery('#new_image_link').show();
18
+ jQuery('#images').html('');
19
+ });
20
+ </script>
@@ -0,0 +1,73 @@
1
+ <%= form.field_container :title do %>
2
+ <%= form.label :title, t('page.title') %> <span class="required">*</span><br />
3
+ <%= form.text_field :title, :class => "title" %>
4
+ <%= error_message_on :page, :title %>
5
+ <% end %>
6
+
7
+ <%= form.field_container :meta_title do %>
8
+ <%= form.label :meta_title, t('page.meta_title') %><br />
9
+ <%= form.text_field :meta_title, :class => "text" %>
10
+ <%= error_message_on :page, :meta_title %>
11
+ <% end %>
12
+
13
+ <%= form.field_container :meta_description do %>
14
+ <%= form.label :meta_description, t('page.meta_description') %><br />
15
+ <%= form.text_field :meta_description, :class => "text" %>
16
+ <%= error_message_on :page, :meta_description %>
17
+ <% end %>
18
+
19
+ <%= form.field_container :meta_keywords do %>
20
+ <%= form.label :meta_keywords, t('page.meta_keywords') %><br />
21
+ <%= form.text_field :meta_keywords, :class => "text" %>
22
+ <%= error_message_on :page, :meta_keywords %>
23
+ <% end %>
24
+
25
+ <%= form.field_container :accessible do %>
26
+ <%= form.check_box :accessible, :class => "text" %> &nbsp;
27
+ <%= form.label :accessible, t('page.accessible') %>
28
+ &ndash; <em><%= t('page.explain_accessible') %></em>
29
+ <%= error_message_on :page, :accessible %>
30
+ <% end %>
31
+
32
+ <div id="field_path">
33
+
34
+ <%= form.field_container :path do %>
35
+ <%= form.label :path, t('page.path') %><br />
36
+ <%= form.text_field :path, :class => "text" %>
37
+ <%= error_message_on :page, :path %>
38
+ <% end %>
39
+
40
+ <%= form.field_container :visible do %>
41
+ <%= form.check_box :visible, :class => "text" %> &nbsp;
42
+ <%= form.label :visible, t('page.visible') %>
43
+ &ndash; <em><%= t('page.explain_visible') %></em>
44
+ <%= error_message_on :page, :visible %>
45
+ <% end %>
46
+
47
+ <div id="field_nav_title">
48
+ <%= form.field_container :nav_title do %>
49
+ <%= form.label :nav_title, t('page.nav_title') %><br />
50
+ <%= form.text_field :nav_title, :class => "text" %>
51
+ <%= error_message_on :page, :nav_title %>
52
+ <% end %>
53
+ </div>
54
+
55
+ </div>
56
+
57
+ <script type="text/javascript">
58
+ //<![CDATA[
59
+
60
+ $(document).ready(function() {
61
+
62
+ $('#page_accessible').change(function(evt) {
63
+ $('#field_path').toggle(this.checked);
64
+ }).change();
65
+
66
+ $('#page_visible').change(function(evt) {
67
+ $('#field_nav_title').toggle(this.checked);
68
+ }).change();
69
+
70
+ });
71
+
72
+ //]]>
73
+ </script>
@@ -0,0 +1,14 @@
1
+ <%= render :partial => 'admin/shared/contents_sub_menu' %>
2
+
3
+ <%= render :partial => 'admin/shared/page_tabs', :locals => {:current => 'Page Details'} %>
4
+
5
+ <% if @page.try(:errors).present? %>
6
+ <%= render 'shared/error_messages', :target => @page %>
7
+ <% end %>
8
+
9
+ <%= form_for([:admin, @page]) do |f| %>
10
+ <%= render "form", :form => f %>
11
+ <p class="form-buttons">
12
+ <%= button t("update") %> <%= t('or') %> <%= link_to t('cancel'), collection_url %>
13
+ </p>
14
+ <% end %>
@@ -0,0 +1,62 @@
1
+ <%= render :partial => 'admin/shared/contents_sub_menu' %>
2
+
3
+ <div class='toolbar'>
4
+ <ul class='actions'>
5
+ <li>
6
+ <p><%= button_link_to t('.new_page'), new_object_url, :icon => 'add' %></p>
7
+ </li>
8
+ </ul>
9
+ <br class='clear' />
10
+ </div>
11
+
12
+ <h1><%= t('.listing_pages') %></h1>
13
+
14
+ <table class="index sortable">
15
+ <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>
23
+ </thead>
24
+ <tbody>
25
+ <%- @collection.each do |page|%>
26
+ <tr id="<%= dom_id page %>">
27
+ <td><span class="handle">&nbsp;</span>&nbsp; <%=link_to page.title, object_url(page) %></td>
28
+ <td><%= page.path %></td>
29
+ <td><%= page.accessible %></td>
30
+ <td><%= page.visible %></td>
31
+ <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 %>
36
+ </td>
37
+ </tr>
38
+ <% end %>
39
+ </tbody>
40
+ </table>
41
+
42
+ <%= will_paginate(:prev => "&#171; #{t('previous')}", :next => "#{t('next')} &#187;") %>
43
+
44
+ <% content_for :sidebar do %>
45
+ <div class="box">
46
+ <h3><%= t(:search) %></h3>
47
+
48
+ <% @page = Page.metasearch %>
49
+ <%= form_for [:admin, @page] do |f| %>
50
+ <%- locals = {:f => f} %>
51
+ <%= hook :admin_pages_index_search, locals do %>
52
+ <p>
53
+ <label><%= t '.title_contains' %></label><br />
54
+ <%= f.text_field :title_contains, :size => 25 %>
55
+ </p>
56
+ <% end %>
57
+ <%= hook :admin_pages_index_search_buttons, locals do %>
58
+ <p><%= button t("search") %></p>
59
+ <% end %>
60
+ <% end %>
61
+ </div>
62
+ <% end %>
@@ -0,0 +1,16 @@
1
+ <%= render :partial => 'admin/shared/contents_sub_menu' %>
2
+
3
+ <% if @page.try(:errors).present? %>
4
+ <%= render 'shared/error_messages', :target => @page %>
5
+ <% end %>
6
+
7
+ <h1><%= t('.new_page') %></h1>
8
+
9
+ <% form_for([:admin, @page], :html => { :multipart => true }) do |f| %>
10
+ <%= render "form", :form => f %>
11
+
12
+ <p class="form-buttons">
13
+ <%= button t('create') %> <%= t('or') %> <%= link_to t('cancel'), collection_url %>
14
+ </p>
15
+ <% end %>
16
+
@@ -0,0 +1,23 @@
1
+ <%= render :partial => 'admin/shared/contents_sub_menu' %>
2
+
3
+ <%= render :partial => 'admin/shared/page_tabs', :locals => {:current => "Page Details"} %>
4
+
5
+ <h3>Meta Data:</h3>
6
+ <p>
7
+ <b><%= t('page.meta_title') %>:</b> <%= @page.meta_title %><br/>
8
+ <b><%= t('page.meta_description') %>:</b> <%= @page.meta_description %><br/>
9
+ <b><%= t('page.meta_keywords') %>:</b> <%= @page.meta_keywords %>
10
+ </p>
11
+
12
+ <hr/>
13
+
14
+ <% @page.contents.each do |content| %>
15
+
16
+ <%= content.title %>
17
+
18
+ <% end %>
19
+
20
+ <p>
21
+ <%= link_to_edit @page %> &nbsp;
22
+ <%= link_to t('back'), collection_url %>
23
+ </p>
@@ -0,0 +1,23 @@
1
+ <h1><%= (t('.editing_page') + " &ldquo;#{@page.title}&rdquo;").html_safe %></h1>
2
+
3
+ <% content_for :sidebar do %>
4
+
5
+ <h3 class="name"><%= @page.title %></h3>
6
+ <br clear="clear" />
7
+
8
+ <ul class="sidebar post-menu">
9
+ <%= hook :admin_page_tabs, {:current => current} do %>
10
+ <li<%== ' class="active"' if current == t('.page_details') %>>
11
+ <%= link_to t('.page_details'), edit_admin_page_url(@page) %>
12
+ </li>
13
+ <li<%== ' class="active"' if current == "Contents" %>>
14
+ <%= link_to t('.contents'), admin_page_contents_url(@page) %>
15
+ </li>
16
+ <li<%== ' class="active"' if current == "Images" %>>
17
+ <%= link_to t('.images'), admin_page_images_url(@page) %>
18
+ </li>
19
+ <% end %>
20
+ </ul>
21
+ <br clear="clear" />
22
+
23
+ <% end %>
@@ -0,0 +1,28 @@
1
+ <% unless @page.images.empty? %>
2
+ <%= render 'shared/slideshow', :images => @page.images, :size => :slide %>
3
+ <% end %>
4
+
5
+ <% if @page.has_context?('intro') %>
6
+ <div class="intro">
7
+ <%= render 'shared/content', :content => @page.for_context('intro').first %>
8
+ </div>
9
+ <% end %>
10
+
11
+ <div class="left">
12
+ <%= render :partial => 'shared/content', :collection => @page.for_context("") %>
13
+ </div>
14
+
15
+ <div class="right">
16
+ <% if defined?(SpreeEssentialBlog) && !@posts.blank? %>
17
+ <div class="home-posts">
18
+ <h1><%= t('blog.home.title') %></h1>
19
+ <%= render :partial => 'blog/posts/preview', :collection => @posts, :as => :post %>
20
+ </div>
21
+ <% end %>
22
+ <% if defined?(SpreeEssentialNews) && !@articles.blank? %>
23
+ <div class="home-articles">
24
+ <h1><%= t('news.home.title') %></h1>
25
+ <%= render :partial => 'news/articles/preview', :collection => @articles, :as => :article %>
26
+ </div>
27
+ <% end %>
28
+ </div>
@@ -0,0 +1,3 @@
1
+ <div class="for-<%= @page.to_param %>">
2
+ <%= render :partial => 'shared/content', :collection => @page.contents %>
3
+ </div>
@@ -0,0 +1,33 @@
1
+ <% content ||= @content %>
2
+ <% html ||= false %>
3
+ <% content_counter ||= 0 %>
4
+
5
+ <% unless content.nil? %>
6
+
7
+ <div class="content<%= ' alt' if content_counter % 2 == 0 %>" id="<%= dom_id(content) %>">
8
+
9
+ <% if content.has_image? %>
10
+ <div class="content-left">
11
+ <%= image_tag content.attachment.url(:medium), :alt => content.title, :class => 'in-content' %>
12
+ </div>
13
+ <% end %>
14
+
15
+ <div class="<%= content.has_image? ? "content-right" : "content-main" %>">
16
+ <% unless content.hide_title? %>
17
+ <h1 class="title"><%= content.title %></h1>
18
+ <% end %>
19
+
20
+ <%= content.rendered_body %>
21
+
22
+ <% if content.has_full_link? %>
23
+ <%= link_to content.link_text || 'read more', content.link %>
24
+ <% end %>
25
+ </div>
26
+
27
+ <br class="clear"/>
28
+
29
+ </div>
30
+
31
+ <br class="clear"/>
32
+
33
+ <% end %>
@@ -0,0 +1,7 @@
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 %>
@@ -0,0 +1,8 @@
1
+ <% size ||= nil %>
2
+ <% if defined?(images) && !images.nil? %>
3
+ <div class="slideshow<%= " #{size}" if size %>">
4
+ <% images.each do |image| %>
5
+ <%= image_tag image.attachment.url(size), :alt => image.alt %>
6
+ <% end %>
7
+ </div>
8
+ <% end %>
@@ -0,0 +1,55 @@
1
+ en:
2
+ page:
3
+ contents: Contents
4
+ title: Title
5
+ nav_title: Navigation Title
6
+ path: Path
7
+ meta_title: Meta Title
8
+ meta_description: Meta Description
9
+ meta_keywords: Meta Keywords
10
+ accessible: Accessible
11
+ visible: Visible
12
+ explain_accessible: non-accessible pages must be coded into a custom controller.
13
+ explain_visible: visible pages will show up in the main menu.
14
+
15
+ content:
16
+ page_title: Page Title
17
+ page: Page
18
+ title: Title
19
+ body: Body
20
+ attachment: Attachment
21
+ link: Link URL
22
+ link_text: Link Text
23
+ context: Context
24
+ hide_title: Hide Title
25
+
26
+ pages: Pages
27
+
28
+ admin:
29
+ subnav:
30
+ pages: Pages
31
+ shared:
32
+ contents_tab:
33
+ content: Content
34
+ page_tabs:
35
+ editing_page: Editing Page
36
+ page_details: Page Details
37
+ contents: Contents
38
+ images: Images
39
+ pages:
40
+ index:
41
+ title: Title
42
+ listing_pages: Listing Pages
43
+ new_page: New Page
44
+ title_contains: Title
45
+ new:
46
+ new_page: New Page
47
+
48
+ contents:
49
+ index:
50
+ new_content: New Content
51
+ listing_contents: Listing Contents
52
+ new:
53
+ new_content: New Content
54
+ edit:
55
+ edit_content: Edit Content
data/config/routes.rb ADDED
@@ -0,0 +1,38 @@
1
+ class PossiblePage
2
+ def self.matches?(request)
3
+ path = request.fullpath
4
+ return false if path =~ /(^\/(admin|account|cart|checkout|content|login|pg\/|orders|products|s\/|session|signup|shipments|states|t\/|tax_categories|user))/
5
+ count = Page.active.where(:path => path).count
6
+ 0 < count
7
+ end
8
+ end
9
+
10
+ Rails.application.routes.draw do
11
+
12
+ namespace :admin do
13
+
14
+ resources :pages do
15
+ collection do
16
+ post :update_positions
17
+ end
18
+
19
+ resources :contents do
20
+ collection do
21
+ post :update_positions
22
+ end
23
+ end
24
+
25
+ resources :images, :controller => "page_images" do
26
+ collection do
27
+ post :update_positions
28
+ end
29
+ end
30
+ end
31
+
32
+ end
33
+
34
+ constraints(PossiblePage) do
35
+ get '(:page_path)', :to => 'pages#show', :page_path => /.*/, :as => :page
36
+ end
37
+
38
+ end
@@ -0,0 +1 @@
1
+ rake "db:migrate db:seed db:admin:create", :env => "development"
@@ -0,0 +1 @@
1
+ rake "db:migrate db:seed db:admin:create", :env => "development"
@@ -0,0 +1,6 @@
1
+ say_status "installing", "spree_core, spree_auth"
2
+ rake "spree_core:install spree_auth:install"
3
+
4
+ say_status "installing", "spree_essentials and spree_essential_cms"
5
+ run "rails g spree_essentials:install"
6
+ run "rails g spree_essentials:cms"
@@ -0,0 +1,23 @@
1
+ module SpreeEssentials
2
+ module Generators
3
+ class EssentialsBase < Rails::Generators::Base
4
+
5
+ include Rails::Generators::Migration
6
+
7
+ def self.count!
8
+ @count ||= 0
9
+ (@count += 1) * 3
10
+ end
11
+
12
+ def self.next_migration_number(path)
13
+ @time ||= Time.new.utc
14
+ if ActiveRecord::Base.timestamped_migrations
15
+ (@time + self.count!).strftime("%Y%m%d%H%M%S")
16
+ else
17
+ "%.3d" % (current_migration_number(dirname) + 1)
18
+ end
19
+ end
20
+
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,17 @@
1
+ require 'generators/essentials_base'
2
+
3
+ module SpreeEssentials
4
+ module Generators
5
+ class CmsGenerator < SpreeEssentials::Generators::EssentialsBase
6
+
7
+ desc "Installs required migrations for spree_essentials"
8
+ source_root File.expand_path("../../templates/db/migrate", __FILE__)
9
+
10
+ def copy_migrations
11
+ migration_template "create_pages.rb", "db/migrate/create_pages.rb"
12
+ migration_template "create_contents.rb", "db/migrate/create_contents.rb"
13
+ end
14
+
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,27 @@
1
+ class CreateContents < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :contents do |t|
4
+ t.references :page
5
+ t.string :title
6
+ t.text :body
7
+ t.string :link
8
+ t.string :link_text
9
+ t.string :context
10
+ t.boolean :hide_title, :default => false
11
+
12
+ t.integer :position, :default => 999
13
+
14
+ t.string :attachment_file_name
15
+ t.string :attachment_content_type
16
+ t.integer :attachment_file_size
17
+ t.datetime :attachment_updated_at
18
+
19
+ t.timestamps
20
+ end
21
+
22
+ end
23
+
24
+ def self.down
25
+ drop_table :contents
26
+ end
27
+ end
@@ -0,0 +1,24 @@
1
+ class CreatePages < ActiveRecord::Migration
2
+ def self.up
3
+ create_table :pages do |t|
4
+ t.string :title
5
+ t.string :nav_title
6
+ t.string :path
7
+
8
+ t.string :meta_title
9
+ t.string :meta_description
10
+ t.string :meta_keywords
11
+
12
+ t.integer :position, :default => 999
13
+ t.boolean :accessible, :default => true
14
+ t.boolean :visible, :default => true
15
+
16
+ t.timestamps
17
+ end
18
+
19
+ end
20
+
21
+ def self.down
22
+ drop_table :pages
23
+ end
24
+ end
@@ -0,0 +1,3 @@
1
+ module SpreeEssentialCms
2
+ VERSION = "0.1.0"
3
+ end
@@ -0,0 +1,43 @@
1
+ require 'spree_essentials'
2
+
3
+ module SpreeEssentialCms
4
+
5
+ def self.tab
6
+ [:pages, { :route => :admin_pages_index }]
7
+ end
8
+
9
+ def self.sub_tab
10
+ [:pages, { :route => :admin_pages_index, :label => 'admin.subnav.pages', :match_path => '/pages' }]
11
+ end
12
+
13
+ def self.independent?
14
+ return true unless defined?(SpreeEssentials)
15
+ !SpreeEssentials.respond_to?(:register)
16
+ end
17
+
18
+ class Engine < Rails::Engine
19
+ config.autoload_paths += %W(#{config.root}/lib)
20
+
21
+ initializer "static assets" do |app|
22
+ app.middleware.insert_before ::Rack::Lock, ::ActionDispatch::Static, "#{config.root}/public"
23
+ end
24
+
25
+ def self.activate
26
+
27
+ Dir.glob(File.join(File.dirname(__FILE__), "../app/**/*_decorator.rb")) do |c|
28
+ Rails.env.production? ? require(c) : load(c)
29
+ end
30
+
31
+ end
32
+
33
+ config.to_prepare &method(:activate).to_proc
34
+
35
+ end
36
+
37
+ end
38
+
39
+ if SpreeEssentialCms.independent?
40
+ require 'spree_essential_press/custom_hooks'
41
+ else
42
+ SpreeEssentials.register :cms, SpreeEssentialCms
43
+ end