ecm_cms2 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.rdoc +66 -0
- data/Rakefile +25 -0
- data/app/assets/javascripts/ecm_cms.js.coffee +0 -0
- data/app/assets/stylesheets/ecm_cms.css.less +11 -0
- data/app/controllers/ecm/cms/page_controller.rb +24 -0
- data/app/helpers/ecm/cms_helper.rb +46 -0
- data/app/models/concerns/ecm/cms/navigation_item/properties.rb +29 -0
- data/app/models/ecm/cms/content_box.rb +16 -0
- data/app/models/ecm/cms/folder.rb +20 -0
- data/app/models/ecm/cms/navigation.rb +18 -0
- data/app/models/ecm/cms/navigation_item.rb +88 -0
- data/app/models/ecm/cms/page/content_block.rb +24 -0
- data/app/models/ecm/cms/page.rb +33 -0
- data/app/models/ecm/cms/partial.rb +16 -0
- data/app/models/ecm/cms/template.rb +19 -0
- data/config/locales/ecm.cms.content_box.de.yml +15 -0
- data/config/locales/ecm.cms.content_box.en.yml +15 -0
- data/config/locales/ecm.cms.de.yml +17 -0
- data/config/locales/ecm.cms.en.yml +17 -0
- data/config/locales/ecm.cms.navigation.de.yml +15 -0
- data/config/locales/ecm.cms.navigation.en.yml +15 -0
- data/config/locales/ecm.cms.navigation_item.de.yml +25 -0
- data/config/locales/ecm.cms.navigation_item.en.yml +25 -0
- data/config/locales/ecm.cms.page.content_block.de.yml +14 -0
- data/config/locales/ecm.cms.page.content_block.en.yml +14 -0
- data/config/locales/ecm.cms.page.de.yml +25 -0
- data/config/locales/ecm.cms.page.en.yml +25 -0
- data/config/locales/ecm.cms.partial.de.yml +21 -0
- data/config/locales/ecm.cms.partial.en.yml +21 -0
- data/config/locales/ecm.cms.template.de.yml +21 -0
- data/config/locales/ecm.cms.template.en.yml +21 -0
- data/config/routes.rb +2 -0
- data/db/migrate/001_create_ecm_cms_folders.rb +21 -0
- data/db/migrate/002_create_ecm_cms_pages.rb +19 -0
- data/db/migrate/003_create_ecm_cms_templates.rb +18 -0
- data/db/migrate/004_create_ecm_cms_partials.rb +19 -0
- data/db/migrate/005_create_ecm_cms_navigations.rb +13 -0
- data/db/migrate/006_create_ecm_cms_navigation_items.rb +29 -0
- data/db/migrate/007_create_ecm_cms_content_boxes.rb +9 -0
- data/db/migrate/008_create_ecm_cms_page_content_blocks.rb +15 -0
- data/lib/ecm/cms/action_view/template/handlers/textile.rb +18 -0
- data/lib/ecm/cms/action_view/template_patch.rb +19 -0
- data/lib/ecm/cms/action_view/template_renderer_patch.rb +47 -0
- data/lib/ecm/cms/active_admin/ecm_cms_content_box.rb +33 -0
- data/lib/ecm/cms/active_admin/ecm_cms_navigation_items.rb +68 -0
- data/lib/ecm/cms/active_admin/ecm_cms_navigations.rb +65 -0
- data/lib/ecm/cms/active_admin/ecm_cms_pages.rb +110 -0
- data/lib/ecm/cms/active_admin/ecm_cms_partials.rb +53 -0
- data/lib/ecm/cms/active_admin/ecm_cms_templates.rb +55 -0
- data/lib/ecm/cms/configuration.rb +33 -0
- data/lib/ecm/cms/controller_extensions/page_resolver.rb +13 -0
- data/lib/ecm/cms/controller_extensions/partial_resolver.rb +13 -0
- data/lib/ecm/cms/controller_extensions/template_resolver.rb +13 -0
- data/lib/ecm/cms/database_resolver.rb +101 -0
- data/lib/ecm/cms/database_template.rb +61 -0
- data/lib/ecm/cms/engine.rb +28 -0
- data/lib/ecm/cms/importers/navigation.rb +30 -0
- data/lib/ecm/cms/importers/navigation_item.rb +64 -0
- data/lib/ecm/cms/importers/page.rb +41 -0
- data/lib/ecm/cms/resolvers/ecm/cms/page_resolver.rb +45 -0
- data/lib/ecm/cms/resolvers/ecm/cms/partial_resolver.rb +30 -0
- data/lib/ecm/cms/resolvers/ecm/cms/template_resolver.rb +30 -0
- data/lib/ecm/cms/routing.rb +13 -0
- data/lib/ecm/cms/version.rb +5 -0
- data/lib/ecm_cms2.rb +36 -0
- data/lib/generators/ecm/cms/install/install_generator.rb +15 -0
- data/lib/generators/ecm/cms/install/templates/ecm_cms.rb +37 -0
- data/lib/generators/ecm/cms/locales/locales_generator.rb +38 -0
- data/lib/tasks/ecm_cms_tasks.rake +5 -0
- metadata +498 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 8d6fcb88e37f46304a93a16318714c6abb90fcbe
|
4
|
+
data.tar.gz: ae240502120e7e4744700dc2a712a9bd026dd649
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 243c50e7220649305bd6f4bd0210c1d66659b47b5857a8e41dd4a9c0503aac7815fcb2f2b649261a32cd6174e4bb903e74dcd98cdc35982b969659d7dc63cd84
|
7
|
+
data.tar.gz: 8b9949ad93aa390975d1c0524625f62757b4b2ec5e62db291e540a3f5e659bced0224082af92b7b364e45755d2a286fb3187ad1534685a4bb6c0e9aab26ee78b
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2015 Roberto Vasquez Angel
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
= ECM Module Template
|
2
|
+
|
3
|
+
= End-User documentation
|
4
|
+
|
5
|
+
Please look at the[link:doc] Folder.
|
6
|
+
|
7
|
+
|
8
|
+
= Prerequisites
|
9
|
+
|
10
|
+
= Installation
|
11
|
+
|
12
|
+
Add it to your bundle:
|
13
|
+
|
14
|
+
# Gemfile:
|
15
|
+
gem 'ecm_cms2'
|
16
|
+
|
17
|
+
Install your bundle:
|
18
|
+
|
19
|
+
> bundle install
|
20
|
+
|
21
|
+
Install the intializer:
|
22
|
+
|
23
|
+
> rails g ecm:cms:install
|
24
|
+
|
25
|
+
Install the locales
|
26
|
+
|
27
|
+
> rails g ecm:cms:locales
|
28
|
+
|
29
|
+
Generate migrations and migrate:
|
30
|
+
|
31
|
+
> rake ecm_cms_engine:install:migrations
|
32
|
+
> rake db:migrate
|
33
|
+
|
34
|
+
= Configuring localized routing
|
35
|
+
|
36
|
+
Add the routes to your routing file:
|
37
|
+
|
38
|
+
# config/routes.rb:
|
39
|
+
localized do
|
40
|
+
Ecm::Cms::Routing.routes(self)
|
41
|
+
end
|
42
|
+
root to: redirect("/#{I18n.locale}")
|
43
|
+
|
44
|
+
= Optional: Generating example/default data
|
45
|
+
|
46
|
+
There is a task to prepopulate your database tables with example data.
|
47
|
+
|
48
|
+
Warning: *RUNNING THIS WILL DELETE ALL OF YOUR CMS DATA AND REPLACE IT WITH EXAMPLE DATA!*
|
49
|
+
|
50
|
+
> rake ecm:cms:db:populate!
|
51
|
+
|
52
|
+
= Linking to pages
|
53
|
+
|
54
|
+
<%= link_to 'My Page', page_path(i18n_locale: I18n.locale, page: 'my-page') %>
|
55
|
+
|
56
|
+
= Using partials form the database in other controllers
|
57
|
+
|
58
|
+
# app/controllers/application_controller.rb
|
59
|
+
class ApplicationController < ActionController::Base
|
60
|
+
prepend_view_path ::Ecm::Cms::PartialResolver.instance
|
61
|
+
...
|
62
|
+
end
|
63
|
+
|
64
|
+
= License
|
65
|
+
|
66
|
+
This project rocks and uses MIT-LICENSE.
|
data/Rakefile
ADDED
@@ -0,0 +1,25 @@
|
|
1
|
+
#!/usr/bin/env rake
|
2
|
+
begin
|
3
|
+
require 'bundler/setup'
|
4
|
+
rescue LoadError
|
5
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
6
|
+
end
|
7
|
+
begin
|
8
|
+
require 'rdoc/task'
|
9
|
+
rescue LoadError
|
10
|
+
require 'rdoc/rdoc'
|
11
|
+
require 'rake/rdoctask'
|
12
|
+
RDoc::Task = Rake::RDocTask
|
13
|
+
end
|
14
|
+
|
15
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
16
|
+
rdoc.rdoc_dir = 'rdoc'
|
17
|
+
rdoc.title = 'ECM CMS'
|
18
|
+
rdoc.options << '--line-numbers'
|
19
|
+
rdoc.rdoc_files.include('README.rdoc')
|
20
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
21
|
+
end
|
22
|
+
|
23
|
+
Bundler::GemHelper.install_tasks
|
24
|
+
|
25
|
+
require 'rails/dummy/tasks'
|
File without changes
|
@@ -0,0 +1,11 @@
|
|
1
|
+
body.active_admin textarea#ecm_cms_page_body, body.active_admin textarea#ecm_cms_template_body, body.active_admin textarea#ecm_cms_partial_body {
|
2
|
+
font-family: Consolas, Monaco,Lucida Console, Liberation Mono, DejaVu Sans Mono, Bitstream Vera Sans Mono, Courier New, monospace;
|
3
|
+
}
|
4
|
+
|
5
|
+
.active_admin pre {
|
6
|
+
white-space: pre-wrap !important; /* css-3 */
|
7
|
+
white-space: -moz-pre-wrap !important; /* Mozilla, since 1999 */
|
8
|
+
white-space: -pre-wrap !important; /* Opera 4-6 */
|
9
|
+
white-space: -o-pre-wrap !important; /* Opera 7 */
|
10
|
+
}
|
11
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
class Ecm::Cms::PageController < Ecm::Cms::Configuration.base_controller.constantize
|
2
|
+
# add the page resolver
|
3
|
+
include Ecm::Cms::ControllerExtensions::PageResolver
|
4
|
+
include Ecm::Cms::ControllerExtensions::PartialResolver
|
5
|
+
|
6
|
+
# avoid error 500 on missing template
|
7
|
+
rescue_from ActionView::MissingTemplate do
|
8
|
+
respond_to do |format|
|
9
|
+
format.html {
|
10
|
+
render(:file => "#{Rails.root}/public/404", :formats => [:html],
|
11
|
+
:layout => false,
|
12
|
+
:status => 404
|
13
|
+
)
|
14
|
+
}
|
15
|
+
format.xml { head :not_found }
|
16
|
+
format.any { head :not_found }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
def respond
|
21
|
+
render :template => params[:page]
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
@@ -0,0 +1,46 @@
|
|
1
|
+
module Ecm::CmsHelper
|
2
|
+
def cms_render_navigation(name, options = {})
|
3
|
+
options.reverse_merge! renderer: :bootstrap, expand_all: true, level: 1
|
4
|
+
|
5
|
+
level = options.delete(:level)
|
6
|
+
expand_all = options.delete(:expand_all)
|
7
|
+
container_css_class = options.delete(:container_css_class)
|
8
|
+
renderer = options.delete(:renderer)
|
9
|
+
|
10
|
+
level_as_array = (level).is_a?(Range) ? level.to_a : [level]
|
11
|
+
|
12
|
+
navigation = Ecm::Cms::Navigation.where(:name => name.to_s, :locale => I18n.locale.to_s).first
|
13
|
+
unless navigation
|
14
|
+
return I18n.t('ecm.cms.navigation.messages.not_found', {:lang => I18n.locale.to_s, :name => name.to_s})
|
15
|
+
end
|
16
|
+
|
17
|
+
roots = navigation.ecm_cms_navigation_items.roots.all
|
18
|
+
if roots.empty?
|
19
|
+
return I18n.t('ecm.cms.navigation.messages.empty', :lang => I18n.locale.to_s, :name => name)
|
20
|
+
end
|
21
|
+
|
22
|
+
render_navigation(level: level, expand_all: expand_all, renderer: renderer) do |navigation|
|
23
|
+
navigation.dom_class = container_css_class
|
24
|
+
roots.each do |navigation_item|
|
25
|
+
build_navigation_item(navigation, navigation_item, container_css_class)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
def build_navigation_item(navigation, item, container_css_class)
|
31
|
+
options = {}
|
32
|
+
options[:highlights_on] = /#{item.highlights_on}/ if item.highlights_on.present?
|
33
|
+
options = item.li_attributes.marshal_dump.delete_if {|key, value| value.blank? }
|
34
|
+
|
35
|
+
navigation.dom_class = container_css_class
|
36
|
+
if item.children.present?
|
37
|
+
navigation.item item.key, item.name, item.url, options do |sub_navigation|
|
38
|
+
item.children.each do |sub_item|
|
39
|
+
build_navigation_item(sub_navigation, sub_item, container_css_class)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
else
|
43
|
+
navigation.item item.key, item.name, item.url, options
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'active_support/concern'
|
2
|
+
|
3
|
+
module Ecm::Cms
|
4
|
+
module NavigationItem::Properties
|
5
|
+
extend ActiveSupport::Concern
|
6
|
+
|
7
|
+
included do
|
8
|
+
serialize :properties, OpenStruct
|
9
|
+
delegate *Configuration.navigation_item_properties, to: :li_attributes
|
10
|
+
delegate *Configuration.navigation_item_properties.collect { |a| "#{a}=".to_sym }, to: :li_attributes
|
11
|
+
end
|
12
|
+
|
13
|
+
def highlights_on
|
14
|
+
self.properties.highlights_on ||= nil
|
15
|
+
end
|
16
|
+
|
17
|
+
def highlights_on=(highlights_on)
|
18
|
+
properties.highlights_on = highlights_on
|
19
|
+
end
|
20
|
+
|
21
|
+
def li_attributes
|
22
|
+
self.properties.li_attributes ||= OpenStruct.new
|
23
|
+
end
|
24
|
+
|
25
|
+
def li_attributes=(li_attributes)
|
26
|
+
properties.li_attributes = li_attributes
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Ecm::Cms
|
2
|
+
class ContentBox < ActiveRecord::Base
|
3
|
+
# associations
|
4
|
+
has_many :ecm_cms_page_content_blocks, :class_name => 'Page::ContentBlock',
|
5
|
+
:foreign_key => 'ecm_cms_content_box_id'
|
6
|
+
|
7
|
+
# validations
|
8
|
+
validates :name, :presence => true,
|
9
|
+
:uniqueness => true
|
10
|
+
|
11
|
+
def ecm_cms_page_content_blocks_count
|
12
|
+
ecm_cms_page_content_blocks.count
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class Ecm::Cms::Folder < ActiveRecord::Base
|
2
|
+
# associations
|
3
|
+
has_many :ecm_cms_pages,
|
4
|
+
:class_name => 'Ecm::Cms::Page',
|
5
|
+
:dependent => :destroy,
|
6
|
+
:foreign_key => 'ecm_cms_folder_id'
|
7
|
+
has_many :ecm_cms_partials,
|
8
|
+
:class_name => 'Ecm::Cms::Partial',
|
9
|
+
:dependent => :destroy,
|
10
|
+
:foreign_key => 'ecm_cms_folder_id'
|
11
|
+
has_many :ecm_cms_templates,
|
12
|
+
:class_name => 'Ecm::Cms::Template',
|
13
|
+
:dependent => :destroy,
|
14
|
+
:foreign_key => 'ecm_cms_folder_id'
|
15
|
+
|
16
|
+
# validations
|
17
|
+
validates :basename, :presence => true
|
18
|
+
validates :pathname, :presence => true
|
19
|
+
end
|
20
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class Ecm::Cms::Navigation < ActiveRecord::Base
|
2
|
+
# associations
|
3
|
+
has_many :ecm_cms_navigation_items,
|
4
|
+
:class_name => 'Ecm::Cms::NavigationItem',
|
5
|
+
:dependent => :destroy,
|
6
|
+
:foreign_key => 'ecm_cms_navigation_id'
|
7
|
+
|
8
|
+
# validations
|
9
|
+
validates :locale, :inclusion => I18n.available_locales.map(&:to_s),
|
10
|
+
:allow_nil => true
|
11
|
+
validates :name, :presence => true,
|
12
|
+
:uniqueness => { :scope => [ :locale ] }
|
13
|
+
|
14
|
+
def to_s
|
15
|
+
"#{self.name} (#{self.locale})"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
@@ -0,0 +1,88 @@
|
|
1
|
+
module Ecm::Cms
|
2
|
+
class NavigationItem < ActiveRecord::Base
|
3
|
+
include Properties
|
4
|
+
|
5
|
+
# associations
|
6
|
+
belongs_to :ecm_cms_navigation,
|
7
|
+
:class_name => 'Ecm::Cms::Navigation',
|
8
|
+
:foreign_key => 'ecm_cms_navigation_id'
|
9
|
+
belongs_to :ecm_cms_page,
|
10
|
+
:class_name => 'Ecm::Cms::Page',
|
11
|
+
:foreign_key => 'ecm_cms_page_id'
|
12
|
+
|
13
|
+
# awesome nested set
|
14
|
+
acts_as_nested_set :dependent => :destroy, :counter_cache => :children_count, :scope => :ecm_cms_navigation_id
|
15
|
+
|
16
|
+
# callbacks
|
17
|
+
before_validation :update_navigation_from_parent, :if => Proc.new { |ni| ni.child? }
|
18
|
+
before_validation :update_url_form_page, :if => Proc.new { |ni| ni.ecm_cms_page.present? && ni.url.blank? }
|
19
|
+
after_save :update_children_navigations!
|
20
|
+
|
21
|
+
# default_scope
|
22
|
+
default_scope { order(:ecm_cms_navigation_id, :lft) }
|
23
|
+
|
24
|
+
# validations
|
25
|
+
validates :key, :presence => true
|
26
|
+
validates :name, :presence => true
|
27
|
+
validates :url, :presence => true
|
28
|
+
validates :ecm_cms_navigation, :presence => true, :if => :root?
|
29
|
+
|
30
|
+
def params_for_new_page
|
31
|
+
return {} if self.new_record?
|
32
|
+
match = self.url.scan(/(#{I18n.available_locales.join('|')})$/)
|
33
|
+
return { :locale => match[0][0], :pathname => '/', :basename => 'home', :title => self.name, :ecm_cms_navigation_item_ids => [ self.to_param ] } if match.size > 0
|
34
|
+
match = self.url.scan(/(#{I18n.available_locales.join('|')})(.*)\/(.*)/)
|
35
|
+
return {} unless match.first.respond_to?(:size) # && match.first.size != 3
|
36
|
+
params = match.first
|
37
|
+
return {} if params.size != 3
|
38
|
+
params[1] << '/' unless params[1].end_with?('/')
|
39
|
+
return { :locale => params[0], :pathname => params[1], :basename => params[2], :title => self.name, :ecm_cms_navigation_item_ids => [ self.to_param ] }
|
40
|
+
end
|
41
|
+
|
42
|
+
def to_label
|
43
|
+
if depth > 0
|
44
|
+
"#{' ' * depth} ▶ #{name}".html_safe
|
45
|
+
else
|
46
|
+
name
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def to_s
|
51
|
+
"#{ecm_cms_navigation}: #{name}"
|
52
|
+
end
|
53
|
+
|
54
|
+
def update_navigation_from_parent!
|
55
|
+
update_navigation_from_parent
|
56
|
+
save!
|
57
|
+
end
|
58
|
+
|
59
|
+
def update_children_navigations!
|
60
|
+
self.descendants.map(&:"update_navigation_from_parent!")
|
61
|
+
end
|
62
|
+
|
63
|
+
def update_url_form_page!
|
64
|
+
# self.url = build_url_from_page(ecm_cms_page.locale, ecm_cms_page.pathname, ecm_cms_page.basename, ecm_cms_page.home_page?)
|
65
|
+
update_url_form_page
|
66
|
+
save!
|
67
|
+
end
|
68
|
+
|
69
|
+
private
|
70
|
+
|
71
|
+
def build_url_from_page(locale, pathname, basename, is_home_page)
|
72
|
+
if is_home_page
|
73
|
+
"/#{locale}"
|
74
|
+
else
|
75
|
+
"/#{locale}#{pathname}#{basename}"
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
def update_navigation_from_parent
|
80
|
+
self.ecm_cms_navigation = self.parent.ecm_cms_navigation
|
81
|
+
end
|
82
|
+
|
83
|
+
def update_url_form_page
|
84
|
+
self.url = build_url_from_page(ecm_cms_page.locale, ecm_cms_page.pathname, ecm_cms_page.basename, ecm_cms_page.home_page?)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
module Ecm::Cms
|
2
|
+
class Page::ContentBlock < ActiveRecord::Base
|
3
|
+
# associations
|
4
|
+
belongs_to :ecm_cms_content_box, :class_name => 'ContentBox',
|
5
|
+
:foreign_key => 'ecm_cms_content_box_id'
|
6
|
+
belongs_to :ecm_cms_page, :class_name => 'Ecm::Cms::Page',
|
7
|
+
:foreign_key => 'ecm_cms_page_id'
|
8
|
+
|
9
|
+
# attributes
|
10
|
+
attr_accessible(:body,
|
11
|
+
:ecm_cms_content_box_id) if Rails.version < '4.0.0'
|
12
|
+
|
13
|
+
# validations
|
14
|
+
validates :body, :presence => true
|
15
|
+
validates :ecm_cms_content_box, :presence => true
|
16
|
+
validates :ecm_cms_page, :presence => true
|
17
|
+
# validates :ecm_cms_page, :existence => true
|
18
|
+
|
19
|
+
def content_box_name
|
20
|
+
ecm_cms_content_box.name
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
@@ -0,0 +1,33 @@
|
|
1
|
+
module Ecm::Cms
|
2
|
+
class Page < ActiveRecord::Base
|
3
|
+
# add shared behaviour for database backed templates
|
4
|
+
include DatabaseTemplate
|
5
|
+
|
6
|
+
# associations
|
7
|
+
has_many :ecm_cms_navigation_items,
|
8
|
+
:class_name => 'NavigationItem',
|
9
|
+
:dependent => :nullify,
|
10
|
+
:foreign_key => 'ecm_cms_page_id'
|
11
|
+
has_many :ecm_cms_page_content_blocks,
|
12
|
+
:class_name => 'Ecm::Cms::Page::ContentBlock',
|
13
|
+
:dependent => :destroy,
|
14
|
+
:foreign_key => 'ecm_cms_page_id',
|
15
|
+
:inverse_of => :ecm_cms_page
|
16
|
+
|
17
|
+
accepts_nested_attributes_for :ecm_cms_page_content_blocks, :allow_destroy => true
|
18
|
+
|
19
|
+
# callbacks
|
20
|
+
after_save :touch_navigation_items # , :if => Proc.new { |page| page.locale_changed? || page.pathname_changed? || page.basename_changed? }
|
21
|
+
|
22
|
+
# validations
|
23
|
+
validates :title, :presence => true
|
24
|
+
|
25
|
+
def home_page?
|
26
|
+
return self.pathname == '/' && self.basename == 'home'
|
27
|
+
end
|
28
|
+
|
29
|
+
def touch_navigation_items
|
30
|
+
self.ecm_cms_navigation_items.map(&:update_url_form_page!)
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'ecm/cms/database_template'
|
2
|
+
|
3
|
+
class Ecm::Cms::Partial < ActiveRecord::Base
|
4
|
+
# add shared behaviour for database backed templates
|
5
|
+
include Ecm::Cms::DatabaseTemplate
|
6
|
+
|
7
|
+
# callbacks
|
8
|
+
before_validation :ensure_basename_starts_with_underscore, :if => Proc.new { |t| t.basename.present? }
|
9
|
+
|
10
|
+
private
|
11
|
+
|
12
|
+
def ensure_basename_starts_with_underscore
|
13
|
+
self.basename.insert(0, '_') unless self.basename.start_with?('_')
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class Ecm::Cms::Template < ActiveRecord::Base
|
2
|
+
# add shared behaviour for database backed templates
|
3
|
+
include Ecm::Cms::DatabaseTemplate
|
4
|
+
|
5
|
+
# associations
|
6
|
+
belongs_to :ecm_cms_folder,
|
7
|
+
:class_name => 'Ecm::Cms::Folder',
|
8
|
+
:foreign_key => 'ecm_cms_folder_id'
|
9
|
+
|
10
|
+
# callbacks
|
11
|
+
before_validation :ensure_basename_starts_without_underscore, :if => Proc.new { |t| t.basename.present? }
|
12
|
+
|
13
|
+
private
|
14
|
+
|
15
|
+
def ensure_basename_starts_without_underscore
|
16
|
+
self.basename.slice!(0) if self.basename.start_with?('_')
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
de:
|
2
|
+
activerecord:
|
3
|
+
models:
|
4
|
+
ecm/cms/content_box:
|
5
|
+
one: Content Box
|
6
|
+
other: Content Boxen
|
7
|
+
attributes:
|
8
|
+
ecm/cms/content_box:
|
9
|
+
name: Name
|
10
|
+
body: Inhalt
|
11
|
+
created_at: Erstellt am
|
12
|
+
ecm_cms_page_content_blocks: Content Blöcke
|
13
|
+
ecm_cms_page_content_blocks_count: Content Blöcke
|
14
|
+
updated_at: Aktualisiert am
|
15
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
en:
|
2
|
+
activerecord:
|
3
|
+
models:
|
4
|
+
ecm/cms/content_box:
|
5
|
+
one: content box
|
6
|
+
other: content boxes
|
7
|
+
attributes:
|
8
|
+
ecm/cms/content_box:
|
9
|
+
name: name
|
10
|
+
body: body
|
11
|
+
created_at: created at
|
12
|
+
ecm_cms_page_content_blocks: content blocks
|
13
|
+
ecm_cms_page_content_blocks_count: content blocks
|
14
|
+
updated_at: updated at
|
15
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
de:
|
2
|
+
ecm:
|
3
|
+
cms:
|
4
|
+
active_admin:
|
5
|
+
menu: CMS
|
6
|
+
navigation:
|
7
|
+
messages:
|
8
|
+
empty: Navigation %{name} (%{lang}) ist leer
|
9
|
+
not_found: Navigation %{name} (%{lang}) nicht gefunden
|
10
|
+
resources:
|
11
|
+
ecm_cms_folders: ordner
|
12
|
+
ecm_cms_navigations: navigationen
|
13
|
+
ecm_cms_navigation_items: navigationseintraege
|
14
|
+
ecm_cms_pages: seiten
|
15
|
+
ecm_cms_partials: fragmente
|
16
|
+
ecm_cms_templates: vorlagen
|
17
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
en:
|
2
|
+
ecm:
|
3
|
+
cms:
|
4
|
+
active_admin:
|
5
|
+
menu: CMS
|
6
|
+
navigation:
|
7
|
+
messages:
|
8
|
+
empty: Navigation %{name} (%{lang}) is empty
|
9
|
+
not_found: Could not find navigation %{name} (%{lang})
|
10
|
+
resources:
|
11
|
+
ecm_cms_folders: folders
|
12
|
+
ecm_cms_navigations: navigations
|
13
|
+
ecm_cms_navigation_items: navigation_items
|
14
|
+
ecm_cms_pages: pages
|
15
|
+
ecm_cms_partials: partials
|
16
|
+
ecm_cms_templates: templates
|
17
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
de:
|
2
|
+
activerecord:
|
3
|
+
models:
|
4
|
+
ecm/cms/navigation:
|
5
|
+
one: Navigation
|
6
|
+
other: Navigationen
|
7
|
+
attributes:
|
8
|
+
ecm/cms/navigation:
|
9
|
+
created_at: Erstellt am
|
10
|
+
ecm_cms_navigation_items: Navigationseinträge
|
11
|
+
locale: Sprache
|
12
|
+
name: Name
|
13
|
+
slug: Freundliche ID
|
14
|
+
updated_at: Aktualisiert am
|
15
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
en:
|
2
|
+
activerecord:
|
3
|
+
models:
|
4
|
+
ecm/cms/navigation:
|
5
|
+
one: navigation
|
6
|
+
other: navigations
|
7
|
+
attributes:
|
8
|
+
ecm/cms/navigation:
|
9
|
+
created_at: created at
|
10
|
+
ecm_cms_navigation_items: navigation items
|
11
|
+
locale: language
|
12
|
+
name: name
|
13
|
+
slug: friendly id
|
14
|
+
updated_at: updated at
|
15
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
de:
|
2
|
+
activerecord:
|
3
|
+
models:
|
4
|
+
ecm/cms/navigation_item:
|
5
|
+
one: Navigationseintrag
|
6
|
+
other: Navigationseinträge
|
7
|
+
attributes:
|
8
|
+
ecm/cms/navigation_item:
|
9
|
+
created_at: Erstellt am
|
10
|
+
depth: Baumtiefe
|
11
|
+
ecm_cms_navigation: Navigation
|
12
|
+
ecm_cms_page: Seite
|
13
|
+
data_add_icon: Symbol
|
14
|
+
highlights_on: Hervorgehoben bei
|
15
|
+
key: Schlüssel
|
16
|
+
lft: Links
|
17
|
+
li_attributes: 'Listen-Element Attribute'
|
18
|
+
name: Name
|
19
|
+
options: Optionen
|
20
|
+
parent: Untereintrag von
|
21
|
+
rgt: Rechts
|
22
|
+
slug: Freundliche ID
|
23
|
+
updated_at: Aktualisiert am
|
24
|
+
url: Ziel-URL
|
25
|
+
|
@@ -0,0 +1,25 @@
|
|
1
|
+
en:
|
2
|
+
activerecord:
|
3
|
+
models:
|
4
|
+
ecm/cms/navigation_item:
|
5
|
+
one: navigation item
|
6
|
+
other: navigation items
|
7
|
+
attributes:
|
8
|
+
ecm/cms/navigation_item:
|
9
|
+
created_at: created at
|
10
|
+
depth: tree depth
|
11
|
+
ecm_cms_navigation: navigation
|
12
|
+
ecm_cms_page: page
|
13
|
+
data_add_icon: icon
|
14
|
+
highlights_on: highlights on
|
15
|
+
key: key
|
16
|
+
lft: left
|
17
|
+
li_attributes: 'list-element attributes'
|
18
|
+
name: name
|
19
|
+
options: options
|
20
|
+
parent: parent
|
21
|
+
rgt: right
|
22
|
+
slug: friendly id
|
23
|
+
updated_at: updated at
|
24
|
+
url: target url
|
25
|
+
|
@@ -0,0 +1,14 @@
|
|
1
|
+
de:
|
2
|
+
activerecord:
|
3
|
+
models:
|
4
|
+
ecm/cms/page/content_block:
|
5
|
+
one: Content Block
|
6
|
+
other: Content Blöcke
|
7
|
+
attributes:
|
8
|
+
ecm/cms/page/content_block:
|
9
|
+
body: Inhalt
|
10
|
+
created_at: Erstellt am
|
11
|
+
ecm_cms_page: Seite
|
12
|
+
ecm_cms_content_box: Content Box
|
13
|
+
updated_at: Aktualisiert am
|
14
|
+
|
@@ -0,0 +1,14 @@
|
|
1
|
+
en:
|
2
|
+
activerecord:
|
3
|
+
models:
|
4
|
+
ecm/cms/page/content_block:
|
5
|
+
one: content block
|
6
|
+
other: content blocks
|
7
|
+
attributes:
|
8
|
+
ecm/cms/page/content_block:
|
9
|
+
body: body
|
10
|
+
created_at: created at
|
11
|
+
ecm_cms_page: page
|
12
|
+
ecm_cms_content_box: content box
|
13
|
+
updated_at: udpated at
|
14
|
+
|