ecm_cms2 1.1.1 → 2.0.2

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 (54) hide show
  1. checksums.yaml +4 -4
  2. data/README.rdoc +19 -1
  3. data/{lib/ecm/cms/active_admin → app/admin}/ecm_cms_content_box.rb +5 -5
  4. data/{lib/ecm/cms/active_admin → app/admin}/ecm_cms_navigation_items.rb +6 -6
  5. data/{lib/ecm/cms/active_admin → app/admin}/ecm_cms_navigations.rb +11 -12
  6. data/{lib/ecm/cms/active_admin → app/admin}/ecm_cms_pages.rb +20 -22
  7. data/{lib/ecm/cms/active_admin → app/admin}/ecm_cms_partials.rb +6 -7
  8. data/{lib/ecm/cms/active_admin → app/admin}/ecm_cms_templates.rb +7 -8
  9. data/app/controllers/ecm/cms/page_controller.rb +13 -8
  10. data/app/helpers/ecm/cms_helper.rb +8 -4
  11. data/app/models/concerns/model/ecm/cms/navigation_item/properties_concern.rb +25 -0
  12. data/app/models/ecm/cms/content_box.rb +5 -8
  13. data/app/models/ecm/cms/folder.rb +11 -12
  14. data/app/models/ecm/cms/navigation.rb +10 -9
  15. data/app/models/ecm/cms/navigation_item.rb +21 -20
  16. data/app/models/ecm/cms/page/content_block.rb +7 -8
  17. data/app/models/ecm/cms/page.rb +11 -11
  18. data/app/models/ecm/cms/partial.rb +2 -3
  19. data/app/models/ecm/cms/template.rb +4 -5
  20. data/app/services/ecm/cms/add_homepages_service.rb +61 -0
  21. data/app/services/ecm/cms/import_partials_service.rb +37 -32
  22. data/config/locales/ecm.cms.de.yml +3 -0
  23. data/config/locales/ecm.cms.navigation.de.yml +1 -0
  24. data/config/locales/ecm.cms.navigation.en.yml +1 -0
  25. data/config/locales/ecm.cms.page.de.yml +1 -0
  26. data/config/locales/ecm.cms.page.en.yml +1 -0
  27. data/db/migrate/001_create_ecm_cms_folders.rb +2 -2
  28. data/db/migrate/004_create_ecm_cms_partials.rb +1 -1
  29. data/db/migrate/006_create_ecm_cms_navigation_items.rb +1 -1
  30. data/lib/ecm/cms/action_view/template/handlers/textile.rb +0 -3
  31. data/lib/ecm/cms/action_view/template_patch.rb +2 -3
  32. data/lib/ecm/cms/action_view/template_renderer_patch.rb +4 -6
  33. data/lib/ecm/cms/configuration.rb +1 -1
  34. data/lib/ecm/cms/controller_extensions/page_resolver.rb +0 -1
  35. data/lib/ecm/cms/controller_extensions/partial_resolver.rb +0 -1
  36. data/lib/ecm/cms/controller_extensions/template_resolver.rb +0 -1
  37. data/lib/ecm/cms/database_resolver.rb +21 -22
  38. data/lib/ecm/cms/database_template.rb +17 -18
  39. data/lib/ecm/cms/engine.rb +5 -7
  40. data/lib/ecm/cms/importers/navigation.rb +2 -5
  41. data/lib/ecm/cms/importers/navigation_item.rb +6 -9
  42. data/lib/ecm/cms/importers/page.rb +4 -7
  43. data/lib/ecm/cms/resolvers/ecm/cms/page_resolver.rb +3 -6
  44. data/lib/ecm/cms/resolvers/ecm/cms/partial_resolver.rb +0 -1
  45. data/lib/ecm/cms/resolvers/ecm/cms/template_resolver.rb +0 -1
  46. data/lib/ecm/cms/routing.rb +2 -3
  47. data/lib/ecm/cms/version.rb +1 -1
  48. data/lib/ecm_cms2.rb +1 -2
  49. data/lib/generators/ecm/cms/install/install_generator.rb +6 -6
  50. data/lib/generators/ecm/cms/install/templates/ecm_cms.rb +6 -6
  51. data/lib/generators/ecm/cms/locales/locales_generator.rb +19 -18
  52. data/lib/tasks/ecm_cms_tasks.rake +2 -3
  53. metadata +33 -25
  54. data/app/models/concerns/ecm/cms/navigation_item/properties.rb +0 -29
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: e7924e282fbaa1e5c4c7b8eb88c2d40d55818913
4
- data.tar.gz: daf1bc4752377390608d2c2e6d789cc97d048f61
3
+ metadata.gz: e1707440044dae2f74e476338ba1cb70beba1f0b
4
+ data.tar.gz: 5c38d25ea7c5bc14af5ed74010b0add39288b009
5
5
  SHA512:
