Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

refactored application layout, moved flash messages to helper, footer…

… to a separate file
  • Loading branch information...
commit 1a384879b80a62f677c808ff6ba9824a1057af38 1 parent 17603a9
DM authored May 09, 2011
6  app/helpers/application_helper.rb
@@ -5,6 +5,12 @@ def feed_icon_tag(title, url)
5 5
     link_to image_tag('feed-icon.png', :size => '14x14', :alt => "Subscribe to #{title}"), url
6 6
   end
7 7
 
  8
+  def flash_messages
  9
+    flash.map do |name, message|
  10
+      content_tag :p, message, :class => [:notice, name].uniq.join(' ')
  11
+    end.join.html_safe if flash.present?
  12
+  end
  13
+
8 14
   def pagination(collection)
9 15
     if collection.total_entries > 1
10 16
       "<p class='pages'>" + I18n.t('txt.pages', :default => 'Pages') + ": <strong>" + 
16  app/views/layouts/_footer.html.erb
... ...
@@ -0,0 +1,16 @@
58  app/views/layouts/_head.html.erb
... ...
@@ -1,41 +1,21 @@
1  
-<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
2  
-<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
3  
-  <head>
4  
-    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
5  
-    <title><%= current_site && current_site.name || I18n.t('txt.beast_title', :default => 'Altered Beast') %><%= " - " + @page_title if @page_title %></title>
6  
-    <%= stylesheet_link_tag 'display' %>
7  
-    <%= stylesheet_link_tag 'captcha' %>
8  
-    <%= javascript_include_tag "prototype", "effects", "lowpro", 'rails', "application", :cache => "beast" %>
9  
-  <% unless @feed_icons.blank? %>
10  
-    <% @feed_icons.each do |feed| %>
11  
-    <%= auto_discovery_link_tag :atom, feed[:url], :title => "Subscribe to '#{feed[:title]}'" %>
  1
+<ul id="nav">
  2
+  <li><%= link_to I18n.t('txt.forums', :default => 'Forums'), root_path, :rel => 'home' %></li>
  3
+  <li><%= link_to I18n.t('txt.users', :default => 'Users'), users_path %></li>
  4
+  <li id="search">
  5
+    <%= form_tag posts_path, :method => 'get' do %>
  6
+      <%= text_field_tag :q, params[:q], :size => 15, :id => :search_box %>
12 7
     <% end %>
13  
-  <% end %>
14  
-    <link rel="search" type="application/opensearchdescription+xml" href="http://<%= request.host_with_port %>/open_search.xml" />
15  
-    <%= csrf_meta_tag %>
16  
-  </head>
17  
-  <body>
18  
-
19  
-    <div id="header">
20  
-      <ul id="nav">
21  
-        <li><%= link_to I18n.t('txt.forums', :default => 'Forums'), root_path, :rel => 'home' %></li>
22  
-        <li><%= link_to I18n.t('txt.users', :default => 'Users'), users_path %></li>
23  
-        <li id="search">
24  
-          <%= form_tag posts_path, :method => 'get' do %>
25  
-            <%= text_field_tag :q, params[:q], :size => 15, :id => :search_box %>
26  
-          <% end %>
27  
-        </li>
28  
-        <li><%= link_to_function I18n.t('txt.search', :default => 'Search'), "#", :href => root_path, :id => 'search-link' %></li>
  8
+  </li>
  9
+  <li><%= link_to_function I18n.t('txt.search', :default => 'Search'), "#", :href => root_path, :id => 'search-link' %></li>
29 10
 
30  
-        <% if current_site and logged_in? %>
31  
-        <li class="login"><%=  link_to current_user.display_name, user_path(current_user) %></li>
32  
-        <li class="logout"><%= link_to I18n.t('txt.settings', :default => 'Settings'), settings_path %></li>
33  
-        <li class="logout"><%= link_to I18n.t('txt.logout', :default => 'Logout'), logout_path(:to => CGI.escape(request.fullpath)) %></li>
34  
-        <% else %>
35  
-        <li><%= link_to I18n.t('txt.signup', :default => 'Signup'), signup_path(:to => CGI.escape(request.fullpath)) %></li>
36  
-        <li><%= link_to I18n.t('txt.login', :default => 'Login'), login_path(:to => CGI.escape(request.fullpath)) %></li>
37  
-        <% end %>
38  
-      </ul>
39  
-      <% name = (site = current_site || Site.first) && site.name %>
40  
-      <h1><%= link_to name || I18n.t('txt.beast_title', :default => 'Altered Beast'), root_path %>
41  
-    </div>
  11
