kuhsaft 2.2.6 → 2.3.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (125) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +37 -0
  3. data/Rakefile +6 -5
  4. data/app/assets/javascripts/ckeditor/plugins/adv_link/LICENSE.txt +674 -0
  5. data/app/assets/javascripts/ckeditor/plugins/adv_link/README.md +62 -0
  6. data/app/assets/javascripts/ckeditor/plugins/adv_link/dialogs/anchor.js.coffee +81 -0
  7. data/app/assets/javascripts/ckeditor/plugins/adv_link/dialogs/link.js.coffee +1353 -0
  8. data/app/assets/javascripts/ckeditor/plugins/adv_link/images/anchor.png +0 -0
  9. data/app/assets/javascripts/ckeditor/plugins/adv_link/images/hidpi/anchor.png +0 -0
  10. data/app/assets/javascripts/ckeditor/plugins/adv_link/lang/de.js +68 -0
  11. data/app/assets/javascripts/ckeditor/plugins/adv_link/lang/en.js +68 -0
  12. data/app/assets/javascripts/ckeditor/plugins/adv_link/plugin.js.coffee +282 -0
  13. data/app/assets/javascripts/kuhsaft/cms/application.js.coffee.erb +42 -4
  14. data/app/assets/stylesheets/kuhsaft/application.css.sass +0 -3
  15. data/app/assets/stylesheets/kuhsaft/cms/application.css.sass +26 -11
  16. data/app/controllers/kuhsaft/api/pages_controller.rb +14 -0
  17. data/app/controllers/kuhsaft/cms/admin_controller.rb +1 -1
  18. data/app/controllers/kuhsaft/cms/assets_controller.rb +7 -7
  19. data/app/controllers/kuhsaft/cms/bricks_controller.rb +15 -4
  20. data/app/controllers/kuhsaft/cms/pages_controller.rb +8 -15
  21. data/app/controllers/kuhsaft/pages_controller.rb +16 -6
  22. data/app/controllers/kuhsaft/sitemaps_controller.rb +13 -0
  23. data/app/helpers/cms_helper.rb +4 -4
  24. data/app/helpers/kuhsaft/admin_helper.rb +0 -1
  25. data/app/helpers/kuhsaft/cms/admin_helper.rb +1 -2
  26. data/app/helpers/kuhsaft/cms/pages_helper.rb +2 -7
  27. data/app/helpers/pages_helper.rb +8 -37
  28. data/app/helpers/sitemaps_helper.rb +12 -0
  29. data/app/models/kuhsaft/accordion_item_brick.rb +1 -1
  30. data/app/models/kuhsaft/anchor_brick.rb +1 -1
  31. data/app/models/kuhsaft/asset.rb +26 -23
  32. data/app/models/kuhsaft/asset_brick.rb +2 -1
  33. data/app/models/kuhsaft/brick.rb +38 -16
  34. data/app/models/kuhsaft/brick_type.rb +2 -2
  35. data/app/models/kuhsaft/brick_type_filter.rb +0 -2
  36. data/app/models/kuhsaft/column_brick.rb +0 -1
  37. data/app/models/kuhsaft/image_brick.rb +2 -2
  38. data/app/models/kuhsaft/image_size.rb +0 -1
  39. data/app/models/kuhsaft/link_brick.rb +1 -1
  40. data/app/models/kuhsaft/page.rb +111 -107
  41. data/app/models/kuhsaft/page_type.rb +1 -1
  42. data/app/models/kuhsaft/partition.rb +12 -12
  43. data/app/models/kuhsaft/placeholder_brick.rb +8 -0
  44. data/app/models/kuhsaft/publish_state.rb +9 -10
  45. data/app/models/kuhsaft/slider_brick.rb +0 -2
  46. data/app/models/kuhsaft/text_brick.rb +1 -1
  47. data/app/models/kuhsaft/two_column_brick.rb +0 -1
  48. data/app/models/kuhsaft/video_brick.rb +1 -2
  49. data/app/uploaders/kuhsaft/asset_brick_asset_uploader.rb +39 -38
  50. data/app/uploaders/kuhsaft/asset_uploader.rb +43 -43
  51. data/app/uploaders/kuhsaft/image_brick_image_uploader.rb +7 -34
  52. data/app/views/kuhsaft/asset_bricks/asset_brick/_edit.html.haml +3 -2
  53. data/app/views/kuhsaft/cms/admin/_brick_type_dropdown.html.haml +2 -2
  54. data/app/views/kuhsaft/cms/bricks/_brick_item.html.haml +17 -10
  55. data/app/views/kuhsaft/cms/bricks/_new.html.haml +34 -0
  56. data/app/views/kuhsaft/cms/bricks/create.js.haml +6 -0
  57. data/app/views/kuhsaft/cms/bricks/destroy.js.haml +4 -0
  58. data/app/views/kuhsaft/cms/bricks/new.js.haml +11 -0
  59. data/app/views/kuhsaft/cms/pages/_branch.html.haml +2 -2
  60. data/app/views/kuhsaft/cms/pages/_form.html.haml +29 -18
  61. data/app/views/kuhsaft/image_bricks/_image_brick.html.haml +9 -7
  62. data/app/views/kuhsaft/image_bricks/image_brick/_edit.html.haml +3 -0
  63. data/app/views/kuhsaft/pages/show.html.haml +1 -9
  64. data/app/views/kuhsaft/placeholder_bricks/_placeholder_brick.html.haml +1 -1
  65. data/app/views/kuhsaft/sitemaps/index.xml.haml +9 -0
  66. data/app/views/kuhsaft/video_bricks/_video_brick.html.haml +4 -4
  67. data/app/views/layouts/kuhsaft/cms/application.html.haml +4 -3
  68. data/config/initializers/simple_form.rb +4 -4
  69. data/config/initializers/simple_form_bootstrap.rb +14 -14
  70. data/config/locales/de.yml +203 -0
  71. data/config/locales/en.yml +282 -0
  72. data/config/locales/kuhsaft.de.yml +14 -0
  73. data/config/locales/kuhsaft.en.yml +60 -0
  74. data/config/locales/models/kuhsaft/image_brick/de.yml +1 -0
  75. data/config/locales/models/kuhsaft/image_brick/en.yml +16 -0
  76. data/config/locales/models/kuhsaft/text_brick/de.yml +3 -0
  77. data/config/locales/models/kuhsaft/text_brick/en.yml +16 -0
  78. data/config/locales/models/kuhsaft/video_brick/en.yml +15 -0
  79. data/config/locales/views/kuhsaft/cms/pages/de.yml +3 -0
  80. data/config/locales/views/kuhsaft/cms/video_bricks/de.yml +1 -1
  81. data/config/routes.rb +18 -9
  82. data/db/migrate/10_add_redirect_url_to_kuhsaft_pages.rb +1 -1
  83. data/db/migrate/11_update_url_and_redirect_url_value.rb +4 -4
  84. data/db/migrate/13_add_page_title_to_pages.rb +1 -1
  85. data/db/migrate/15_add_alt_text_to_bricks.rb +5 -0
  86. data/db/migrate/16_update_default_value_for_page_type.rb +9 -0
  87. data/db/migrate/17_set_page_type_to_content_for_empty_fields.rb +7 -0
  88. data/lib/generators/kuhsaft/assets/install_generator.rb +1 -2
  89. data/lib/generators/kuhsaft/translations/add_generator.rb +19 -4
  90. data/lib/kuhsaft.rb +1 -0
  91. data/lib/kuhsaft/brick_list.rb +6 -8
  92. data/lib/kuhsaft/engine.rb +5 -1
  93. data/lib/kuhsaft/orderable.rb +22 -19
  94. data/lib/kuhsaft/partial_extractor.rb +1 -1
  95. data/lib/kuhsaft/searchable.rb +8 -11
  96. data/lib/kuhsaft/translatable.rb +35 -19
  97. data/lib/kuhsaft/version.rb +1 -1
  98. data/lib/tasks/kuhsaft_tasks.rake +12 -0
  99. data/lib/templates/kuhsaft/assets/ck-config.js.coffee +7 -0
  100. data/lib/templates/kuhsaft/translations/add_translation.html.erb +4 -10
  101. data/spec/controllers/kuhsaft/api/pages_controller_spec.rb +70 -0
  102. data/spec/controllers/kuhsaft/pages_controller_spec.rb +18 -14
  103. data/spec/controllers/kuhsaft/sitemaps_controller_spec.rb +13 -0
  104. data/spec/dummy/app/assets/javascripts/kuhsaft/cms/ck-config.js.coffee +7 -0
  105. data/spec/dummy/config/application.rb +2 -1
  106. data/spec/dummy/config/database.yml +1 -1
  107. data/spec/factories.rb +3 -3
  108. data/spec/features/cms_pages_spec.rb +13 -13
  109. data/spec/features/search_spec.rb +16 -18
  110. data/spec/helpers/kuhsaft/cms/pages_helper_spec.rb +2 -1
  111. data/spec/kuhsaft_spec.rb +1 -1
  112. data/spec/lib/brick_list_spec.rb +1 -1
  113. data/spec/lib/page_tree_spec.rb +10 -6
  114. data/spec/lib/searchable_spec.rb +4 -4
  115. data/spec/lib/translatable_spec.rb +114 -44
  116. data/spec/models/anchor_brick_spec.rb +1 -1
  117. data/spec/models/asset_spec.rb +1 -1
  118. data/spec/models/brick_spec.rb +1 -1
  119. data/spec/models/page_spec.rb +48 -37
  120. data/spec/models/publish_state_spec.rb +9 -9
  121. data/spec/spec_helper.rb +43 -21
  122. data/spec/support/kuhsaft_spec_helper.rb +2 -2
  123. data/spec/support/write_expectation.rb +57 -0
  124. data/spec/views/kuhsaft/sitemaps/index.xml.haml_spec.rb +67 -0
  125. metadata +119 -4
