diff options
Diffstat (limited to 'app/helpers')
-rw-r--r-- | app/helpers/application_helper.rb | 8 | ||||
-rw-r--r-- | app/helpers/blog_helper.rb | 4 | ||||
-rw-r--r-- | app/helpers/navigation_helper.rb | 37 |
3 files changed, 31 insertions, 18 deletions
diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index b5bb657..2933bd1 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -33,7 +33,7 @@ module ApplicationHelper if name.starts_with?('#') || name.starts_with?('http') path = name else - page = StaticPage.find(name) + page = site.find_page(name) if page label ||= page.title path = page_path(page) @@ -69,7 +69,11 @@ module ApplicationHelper def page_title if @page - @page.props.title || @page.title + if @page.props + @page.props.title || @page.title + else + @page.title + end else "" end diff --git a/app/helpers/blog_helper.rb b/app/helpers/blog_helper.rb index 42e6f9c..2fc6b85 100644 --- a/app/helpers/blog_helper.rb +++ b/app/helpers/blog_helper.rb @@ -1,9 +1,9 @@ module BlogHelper def recent_blog_summaries(path) - root = StaticPage.find(path) + root = site.find_page(path) if root - pages = root.all_children.order_by(:posted_at, :direction => :desc).limit(PAGINATION_SIZE) + pages = root.all_children.order_by(:posted_at, :direction => :desc).limit(site.pagination_size) haml do pages.each do |page| haml render(:partial => 'layouts/blog/summary', :locals => {:page => page}) diff --git a/app/helpers/navigation_helper.rb b/app/helpers/navigation_helper.rb index 8582391..a43eecd 100644 --- a/app/helpers/navigation_helper.rb +++ b/app/helpers/navigation_helper.rb @@ -1,18 +1,21 @@ module NavigationHelper def has_side_column? - second_level_children_count = Menu.menu.submenu(current_page_path.first).try(:size) + if root_page? + return false + end + second_level_children_count = site.menu.submenu(current_page_path.first).try(:size) if second_level_children_count.nil? false else - second_level_children_count > 1 + second_level_children_count >= 1 end end def top_level_navigation_links haml do first = 'first' - Menu.menu.each do |item| + site.menu.each do |item| active = current_page_path.first == item.name ? 'active' : '' haml 'li.tab', :class => first do haml 'a.tab', I18n.t('pages.' + item.name), :href => menu_item_path(item), :class => active @@ -23,7 +26,7 @@ module NavigationHelper end def side_column_navigation_links - if menu = Menu.menu.submenu(current_page_path.first) + if menu = site.menu.submenu(current_page_path.first) haml do haml 'ul.nav.nav-tabs.nav-stacked' do display_menu(menu, 1) @@ -33,7 +36,7 @@ module NavigationHelper end def act_as(page) - page = StaticPage.find(page) + page = site.find_page(page) @current_page_path = page.path render_page(page) end @@ -54,7 +57,17 @@ module NavigationHelper end def path_active(page_path, menu_item) - array_starts_with(page_path, menu_item.path) ? 'active' : '' + active = '' + if menu_item.path == page_path + active = 'active' + elsif menu_item.path_prefix_of?(page_path) + if menu_item.leaf_for_path?(page_path) + active = 'active' + else + active = 'semi-active' + end + end + active end def current_page_path @@ -70,15 +83,11 @@ module NavigationHelper end # - # returns true if first part of array_long contains array_short + # the usage of 'home' as the default root page is hardcoded right now in the routes. + # this should be changed in the future. # - def array_starts_with(array_long, array_short) - array_short.length.times do |i| - if array_short[i] != array_long[i] - return false - end - end - return true + def root_page? + @page && @page.path == ['home'] end end |