kuhsaft 0.3.6 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +127 -77
- data/Rakefile +15 -10
- data/app/assets/javascripts/kuhsaft/application.js +2 -0
- data/app/assets/javascripts/kuhsaft/cms/application.js +16 -4
- data/app/assets/javascripts/kuhsaft/cms/customizations.js +1 -0
- data/app/assets/stylesheets/kuhsaft/application.css.sass +4 -0
- data/app/assets/stylesheets/kuhsaft/cms/application.css.sass +125 -0
- data/app/assets/stylesheets/kuhsaft/cms/customizations.css.sass +1 -0
- data/app/controllers/kuhsaft/application_controller.rb +5 -0
- data/app/controllers/kuhsaft/cms/admin_controller.rb +8 -10
- data/app/controllers/kuhsaft/cms/bricks_controller.rb +35 -0
- data/app/controllers/kuhsaft/cms/pages_controller.rb +16 -19
- data/app/controllers/kuhsaft/pages_controller.rb +4 -10
- data/app/helpers/cms_helper.rb +3 -3
- data/app/helpers/kuhsaft/application_helper.rb +21 -0
- data/app/helpers/kuhsaft/cms/application_helper.rb +10 -0
- data/app/helpers/kuhsaft/cms/pages_helper.rb +14 -0
- data/app/helpers/pages_helper.rb +18 -21
- data/app/models/kuhsaft/accordion_brick.rb +16 -0
- data/app/models/kuhsaft/accordion_item_brick.rb +22 -0
- data/app/models/kuhsaft/brick.rb +85 -0
- data/app/models/kuhsaft/brick_type.rb +7 -0
- data/app/models/kuhsaft/cms.rb +7 -0
- data/app/models/kuhsaft/cms/admin.rb +20 -0
- data/app/models/kuhsaft/column_brick.rb +23 -0
- data/app/models/kuhsaft/image_brick.rb +19 -0
- data/app/models/kuhsaft/image_size.rb +52 -0
- data/app/models/kuhsaft/link_brick.rb +19 -0
- data/app/models/kuhsaft/page.rb +83 -101
- data/app/models/kuhsaft/partition.rb +18 -0
- data/app/models/kuhsaft/placeholder_brick.rb +11 -0
- data/app/models/kuhsaft/slider_brick.rb +16 -0
- data/app/models/kuhsaft/text_brick.rb +9 -0
- data/app/models/kuhsaft/two_column_brick.rb +50 -0
- data/app/models/kuhsaft/video_brick.rb +20 -0
- data/app/uploaders/kuhsaft/asset_uploader.rb +2 -2
- data/app/uploaders/kuhsaft/image_brick_image_uploader.rb +63 -0
- data/app/views/kuhsaft/accordion_bricks/_accordion_brick.html.haml +3 -0
- data/app/{assets/stylesheets/kuhsaft/cms/base/partials/_forms.css.sass → views/kuhsaft/accordion_bricks/accordion_brick/_edit.html.haml} +0 -0
- data/app/views/kuhsaft/accordion_item_bricks/_accordion_item_brick.html.haml +8 -0
- data/app/views/kuhsaft/accordion_item_bricks/accordion_item_brick/_edit.html.haml +1 -0
- data/app/views/kuhsaft/cms/admin/_brick_type_dropdown.html.haml +10 -0
- data/app/views/kuhsaft/cms/admin/_content_language_switch.html.haml +7 -0
- data/app/views/kuhsaft/cms/admin/_empty_state.html.haml +5 -0
- data/app/views/kuhsaft/cms/admin/_main_navigation.html.haml +6 -0
- data/app/views/kuhsaft/cms/assets/index.html.haml +2 -2
- data/app/views/kuhsaft/cms/bricks/_brick_item.html.haml +38 -0
- data/app/views/kuhsaft/cms/bricks/_brick_list.html.haml +4 -0
- data/app/views/kuhsaft/cms/bricks/create.js.haml +1 -0
- data/app/views/kuhsaft/cms/bricks/destroy.js.haml +7 -0
- data/app/views/kuhsaft/cms/bricks/update.js.haml +2 -0
- data/app/views/kuhsaft/cms/pages/_branch.html.haml +17 -9
- data/app/views/kuhsaft/cms/pages/_form.html.haml +25 -60
- data/app/views/kuhsaft/cms/pages/edit.html.haml +14 -8
- data/app/views/kuhsaft/cms/pages/index.html.haml +8 -8
- data/app/views/kuhsaft/cms/pages/new.html.haml +1 -10
- data/app/views/kuhsaft/column_bricks/_column_brick.html.haml +3 -0
- data/app/views/kuhsaft/{cms/page_parts/edit.html.haml → column_bricks/column_brick/_edit.html.haml} +0 -0
- data/app/views/kuhsaft/image_bricks/_image_brick.html.haml +9 -0
- data/app/views/kuhsaft/image_bricks/image_brick/_edit.html.haml +10 -0
- data/app/views/kuhsaft/link_bricks/_link_brick.html.haml +3 -0
- data/app/views/kuhsaft/link_bricks/link_brick/_edit.html.haml +3 -0
- data/app/views/kuhsaft/pages/show.html.haml +5 -3
- data/app/views/kuhsaft/placeholder_bricks/_placeholder_brick.html.haml +2 -0
- data/app/views/kuhsaft/placeholder_bricks/placeholder_brick/_edit.html.haml +1 -0
- data/app/views/kuhsaft/slider_bricks/_slider_brick.html.haml +10 -0
- data/app/views/kuhsaft/{cms/page_parts/index.html.haml → slider_bricks/slider_brick/_edit.html.haml} +0 -0
- data/app/views/kuhsaft/text_bricks/_text_brick.html.haml +12 -0
- data/app/views/kuhsaft/text_bricks/text_brick/_edit.html.haml +2 -0
- data/app/views/kuhsaft/two_column_bricks/_two_column_brick.html.haml +3 -0
- data/app/views/kuhsaft/two_column_bricks/two_column_brick/_childs.html.haml +5 -0
- data/app/views/kuhsaft/two_column_bricks/two_column_brick/_edit.html.haml +1 -0
- data/app/views/kuhsaft/video_bricks/_video_brick.html.haml +9 -0
- data/app/views/kuhsaft/video_bricks/video_brick/_edit.html.haml +8 -0
- data/app/views/layouts/kuhsaft/cms/application.html.haml +20 -0
- data/config/initializers/devise.rb +231 -0
- data/config/initializers/simple_form.rb +142 -0
- data/config/initializers/simple_form_bootstrap.rb +45 -0
- data/config/locales/kuhsaft.en.yml +4 -1
- data/config/locales/models/kuhsaft/accordion_brick/de.yml +4 -0
- data/config/locales/models/kuhsaft/accordion_item_brick/de.yml +7 -0
- data/config/locales/models/kuhsaft/column_brick/de.yml +6 -0
- data/config/locales/models/kuhsaft/image_brick/de.yml +10 -0
- data/config/locales/models/kuhsaft/image_size/de.yml +13 -0
- data/config/locales/models/kuhsaft/link_brick/de.yml +9 -0
- data/config/locales/models/kuhsaft/page/de.yml +17 -0
- data/config/locales/models/kuhsaft/placeholder_brick/de.yml +8 -0
- data/config/locales/models/kuhsaft/slider_brick/de.yml +4 -0
- data/config/locales/models/kuhsaft/text_brick/de.yml +8 -0
- data/config/locales/models/kuhsaft/two_column_brick/de.yml +7 -0
- data/config/locales/models/kuhsaft/video_brick/de.yml +9 -0
- data/config/locales/simple_form.en.yml +26 -0
- data/config/locales/views/kuhsaft/cms/admin/de.yml +10 -0
- data/config/locales/views/kuhsaft/cms/bricks/de.yml +8 -0
- data/config/locales/views/kuhsaft/cms/pages/de.yml +9 -0
- data/config/locales/views/kuhsaft/cms/video_bricks/de.yml +7 -0
- data/config/locales/views/kuhsaft/text_brick/de.yml +6 -0
- data/config/locales/views/layouts/de.yml +6 -0
- data/config/routes.rb +10 -11
- data/db/migrate/01_create_kuhsaft_pages.rb +31 -0
- data/db/migrate/02_create_kuhsaft_bricks.rb +23 -0
- data/db/migrate/03_create_kuhsaft_brick_types.rb +12 -0
- data/db/migrate/04_create_kuhsaft_assets.rb +10 -0
- data/db/migrate/05_create_kuhsaft_cms_admins.rb +46 -0
- data/db/migrate/06_add_template_name_to_kuhsaft_bricks.rb +7 -0
- data/db/seeds.rb +14 -0
- data/lib/generators/kuhsaft/translations/add_generator.rb +26 -0
- data/lib/kuhsaft.rb +8 -1
- data/lib/kuhsaft/brick_list.rb +71 -0
- data/lib/kuhsaft/engine.rb +17 -12
- data/lib/kuhsaft/partial_extractor.rb +21 -0
- data/lib/kuhsaft/translatable.rb +40 -0
- data/lib/kuhsaft/version.rb +1 -1
- data/lib/tasks/kuhsaft_tasks.rake +10 -0
- data/lib/templates/kuhsaft/translations/add_translation.html.erb +13 -0
- data/spec/dummy/Rakefile +1 -1
- data/spec/dummy/app/assets/javascripts/application.js +9 -3
- data/spec/dummy/app/assets/stylesheets/application.css +11 -5
- data/spec/dummy/app/controllers/application_controller.rb +0 -6
- data/spec/dummy/app/views/layouts/application.html.erb +1 -1
- data/spec/dummy/config/application.rb +24 -7
- data/spec/dummy/config/boot.rb +3 -2
- data/spec/dummy/config/database.yml +6 -3
- data/spec/dummy/config/environments/development.rb +8 -1
- data/spec/dummy/config/environments/production.rb +9 -2
- data/spec/dummy/config/environments/test.rb +4 -9
- data/spec/dummy/config/initializers/inflections.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +1 -1
- data/spec/dummy/config/initializers/session_store.rb +1 -1
- data/spec/dummy/config/initializers/wrap_parameters.rb +1 -1
- data/spec/dummy/config/locales/en.yml +2 -2
- data/spec/dummy/config/routes.rb +2 -57
- data/spec/dummy/db/{migrate/.gitkeep → .gitkeep} +0 -0
- data/spec/dummy/public/500.html +0 -1
- data/spec/dummy/{lib/tasks → public/stylesheets}/.gitkeep +0 -0
- data/spec/factories.rb +11 -17
- data/spec/features/cms_auth_spec.rb +9 -0
- data/spec/features/cms_pages_spec.rb +23 -0
- data/spec/helpers/kuhsaft/cms/application_helper_spec.rb +25 -0
- data/spec/lib/brick_list_spec.rb +39 -0
- data/spec/lib/engine_spec.rb +25 -0
- data/spec/lib/translatable_spec.rb +85 -0
- data/spec/models/accordion_brick_spec.rb +32 -0
- data/spec/models/accordion_item_brick_spec.rb +50 -0
- data/spec/models/asset_spec.rb +25 -23
- data/spec/models/brick_spec.rb +110 -0
- data/spec/models/cms/admin_spec.rb +26 -0
- data/spec/models/column_brick_spec.rb +32 -0
- data/spec/models/image_brick_spec.rb +36 -0
- data/spec/models/image_size_spec.rb +36 -0
- data/spec/models/link_brick_spec.rb +45 -0
- data/spec/models/page_spec.rb +262 -281
- data/spec/models/placeholder_brick_spec.rb +40 -0
- data/spec/models/slider_brick_spec.rb +20 -0
- data/spec/models/text_brick_spec.rb +14 -0
- data/spec/models/two_column_brick_spec.rb +72 -0
- data/spec/models/video_brick_spec.rb +26 -0
- data/spec/spec_helper.rb +60 -51
- data/spec/support/kuhsaft_spec_helper.rb +4 -28
- data/spec/support/request_macros.rb +19 -0
- data/vendor/assets/javascripts/redactor.min.js +12 -0
- data/vendor/assets/stylesheets/redactor.css +692 -0
- metadata +402 -346
- data/.gitignore +0 -19
- data/.rspec +0 -2
- data/.rvmrc +0 -47
- data/CHANGELOG.md +0 -81
- data/Gemfile +0 -2
- data/Guardfile +0 -25
- data/LICENSE +0 -7
- data/app/assets/images/kuhsaft/add-child-page.png +0 -0
- data/app/assets/images/kuhsaft/closedhand.cur +0 -0
- data/app/assets/images/kuhsaft/delete.png +0 -0
- data/app/assets/images/kuhsaft/header-bg.jpg +0 -0
- data/app/assets/images/kuhsaft/module-nav-tab-bg.png +0 -0
- data/app/assets/images/kuhsaft/openhand.cur +0 -0
- data/app/assets/images/kuhsaft/page-edit-icon.png +0 -0
- data/app/assets/images/kuhsaft/page-new-icon.png +0 -0
- data/app/assets/images/kuhsaft/page-part-draggable-area.png +0 -0
- data/app/assets/images/kuhsaft/page-tree-breadcrumb-arrow.png +0 -0
- data/app/assets/images/kuhsaft/pages-breadcrumb-icon.png +0 -0
- data/app/assets/images/kuhsaft/tab-bg.png +0 -0
- data/app/assets/images/kuhsaft/toggle-arrow-closed.png +0 -0
- data/app/assets/images/kuhsaft/toggle-arrow-open.png +0 -0
- data/app/assets/images/kuhsaft/wrapper-bg.png +0 -0
- data/app/assets/javascripts/kuhsaft/cms/backend.js +0 -34
- data/app/assets/javascripts/kuhsaft/cms/jquery-ui-1.8.12.custom.min.js +0 -192
- data/app/assets/javascripts/kuhsaft/cms/jquery.elastic.source.js +0 -161
- data/app/assets/javascripts/kuhsaft/cms/jquery.min.js +0 -18
- data/app/assets/javascripts/kuhsaft/cms/jquery_ujs.js +0 -336
- data/app/assets/stylesheets/kuhsaft/cms/application.css +0 -6
- data/app/assets/stylesheets/kuhsaft/cms/base/base.css.sass +0 -9
- data/app/assets/stylesheets/kuhsaft/cms/base/partials/_assets.css.sass +0 -15
- data/app/assets/stylesheets/kuhsaft/cms/base/partials/_buttons.css.sass +0 -34
- data/app/assets/stylesheets/kuhsaft/cms/base/partials/_generic.css.sass +0 -342
- data/app/assets/stylesheets/kuhsaft/cms/base/partials/_simple_form.css.sass +0 -76
- data/app/controllers/kuhsaft/cms/page_parts_controller.rb +0 -34
- data/app/models/kuhsaft/localized_page.rb +0 -81
- data/app/models/kuhsaft/page_part.rb +0 -12
- data/app/models/kuhsaft/page_part/content.rb +0 -76
- data/app/models/kuhsaft/page_part/markdown.rb +0 -8
- data/app/views/kuhsaft/cms/page_parts/destroy.js.haml +0 -1
- data/app/views/kuhsaft/cms/page_parts/new.html.haml +0 -0
- data/app/views/kuhsaft/cms/page_parts/show.html.haml +0 -0
- data/app/views/kuhsaft/cms/page_parts/update.js.haml +0 -0
- data/app/views/kuhsaft/page_part/markdowns/_edit_markdown.html.haml +0 -1
- data/app/views/kuhsaft/page_part/markdowns/_show_markdown.html.haml +0 -1
- data/app/views/kuhsaft/pages/index.html.haml +0 -0
- data/app/views/layouts/kuhsaft/admin.html.haml +0 -35
- data/config/initializers/generators.rb +0 -7
- data/config/initializers/page_parts.rb +0 -17
- data/kuhsaft.gemspec +0 -39
- data/lib/generators/kuhsaft/install/assets_generator.rb +0 -12
- data/lib/generators/kuhsaft/install/migrations_generator.rb +0 -43
- data/lib/templates/kuhsaft/install/acts_as_taggable_on_migration.rb +0 -37
- data/lib/templates/kuhsaft/install/add_fulltext_to_localized_page.rb +0 -9
- data/lib/templates/kuhsaft/install/add_page_type_to_localized_pages.rb +0 -9
- data/lib/templates/kuhsaft/install/add_published_at_to_localized_pages.rb +0 -9
- data/lib/templates/kuhsaft/install/add_tags_to_page_part_contents.rb +0 -9
- data/lib/templates/kuhsaft/install/add_type_to_page_part_contents.rb +0 -9
- data/lib/templates/kuhsaft/install/add_url_to_localized_pages.rb +0 -9
- data/lib/templates/kuhsaft/install/create_assets.rb +0 -12
- data/lib/templates/kuhsaft/install/create_kuhsaft_localized_pages.rb +0 -19
- data/lib/templates/kuhsaft/install/create_kuhsaft_pages.rb +0 -14
- data/lib/templates/kuhsaft/install/create_page_part_contents.rb +0 -14
- data/spec/controllers/cms_assets_controller_spec.rb +0 -26
- data/spec/controllers/cms_pages_controller_spec.rb +0 -65
- data/spec/controllers/page_parts_controller_spec.rb +0 -60
- data/spec/controllers/pages_controller_spec.rb +0 -30
- data/spec/dummy/app/assets/images/rails.png +0 -0
- data/spec/helpers/cms_helper_spec.rb +0 -22
- data/spec/helpers/pages_helper_spec.rb +0 -119
- data/spec/integration/navigation_spec.rb +0 -9
- data/spec/models/localized_page_spec.rb +0 -266
- data/spec/models/page_part_content_spec.rb +0 -95
- data/spec/models/page_part_spec.rb +0 -17
- data/spec/requests/cms_pages_spec.rb +0 -27
- data/spec/routing/assets_routing_spec.rb +0 -63
- data/spec/routing/page_part_routing_spec.rb +0 -70
- data/spec/routing/pages_routing_spec.rb +0 -74
@@ -0,0 +1,20 @@
|
|
1
|
+
module Kuhsaft
|
2
|
+
module Cms
|
3
|
+
class Admin < ActiveRecord::Base
|
4
|
+
devise :database_authenticatable, :rememberable
|
5
|
+
attr_accessible :email, :password, :password_confirmation, :remember_me
|
6
|
+
|
7
|
+
def admin?
|
8
|
+
true
|
9
|
+
end
|
10
|
+
|
11
|
+
def editor?
|
12
|
+
false
|
13
|
+
end
|
14
|
+
|
15
|
+
def author?
|
16
|
+
false
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module Kuhsaft
|
2
|
+
class ColumnBrick < Brick
|
3
|
+
include Kuhsaft::BrickList
|
4
|
+
acts_as_brick_list
|
5
|
+
|
6
|
+
#
|
7
|
+
# Users should not be able to delete this brick through the UI
|
8
|
+
#
|
9
|
+
def user_can_delete?
|
10
|
+
false
|
11
|
+
end
|
12
|
+
|
13
|
+
# No need to save
|
14
|
+
def user_can_save?
|
15
|
+
false
|
16
|
+
end
|
17
|
+
|
18
|
+
def renders_own_childs?
|
19
|
+
false
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Kuhsaft
|
2
|
+
class ImageBrick < Brick
|
3
|
+
attr_accessible :image, :caption, :href, :image_size
|
4
|
+
mount_uploader :image, Kuhsaft::ImageBrickImageUploader
|
5
|
+
|
6
|
+
validates :image, :presence => true
|
7
|
+
validates :image_size, :presence => true
|
8
|
+
|
9
|
+
before_save :resize_image_if_size_changed
|
10
|
+
|
11
|
+
def resize_image_if_size_changed
|
12
|
+
image.recreate_versions! if image_size_changed?
|
13
|
+
end
|
14
|
+
|
15
|
+
def collect_fulltext
|
16
|
+
[super, caption].join(' ')
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
module Kuhsaft
|
2
|
+
class ImageSize
|
3
|
+
attr_accessor :name, :width, :height
|
4
|
+
|
5
|
+
def label
|
6
|
+
I18n.t("activerecord.attributes.kuhsaft/image_size.sizes.#{name}")
|
7
|
+
end
|
8
|
+
|
9
|
+
class << self
|
10
|
+
def all
|
11
|
+
@all ||= []
|
12
|
+
end
|
13
|
+
|
14
|
+
def build_defaults!
|
15
|
+
@all = [gallery_size, teaser_size]
|
16
|
+
end
|
17
|
+
|
18
|
+
def find_by_name(name)
|
19
|
+
all.find { |size| size.name.to_s == name.to_s }
|
20
|
+
end
|
21
|
+
|
22
|
+
def clear!
|
23
|
+
@all = []
|
24
|
+
end
|
25
|
+
|
26
|
+
def add(name, width, height)
|
27
|
+
@all << ImageSize.new.tap do |size|
|
28
|
+
size.name = name.to_sym
|
29
|
+
size.width = width
|
30
|
+
size.height = height
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def gallery_size
|
35
|
+
@gallery_size ||= ImageSize.new.tap do |size|
|
36
|
+
size.name = :gallery
|
37
|
+
size.width = 960
|
38
|
+
size.height = 540
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
def teaser_size
|
43
|
+
@teaser_size ||= ImageSize.new.tap do |size|
|
44
|
+
size.name = :teaser
|
45
|
+
size.width = 320
|
46
|
+
size.height = 180
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
52
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Kuhsaft
|
2
|
+
class LinkBrick < Brick
|
3
|
+
attr_accessible :href, :caption, :link_style
|
4
|
+
|
5
|
+
validates :href, :caption, :presence => true
|
6
|
+
|
7
|
+
def self.styles
|
8
|
+
%w(pdf word excel button external)
|
9
|
+
end
|
10
|
+
|
11
|
+
def to_style_class
|
12
|
+
[super, link_style.presence].join(' ')
|
13
|
+
end
|
14
|
+
|
15
|
+
def collect_fulltext
|
16
|
+
[super, caption].join(' ')
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
data/app/models/kuhsaft/page.rb
CHANGED
@@ -1,131 +1,113 @@
|
|
1
1
|
class Kuhsaft::Page < ActiveRecord::Base
|
2
2
|
include Kuhsaft::Orderable
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
Kuhsaft::PublishState::PUBLISHED_AT
|
13
|
-
)
|
14
|
-
}
|
15
|
-
|
16
|
-
scope :current_locale, lambda {
|
17
|
-
includes(:localized_pages).where('localized_pages.locale = ?', Kuhsaft::Page.current_translation_locale)
|
18
|
-
}
|
19
|
-
|
20
|
-
scope :root_pages, where('parent_id IS NULL')
|
3
|
+
include Kuhsaft::Translatable
|
4
|
+
include Kuhsaft::BrickList
|
5
|
+
|
6
|
+
has_ancestry
|
7
|
+
acts_as_brick_list
|
8
|
+
|
9
|
+
translate :title, :slug, :keywords, :description, :body, :url, :fulltext
|
10
|
+
attr_accessible :title, :slug, :url, :page_type, :parent_id, :keywords, :description, :published
|
11
|
+
|
21
12
|
default_scope order('position ASC')
|
22
|
-
|
23
|
-
delegate :title, :slug, :published, :published?, :page_type, :keywords, :description,
|
24
|
-
:locale, :body, :url, :fulltext, :page_parts, :redirect?, :navigation?,
|
25
|
-
:to => :translation, :allow_nil => true
|
26
13
|
|
27
|
-
|
14
|
+
scope :published, where(:published => Kuhsaft::PublishState::PUBLISHED)
|
15
|
+
scope :search, lambda{ |term| published.where("`#{locale_attr(:fulltext)}` LIKE ?", "%#{term}%") }
|
16
|
+
scope :navigation, lambda{ |slug| where(locale_attr(:slug) => slug).where(locale_attr(:page_type) => Kuhsaft::PageType::NAVIGATION) }
|
17
|
+
|
18
|
+
before_validation :create_slug, :create_url, :collect_fulltext
|
19
|
+
|
20
|
+
validates :title, :presence => true
|
21
|
+
validates :slug, :presence => true
|
22
|
+
#validates :url, :uniqueness => true, :unless => :navigation?
|
23
|
+
|
24
|
+
class << self
|
25
|
+
def flat_tree(pages = nil)
|
26
|
+
arrange_as_array
|
27
|
+
end
|
28
|
+
|
29
|
+
def arrange_as_array(options={}, hash=nil)
|
30
|
+
hash ||= arrange(options)
|
28
31
|
|
29
|
-
|
32
|
+
arr = []
|
33
|
+
hash.each do |node, children|
|
34
|
+
arr << node
|
35
|
+
arr += arrange_as_array(options, children) unless children.empty?
|
36
|
+
end
|
30
37
|
|
31
|
-
|
32
|
-
|
33
|
-
#
|
34
|
-
attr_accessor :page_part_type
|
38
|
+
arr
|
39
|
+
end
|
35
40
|
|
36
|
-
|
37
|
-
|
41
|
+
def find_by_url(url)
|
42
|
+
send "find_by_#{locale_attr(:url)}", url
|
43
|
+
end
|
38
44
|
end
|
39
45
|
|
40
46
|
def without_self
|
41
47
|
Kuhsaft::Page.where('id != ?', self.id)
|
42
48
|
end
|
43
49
|
|
44
|
-
def
|
45
|
-
|
46
|
-
parent = self
|
47
|
-
|
48
|
-
while parent
|
49
|
-
parent_pages_list << parent unless parent.translation.blank? || parent.translation.navigation?
|
50
|
-
parent = parent.parent
|
51
|
-
end
|
52
|
-
parent_pages_list.reverse
|
50
|
+
def published?
|
51
|
+
published == Kuhsaft::PublishState::PUBLISHED
|
53
52
|
end
|
54
|
-
|
55
|
-
def
|
56
|
-
|
53
|
+
|
54
|
+
def redirect?
|
55
|
+
page_type == Kuhsaft::PageType::REDIRECT
|
57
56
|
end
|
58
|
-
|
59
|
-
def
|
60
|
-
|
61
|
-
@translation = localized_pages.where('locale = ?', lang).first if @translation.blank? || @translation.locale != lang
|
62
|
-
@translation
|
57
|
+
|
58
|
+
def navigation?
|
59
|
+
page_type == Kuhsaft::PageType::NAVIGATION
|
63
60
|
end
|
64
|
-
|
65
|
-
def
|
66
|
-
|
67
|
-
@translation.save
|
68
|
-
end
|
69
|
-
childs.each do |child|
|
70
|
-
child.translation.save if child.translation.present? && child.translation.persisted?
|
71
|
-
end
|
61
|
+
|
62
|
+
def parent_pages
|
63
|
+
ancestors
|
72
64
|
end
|
73
|
-
|
65
|
+
|
74
66
|
def link
|
75
|
-
if
|
76
|
-
|
67
|
+
if bricks.count == 0 && children.count > 0
|
68
|
+
children.first.link
|
77
69
|
else
|
78
|
-
if
|
70
|
+
if redirect?
|
79
71
|
url
|
80
72
|
else
|
81
73
|
"/#{url}"
|
82
74
|
end
|
83
75
|
end
|
84
76
|
end
|
85
|
-
|
77
|
+
|
78
|
+
def create_url
|
79
|
+
return if redirect?
|
80
|
+
|
81
|
+
complete_slug = ''
|
82
|
+
if parent.present?
|
83
|
+
complete_slug << parent.url.to_s
|
84
|
+
else
|
85
|
+
complete_slug = "#{I18n.locale}"
|
86
|
+
end
|
87
|
+
complete_slug << "/#{self.slug}" unless navigation?
|
88
|
+
self.url = complete_slug
|
89
|
+
end
|
90
|
+
|
91
|
+
def create_slug
|
92
|
+
has_slug = title.present? && slug.blank?
|
93
|
+
self.slug = title.downcase.parameterize if has_slug
|
94
|
+
end
|
95
|
+
|
96
|
+
def collect_fulltext
|
97
|
+
self.fulltext =[super, title.to_s, keywords.to_s, description.to_s].join(' ')
|
98
|
+
end
|
99
|
+
|
86
100
|
def nesting_name
|
87
|
-
num_dashes = parent_pages.size
|
101
|
+
num_dashes = parent_pages.size
|
88
102
|
num_dashes = 0 if num_dashes < 0
|
89
103
|
"#{'-' * num_dashes} #{self.title}".strip
|
90
104
|
end
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
page
|
99
|
-
else
|
100
|
-
nil
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
def translation_locales
|
105
|
-
@translation_locales
|
106
|
-
end
|
107
|
-
|
108
|
-
def translation_locales=(array)
|
109
|
-
@translation_locales = array.map(&:to_sym) if array.class == Array
|
110
|
-
end
|
111
|
-
|
112
|
-
def current_translation_locale
|
113
|
-
@translation_locale ||= translation_locales.first
|
114
|
-
end
|
115
|
-
|
116
|
-
def current_translation_locale=(locale)
|
117
|
-
@translation_locale = locale.to_sym
|
118
|
-
I18n.locale = @translation_locale if I18n.available_locales.include?(@translation_locale)
|
119
|
-
end
|
120
|
-
|
121
|
-
def flat_tree pages= nil
|
122
|
-
pages ||= Kuhsaft::Page.root_pages
|
123
|
-
list ||= []
|
124
|
-
pages.each do |page|
|
125
|
-
list << page
|
126
|
-
flat_tree(page.childs).each { |p| list << p } if page.childs.count > 0
|
127
|
-
end
|
128
|
-
list
|
129
|
-
end
|
105
|
+
|
106
|
+
def brick_list_type
|
107
|
+
'Kuhsaft::Page'
|
108
|
+
end
|
109
|
+
|
110
|
+
def to_style_class
|
111
|
+
'kuhsaft-page'
|
130
112
|
end
|
131
|
-
end
|
113
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module Kuhsaft
|
2
|
+
class Partition
|
3
|
+
attr_reader :name, :id
|
4
|
+
|
5
|
+
def initialize(name, id)
|
6
|
+
@name = name
|
7
|
+
@id = id
|
8
|
+
end
|
9
|
+
|
10
|
+
def self.style_for_index(style, idx)
|
11
|
+
[
|
12
|
+
['span4', 'span8'],
|
13
|
+
['span6', 'span6'],
|
14
|
+
['span8', 'span4']
|
15
|
+
][style][idx]
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module Kuhsaft
|
2
|
+
class PlaceholderBrick < Brick
|
3
|
+
|
4
|
+
attr_accessible :template_name
|
5
|
+
PARTIAL_PATH = '/app/views/kuhsaft/placeholder_bricks/partials/_*.haml'
|
6
|
+
|
7
|
+
def self.available_partials
|
8
|
+
@partials ||= Kuhsaft::PartialExtractor.new.partials(PARTIAL_PATH)
|
9
|
+
end
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module Kuhsaft
|
2
|
+
class TwoColumnBrick < ColumnBrick
|
3
|
+
|
4
|
+
before_create :add_columns
|
5
|
+
|
6
|
+
attr_accessible :partitioning
|
7
|
+
|
8
|
+
#
|
9
|
+
# Childs should only contain ColumnBricks, therefore we
|
10
|
+
# don't want the user to mess with it
|
11
|
+
#
|
12
|
+
def user_can_add_childs?
|
13
|
+
false
|
14
|
+
end
|
15
|
+
|
16
|
+
def user_can_delete?
|
17
|
+
true
|
18
|
+
end
|
19
|
+
|
20
|
+
def user_can_save?
|
21
|
+
true
|
22
|
+
end
|
23
|
+
|
24
|
+
#
|
25
|
+
# Use own rendering implementation to show columns side by side
|
26
|
+
#
|
27
|
+
def renders_own_childs?
|
28
|
+
true
|
29
|
+
end
|
30
|
+
|
31
|
+
def partitioning
|
32
|
+
super || 0
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.partitionings
|
36
|
+
[Partition.new('70/30', 0), Partition.new('50/50', 1), Partition.new('30/70', 2)]
|
37
|
+
end
|
38
|
+
|
39
|
+
def to_style_class
|
40
|
+
[super, 'row-fluid'].join(' ')
|
41
|
+
end
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def add_columns
|
46
|
+
bricks << Kuhsaft::ColumnBrick.new
|
47
|
+
bricks << Kuhsaft::ColumnBrick.new
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|