Skip to content

Commit

Permalink
improve helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
danielvlopes committed Sep 20, 2010
1 parent 1175521 commit ebae5e0
Show file tree
Hide file tree
Showing 5 changed files with 53 additions and 20 deletions.
24 changes: 13 additions & 11 deletions app/helpers/application_helper.rb
@@ -1,24 +1,24 @@
module ApplicationHelper
def javascript(*files)
content_for(:javascripts) { javascript_include_tag(*files) }
def error_messages_for(resource)
render 'shared/error_messages', :resource => resource
end

def stylesheet(*files)
content_for(:stylesheets) { stylesheet_link_tag(*files) }
def flash_messages
flash.collect do |key, msg|
content_tag(:p, msg, :id => key, :class => "flash-message")
end.join.html_safe
end

def favicon
"<link rel=\"shortcut icon\" href=\"/images/favicon.png\" />"
def display_when_present(collection, &block)
collection.present? ? capture(&block) : I18n.t("empty")
end

def flash_notices
flash.collect do |key, value|
content_tag('div', value, :class=>"message #{key}", :id => "flash_messages")
end
def favicon
"<link rel=\"shortcut icon\" href=\"/images/favicon.png\" />".html_safe
end

def analytics(site_id)
<<-ANALYTICS
html = <<-ANALYTICS
<script>
var _gaq = [['_setAccount', '#{site_id}'], ['_trackPageview']];
(function(d, t) {
Expand All @@ -30,6 +30,8 @@ def analytics(site_id)
})(document, 'script');
</script>
ANALYTICS

html.html_safe
end

end
8 changes: 4 additions & 4 deletions app/views/layouts/application.html.erb
Expand Up @@ -18,10 +18,10 @@
<%= link_to image_tag("ua_ie.jpg", :class => "middle"),
"http://www.microsoft.com/windows/internet-explorer", :target => "_blank" %>
ou escolha outro suportado:</strong>
<%= link_to image_tag("ua_ff.jpg", :class => "middle"), "http://www.mozilla.com/", :popup => true %>
<%= link_to image_tag("ua_sf.jpg", :class => "middle"), "http://www.apple.com/safari/", :popup => true %>
<%= link_to image_tag("ua_ch.jpg", :class => "middle"), "http://www.google.com/chrome/", :popup => true %>
<%= link_to image_tag("ua_op.jpg", :class => "middle"), "http://www.opera.com/", :popup => true %>
<%= link_to image_tag("ua_ff.jpg", :class => "middle"), "http://www.mozilla.com/", :target => "_blank" %>
<%= link_to image_tag("ua_sf.jpg", :class => "middle"), "http://www.apple.com/safari/", :target => "_blank" %>
<%= link_to image_tag("ua_ch.jpg", :class => "middle"), "http://www.google.com/chrome/", :target => "_blank" %>
<%= link_to image_tag("ua_op.jpg", :class => "middle"), "http://www.opera.com/", :target => "_blank" %>
</p>
</div>
<![endif]-->
Expand Down
14 changes: 14 additions & 0 deletions app/views/shared/_error_messages.html.erb
@@ -0,0 +1,14 @@
<% if resource.errors.any? %>
<div id="error_explanation">
<h2>
<%= resource.errors.count %> error(s) prohibited this
<%= resource.class.model_name.human %> from being saved:
</h2>

<ul>
<% resource.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
19 changes: 19 additions & 0 deletions public/stylesheets/application.css
@@ -1,3 +1,22 @@
@import "reset.css";
@import "common.css";

body {
font-size: 14px;
font-family: Lucida Grande, Lucida Sans Unicode, verdana, helvetica, arial, sans-serif;
text-align:center;
}

h1, h2, h3, h4, h5, h6 { margin: 10px 0 10px 0; }
p, pre, blockquote, label, ul, ol, dl, fieldset, address { margin:1em 0; }

h1 { font-size: 30px; }
h2 { font-size: 25px; }
h3 { font-size: 20px; }

p { margin: }

#wrapper {
padding:10px;
text-align:left;
}
8 changes: 3 additions & 5 deletions template.rb
Expand Up @@ -6,11 +6,6 @@ def base_app_url
"http://github.com/danielvlopes/base_app/raw/master"
end

# bundler
# run "rm -Rf Gemfile"
# get_file "Gemfile"
# run "bundle install"

# capistrano
get_file "Capfile"
get_file "config/deploy.rb"
Expand All @@ -35,6 +30,9 @@ def base_app_url
get_file "app/views/layouts/application.html.erb"
get_file "app/helpers/application_helper.rb"

run "mkdir -p app/views/shared"
get_file "app/views/shared/_error_messages.html.erb"

# public folder
run "rm -Rf public/index.html"
run "rm -Rf public/javascripts"
Expand Down

0 comments on commit ebae5e0

Please sign in to comment.