6
- metadata.gz: 7e48db3b8611184f726889f3446652695d84d57a2562184a2df8d260d56a50142c07866ee37a6b83991c07350d328b9eae201c895661497dce10d6a024847458
7
- data.tar.gz: f1183f4235f01e5f50d595776a9616a84a0d9404449daf3dcf2d2bf2f8129facea3bb1ee3cd7d1fe940a37bb537f9fbafa4b94d1d3df206c3280f893cd5e5a3a
6
+ metadata.gz: 2bf055d316ccafcf21289db136779fcbe23483017ef1dd73edfa50f620b5dd102e138a0c923a6b2c85feabd11982f3b857a1a68a8cffd5e6376dff67b17f631d
7
+ data.tar.gz: f7c48ee4aef4c8b2ea6769b4ebf3d269f66c4486f524388416cdf4db1a10e34bad71f988238c4205706be5b9d9abbc76d12c83c9e78da5b704804eaee39db5ef
data/README.rdoc CHANGED
@@ -1,12 +1,23 @@
1
- = ECM Module Template
1
+ = ECM CMS 2
2
2
 
3
3
  = End-User documentation
4
4
 
5
5
  Please look at the[link:doc] Folder.
6
6
 
7
+ = Migrating from 1.x.x to 2.0.0
8
+
9
+ Add active_admin-awesome_nested_set to your gemfile, if you are using activeadmin:
10
+
11
+ # Gemfile
12
+ gem 'active_admin-awesome_nested_set'
7
13
 
8
14
  = Prerequisites
9
15
 
16
+ if you are using activeadmin as backend, ecm_cms2 comes with admin files to provide a backend. In that case, you'll need active_admin-awesome_nested_set. Add it to your gemfile:
17
+
18
+ # Gemfile
19
+ gem 'active_admin-awesome_nested_set'
20
+
10
21
  = Installation
11
22
 
12
23
  Add it to your bundle:
@@ -61,6 +72,13 @@ Warning: *RUNNING THIS WILL DELETE ALL OF YOUR CMS DATA AND REPLACE IT WITH EXAM
61
72
  ...
62
73
  end
63
74
 
75
+ = Running specs
76
+
77
+ gem install bundler
78
+ bundle
79
+ cd spec/dummy && rake db:migrate RAILS_ENV=test && cd ../..
80
+ guard
81
+
64
82
  = License
65
83
 
66
84
  This project rocks and uses MIT-LICENSE.
@@ -1,19 +1,19 @@
1
1
  ActiveAdmin.register Ecm::Cms::ContentBox do
2
2
  permit_params(:name) if Rails.version >= '4.0.0'
3
3
 
4
- menu :parent => Proc.new { I18n.t('ecm.cms.active_admin.menu') }.call
4
+ menu parent: proc { I18n.t('ecm.cms.active_admin.menu') }.call
5
5
 
6
6
  index do
7
7
  selectable_column
8
8
  column :name
9
9
  column :created_at
10
- column :updated_at
10
+ column :updated_at
11
11
  ActiveAdmin::VERSION[0] < '1' ? default_actions : actions
12
12
  end
13
13
 
14
14
  show do
15
15
  panel Ecm::Cms::ContentBox.human_attribute_name(:ecm_cms_page_content_blocks) do
16
- table_for ecm_cms_content_box.ecm_cms_page_content_blocks, :i18n => Ecm::Cms::Page::ContentBlock do |content_block|
16
+ table_for ecm_cms_content_box.ecm_cms_page_content_blocks, i18n: Ecm::Cms::Page::ContentBlock do |_content_block|
17
17
  column :ecm_cms_page
18
18
  column :body
19
19
  column :created_at
@@ -22,7 +22,7 @@ ActiveAdmin.register Ecm::Cms::ContentBox do
22
22
  end
23
23
  end
24
24
 
25
- sidebar Ecm::Cms::ContentBox.human_attribute_name(:details), :only => :show do
25
+ sidebar Ecm::Cms::ContentBox.human_attribute_name(:details), only: :show do
26
26
  attributes_table_for ecm_cms_content_box do
