+
+<% if @pages.none? %>
+
+
+ <%= t('pages.index.empty_collection') %>
+
+
+<% else %>
+ <%= render partial: 'pages/collection' %>
+<% end %>
+
+
+
+
+ <%= t('pages.new.title') %>
+
+
+
<% if @page_module_collection_slug_stubs.none? %>
@@ -63,5 +90,5 @@
<% content_for :javascript_includes do %>
- <%= javascript_include_tag 'home_page/page_module_collections/index' %>
+ <%= javascript_include_tag 'home_page/pages/index' %>
<% end %>
\ No newline at end of file
diff --git a/app/views/pages/new.html.erb b/app/views/pages/new.html.erb
new file mode 100644
index 0000000..cef7972
--- /dev/null
+++ b/app/views/pages/new.html.erb
@@ -0,0 +1,3 @@
+<% content_for :title do %><%= t('pages.new.title') %><% end %>
+
+<%= render partial: 'pages/form' %>
\ No newline at end of file
diff --git a/app/views/pages/show.html.erb b/app/views/pages/show.html.erb
new file mode 100644
index 0000000..e6e130c
--- /dev/null
+++ b/app/views/pages/show.html.erb
@@ -0,0 +1,3 @@
+<% content_for :title do %><%= @page.title %><% end %>
+
+<%= raw liquidize(@page.content) %>
\ No newline at end of file
diff --git a/app/views/pages/update.js.erb b/app/views/pages/update.js.erb
new file mode 100644
index 0000000..3d119fa
--- /dev/null
+++ b/app/views/pages/update.js.erb
@@ -0,0 +1,11 @@
+<% message = flash[:notice] %>
+<% flash.delete(:notice) %>
+<% alert = message.present? ? "alert('#{message}');" : '' %>
+
+$("#pages_row_<%= @page.id %>").replaceWith("<%= escape_javascript(
+ render(
+ partial: 'pages/page', locals: { page: @page }
+ )
+) %>");
+$('#modal').modal('hide');
+<%= raw alert %>
\ No newline at end of file
diff --git a/config/locales/resources/page/en.yml b/config/locales/resources/page/en.yml
new file mode 100644
index 0000000..df6ec65
--- /dev/null
+++ b/config/locales/resources/page/en.yml
@@ -0,0 +1,16 @@
+en:
+ pages:
+ index:
+ title: Pages
+ long_title: Pages & Modules
+ empty_collection: No pages available.
+
+ new:
+ title: New Page
+
+ edit:
+ title: Edit Page
+
+ activerecord:
+ models:
+ page: Page
diff --git a/config/locales/resources/page_module_collection/en.yml b/config/locales/resources/page_module_collection/en.yml
index fc73dd7..b34643d 100644
--- a/config/locales/resources/page_module_collection/en.yml
+++ b/config/locales/resources/page_module_collection/en.yml
@@ -2,6 +2,7 @@ en:
page_module_collections:
index:
title: Page Module Collections
+ medium_title: Module Collections
short_title: Collections
empty_collection: No page module collections available.
diff --git a/config/routes.rb b/config/routes.rb
index a5c433d..4a57a44 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -4,6 +4,8 @@
sessions: 'devise_extensions/sessions'
}
+ resources :pages
+
resources :page_module_collections do
resources :modules, controller: 'page_modules', only: [:index, :new] do
collection do
diff --git a/db/migrate/20150325183940_create_pages.rb b/db/migrate/20150325183940_create_pages.rb
new file mode 100644
index 0000000..c20dc66
--- /dev/null
+++ b/db/migrate/20150325183940_create_pages.rb
@@ -0,0 +1,13 @@
+class CreatePages < ActiveRecord::Migration
+ def change
+ create_table :pages do |t|
+ t.string :slug
+ t.string :title
+ t.text :content
+ t.text :data, limit: 16777215
+ t.timestamps
+ end
+
+ add_index :pages, :slug, unique: true
+ end
+end
diff --git a/dummy/Gemfile.lock b/dummy/Gemfile.lock
index 945517b..f89cf48 100644
--- a/dummy/Gemfile.lock
+++ b/dummy/Gemfile.lock
@@ -14,6 +14,7 @@ PATH
remote: /Users/gawlim/workspace/home_page/home_page
specs:
home_page (0.0.6)
+ RedCloth (~> 4.2.9)
activerecord-deprecated_finders (~> 1.0.3)
acts_as_list (~> 0.4.0)
albino (~> 1.3.3)
@@ -49,6 +50,7 @@ GEM
remote: http://gems.github.com/
remote: http://rubygems.org/
specs:
+ RedCloth (4.2.9)
actionmailer (4.2.0)
actionpack (= 4.2.0)
actionview (= 4.2.0)
diff --git a/dummy/db/migrate/20150325184310_create_pages.home_page_engine.rb b/dummy/db/migrate/20150325184310_create_pages.home_page_engine.rb
new file mode 100644
index 0000000..0544173
--- /dev/null
+++ b/dummy/db/migrate/20150325184310_create_pages.home_page_engine.rb
@@ -0,0 +1,14 @@
+# This migration comes from home_page_engine (originally 20150325183940)
+class CreatePages < ActiveRecord::Migration
+ def change
+ create_table :pages do |t|
+ t.string :slug
+ t.string :title
+ t.text :content
+ t.text :data, limit: 16777215
+ t.timestamps
+ end
+
+ add_index :pages, :slug, unique: true
+ end
+end
diff --git a/home_page.gemspec b/home_page.gemspec
index 4799a7c..fcf1f6c 100644
--- a/home_page.gemspec
+++ b/home_page.gemspec
@@ -47,7 +47,8 @@ Gem::Specification.new do |s|
s.add_dependency 'will_paginate-bootstrap', '~> 1.0.1'
s.add_dependency 'turbolinks', '~> 2.5.3'
s.add_dependency 'liquid', '~> 3.0.1'
-
+ s.add_dependency 'RedCloth', '~> 4.2.9'
+
# CSS & JavaScript
s.add_dependency 'twitter-bootswatch-rails', '~> 3.3.2.0'
s.add_dependency 'twitter-bootswatch-rails-fontawesome', '~> 4.3.0.0'
diff --git a/lib/home_page.rb b/lib/home_page.rb
index 10738bf..d8e59c7 100644
--- a/lib/home_page.rb
+++ b/lib/home_page.rb
@@ -28,6 +28,7 @@
require 'liquid'
require 'selectize-rails'
require 'acts_as_list'
+require 'redcloth'
require 'home_page/api_provider_host'
require 'home_page/navigation'
diff --git a/lib/home_page/navigation.rb b/lib/home_page/navigation.rb
index 5bdeaf7..c75a913 100644
--- a/lib/home_page/navigation.rb
+++ b/lib/home_page/navigation.rb
@@ -27,7 +27,7 @@ def self.code
Proc.new do |navigation|
navigation.items do |primary, options|
primary.dom_class = 'nav navbar-nav'
-
+
Setting['home_page.general.navigation.items'].each do |item|
klass = "HomePage#{item.is_a?(Array) ? item.first.classify : ''}::Navigation"
item = item.is_a?(Array) ? item.last : item
@@ -39,40 +39,58 @@ def self.code
def self.menu_code(resource)
case resource
- when 'page_modules'
+ when 'pages', 'page_modules'
Proc.new do |primary, options|
if user_signed_in?
- primary.item(
- :page_module_collections, t('page_modules.index.title'), page_module_collections_path,
- breadcrumb_title: t('page_module_collections.index.title')
- ) do |page_module_collections|
- page_module_collections.item :new, t('general.new'), new_page_module_collection_path
+ primary.item :pages, t('pages.index.title'), pages_path do |pages|
+ pages.item :new, t('general.new'), new_page_path
- unless (@page_module_collection.new_record? rescue true)
- page_module_collections.item(
- :show, @page_module_collection.title, page_module_collection_path(@page_module_collection)
- ) do |page_module_collection|
- page_module_collection.item(
- :edit, t('general.edit'), edit_page_module_collection_path(@page_module_collection)
+ unless (@page.new_record? rescue true)
+ pages.item(
+ :show, @page.title, page_path(@page)
+ ) do |page|
+ page.item(
+ :edit, t('general.edit'), edit_page_path(@page)
)
- page_module_collection.item(
- :destroy, t('general.destroy'), page_module_collection_path(@page_module_collection), method: :delete,
+ page.item(
+ :destroy, t('general.destroy'), page_path(@page), method: :delete,
confirm: t('general.questions.are_you_sure')
)
-
- page_module_collection.item(
- :new_module, t('page_modules.new.short_title'), new_page_module_collection_module_path(@page_module_collection)
- )
-
- page_module_collection.item(
- :modules, t('page_modules.index.short_title'), page_module_collection_modules_path(@page_module_collection)
- ) do |page_modules|
- unless (@page_module.new_record? rescue true)
- page_modules.item :edit, t('general.edit'), edit_page_module_path(@page_module) do |page_module|
- page_module.item(
- :destroy, t('general.destroy'), page_module_path(@page_module), method: :delete,
- confirm: t('general.questions.are_you_sure')
- )
+ end
+ end
+
+ pages.item(
+ :page_module_collections, t('page_module_collections.index.medium_title'), page_module_collections_path,
+ breadcrumb_title: t('page_module_collections.index.short_title')
+ ) do |page_module_collections|
+ page_module_collections.item :new, t('general.new'), new_page_module_collection_path
+
+ unless (@page_module_collection.new_record? rescue true)
+ page_module_collections.item(
+ :show, @page_module_collection.title, page_module_collection_path(@page_module_collection)
+ ) do |page_module_collection|
+ page_module_collection.item(
+ :edit, t('general.edit'), edit_page_module_collection_path(@page_module_collection)
+ )
+ page_module_collection.item(
+ :destroy, t('general.destroy'), page_module_collection_path(@page_module_collection), method: :delete,
+ confirm: t('general.questions.are_you_sure')
+ )
+
+ page_module_collection.item(
+ :new_module, t('page_modules.new.short_title'), new_page_module_collection_module_path(@page_module_collection)
+ )
+
+ page_module_collection.item(
+ :modules, t('page_modules.index.short_title'), page_module_collection_modules_path(@page_module_collection)
+ ) do |page_modules|
+ unless (@page_module.new_record? rescue true)
+ page_modules.item :edit, t('general.edit'), edit_page_module_path(@page_module) do |page_module|
+ page_module.item(
+ :destroy, t('general.destroy'), page_module_path(@page_module), method: :delete,
+ confirm: t('general.questions.are_you_sure')
+ )
+ end
end
end
end