+  <% if current_site and logged_in? %>
  12
+  <li class="login"><%=  link_to current_user.display_name, user_path(current_user) %></li>
  13
+  <li class="logout"><%= link_to I18n.t('txt.settings', :default => 'Settings'), settings_path %></li>
  14
+  <li class="logout"><%= link_to I18n.t('txt.logout', :default => 'Logout'), logout_path(:to => CGI.escape(request.fullpath)) %></li>
  15
+  <% else %>
  16
+  <li><%= link_to I18n.t('txt.signup', :default => 'Signup'), signup_path(:to => CGI.escape(request.fullpath)) %></li>
  17
+  <li><%= link_to I18n.t('txt.login', :default => 'Login'), login_path(:to => CGI.escape(request.fullpath)) %></li>
  18
+  <% end %>
  19
+</ul>
  20
+<% name = (site = current_site || Site.first) && site.name %>
  21
+<h1><%= link_to name || I18n.t('txt.beast_title', :default => 'Altered Beast'), root_path %>
45  app/views/layouts/application.html.erb
... ...
@@ -1,41 +1,36 @@
1  
-    <%= render :partial => "layouts/head" %>
  1
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  3
+  <head>
  4
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  5
+    <title><%= current_site && current_site.name || I18n.t('txt.beast_title', :default => 'Altered Beast') %><%= " - " + @page_title if @page_title %></title>
  6
+    <%= stylesheet_link_tag %w(display captcha) %>
  7
+    <%= javascript_include_tag %w(prototype effects lowpro rails application), :cache => "beast" %>
  8
+    <% @feed_icons.each do |feed| %>
  9
+    <%= auto_discovery_link_tag :atom, feed[:url], :title => "Subscribe to '#{feed[:title]}'" %>
  10
+    <% end if @feed_icons.present? %>
  11
+    <link rel="search" type="application/opensearchdescription+xml" href="http://<%= request.host_with_port %>/open_search.xml" />
  12
+    <%= csrf_meta_tag %>
  13
+  </head>
  14
+  <body>
  15
+    <div id="header">
  16
+      <%= render "layouts/head" %>
  17
+    </div>
2 18
 
3 19
     <div id="container">
4 20
       <div id="content">
5  
-        <% flash.each do |name, message| %>
6  
-          <%= content_tag :p, message, :class => [:notice, name].uniq.join(' ') %>
7  
-        <% end %>
  21
+        <%= flash_messages %>
8 22
         <%= yield %>
9 23
       </div>
10 24
 
11 25
       <div id="right">
12  
-        <%= yield :right %>
  26
+        <%= yield(:right) %>
13 27
       </div>
14 28
 
15 29
       <br style="clear:both;" />
16 30
     </div>
17 31
 
18 32
     <div id="footer">
19  
-      <p class="disclaim">
20  
-        <strong>
21  
-        <% if site = current_site || Site.first %>
22  
-          <%= site.tagline %>
23  
-        <% end %>
24  
-        </strong>
25  
-      </p>
26  
-        <%
27  
-        footers=[I18n.t('txt.footer_message', :default => "Two's company. Three's a forum. More's a Beast.")
28  
-        ]
29  
-        %>
30  
-        <%= footers[rand(footers.size)]%>
31  
-        </strong>
32  
-      </p>
33  
-      <p class="credit">
34  
-        <%= I18n.t('txt.powered_by', :default => 'Powered by') %> <a href="http://github.com/courtenay/altered_beast/">Altered Beast</a><br />
35  
-        &copy; 2006 - 2009 <a href="http://www.workingwithrails.com/person/5337-josh-goebel" class="subtle">Josh Goebel</a>,
36  
-        <a href="http://blog.caboo.se">Courtenay Gasking</a> <%= I18n.t 'txt.and', :default => 'and' %> 
37  
-        <a href="http://weblog.techno-weenie.net" class="subtle">Rick Olson</a>
38  
-      </p>
  33
+      <%= render "layouts/footer" %>
39 34
       <br style="clear:both;" />
40 35
     </div>
41 36
   </body>

0 notes on commit 1a38487

Please sign in to comment.
Something went wrong with that request. Please try again.