27
27
  row :name
28
28
  row :created_at
@@ -30,4 +30,4 @@ ActiveAdmin.register Ecm::Cms::ContentBox do
30
30
  row :ecm_cms_page_content_blocks_count
31
31
  end
32
32
  end # sidebar
33
- end
33
+ end if Gem::Specification.find_all_by_name('activeadmin').any?
@@ -11,16 +11,16 @@ ActiveAdmin.register Ecm::Cms::NavigationItem do
11
11
  :url,
12
12
  *Ecm::Cms::Configuration.navigation_item_properties,
13
13
  :highlights_on
14
- )
14
+ )
15
15
 
16
16
  sortable_tree_member_actions
17
17
 
18
18
  # Menu
19
- menu :parent => Proc.new { I18n.t('ecm.cms.active_admin.menu') }.call
19
+ menu parent: proc { I18n.t('ecm.cms.active_admin.menu') }.call
20
20
 
21
21
  form do |f|
22
22
  f.inputs do
23
- f.input :ecm_cms_navigation, :collection => Ecm::Cms::Navigation.all.collect { |navigation| [navigation.to_s, navigation.id] }
23
+ f.input :ecm_cms_navigation, collection: Ecm::Cms::Navigation.all.collect { |navigation| [navigation.to_s, navigation.id] }
24
24
  f.input :parent
25
25
  f.input :name
26
26
  end
@@ -48,7 +48,7 @@ ActiveAdmin.register Ecm::Cms::NavigationItem do
48
48
  f.actions
49
49
  end
50
50
 
51
- index :as => :nested_set do
51
+ index as: :nested_set do
52
52
  selectable_column
53
53
  sortable_tree_columns
54
54
  column(:ecm_cms_navigation) { |ni| link_to(ni.ecm_cms_navigation.to_s, [:admin, ni.ecm_cms_navigation]) }
@@ -56,7 +56,7 @@ ActiveAdmin.register Ecm::Cms::NavigationItem do
56
56
  column :url
57
57
  column :ecm_cms_page do |ni|
58
58
  if ni.ecm_cms_page.blank?
59
- link_to(I18n.t('active_admin.new_model', :model => Ecm::Cms::Page.model_name.human), new_admin_ecm_cms_page_path({:ecm_cms_page => ni.params_for_new_page}))
59
+ link_to(I18n.t('active_admin.new_model', model: Ecm::Cms::Page.model_name.human), new_admin_ecm_cms_page_path(ecm_cms_page: ni.params_for_new_page))
60
60
  else
61
61
  link_to(ni.ecm_cms_page.title, [:admin, ni.ecm_cms_page])
62
62
  end
@@ -65,4 +65,4 @@ ActiveAdmin.register Ecm::Cms::NavigationItem do
65
65
  column :updated_at
66
66
  ActiveAdmin::VERSION[0] < '1' ? default_actions : actions
67
67
  end
68
- end
68
+ end if Gem::Specification.find_all_by_name('activeadmin').any?
@@ -1,20 +1,20 @@
1
- include ActiveAdmin::AwesomeNestedSet::Helper
1
+ include ActiveAdmin::AwesomeNestedSet::Helper if Gem::Specification.find_all_by_name('activeadmin').any?
2
2
 
3
3
  ActiveAdmin.register Ecm::Cms::Navigation do
4
4
  permit_params(:locale,
5
5
  :name,
6
6
  :slug) if Rails.version >= '4.0.0'
7
-
7
+
8
8
  # Filters
9
- filter :locale, :as => :select, :collection => I18n.available_locales.map(&:to_s)
9
+ filter :locale, as: :select, collection: I18n.available_locales.map(&:to_s)
10
10
  filter :name
11
11
 
12
12
  # Menu
13
- menu :parent => Proc.new { I18n.t('ecm.cms.active_admin.menu') }.call
13
+ menu parent: proc { I18n.t('ecm.cms.active_admin.menu') }.call
14
14
 
15
15
  form do |f|
16
16
  f.inputs do
17
- f.input :locale, :as => :select, :collection => I18n.available_locales.map(&:to_s)
17
+ f.input :locale, as: :select, collection: I18n.available_locales.map(&:to_s)
18
18
  f.input :name
19
19
  end
20
20
 
@@ -30,13 +30,13 @@ ActiveAdmin.register Ecm::Cms::Navigation do
30
30
 
31
31
  show do
32
32
  panel Ecm::Cms::Navigation.human_attribute_name(:ecm_cms_navigation_items) do
