From 03e985f546634b9bfc3053e965477d555c6663a8 Mon Sep 17 00:00:00 2001 From: hukl Date: Sun, 19 Jul 2009 12:26:42 +0200 Subject: intermediate commit introducing main menu and calendar widget which will get refactored soon. need another feature first --- app/helpers/content_helper.rb | 14 ++++++++++++++ app/helpers/link_helper.rb | 16 ++++++++++------ 2 files changed, 24 insertions(+), 6 deletions(-) (limited to 'app/helpers') diff --git a/app/helpers/content_helper.rb b/app/helpers/content_helper.rb index e945efba..536377bb 100644 --- a/app/helpers/content_helper.rb +++ b/app/helpers/content_helper.rb @@ -1,5 +1,19 @@ module ContentHelper + def main_menu + nodes = Node.find(:all, :conditions => {:parent_id => 1}) + render :partial => 'content/main_navigation', :locals => {:nodes => nodes} + end + + def calendar + occurrences = Occurrence.find_in_range(Time.now, (Time.now+14.days)) + render( + :partial => 'content/front_page_calendar', + :locals => {:occurrences => occurrences} + ) + end + + # Returns the published_at attribute of a page if it is not nil, otherwise # it returns the auto-filled value of the created_at attribute def date_for_page page diff --git a/app/helpers/link_helper.rb b/app/helpers/link_helper.rb index 881c5535..3be5953a 100644 --- a/app/helpers/link_helper.rb +++ b/app/helpers/link_helper.rb @@ -1,14 +1,18 @@ module LinkHelper - def link_to_path title, path + def link_to_path title, path, html_options = {} + active = (params[:page_path].join("/") == path.sub(/^\//, "")) + params[:locale] ||= I18n.locale link_to( - title, - :controller => :content, - :action => :render_page, - :locale => params[:locale], - :page_path => path + title, { + :controller => :content, + :action => :render_page, + :locale => params[:locale], + :page_path => path.sub(/^\//, "").split("/") + }, + active ? {:class => 'active'} : {:class => 'inactive'} ) end -- cgit v1.3