@@ -1,6 +1,6 @@
1
1
  module Kuhsaft
2
2
  class AnchorBrick < Brick
3
- validates :caption, :presence => true
3
+ validates :caption, presence: true
4
4
 
5
5
  def user_can_add_childs?
6
6
  false
@@ -1,26 +1,29 @@
1
- class Kuhsaft::Asset < ActiveRecord::Base
2
- scope :by_date, -> { order('updated_at DESC') }
3
- mount_uploader :file, Kuhsaft::AssetUploader
4
-
5
- def file_type
6
- if file.path.present? && ext = File.extname(file.path).split('.').last
7
- ext.to_sym unless ext.blank?
1
+ module Kuhsaft
2
+ class Asset < ActiveRecord::Base
3
+ scope :by_date, -> { order('updated_at DESC') }
4
+ mount_uploader :file, Kuhsaft::AssetUploader
5
+
6
+ def file_type
7
+ return unless file.path.present?
8
+
9
+ ext = File.extname(file.path).split('.').last
10
+ ext.to_sym if ext.present?
11
+ end
12
+
13
+ def name
14
+ File.basename(file.path) if file.present? && file.path.present?
15
+ end
16
+
17
+ def path
18
+ file.url
19
+ end
20
+
21
+ def path=(val)
22
+ # do nothing
23
+ end
24
+
25
+ def filename
26
+ try(:file).try(:file).try(:filename)
8
27
  end