33
- table_for ecm_cms_navigation.ecm_cms_navigation_items, :i18n => Ecm::Cms::NavigationItem do
33
+ table_for ecm_cms_navigation.ecm_cms_navigation_items, i18n: Ecm::Cms::NavigationItem do
34
34
  sortable_tree_columns
35
35
  sortable_tree_indented_column :name
36
36
  column :url
37
37
  column :ecm_cms_page do |ni|
38
38
  if ni.ecm_cms_page.blank?
39
- link_to(I18n.t('active_admin.create_model', :model => Ecm::Cms::Page.model_name.human), new_admin_ecm_cms_page_path({:ecm_cms_page => ni.params_for_new_page}))
39
+ link_to(I18n.t('active_admin.create_model', model: Ecm::Cms::Page.model_name.human), new_admin_ecm_cms_page_path(ecm_cms_page: ni.params_for_new_page))
40
40
  else
41
41
  link_to(ni.ecm_cms_page.title, [:admin, ni.ecm_cms_page])
42
42
  end
@@ -45,14 +45,14 @@ ActiveAdmin.register Ecm::Cms::Navigation do
45
45
  column :updated_at
46
46
 
47
47
  column do |ni|
48
- link_to(I18n.t('active_admin.view'), [:admin, ni], :class => "member_link view_link") +
49
- link_to(I18n.t('active_admin.edit'), [:edit, :admin, ni], :class => "member_link edit_link")
48
+ link_to(I18n.t('active_admin.view'), [:admin, ni], class: 'member_link view_link') +
49
+ link_to(I18n.t('active_admin.edit'), [:edit, :admin, ni], class: 'member_link edit_link')
50
50
  end
51
51
  end
52
52
  end
53
53
  end
54
54
 
55
- sidebar Ecm::Cms::Navigation.human_attribute_name(:details), :only => :show do
55
+ sidebar Ecm::Cms::Navigation.human_attribute_name(:details), only: :show do
56
56
  attributes_table_for ecm_cms_navigation do
57
57
  row :locale
58
58
  row :name
@@ -61,5 +61,4 @@ ActiveAdmin.register Ecm::Cms::Navigation do
61
61
  row :updated_at
62
62
  end
63
63
  end # sidebar
64
- end if defined?(::ActiveAdmin)
65
-
64
+ end if Gem::Specification.find_all_by_name('activeadmin').any?
@@ -12,13 +12,12 @@ ActiveAdmin.register Ecm::Cms::Page do
12
12
  :pathname,
13
13
  :title) if Rails.version >= '4.0.0'
14
14
 
15
-
16
- menu :parent => Proc.new { I18n.t('ecm.cms.active_admin.menu') }.call
15
+ menu parent: proc { I18n.t('ecm.cms.active_admin.menu') }.call
17
16
 
18
17
  form do |f|
19
- # f.inputs do
20
- # f.object.errors.inspect
21
- # end
18
+ # f.inputs do
19
+ # f.object.errors.inspect
20
+ # end
22
21
 
23
22
  f.inputs do
24
23
  f.input :title
@@ -28,21 +27,21 @@ ActiveAdmin.register Ecm::Cms::Page do
28
27
 
29
28
  f.has_many :ecm_cms_page_content_blocks do |cb|
30
29
  # cb.inputs do
31
- if cb.object.persisted?
32
- cb.input :_destroy, :as => :boolean, :label => I18n.t('active_admin.delete')
33
- end
30
+ if cb.object.persisted?
31
+ cb.input :_destroy, as: :boolean, label: I18n.t('active_admin.delete')
32
+ end
34
33
 
35
- cb.input :ecm_cms_content_box
36
- cb.input :body
34
+ cb.input :ecm_cms_content_box
35
+ cb.input :body
37
36
  # end
38
37
  end if Ecm::Cms::ContentBox.count > 0
39
38
 
40
39
  f.inputs do
41
40
  f.input :pathname
42
41
  f.input :basename
43
- f.input :locale, :as => :select, :collection => I18n.available_locales.map(&:to_s)
44
- f.input :format, :as => :select, :collection => Mime::SET.symbols.map(&:to_s)
45
- f.input :handler, :as => :select, :collection => ActionView::Template::Handlers.extensions.map(&:to_s)
42
+ f.input :locale, as: :select, collection: I18n.available_locales.map(&:to_s)
43
+ f.input :format, as: :select, collection: Mime::SET.symbols.map(&:to_s)
44
+ f.input :handler, as: :select, collection: ActionView::Template::Handlers.extensions.map(&:to_s)
46
45
  end
