Permalink
Browse files

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

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

0 comments on commit 1a38487

Please sign in to comment.