9
- end
10
-
11
- def name
12
- File.basename(file.path) if file.present? && file.path.present?
13
- end
14
-
15
- def path
16
- file.url
17
- end
18
-
19
- def path=val
20
- # do nothing
21
- end
22
-
23
- def filename
24
- try(:file).try(:file).try(:filename)
25
28
  end
26
29
  end
@@ -2,7 +2,8 @@ module Kuhsaft
2
2
  class AssetBrick < Brick
3
3
  mount_uploader :asset, Kuhsaft::AssetBrickAssetUploader
4
4
 
5
- validates :caption, :asset, :presence => true
5
+ validates :caption,
6
+ :asset, presence: true
6
7
 
7
8
  def self.styles
8
9
  %w(pdf word excel button)
@@ -2,10 +2,10 @@ module Kuhsaft
2
2
  class Brick < ActiveRecord::Base
3
3
  include Kuhsaft::BrickList
4
4
 
5
- belongs_to :brick_list, :polymorphic => true, :touch => true
5
+ belongs_to :brick_list, polymorphic: true, touch: true
6
6
 
7
- scope :localized, -> { where(:locale => I18n.locale) }
8
- default_scope -> { order('position ASC').localized }
7
+ scope :localized, -> { where(locale: I18n.locale) }
8
+ default_scope { order('position ASC').localized }
9
9
 