47
46
 
48
47
  f.inputs do
@@ -50,12 +49,12 @@ ActiveAdmin.register Ecm::Cms::Page do
50
49
  end
51
50
 
52
51
  I18n.available_locales.each do |locale|
53
- Ecm::Cms::Navigation.where(:locale => locale).all.each do |navigation|
52
+ Ecm::Cms::Navigation.where(locale: locale).all.each do |navigation|
54
53
  f.inputs navigation.to_s do
55
54
  f.input :ecm_cms_navigation_items,
56
- :as => :check_boxes,
57
- :collection => navigation.ecm_cms_navigation_items.joins(:ecm_cms_navigation).where(:ecm_cms_navigations => { :locale => locale }),
58
- :label_method => :key # .all.collect { |i| "#{'--' * i.depth} #{i.name}" }
55
+ as: :check_boxes,
56
+ collection: navigation.ecm_cms_navigation_items.joins(:ecm_cms_navigation).where(ecm_cms_navigations: { locale: locale }),
57
+ label_method: :key # .all.collect { |i| "#{'--' * i.depth} #{i.name}" }
59
58
  end
60
59
  end
61
60
  end
@@ -66,12 +65,12 @@ ActiveAdmin.register Ecm::Cms::Page do
66
65
  index do
67
66
  selectable_column
68
67
  column :pathname
69
- column :filename, :sortable => :basename
68
+ column :filename, sortable: :basename
70
69
  column :title
71
70
  column :home_page?
72
71
  column :layout
73
72
  column(:ecm_cms_navigation_items) do |page|
74
- output = ""
73
+ output = ''
75
74
  page.ecm_cms_navigation_items.each do |navigation_item|
76
75
  output << link_to(navigation_item, [:admin, navigation_item])
77
76
  end
@@ -94,7 +93,7 @@ ActiveAdmin.register Ecm::Cms::Page do
94
93
  end
95
94
  end
96
95
 
97
- sidebar Ecm::Cms::Page.human_attribute_name(:details), :only => :show do
96
+ sidebar Ecm::Cms::Page.human_attribute_name(:details), only: :show do
98
97
  attributes_table_for ecm_cms_page do
99
98
  # row :ecm_cms_navigation_item
100
99
  # row :folder
@@ -106,5 +105,4 @@ ActiveAdmin.register Ecm::Cms::Page do
106
105
  row :updated_at
107
106
  end
108
107
  end # sidebar
109
- end if defined?(::ActiveAdmin)
110
-
108
+ end if Gem::Specification.find_all_by_name('activeadmin').any?
@@ -8,7 +8,7 @@ ActiveAdmin.register Ecm::Cms::Partial do
8
8
  :locale,
9
9
  :pathname) if Rails.version >= '4.0.0'
10
10
  # Menu
11
- menu :parent => Proc.new { I18n.t('ecm.cms.active_admin.menu') }.call
11
+ menu parent: proc { I18n.t('ecm.cms.active_admin.menu') }.call
12
12
 
13
13
  form do |f|
14
14
  f.inputs do
@@ -18,9 +18,9 @@ ActiveAdmin.register Ecm::Cms::Partial do
18
18
  f.inputs do
19
19
  f.input :pathname
20
20
  f.input :basename
21
- f.input :locale, :as => :select, :collection => I18n.available_locales.map(&:to_s)
22
- f.input :format, :as => :select, :collection => Mime::SET.symbols.map(&:to_s)
23
- f.input :handler, :as => :select, :collection => ActionView::Template::Handlers.extensions.map(&:to_s)
21
+ f.input :locale, as: :select, collection: I18n.available_locales.map(&:to_s)
22
+ f.input :format, as: :select, collection: Mime::SET.symbols.map(&:to_s)
23
+ f.input :handler, as: :select, collection: ActionView::Template::Handlers.extensions.map(&:to_s)
24
24
  end
25
25
 
26
26
  f.actions
@@ -41,7 +41,7 @@ ActiveAdmin.register Ecm::Cms::Partial do
41
41
  end
42
42
  end
43
43
 
44
- sidebar Ecm::Cms::Partial.human_attribute_name(:details), :only => :show do
44
+ sidebar Ecm::Cms::Partial.human_attribute_name(:details), only: :show do
45
45
  attributes_table_for ecm_cms_partial do
