summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/helpers/content_helper.rb5
-rw-r--r--app/models/menu_item.rb26
-rw-r--r--app/views/content/_featured_articles.html.erb9
-rw-r--r--app/views/content/_search.html.erb8
-rw-r--r--app/views/layouts/application.html.erb12
-rw-r--r--db/migrate/20090907103525_add_type_column_to_menu_items.rb9
-rw-r--r--db/migrate/20090907111533_add_type_id_to_menu_items.rb9
7 files changed, 68 insertions, 10 deletions
diff --git a/app/helpers/content_helper.rb b/app/helpers/content_helper.rb
index d9ec5db..5a288ed 100644
--- a/app/helpers/content_helper.rb
+++ b/app/helpers/content_helper.rb
@@ -20,6 +20,11 @@ module ContentHelper
20 render :partial => 'content/tags' 20 render :partial => 'content/tags'
21 end 21 end
22 22
23 def featured_articles
24 @featured_articles = FeaturedArticle.all
25 render :partial => 'content/featured_articles'
26 end
27
23 def headline_image 28 def headline_image
24 image = @page.assets.images.first 29 image = @page.assets.images.first
25 if image 30 if image
diff --git a/app/models/menu_item.rb b/app/models/menu_item.rb
index e86be0e..054e7ee 100644
--- a/app/models/menu_item.rb
+++ b/app/models/menu_item.rb
@@ -1,6 +1,28 @@
1class MenuItem < ActiveRecord::Base 1class MenuItem < ActiveRecord::Base
2 2
3 translates :title 3 default_scope :conditions => {:type => "MenuItem"}
4 4
5 acts_as_list 5 translates :title
6
7 acts_as_list :scope => :type
8
9 before_save :determine_type_id
10
11
12 private
13
14 def determine_type_id
15 case self.class.name
16
17 when "MenuItem"
18 self.type_id = 1
19 when "FeaturedArticle"
20 self.type_id = 2
21 end
22 end
6end 23end
24
25
26class FeaturedArticle < MenuItem
27 default_scope :conditions => {:type => "FeaturedArticle"}
28end \ No newline at end of file
diff --git a/app/views/content/_featured_articles.html.erb b/app/views/content/_featured_articles.html.erb
new file mode 100644
index 0000000..08f7624
--- /dev/null
+++ b/app/views/content/_featured_articles.html.erb
@@ -0,0 +1,9 @@
1<div id="frontpage_calendar">
2 <h2>Featured</h2>
3 <ul>
4 <% @featured_articles.each do |item| %>
5 <li><%= link_to_path item.title, item.path %></li>
6 <% end %>
7 </ul>
8</div>
9
diff --git a/app/views/content/_search.html.erb b/app/views/content/_search.html.erb
new file mode 100644
index 0000000..c6029e0
--- /dev/null
+++ b/app/views/content/_search.html.erb
@@ -0,0 +1,8 @@
1<table>
2<% form_tag search_path, :method => 'get' do %>
3 <tr>
4 <td><%= text_field_tag :search_term %></td>
5 <td style="padding-top: 2px"><%= image_submit_tag("search_button.png") %></td>
6 </tr>
7<% end %>
8</table> \ No newline at end of file
diff --git a/app/views/layouts/application.html.erb b/app/views/layouts/application.html.erb
index 0b32673..7a5222d 100644
--- a/app/views/layouts/application.html.erb
+++ b/app/views/layouts/application.html.erb
@@ -15,18 +15,13 @@
15 <%= image_tag "header.png" %> 15 <%= image_tag "header.png" %>
16 </div> 16 </div>
17 <div id="search"> 17 <div id="search">
18 <table> 18 <%= render :partial => "content/search" %>
19 <% form_tag search_path, :method => 'get' do %>
20 <tr>
21 <td><%= text_field_tag :search_term %></td>
22 <td style="padding-top: 2px"><%= image_submit_tag("search_button.png") %></td>
23 </tr>
24 <% end %>
25 </table>
26 </div> 19 </div>
27 <div id="left_column"> 20 <div id="left_column">
28 <%= main_menu %> 21 <%= main_menu %>
29 22
23 <%= language_selector %>
24
30 <%= calendar %> 25 <%= calendar %>
31 </div> 26 </div>
32 <div id="center_column"> 27 <div id="center_column">
@@ -34,6 +29,7 @@
34 </div> 29 </div>
35 <div id="right_column"> 30 <div id="right_column">
36 <%= tags %> 31 <%= tags %>
32 <%= featured_articles %>
37 </div> 33 </div>
38 </div> 34 </div>
39 35
diff --git a/db/migrate/20090907103525_add_type_column_to_menu_items.rb b/db/migrate/20090907103525_add_type_column_to_menu_items.rb
new file mode 100644
index 0000000..dda0f9c
--- /dev/null
+++ b/db/migrate/20090907103525_add_type_column_to_menu_items.rb
@@ -0,0 +1,9 @@
1class AddTypeColumnToMenuItems < ActiveRecord::Migration
2 def self.up
3 add_column :menu_items, :type, :string
4 end
5
6 def self.down
7 remove_column :menu_items, :type
8 end
9end
diff --git a/db/migrate/20090907111533_add_type_id_to_menu_items.rb b/db/migrate/20090907111533_add_type_id_to_menu_items.rb
new file mode 100644
index 0000000..5000e92
--- /dev/null
+++ b/db/migrate/20090907111533_add_type_id_to_menu_items.rb
@@ -0,0 +1,9 @@
1class AddTypeIdToMenuItems < ActiveRecord::Migration
2 def self.up
3 add_column :menu_items, :type_id, :integer
4 end
5
6 def self.down
7 remove_column :menu_items, :type_id
8 end
9end