diff options
| author | hukl <contact@smyck.org> | 2009-07-19 12:26:42 +0200 |
|---|---|---|
| committer | hukl <contact@smyck.org> | 2009-07-19 12:26:42 +0200 |
| commit | 03e985f546634b9bfc3053e965477d555c6663a8 (patch) | |
| tree | ef622a72a49a676bc7e89254a073b0ad53e76d90 /app | |
| parent | 144b18c5db61c53028177680295f3fc9d4e8711d (diff) | |
intermediate commit introducing main menu and calendar widget which will get refactored soon. need another feature first
Diffstat (limited to 'app')
| -rw-r--r-- | app/helpers/content_helper.rb | 14 | ||||
| -rw-r--r-- | app/helpers/link_helper.rb | 16 | ||||
| -rw-r--r-- | app/views/content/_front_page_calendar.html.erb | 11 | ||||
| -rw-r--r-- | app/views/content/_main_navigation.html.erb | 7 | ||||
| -rw-r--r-- | app/views/layouts/application.html.erb | 2 |
5 files changed, 44 insertions, 6 deletions
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 @@ | |||
| 1 | module ContentHelper | 1 | module ContentHelper |
| 2 | 2 | ||
| 3 | def main_menu | ||
| 4 | nodes = Node.find(:all, :conditions => {:parent_id => 1}) | ||
| 5 | render :partial => 'content/main_navigation', :locals => {:nodes => nodes} | ||
| 6 | end | ||
| 7 | |||
| 8 | def calendar | ||
| 9 | occurrences = Occurrence.find_in_range(Time.now, (Time.now+14.days)) | ||
| 10 | render( | ||
| 11 | :partial => 'content/front_page_calendar', | ||
| 12 | :locals => {:occurrences => occurrences} | ||
| 13 | ) | ||
| 14 | end | ||
| 15 | |||
| 16 | |||
| 3 | # Returns the published_at attribute of a page if it is not nil, otherwise | 17 | # Returns the published_at attribute of a page if it is not nil, otherwise |
| 4 | # it returns the auto-filled value of the created_at attribute | 18 | # it returns the auto-filled value of the created_at attribute |
| 5 | def date_for_page page | 19 | 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 @@ | |||
| 1 | module LinkHelper | 1 | module LinkHelper |
| 2 | 2 | ||
| 3 | def link_to_path title, path | 3 | def link_to_path title, path, html_options = {} |
| 4 | active = (params[:page_path].join("/") == path.sub(/^\//, "")) | ||
| 5 | |||
| 4 | params[:locale] ||= I18n.locale | 6 | params[:locale] ||= I18n.locale |
| 5 | 7 | ||
| 6 | link_to( | 8 | link_to( |
| 7 | title, | 9 | title, { |
| 8 | :controller => :content, | 10 | :controller => :content, |
| 9 | :action => :render_page, | 11 | :action => :render_page, |
| 10 | :locale => params[:locale], | 12 | :locale => params[:locale], |
| 11 | :page_path => path | 13 | :page_path => path.sub(/^\//, "").split("/") |
| 14 | }, | ||
| 15 | active ? {:class => 'active'} : {:class => 'inactive'} | ||
| 12 | ) | 16 | ) |
| 13 | end | 17 | end |
| 14 | 18 | ||
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 @@ | |||
| 1 | <div id="frontpage_calendar"> | ||
| 2 | <h2>Calendar</h2> | ||
| 3 | <ul class="teasertext"> | ||
| 4 | <% occurrences.each do |occurrence| %> | ||
| 5 | <li> | ||
| 6 | <div><%= l occurrence.start_time.to_date, :format => :default %></div> | ||
| 7 | <%= link_to_path occurrence.node.head.title, occurrence.node.unique_name %> | ||
| 8 | </li> | ||
| 9 | <% end %> | ||
| 10 | </ul> | ||
| 11 | </div> \ 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 @@ | |||
| 1 | <div id="main_navigation"> | ||
| 2 | <ul> | ||
| 3 | <% nodes.each do |node| %> | ||
| 4 | <li><%= link_to node.head.try(:title), node.unique_name %></li> | ||
| 5 | <% end %> | ||
| 6 | </ul> | ||
| 7 | </div> \ 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 @@ | |||
| 16 | </div> | 16 | </div> |
| 17 | <div id="left_column"> | 17 | <div id="left_column"> |
| 18 | <%= main_menu %> | 18 | <%= main_menu %> |
| 19 | |||
| 20 | <%= calendar %> | ||
| 19 | </div> | 21 | </div> |
| 20 | <div id="center_column"> | 22 | <div id="center_column"> |
| 21 | <%= yield :layout %> | 23 | <%= yield :layout %> |
