Skip to content

Commit

Permalink
Demo design and seeds
Browse files Browse the repository at this point in the history
  • Loading branch information
kirs committed Nov 1, 2011
1 parent 0ed75aa commit 93f6d60
Show file tree
Hide file tree
Showing 9 changed files with 141 additions and 18 deletions.
1 change: 0 additions & 1 deletion Gemfile
Expand Up @@ -38,4 +38,3 @@ gem 'jquery-rails'

# To use debugger
gem 'ruby-debug'

2 changes: 2 additions & 0 deletions Gemfile.lock
Expand Up @@ -74,6 +74,7 @@ GEM
treetop (~> 1.4.8)
mime-types (1.17.2)
multi_json (1.0.3)
nifty-generators (0.4.6)
orm_adapter (0.0.5)
polyglot (0.3.2)
rack (1.3.5)
Expand Down Expand Up @@ -143,6 +144,7 @@ DEPENDENCIES
inboxes!
jquery-rails
json
nifty-generators
rails (= 3.1.1)
ruby-debug
sass-rails (~> 3.1.4)
Expand Down
3 changes: 0 additions & 3 deletions app/assets/stylesheets/home.css.scss

This file was deleted.

75 changes: 75 additions & 0 deletions app/assets/stylesheets/scaffold.css
@@ -0,0 +1,75 @@
body {
background-color: #4B7399;
font-family: Verdana, Helvetica, Arial;
font-size: 14px;
}

a img {
border: none;
}

a {
color: #0000FF;
}

.clear {
clear: both;
height: 0;
overflow: hidden;
}

#container {
width: 75%;
margin: 0 auto;
background-color: #FFF;
padding: 20px 40px;
border: solid 1px black;
margin-top: 20px;
}

#flash_notice, #flash_error, #flash_alert {
padding: 5px 8px;
margin: 10px 0;
}

#flash_notice {
background-color: #CFC;
border: solid 1px #6C6;
}

#flash_error, #flash_alert {
background-color: #FCC;
border: solid 1px #C66;
}

.fieldWithErrors {
display: inline;
}

.error_messages {
width: 400px;
border: 2px solid #CF0000;
padding: 0px;
padding-bottom: 12px;
margin-bottom: 20px;
background-color: #f0f0f0;
font-size: 12px;
}

.error_messages h2 {
text-align: left;
font-weight: bold;
padding: 5px 10px;
font-size: 12px;
margin: 0;
background-color: #c00;
color: #fff;
}

.error_messages p {
margin: 8px 10px;
}

.error_messages ul {
margin: 0;
}
23 changes: 23 additions & 0 deletions app/helpers/error_messages_helper.rb
@@ -0,0 +1,23 @@
module ErrorMessagesHelper
# Render error messages for the given objects. The :message and :header_message options are allowed.
def error_messages_for(*objects)
options = objects.extract_options!
options[:header_message] ||= I18n.t(:"activerecord.errors.header", :default => "Invalid Fields")
options[:message] ||= I18n.t(:"activerecord.errors.message", :default => "Correct the following errors and try again.")
messages = objects.compact.map { |o| o.errors.full_messages }.flatten
unless messages.empty?
content_tag(:div, :class => "error_messages") do
list_items = messages.map { |msg| content_tag(:li, msg) }
content_tag(:h2, options[:header_message]) + content_tag(:p, options[:message]) + content_tag(:ul, list_items.join.html_safe)
end
end
end

module FormBuilderAdditions
def error_messages(options = {})
@template.error_messages_for(@object, options)
end
end
end

ActionView::Helpers::FormBuilder.send(:include, ErrorMessagesHelper::FormBuilderAdditions)
22 changes: 22 additions & 0 deletions app/helpers/layout_helper.rb
@@ -0,0 +1,22 @@
# These helper methods can be called in your template to set variables to be used in the layout
# This module should be included in all views globally,
# to do so you may need to add this line to your ApplicationController
# helper :layout
module LayoutHelper
def title(page_title, show_title = true)
content_for(:title) { h(page_title.to_s) }
@show_title = show_title
end

def show_title?
@show_title
end

def stylesheet(*args)
content_for(:head) { stylesheet_link_tag(*args) }
end

def javascript(*args)
content_for(:head) { javascript_include_tag(*args) }
end
end
2 changes: 1 addition & 1 deletion app/views/home/index.html.haml
@@ -1,5 +1,5 @@
%h1
Home#index
Home
%p
Find me in app/views/home/index.html.erb

Expand Down
29 changes: 16 additions & 13 deletions app/views/layouts/application.html.erb
@@ -1,16 +1,19 @@
<!DOCTYPE html>
<html>
<head>
<title>InboxesApp</title>
<%= stylesheet_link_tag "application" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tags %>
</head>
<body>
<p class="notice"><%= notice %></p>
<p class="alert"><%= alert %></p>

<%= yield %>

</body>
<head>
<title><%= content_for?(:title) ? yield(:title) : "Untitled" %></title>
<%= stylesheet_link_tag "application" %>
<%= javascript_include_tag "application" %>
<%= csrf_meta_tag %>
<%= yield(:head) %>
</head>
<body>
<div id="container">
<% flash.each do |name, msg| %>
<%= content_tag :div, msg, :id => "flash_#{name}" %>
<% end %>
<%= content_tag :h1, yield(:title) if show_title? %>
<%= yield %>
</div>
</body>
</html>
2 changes: 2 additions & 0 deletions db/seeds.rb
Expand Up @@ -5,3 +5,5 @@
#
# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }])
# Mayor.create(:name => 'Emanuel', :city => cities.first)
User.create(:name => 'Emanuel', :email => "emanuel@example.com", :password => "123456")
User.create(:name => 'Alex', :email => "alex@example.com", :password => "123456")

0 comments on commit 93f6d60

Please sign in to comment.