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 ++++++++++------ app/views/content/_front_page_calendar.html.erb | 11 +++++++++++ app/views/content/_main_navigation.html.erb | 7 +++++++ app/views/layouts/application.html.erb | 2 ++ 5 files changed, 44 insertions(+), 6 deletions(-) create mode 100644 app/views/content/_front_page_calendar.html.erb create mode 100644 app/views/content/_main_navigation.html.erb (limited to 'app') diff --git a/app/helpers/content_helper.rb b/app/helpers/content_helper.rb index e945efb..536377b 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 881c553..3be5953 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 diff --git a/app/views/content/_front_page_calendar.html.erb b/app/views/content/_front_page_calendar.html.erb new file mode 100644 index 0000000..1a409a6 --- /dev/null +++ b/app/views/content/_front_page_calendar.html.erb @@ -0,0 +1,11 @@ +
+

Calendar

+ +
\ No newline at end of file diff --git a/app/views/content/_main_navigation.html.erb b/app/views/content/_main_navigation.html.erb new file mode 100644 index 0000000..3160fd4 --- /dev/null +++ b/app/views/content/_main_navigation.html.erb @@ -0,0 +1,7 @@ + \ No newline at end of file diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb index 93146d8..2496595 100644 --- a/app/views/layouts/application.html.erb +++ b/app/views/layouts/application.html.erb @@ -16,6 +16,8 @@
<%= main_menu %> + + <%= calendar %>
<%= yield :layout %> -- cgit v1.3