10
10
  serialize :display_styles, Array
11
11
 
@@ -16,7 +16,17 @@ module Kuhsaft
16
16
  :type,
17
17
  :brick_list_id,
18
18
  :brick_list_type,
19
- :presence => true
19
+ presence: true
20
+
21
+ validates :template_name,
22
+ :type,
23
+ :locale,
24
+ :caption,
25
+ :link_style,
26
+ :image_size,
27
+ :video,
28
+ :alt_text,
29
+ length: { maximum: 255 }
20
30
 
21
31
  after_initialize do
22
32
  self.position ||= has_siblings? ? brick_list.bricks.maximum(:position).to_i + 1 : 1
@@ -39,15 +49,13 @@ module Kuhsaft
39
49
  end
40
50
 
41
51
  def to_edit_partial_path
42
- path = self.to_partial_path.split '/'
52
+ path = to_partial_path.split '/'
43
53
  path << 'edit'
44
54
  path.join '/'
45
55
  end
46
56
 
47
57
  def has_siblings?
48
- if brick_list
49
- brick_list.bricks.any?
50
- end
58
+ brick_list.present? && brick_list.bricks.any?
51
59
  end
52
60
 
53
61
  #
@@ -56,7 +64,7 @@ module Kuhsaft
56
64
  # Returns the path to this partial.
57
65
  #
58
66
  def to_edit_childs_partial_path
59
- path = self.to_partial_path.split '/'
67
+ path = to_partial_path.split '/'
60
68
  path << 'childs'
61
69
  path.join '/'
62
70
  end
@@ -74,12 +82,12 @@ module Kuhsaft
74
82
 
75
83
  def set_position
76
84
  self.position = if self.position.present?
77
- self.position
78
- elsif self.respond_to?(:brick_list) && self.brick_list.respond_to?(:bricks)
79
- brick_list.bricks.maximum(:position).to_i + 1
80
- else
81
- 1
82
- end
85
+ self.position
86
+ elsif self.respond_to?(:brick_list) && brick_list.respond_to?(:bricks)
87
+ brick_list.bricks.maximum(:position).to_i + 1
88
+ else
89
+ 1
90
+ end
83
91
  end
84
92
 
85
93
  def brick_list_type
@@ -88,7 +96,7 @@ module Kuhsaft
88
96
 
89
97
  # Returns a css classname suitable for use in the frontend
90
98
  def to_style_class
91
- ([self.class.to_s.underscore.dasherize.gsub('/', '-')] + self.display_styles).join(' ')
99
+ ([self.class.to_s.underscore.dasherize.gsub('/', '-')] + display_styles).join(' ')
92
100
  end
93
101
 