46
46
  row :pathname
47
47
  row :filename
@@ -49,5 +49,4 @@ ActiveAdmin.register Ecm::Cms::Partial do
49
49
  row :updated_at
50
50
  end
51
51
  end # sidebar
52
- end
53
-
52
+ end if Gem::Specification.find_all_by_name('activeadmin').any?
@@ -7,9 +7,9 @@ ActiveAdmin.register Ecm::Cms::Template do
7
7
  :layout,
8
8
  :locale,
9
9
  :pathname) if Rails.version >= '4.0.0'
10
-
10
+
11
11
  # Menu
12
- menu :parent => Proc.new { I18n.t('ecm.cms.active_admin.menu') }.call
12
+ menu parent: proc { I18n.t('ecm.cms.active_admin.menu') }.call
13
13
 
14
14
  form do |f|
15
15
  f.inputs do
@@ -19,9 +19,9 @@ ActiveAdmin.register Ecm::Cms::Template do
19
19
  f.inputs do
20
20
  f.input :pathname
21
21
  f.input :basename
22
- f.input :locale, :as => :select, :collection => I18n.available_locales.map(&:to_s)
23
- f.input :format, :as => :select, :collection => Mime::SET.symbols.map(&:to_s)
24
- f.input :handler, :as => :select, :collection => ActionView::Template::Handlers.extensions.map(&:to_s)
22
+ f.input :locale, as: :select, collection: I18n.available_locales.map(&:to_s)
23
+ f.input :format, as: :select, collection: Mime::SET.symbols.map(&:to_s)
24
+ f.input :handler, as: :select, collection: ActionView::Template::Handlers.extensions.map(&:to_s)
25
25
  end
26
26
 
27
27
  f.actions
@@ -42,7 +42,7 @@ ActiveAdmin.register Ecm::Cms::Template do
42
42
  end
43
43
  end
44
44
 
45
- sidebar Ecm::Cms::Template.human_attribute_name(:details), :only => :show do
45
+ sidebar Ecm::Cms::Template.human_attribute_name(:details), only: :show do
46
46
  attributes_table_for ecm_cms_template do
47
47
  # row :folder
48
48
  row :pathname
@@ -51,5 +51,4 @@ ActiveAdmin.register Ecm::Cms::Template do
51
51
  row :updated_at
52
52
  end
53
53
  end # sidebar
54
- end
55
-
54
+ end if Gem::Specification.find_all_by_name('activeadmin').any?
@@ -6,19 +6,24 @@ class Ecm::Cms::PageController < Ecm::Cms::Configuration.base_controller.constan
6
6
  # avoid error 500 on missing template
7
7
  rescue_from ActionView::MissingTemplate do
8
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
- }
9
+ format.html do
10
+ render(file: "#{Rails.root}/public/404", formats: [:html],
11
+ layout: false,
12
+ status: 404
13
+ )
14
+ end
15
15
  format.xml { head :not_found }
16
16
  format.any { head :not_found }
17
17
  end
18
18
  end
19
19
 
20
20
  def respond
21
- render :template => params[:page]
21
+ respond_to do |format|
22
+ format.html { render template: params[:page] }
23
+ format.pdf do
24
+ output = render_to_string template: params[:page], formats: [:html, :pdf], layout: false
25
+ self.response_body = WickedPdf.new.pdf_from_string(output)
26
+ end if Gem::Specification.find_all_by_name('wicked_pdf').any?
27
+ end
22
28
  end
23
29
  end
24
-
@@ -9,14 +9,14 @@ module Ecm::CmsHelper
9
9
 
10
10
  level_as_array = (level).is_a?(Range) ? level.to_a : [level]
11
11
 
12
- navigation = Ecm::Cms::Navigation.where(:name => name.to_s, :locale => I18n.locale.to_s).first
12
+ navigation = Ecm::Cms::Navigation.where(name: name.to_s, locale: I18n.locale.to_s).first
13
13
  unless navigation
14
- return I18n.t('ecm.cms.navigation.messages.not_found', {:lang => I18n.locale.to_s, :name => name.to_s})
14
+ return I18n.t('ecm.cms.navigation.messages.not_found', lang: I18n.locale.to_s, name: name.to_s)
15
15
  end
16
16
 
17
17
  roots = navigation.ecm_cms_navigation_items.roots.all
18
18
  if roots.empty?
