From bb83f28a5e9326be55a431d5c3f7b4ae7529a942 Mon Sep 17 00:00:00 2001 From: Tom Hughes Date: Sun, 3 Apr 2011 10:27:08 +0100 Subject: [PATCH] Factor out comment code from layouts into partials --- app/views/layouts/_flash.html.erb | 11 +++++++++++ app/views/layouts/_head.html.erb | 18 ++++++++++++++++++ app/views/layouts/site.html.erb | 29 ++--------------------------- app/views/layouts/slim.html.erb | 31 ++----------------------------- 4 files changed, 33 insertions(+), 56 deletions(-) create mode 100644 app/views/layouts/_flash.html.erb create mode 100644 app/views/layouts/_head.html.erb diff --git a/app/views/layouts/_flash.html.erb b/app/views/layouts/_flash.html.erb new file mode 100644 index 000000000..da559d55c --- /dev/null +++ b/app/views/layouts/_flash.html.erb @@ -0,0 +1,11 @@ +<% if flash[:error] %> +
<%= flash[:error] %>
+<% end %> + +<% if flash[:warning] %> +
<%= flash[:warning] %>
+<% end %> + +<% if flash[:notice] %> +
<%= flash[:notice] %>
+<% end %> diff --git a/app/views/layouts/_head.html.erb b/app/views/layouts/_head.html.erb new file mode 100644 index 000000000..517e02146 --- /dev/null +++ b/app/views/layouts/_head.html.erb @@ -0,0 +1,18 @@ + + + <%= javascript_strings %> + <%= javascript_include_tag 'prototype' %> + <%= javascript_include_tag 'site' %> + <%= javascript_include_tag 'menu' %> + + <%= stylesheet_link_tag 'common' %> + + <%= stylesheet_link_tag 'small', :media => "only screen and (max-width: 481px)" %> + <%= stylesheet_link_tag 'large', :media => "screen and (min-width: 482px)" %> + <%= stylesheet_link_tag 'print', :media => "print" %> + <%= tag("link", { :rel => "search", :type => "application/opensearchdescription+xml", :title => "OpenStreetMap Search", :href => "/opensearch/osm.xml" }) %> + <%= tag("meta", { :name => "description", :content => "OpenStreetMap is the free wiki world map." }) %> + <%= style_rules %> + <%= yield :head %> + <%= t 'layouts.project_name.title' %><%= ' | '+ h(@title) if @title %> + diff --git a/app/views/layouts/site.html.erb b/app/views/layouts/site.html.erb index b3f614257..d04a2877f 100644 --- a/app/views/layouts/site.html.erb +++ b/app/views/layouts/site.html.erb @@ -1,34 +1,9 @@ - - - <%= javascript_strings %> - <%= javascript_include_tag 'prototype' %> - <%= javascript_include_tag 'site' %> - <%= javascript_include_tag 'menu' %> - - <%= stylesheet_link_tag 'common' %> - - <%= stylesheet_link_tag 'small', :media => "only screen and (max-width: 481px)" %> - <%= stylesheet_link_tag 'large', :media => "screen and (min-width: 482px)" %> - <%= stylesheet_link_tag 'print', :media => "print" %> - <%= tag("link", { :rel => "search", :type => "application/opensearchdescription+xml", :title => "OpenStreetMap Search", :href => "/opensearch/osm.xml" }) %> - <%= tag("meta", { :name => "description", :content => "OpenStreetMap is the free wiki world map." }) %> - <%= style_rules %> - <%= yield :head %> - <%= t 'layouts.project_name.title' %><%= ' | '+ h(@title) if @title %> - + <%= render :partial => "layouts/head" %>
- <% if flash[:error] %> -
<%= flash[:error] %>
- <% end %> - <% if flash[:warning] %> -
<%= flash[:warning] %>
- <% end %> - <% if flash[:notice] %> -
<%= flash[:notice] %>
- <% end %> + <%= render :partial => "layouts/flash", :locals => { :flash => flash } %> <%= yield %>
diff --git a/app/views/layouts/slim.html.erb b/app/views/layouts/slim.html.erb index a97e526b1..862f55d87 100644 --- a/app/views/layouts/slim.html.erb +++ b/app/views/layouts/slim.html.erb @@ -1,36 +1,11 @@ - - - <%= javascript_strings %> - <%= javascript_include_tag 'prototype' %> - <%= javascript_include_tag 'site' %> - <%= javascript_include_tag 'menu' %> - - <%= stylesheet_link_tag 'common' %> - - <%= stylesheet_link_tag 'small', :media => "only screen and (max-width: 481px)" %> - <%= stylesheet_link_tag 'large', :media => "screen and (min-width: 482px)" %> - <%= stylesheet_link_tag 'print', :media => "print" %> - <%= tag("link", { :rel => "search", :type => "application/opensearchdescription+xml", :title => "OpenStreetMap Search", :href => "/opensearch/osm.xml" }) %> - <%= tag("meta", { :name => "description", :content => "OpenStreetMap is the free wiki world map." }) %> - <%= style_rules %> - <%= yield :head %> - <%= t 'layouts.project_name.title' %><%= ' | '+ h(@title) if @title %> - + <%= render :partial => "layouts/head" %>
- <% if flash[:error] %> -
<%= flash[:error] %>
- <% end %> - <% if flash[:warning] %> -
<%= flash[:warning] %>
- <% end %> - <% if flash[:notice] %> -
<%= flash[:notice] %>
- <% end %> + <%= render :partial => "layouts/flash", :locals => { :flash => flash } %> <%= yield %>
@@ -40,7 +15,5 @@
- - -- 2.43.2