94
102
  # Returns a unique DOM id suitable for use in the frontend
@@ -101,6 +109,12 @@ module Kuhsaft
101
109
  []
102
110
  end
103
111
 
112
+ def translated_available_display_styles
113
+ available_display_styles.map do |style|
114
+ [I18n.t("#{self.class.to_s.demodulize.underscore}.display_styles.#{style}"), style]
115
+ end
116
+ end
117
+
104
118
  def backend_label(options = {})
105
119
  label = self.class.model_name.human
106
120
  if options[:parenthesis] == true
@@ -109,5 +123,13 @@ module Kuhsaft
109
123
  label
110
124
  end
111
125
  end
126
+
127
+ def partial_digest(name)
128
+ ActionView::Digestor.digest(name, 'haml', ApplicationController.new.lookup_context, partial: true)
129
+ end
130
+
131
+ def cache_key
132
+ super + partial_digest(to_partial_path)
133
+ end
112
134
  end
113
135
  end
@@ -1,7 +1,7 @@
1
1
  module Kuhsaft
2
2
  class BrickType < ActiveRecord::Base
3
3
  scope :grouped, -> { order('`group`, `id` asc') }
4
- scope :enabled, -> { where(:enabled => true) }
5
- scope :constrained, ->(list) { where(:class_name => list) }
4
+ scope :enabled, -> { where(enabled: true) }
5
+ scope :constrained, ->(list) { where(class_name: list) }
6
6
  end
7
7
  end
@@ -1,7 +1,6 @@
1
1
 
2
2
  module Kuhsaft
3
3
  class BrickTypeFilter < SimpleDelegator
4
-
5
4
  def empty?
6
5
  !(respond_to?(:user_can_add_childs?) && user_can_add_childs? && !allowed.empty?)
7
6
  end
@@ -15,6 +14,5 @@ module Kuhsaft
15
14
  Kuhsaft::BrickType.enabled.constrained(allowed_brick_types)
16
15
  end
17
16
  end
18
-
19
17
  end
20
18
  end
@@ -18,6 +18,5 @@ module Kuhsaft
18
18
  def renders_own_childs?
19
19
  false
20
20
  end
21
-
22
21
  end
23
22
  end
@@ -2,8 +2,8 @@ module Kuhsaft
2
2
  class ImageBrick < Brick
3
3
  include Kuhsaft::ImageUploaderMounting
4
4
 
5
- validates :image, :presence => true
6
- validates :image_size, :presence => true
5
+ validates :image,
6
+ :image_size, presence: true
7
7
 
8
8
  def collect_fulltext
9
9
  [super, caption].join(' ')
@@ -47,6 +47,5 @@ module Kuhsaft
47
47
  end
48
48
  end
49
49
  end
50
-
51
50
  end
52
51
  end
@@ -1,6 +1,6 @@
1
1
  module Kuhsaft
2
2
  class LinkBrick < Brick
3
- validates :href, :caption, :presence => true
3
+ validates :href, :caption, presence: true
4
4
 
5
5
  def self.styles
6
6
  %w(pdf word excel button external)
@@ -1,142 +1,146 @@
1
- class Kuhsaft::Page < ActiveRecord::Base
2
- include Kuhsaft::Engine.routes.url_helpers
3
- include Kuhsaft::Orderable
4
- include Kuhsaft::Translatable
5
- include Kuhsaft::BrickList
6
- include Kuhsaft::Searchable
1
+ module Kuhsaft
2
+ class Page < ActiveRecord::Base
3
+ include Kuhsaft::Engine.routes.url_helpers
4
+ include Kuhsaft::Orderable
5
+ include Kuhsaft::Translatable
6
+ include Kuhsaft::BrickList
7
+ include Kuhsaft::Searchable
7
8
 
8
- has_ancestry
9
- acts_as_brick_list
9
+ has_ancestry
10
+ acts_as_brick_list
10
11
 
