From a3b3536adc62041561a47852b69c482c0afdb14e Mon Sep 17 00:00:00 2001 From: Benjamin ter Kuile Date: Mon, 12 Oct 2015 18:09:33 +0200 Subject: [PATCH] add theme1 with subnavigation first setup kind of ugly layout --- .../stylesheets/theme1/_theme_structure.sass | 4 +++ .../stylesheets/theme1/application.sass | 1 + .../theme1/elements/_subnavigation.sass | 20 +++++++++++ app/controllers/application_controller.rb | 10 ++++-- app/helpers/application_helper.rb | 31 +++++++++++++++++ app/models/page.rb | 2 +- .../theme1-with-subnavigation.html.slim | 33 +++++++++++++++++++ app/views/theme1/_sub_navigation.html.slim | 6 ++++ 8 files changed, 103 insertions(+), 4 deletions(-) create mode 100644 app/assets/stylesheets/theme1/elements/_subnavigation.sass create mode 100644 app/views/layouts/theme1-with-subnavigation.html.slim create mode 100644 app/views/theme1/_sub_navigation.html.slim diff --git a/app/assets/stylesheets/theme1/_theme_structure.sass b/app/assets/stylesheets/theme1/_theme_structure.sass index 7ee46607..17636add 100644 --- a/app/assets/stylesheets/theme1/_theme_structure.sass +++ b/app/assets/stylesheets/theme1/_theme_structure.sass @@ -94,6 +94,10 @@ body margin: 0 padding: 0 margin-bottom: 12px + &.with-subnavigation + .container + .main-inner + margin: 0 a color: $green text-decoration: none diff --git a/app/assets/stylesheets/theme1/application.sass b/app/assets/stylesheets/theme1/application.sass index 354bd154..36b00905 100644 --- a/app/assets/stylesheets/theme1/application.sass +++ b/app/assets/stylesheets/theme1/application.sass @@ -8,6 +8,7 @@ $green: #7BB459 //Heineken $header-color: #AE571F $text-color: #333 $font-family-content: Georgia, serif +$active-color: #fc3 @import font-awesome @import ./mixins @import ./foundation_and_overrides diff --git a/app/assets/stylesheets/theme1/elements/_subnavigation.sass b/app/assets/stylesheets/theme1/elements/_subnavigation.sass new file mode 100644 index 00000000..509baf4c --- /dev/null +++ b/app/assets/stylesheets/theme1/elements/_subnavigation.sass @@ -0,0 +1,20 @@ +#page-subnavigation + ul + list-style: none + background-color: white + margin: 0 + li + padding-left: 14px + &.subpage + a + &:before + content: " - " + &.current + padding-left: 8px + padding-bottom: 10px + border-bottom: 2px solid #667 + margin-bottom: 10px + a + color: $active-color + &.ancestor + padding-left: 3px diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 14b39d52..f4c62390 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -36,10 +36,14 @@ private end def go_to_page_path(record, locale: I18n.locale) - str = case record - when Page then record.name - else record + case record + when Page + str = record.name + locale = record.locale + else + str = record end + locale ||= I18n.locale main_app.page_path(str, locale: locale) end helper_method :go_to_page_path diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index a1f29772..c6d704dc 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -221,4 +221,35 @@ module ApplicationHelper end end end + + # used for rendering page trees + def tree_ul(acts_as_tree_set, options = {}, &block) + # If only one option is given, a select is assumed + options = {:select => options} unless options.is_a?(Hash) + # Ensure a select option + options[:select] ||= lambda{|p| true} + options[:select] = options[:select].to_proc if options[:select].is_a?(Symbol) + block ||= lambda{|item| item.name } + acts_as_tree_set.reject!{|m| not options[:select].call(m)} + ret = '' + if acts_as_tree_set.size > 0 + if list_id = options.delete(:list_id).presence + ret = %|