19
- return I18n.t('ecm.cms.navigation.messages.empty', :lang => I18n.locale.to_s, :name => name)
19
+ return I18n.t('ecm.cms.navigation.messages.empty', lang: I18n.locale.to_s, name: name)
20
20
  end
21
21
 
22
22
  render_navigation(level: level, expand_all: expand_all, renderer: renderer) do |navigation|
@@ -30,7 +30,7 @@ module Ecm::CmsHelper
30
30
  def build_navigation_item(navigation, item, container_css_class)
31
31
  options = {}
32
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? }
33
+ options = item.li_attributes.marshal_dump.delete_if { |_key, value| value.blank? }
34
34
 
35
35
  navigation.dom_class = container_css_class
36
36
  if item.children.present?
@@ -47,4 +47,8 @@ module Ecm::CmsHelper
47
47
  def link_to_top
48
48
  render partial: '/ecm/cms/link_to_top'
49
49
  end
50
+
51
+ def cms_page?
52
+ params[:action] == 'respond' && params.has_key?(:page)
53
+ end
50
54
  end
@@ -0,0 +1,25 @@
1
+ require 'active_support/concern'
2
+
3
+ module Model::Ecm::Cms::NavigationItem
4
+ module PropertiesConcern
5
+ extend ActiveSupport::Concern
6
+
7
+ included do
8
+ serialize :properties, OpenStruct
9
+ delegate *Ecm::Cms::Configuration.navigation_item_properties, to: :li_attributes
10
+ delegate *Ecm::Cms::Configuration.navigation_item_properties.collect { |a| "#{a}=".to_sym }, to: :li_attributes
11
+ end
12
+
13
+ def highlights_on
14
+ properties.highlights_on ||= nil
15
+ end
16
+
17
+ delegate :highlights_on=, to: :properties
18
+
19
+ def li_attributes
20
+ properties.li_attributes ||= OpenStruct.new
21
+ end
22
+
23
+ delegate :li_attributes=, to: :properties
24
+ end
25
+ end
@@ -1,16 +1,13 @@
1
1
  module Ecm::Cms
2
2
  class ContentBox < ActiveRecord::Base
3
3
  # associations
4
- has_many :ecm_cms_page_content_blocks, :class_name => 'Page::ContentBlock',
5
- :foreign_key => 'ecm_cms_content_box_id'
4
+ has_many :ecm_cms_page_content_blocks, class_name: 'Page::ContentBlock',
5
+ foreign_key: 'ecm_cms_content_box_id'
6
6
 
7
7
  # validations
8
- validates :name, :presence => true,
9
- :uniqueness => true
8
+ validates :name, presence: true,
9
+ uniqueness: true
10
10
 
11
- def ecm_cms_page_content_blocks_count
12
- ecm_cms_page_content_blocks.count
13
- end
11
+ delegate :count, to: :ecm_cms_page_content_blocks, prefix: true
14
12
  end
15
13
  end
16
-
@@ -1,20 +1,19 @@
1
1
  class Ecm::Cms::Folder < ActiveRecord::Base
2
2
  # associations
3
3
  has_many :ecm_cms_pages,
4
- :class_name => 'Ecm::Cms::Page',
5
- :dependent => :destroy,
6
- :foreign_key => 'ecm_cms_folder_id'
4
+ class_name: 'Ecm::Cms::Page',
5
+ dependent: :destroy,
6
+ foreign_key: 'ecm_cms_folder_id'
7
7
  has_many :ecm_cms_partials,
8
- :class_name => 'Ecm::Cms::Partial',
9
- :dependent => :destroy,
10
- :foreign_key => 'ecm_cms_folder_id'
8
+ class_name: 'Ecm::Cms::Partial',
9
+ dependent: :destroy,
10
+ foreign_key: 'ecm_cms_folder_id'
11
11
  has_many :ecm_cms_templates,
12
- :class_name => 'Ecm::Cms::Template',
13
- :dependent => :destroy,
14
- :foreign_key => 'ecm_cms_folder_id'
12
+ class_name: 'Ecm::Cms::Template',
13
+ dependent: :destroy,
14
+ foreign_key: 'ecm_cms_folder_id'
15
15
 
16
16
  # validations
17
- validates :basename, :presence => true
18
- validates :pathname, :presence => true
17
+ validates :basename, presence: true
18
+ validates :pathname, presence: true
19
19
  end
20
-
@@ -1,18 +1,19 @@
1
1
  class Ecm::Cms::Navigation < ActiveRecord::Base
2
2
  # associations
3
3
  has_many :ecm_cms_navigation_items,
