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 @@
|
|
1
|
+
// Override this empty file to add custom CSS behaviour!
|
@@ -1,17 +1,15 @@
|
|
1
1
|
module Kuhsaft
|
2
2
|
module Cms
|
3
3
|
class AdminController < ApplicationController
|
4
|
-
|
5
4
|
respond_to :html
|
6
|
-
layout 'kuhsaft/
|
7
|
-
before_filter :
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
Kuhsaft::Page.current_translation_locale = params[:locale] if params[:locale].present?
|
5
|
+
layout 'kuhsaft/cms/application'
|
6
|
+
before_filter :set_content_locale
|
7
|
+
before_filter :authenticate_cms_admin!
|
8
|
+
|
9
|
+
def set_content_locale
|
10
|
+
if params[:content_locale].present?
|
11
|
+
I18n.locale = params[:content_locale]
|
12
|
+
end
|
15
13
|
end
|
16
14
|
end
|
17
15
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
module Kuhsaft
|
2
|
+
module Cms
|
3
|
+
class BricksController < AdminController
|
4
|
+
|
5
|
+
respond_to :html, :js
|
6
|
+
|
7
|
+
def create
|
8
|
+
@brick = params[:brick][:type].constantize.new(params[:brick])
|
9
|
+
@brick.save(:validate => false)
|
10
|
+
end
|
11
|
+
|
12
|
+
def update
|
13
|
+
@brick = Kuhsaft::Brick.find(params[:id])
|
14
|
+
@brick.update_attributes(params[:brick])
|
15
|
+
|
16
|
+
#
|
17
|
+
# rails will fall back to html if ajax can't be used
|
18
|
+
# this is the case with the image brick, because ajax does not
|
19
|
+
# support image uploads
|
20
|
+
#
|
21
|
+
respond_with @brick do |format|
|
22
|
+
format.js
|
23
|
+
format.html { redirect_to edit_cms_page_path(@brick.parents.first) }
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def destroy
|
28
|
+
@brick = Kuhsaft::Brick.find(params[:id])
|
29
|
+
@parent_brick = @brick.brick_list
|
30
|
+
@brick.destroy
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -2,7 +2,7 @@ module Kuhsaft
|
|
2
2
|
module Cms
|
3
3
|
class PagesController < AdminController
|
4
4
|
def index
|
5
|
-
@pages = Kuhsaft::Page.
|
5
|
+
@pages = Kuhsaft::Page.roots
|
6
6
|
respond_with @pages
|
7
7
|
end
|
8
8
|
|
@@ -13,47 +13,44 @@ module Kuhsaft
|
|
13
13
|
|
14
14
|
def new
|
15
15
|
@page = Kuhsaft::Page.new
|
16
|
-
@
|
17
|
-
@localized_page.published ||= Kuhsaft::PublishState::UNPUBLISHED
|
16
|
+
@page.published ||= Kuhsaft::PublishState::UNPUBLISHED
|
18
17
|
respond_with @page
|
19
18
|
end
|
20
19
|
|
21
20
|
def create
|
22
|
-
|
23
|
-
|
24
|
-
if
|
25
|
-
|
26
|
-
|
21
|
+
@page = Kuhsaft::Page.create params[:page]
|
22
|
+
|
23
|
+
if @page.valid?
|
24
|
+
respond_with @page, :location => kuhsaft.edit_cms_page_path(@page)
|
25
|
+
else
|
26
|
+
render 'new'
|
27
27
|
end
|
28
|
-
respond_with @page, :location => edit_cms_page_path(@page)
|
29
28
|
end
|
30
29
|
|
31
30
|
def edit
|
32
31
|
@page = Kuhsaft::Page.find(params[:id])
|
33
|
-
@
|
34
|
-
@localized_page.published ||= Kuhsaft::PublishState::UNPUBLISHED
|
32
|
+
@page.published ||= Kuhsaft::PublishState::UNPUBLISHED
|
35
33
|
respond_with @page
|
36
34
|
end
|
37
35
|
|
38
36
|
def update
|
39
37
|
@page = Kuhsaft::Page.find(params[:id])
|
40
|
-
|
41
|
-
@page.update_attributes(params[:kuhsaft_page]) if params[:kuhsaft_page].present?
|
38
|
+
@page.update_attributes(params[:page]) if params[:page].present?
|
42
39
|
# TODO: refactor 'reposition' as a page attribute, so it can be set through update_attributes
|
43
40
|
@page.reposition params[:reposition] if params[:reposition].present? || params.key?(:reposition)
|
44
|
-
|
41
|
+
|
45
42
|
if params[:add_page_part].present?
|
46
|
-
@page.
|
43
|
+
@page.bricks << params[:page][:page_part_type].constantize.new
|
47
44
|
end
|
48
|
-
|
49
|
-
respond_with @page, :location => edit_cms_page_path(@page)
|
45
|
+
|
46
|
+
respond_with @page, :location => kuhsaft.edit_cms_page_path(@page)
|
50
47
|
end
|
51
48
|
|
52
49
|
def destroy
|
53
50
|
@page = Kuhsaft::Page.find(params[:id])
|
54
51
|
@page.destroy
|
55
|
-
redirect_to cms_pages_path
|
52
|
+
redirect_to kuhsaft.cms_pages_path
|
56
53
|
end
|
57
54
|
end
|
58
55
|
end
|
59
|
-
end
|
56
|
+
end
|
@@ -1,11 +1,10 @@
|
|
1
1
|
module Kuhsaft
|
2
2
|
class PagesController < ApplicationController
|
3
|
-
|
4
3
|
respond_to :html
|
5
|
-
|
6
|
-
|
4
|
+
|
7
5
|
def show
|
8
|
-
@
|
6
|
+
@url = "#{params[:locale]}/#{params[:url]}" if params[:url].present? && params[:locale].present?
|
7
|
+
@page = Kuhsaft::Page.find_by_url(@url)
|
9
8
|
if @page.present?
|
10
9
|
respond_with @page
|
11
10
|
else
|
@@ -16,10 +15,5 @@ module Kuhsaft
|
|
16
15
|
end
|
17
16
|
end
|
18
17
|
end
|
19
|
-
|
20
|
-
private
|
21
|
-
def complete_url
|
22
|
-
params[:url] = "#{params[:locale]}/#{params[:url]}" if params[:url].present? && params[:locale].present?
|
23
|
-
end
|
24
18
|
end
|
25
|
-
end
|
19
|
+
end
|
data/app/helpers/cms_helper.rb
CHANGED
@@ -2,14 +2,14 @@ module CmsHelper
|
|
2
2
|
def admin_tab title, path
|
3
3
|
content_tag :li, link_to(title, path), :class => (:current if request.path.include?(path))
|
4
4
|
end
|
5
|
-
|
5
|
+
|
6
6
|
def available_parent_pages
|
7
7
|
pages = []
|
8
|
-
pages << { :title => t('kuhsaft.cms.pages.new.pages'), :link => cms_pages_path(:locale => :en) }
|
8
|
+
pages << { :title => t('kuhsaft.cms.pages.new.pages'), :link => kuhsaft.cms_pages_path(:locale => :en) }
|
9
9
|
if params[:parent_id].present?
|
10
10
|
parent_page = Kuhsaft::Page.find(params[:parent_id])
|
11
11
|
pages += parent_page.parent_pages
|
12
12
|
end
|
13
13
|
pages << { :title => t('kuhsaft.cms.pages.new.new_page'), :link => '#' }
|
14
14
|
end
|
15
|
-
end
|
15
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Kuhsaft
|
2
|
+
module ApplicationHelper
|
3
|
+
|
4
|
+
#
|
5
|
+
# When rendering the layout of our host application,
|
6
|
+
# the paths of the host application are not visible to the engine
|
7
|
+
# therefore we delegate all failing helper calls to 'main_app',
|
8
|
+
# which is our host application
|
9
|
+
#
|
10
|
+
def method_missing(method, *args, &block)
|
11
|
+
main_app.send(method, *args, &block)
|
12
|
+
rescue NoMethodError
|
13
|
+
super
|
14
|
+
end
|
15
|
+
|
16
|
+
def sublime_video_include_tag
|
17
|
+
token = Kuhsaft::Engine.config.sublime_video_token
|
18
|
+
javascript_include_tag "//cdn.sublimevideo.net/js/#{token}-beta.js"
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/app/helpers/pages_helper.rb
CHANGED
@@ -1,47 +1,44 @@
|
|
1
1
|
module PagesHelper
|
2
2
|
def current_page
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
yield page if block_given?
|
7
|
-
page
|
8
|
-
rescue
|
3
|
+
# page = @page
|
4
|
+
# yield @page if block_given?
|
5
|
+
# rescue
|
9
6
|
end
|
10
|
-
|
7
|
+
|
11
8
|
def current_page_path(lang=nil)
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
rescue
|
18
|
-
|
9
|
+
# if @page.present?
|
10
|
+
# '/' + Kuhsaft::Page.find(@page.id).localized_pages.where('locale = ?', lang).first.url
|
11
|
+
# else
|
12
|
+
# root_path
|
13
|
+
# end
|
14
|
+
# rescue
|
15
|
+
# root_path
|
19
16
|
end
|
20
17
|
|
21
18
|
def asset_for id
|
22
19
|
Kuhsaft::Asset.find(id)
|
23
20
|
end
|
24
|
-
|
21
|
+
|
25
22
|
def render_markdown text
|
26
23
|
RDiscount.new(text).to_html if text.present?
|
27
24
|
end
|
28
25
|
|
29
26
|
def navigation_for options
|
30
27
|
if options.is_a?(Hash) && slug = options.delete(:slug)
|
31
|
-
pages = Kuhsaft::LocalizedPage.navigation(slug).first.page.
|
28
|
+
pages = Kuhsaft::LocalizedPage.navigation(slug).first.page.children.current_locale.published rescue []
|
32
29
|
elsif (options.is_a?(Fixnum) && id = options) || id = options.delete(:id)
|
33
30
|
pages = Kuhsaft::Page.published.where('parent_id = ?', id)
|
34
31
|
elsif options.nil?
|
35
|
-
pages = Kuhsaft::Page.published.
|
32
|
+
pages = Kuhsaft::Page.published.roots
|
36
33
|
end
|
37
34
|
yield pages if block_given? && pages.length > 0
|
38
35
|
pages
|
39
36
|
end
|
40
|
-
|
37
|
+
|
41
38
|
def homepage
|
42
|
-
Kuhsaft::Page.
|
39
|
+
Kuhsaft::Page.roots.first
|
43
40
|
end
|
44
|
-
|
41
|
+
|
45
42
|
def page_for_level num
|
46
43
|
input = controller.current_url if controller.respond_to? :current_url
|
47
44
|
input ||= params[:url].presence || ''
|
@@ -61,4 +58,4 @@ module PagesHelper
|
|
61
58
|
def current_page_class page
|
62
59
|
:current if active_page_class(page) == :active
|
63
60
|
end
|
64
|
-
end
|
61
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Kuhsaft
|
2
|
+
class AccordionBrick < ColumnBrick
|
3
|
+
attr_accessible :caption
|
4
|
+
validates :caption, :presence => true
|
5
|
+
|
6
|
+
# TODO: validate only accept AccordionItem as child
|
7
|
+
|
8
|
+
def user_can_delete?
|
9
|
+
true
|
10
|
+
end
|
11
|
+
|
12
|
+
def to_style_class
|
13
|
+
[super, 'accordion'].join(' ')
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Kuhsaft
|
2
|
+
class AccordionItemBrick < ColumnBrick
|
3
|
+
attr_accessible :caption
|
4
|
+
validates :caption, :presence => true
|
5
|
+
|
6
|
+
def user_can_delete?
|
7
|
+
true
|
8
|
+
end
|
9
|
+
|
10
|
+
def to_style_class
|
11
|
+
[super, 'accordion-group'].join(' ')
|
12
|
+
end
|
13
|
+
|
14
|
+
def user_can_save?
|
15
|
+
true
|
16
|
+
end
|
17
|
+
|
18
|
+
def collect_fulltext
|
19
|
+
[super, caption].join(' ')
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,85 @@
|
|
1
|
+
module Kuhsaft
|
2
|
+
class Brick < ActiveRecord::Base
|
3
|
+
include Kuhsaft::BrickList
|
4
|
+
|
5
|
+
belongs_to :brick_list, :polymorphic => true, :touch => true
|
6
|
+
|
7
|
+
scope :localized, lambda { where(:locale => I18n.locale) }
|
8
|
+
default_scope order('position ASC').localized
|
9
|
+
|
10
|
+
attr_accessible :locale,
|
11
|
+
:position,
|
12
|
+
:type,
|
13
|
+
:brick_list_id,
|
14
|
+
:brick_list_type
|
15
|
+
|
16
|
+
before_validation :set_locale
|
17
|
+
before_validation :set_position
|
18
|
+
|
19
|
+
validates :locale,
|
20
|
+
:position,
|
21
|
+
:type,
|
22
|
+
:brick_list_id,
|
23
|
+
:brick_list_type,
|
24
|
+
:presence => true
|
25
|
+
|
26
|
+
def to_edit_partial_path
|
27
|
+
path = self.to_partial_path.split '/'
|
28
|
+
path << 'edit'
|
29
|
+
path.join '/'
|
30
|
+
end
|
31
|
+
|
32
|
+
#
|
33
|
+
# The child partial can contain your own implementation
|
34
|
+
# of how the brick renders it's child in the edit form.
|
35
|
+
# Returns the path to this partial.
|
36
|
+
#
|
37
|
+
def to_edit_childs_partial_path
|
38
|
+
path = self.to_partial_path.split '/'
|
39
|
+
path << 'childs'
|
40
|
+
path.join '/'
|
41
|
+
end
|
42
|
+
|
43
|
+
def parents
|
44
|
+
p = []
|
45
|
+
parent = brick_list.presence
|
46
|
+
|
47
|
+
while parent
|
48
|
+
p << parent
|
49
|
+
parent = parent.respond_to?(:brick_list) ? parent.brick_list : nil
|
50
|
+
end
|
51
|
+
p.reverse
|
52
|
+
end
|
53
|
+
|
54
|
+
def set_locale
|
55
|
+
self.locale = self.locale.presence || I18n.locale
|
56
|
+
end
|
57
|
+
|
58
|
+
def set_position
|
59
|
+
self.position = self.position.presence || 1
|
60
|
+
end
|
61
|
+
|
62
|
+
def brick_list_type
|
63
|
+
'Kuhsaft::Brick'
|
64
|
+
end
|
65
|
+
|
66
|
+
# Returns a css classname suitable for use in the frontend
|
67
|
+
def to_style_class
|
68
|
+
self.class.to_s.underscore.dasherize.gsub('/', '-')
|
69
|
+
end
|
70
|
+
|
71
|
+
# Returns a unique DOM id suitable for use in the frontend
|
72
|
+
def to_style_id
|
73
|
+
"#{self.class.to_s.underscore.dasherize.gsub('/', '-')}-#{id}"
|
74
|
+
end
|
75
|
+
|
76
|
+
def backend_label(options = {})
|
77
|
+
label = self.class.model_name.human
|
78
|
+
if options[:parenthesis] == true
|
79
|
+
"(#{label})"
|
80
|
+
else
|
81
|
+
label
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|