11
- translate :title,
12
- :page_title,
13
- :slug,
14
- :keywords,
15
- :description,
16
- :body,
17
- :redirect_url,
18
- :url
12
+ translate :title, :page_title, :slug, :keywords, :description,
13
+ :body, :redirect_url, :url
19
14
 
20
- default_scope { order('position ASC') }
15
+ default_scope { order 'position ASC' }
21
16
 
22
- scope :published, -> { where(:published => Kuhsaft::PublishState::PUBLISHED) }
23
- scope :translated, -> { where("url_#{I18n.locale} is not null") }
17
+ scope :published, -> { where published: Kuhsaft::PublishState::PUBLISHED }
18
+ scope :translated, -> { where "url_#{I18n.locale} is not null" }
24
19
 
25
- # TODO: cleanup page_types (content pages => nil or PageType::CONTENT
26
- scope :content_page, -> { where(
27
- ["page_type is NULL or page_type = ?",
28
- Kuhsaft::PageType::CONTENT]) }
20
+ scope :content_page, -> { where page_type: Kuhsaft::PageType::CONTENT }
29
21
 
30
- scope :navigation, ->(slug) {
31
- where(locale_attr(:slug) => slug).where(
32
- locale_attr(:page_type) => Kuhsaft::PageType::NAVIGATION) }
22
+ scope :navigation, lambda { |slug|
23
+ where(
24
+ locale_attr(:slug) => slug,
25
+ locale_attr(:page_type) => Kuhsaft::PageType::NAVIGATION)
26
+ }
33
27
 
34
- before_validation :create_slug, :create_url
28
+ before_validation :create_slug, :create_url
35
29
 
36
- validates :title, :presence => true
37
- validates :slug, :presence => true
38
- validates :redirect_url, :presence => true, :if => :redirect?
30
+ validates :title, presence: true
31
+ validates :slug, presence: true
32
+ validates :redirect_url, presence: true, if: :redirect?
33
+ validates :title, :slug, :keywords, :page_type, length: { maximum: 255 }
39
34
 
40
- class << self
41
- def flat_tree(pages = nil)
42
- arrange_as_array
43
- end
35
+ class << self
36
+ def flat_tree(pages = nil)
37
+ arrange_as_array
38
+ end
39
+
40
+ def arrange_as_array(options = {}, hash = nil)
41
+ hash ||= arrange(options)
44
42
 
45
- def arrange_as_array(options={}, hash=nil)
46
- hash ||= arrange(options)
43
+ arr = []
44
+ hash.each do |node, children|
45
+ arr << node
46
+ arr += arrange_as_array(options, children) unless children.empty?
47
+ end
47
48
 
48
- arr = []
49
- hash.each do |node, children|
50
- arr << node
51
- arr += arrange_as_array(options, children) unless children.empty?
49
+ arr
52
50
  end
51
+ end
53
52
 
54
- arr
53
+ def without_self
54
+ self.class.where 'id != ?', id
55
55
  end
56
- end
57
56
 
58
- def without_self
59
- Kuhsaft::Page.where('id != ?', self.id)
60
- end
57
+ def published?
58
+ published == Kuhsaft::PublishState::PUBLISHED
59
+ end
61
60
 
62
- def published?
63
- published == Kuhsaft::PublishState::PUBLISHED
64
- end
61
+ def state_class
62
+ published? ? 'published' : 'unpublished'
63
+ end
65
64
 
66
- def state_class
67
- if published?
68
- 'published'
69
- else
70
- 'unpublished'
65
+ def redirect?
66
+ page_type == Kuhsaft::PageType::REDIRECT
71
67
  end
72
- end
73
68
 
74
- def redirect?
75
- page_type == Kuhsaft::PageType::REDIRECT
76
- end
69
+ def navigation?
70
+ page_type == Kuhsaft::PageType::NAVIGATION
71
+ end
77
72
 