4
- :class_name => 'Ecm::Cms::NavigationItem',
5
- :dependent => :destroy,
6
- :foreign_key => 'ecm_cms_navigation_id'
4
+ class_name: 'Ecm::Cms::NavigationItem',
5
+ dependent: :destroy,
6
+ foreign_key: 'ecm_cms_navigation_id'
7
7
 
8
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 ] }
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
+ delegate :count, to: :ecm_cms_navigation_items, prefix: true
13
15
 
14
16
  def to_s
15
- "#{self.name} (#{self.locale})"
17
+ "#{name} (#{locale})"
16
18
  end
17
19
  end
18
-
@@ -1,47 +1,49 @@
1
+ require_dependency 'model/ecm/cms/navigation_item/properties_concern'
2
+
1
3
  module Ecm::Cms
2
4
  class NavigationItem < ActiveRecord::Base
3
- include Properties
5
+ include Model::Ecm::Cms::NavigationItem::PropertiesConcern
4
6
 
5
7
  # associations
6
8
  belongs_to :ecm_cms_navigation,
7
- :class_name => 'Ecm::Cms::Navigation',
8
- :foreign_key => 'ecm_cms_navigation_id'
9
+ class_name: 'Ecm::Cms::Navigation',
10
+ foreign_key: 'ecm_cms_navigation_id'
9
11
  belongs_to :ecm_cms_page,
10
- :class_name => 'Ecm::Cms::Page',
11
- :foreign_key => 'ecm_cms_page_id'
12
+ class_name: 'Ecm::Cms::Page',
13
+ foreign_key: 'ecm_cms_page_id'
12
14
 
13
15
  # awesome nested set
14
- acts_as_nested_set :dependent => :destroy, :counter_cache => :children_count, :scope => :ecm_cms_navigation_id
16
+ acts_as_nested_set dependent: :destroy, counter_cache: :children_count, scope: :ecm_cms_navigation_id
15
17
 
16
18
  # 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
+ before_validation :update_navigation_from_parent, if: proc { |ni| ni.child? }
20
+ before_validation :update_url_form_page, if: proc { |ni| ni.ecm_cms_page.present? && ni.url.blank? }
19
21
  after_save :update_children_navigations!
20
22
 
21
23
  # default_scope
22
24
  default_scope { order(:ecm_cms_navigation_id, :lft) }
23
25
 
24
26
  # 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?
27
+ validates :key, presence: true
28
+ validates :name, presence: true
29
+ validates :url, presence: true
30
+ validates :ecm_cms_navigation, presence: true, if: :root?
29
31
 
30
32
  def params_for_new_page
31
33
  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('|')})(.*)\/(.*)/)
34
+ match = url.scan(/(#{I18n.available_locales.join('|')})$/)
35
+ return { locale: match[0][0], pathname: '/', basename: 'home', title: name, ecm_cms_navigation_item_ids: [to_param] } if match.size > 0
36
+ match = url.scan(/(#{I18n.available_locales.join('|')})(.*)\/(.*)/)
35
37
  return {} unless match.first.respond_to?(:size) # && match.first.size != 3
36
38
  params = match.first
37
39
  return {} if params.size != 3
38
40
  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 ] }
41
+ { locale: params[0], pathname: params[1], basename: params[2], title: name, ecm_cms_navigation_item_ids: [to_param] }
40
42
  end
41
43
 
42
44
  def to_label
43
45
  if depth > 0
44
- "#{'&nbsp;' * depth} &#9654; #{name}".html_safe
46
+ "#{'&nbsp;' * depth} &#9654; #{name}".html_safe
45
47
  else
46
48
  name
47
49
  end
@@ -57,7 +59,7 @@ module Ecm::Cms
57
59
  end
58
60
 
59
61
  def update_children_navigations!
60
- self.descendants.map(&:"update_navigation_from_parent!")
62
+ descendants.map(&:"update_navigation_from_parent!")
61
63
  end
62
64
 
63
65
  def update_url_form_page!
@@ -77,7 +79,7 @@ module Ecm::Cms
77
79
  end
78
80
 
79
81
  def update_navigation_from_parent
80
- self.ecm_cms_navigation = self.parent.ecm_cms_navigation
82
+ self.ecm_cms_navigation = parent.ecm_cms_navigation
81
83
  end
82
84
 
83
85
  def update_url_form_page
@@ -85,4 +87,3 @@ module Ecm::Cms
85
87
  end
86
88
  end
87
89
  end
88
-