78
- def navigation?
79
- page_type == Kuhsaft::PageType::NAVIGATION
80
- end
73
+ def parent_pages
74
+ ancestors
75
+ end
81
76
 
82
- def parent_pages
83
- ancestors
84
- end
77
+ def translated?
78
+ url.present? && title.present? && slug.present?
79
+ end
85
80
 
86
- def translated?
87
- url.present? && title.present? && slug.present?
88
- end
81
+ def link
82
+ if bricks.count == 0 && children.count > 0
83
+ children.first.link
84
+ else
85
+ url_with_locale
86
+ end
87
+ end
89
88
 
90
- def link
91
- if bricks.count == 0 && children.count > 0
92
- children.first.link
93
- else
94
- url_with_locale
89
+ # TODO: needs naming and routing refactoring (url/locale/path/slug)
90
+ def path_segments
91
+ paths = parent.present? ? parent.path_segments : []
92
+ paths << slug unless navigation?
93
+ paths
95
94
  end
96
- end
97
95
 
98
- # TODO: needs naming and routing refactoring (url/locale/path/slug)
99
- def path_segments
100
- paths = parent.present? ? parent.path_segments : []
101
- paths << slug unless navigation?
102
- paths
103
- end
96
+ def url_without_locale
97
+ path_segments.join('/')
98
+ end
104
99
 
105
- def url_without_locale
106
- path_segments.join('/')
107
- end
100
+ def url_with_locale
101
+ opts = { locale: I18n.locale }
102
+ url = url_without_locale
103
+ opts[:url] = url if url.present?
104
+ page_path(opts)
105
+ end
108
106
 
109
- def url_with_locale
110
- opts = { :locale => I18n.locale }
111
- url = url_without_locale
112
- opts[:url] = url if url.present?
113
- page_path(opts)
114
- end
107
+ def create_url
108
+ self.url = url_with_locale[1..-1]
109
+ end
115
110
 
116
- def create_url
117
- self.url = url_with_locale[1..-1]
118
- end
111
+ def create_slug
112
+ has_slug = title.present? && slug.blank?
113
+ self.slug = title.downcase.parameterize if has_slug
114
+ end
119
115
 
120
- def create_slug
121
- has_slug = title.present? && slug.blank?
122
- self.slug = title.downcase.parameterize if has_slug
123
- end
116
+ def nesting_name
117
+ num_dashes = parent_pages.size
118
+ num_dashes = 0 if num_dashes < 0
119
+ "#{'-' * num_dashes} #{title}".strip
120
+ end
124
121
 
125
- def nesting_name
126
- num_dashes = parent_pages.size
127
- num_dashes = 0 if num_dashes < 0
128
- "#{'-' * num_dashes} #{self.title}".strip
129
- end
122
+ def brick_list_type
123
+ 'Kuhsaft::Page'
124
+ end
130
125
 
131
- def brick_list_type
132
- 'Kuhsaft::Page'
133
- end
126
+ def to_style_class
127
+ 'kuhsaft-page'
128
+ end
134
129
 
135
- def to_style_class
136
- 'kuhsaft-page'
137
- end
130
+ def allowed_brick_types
131
+ Kuhsaft::BrickType.enabled.pluck(:class_name) - ['Kuhsaft::AccordionItemBrick']
132
+ end
133
+
134
+ def cache_key
135
+ super + bricks.map(&:cache_key).join
136
+ end
138
137
 
139
- def allowed_brick_types
140
- Kuhsaft::BrickType.enabled.pluck(:class_name) - ['Kuhsaft::AccordionItemBrick']
138
+ def as_json(options = {})
139
+ Hash.new.tap do |json|
140
+ json['title'] = send("title_#{I18n.locale}")
141
+ json['pretty_url'] = '/' + send("url_#{I18n.locale}")
142
+ json['url'] = "/pages/#{id}"
143
+ end
144
+ end
141
145
  end
142
146
  end