Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Norman Clarke
committed
Jun 20, 2008
0 parents
commit bdaa5a0
Showing
16 changed files
with
241 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
This is the base layout and utilities I'm using right now for many of | ||
my sites. You're welcome to use it as you wish. | ||
|
||
Credits, suggestions and complaints: | ||
|
||
send to: Norman Clarke <norman@randomba.org> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
class BaseSiteGenerator < Rails::Generator::Base | ||
def manifest | ||
record do |m| | ||
m.file "config/initializers/application_config.rb", "config/initializers/application_config.rb" | ||
m.file "config/application.yml", "config/application.yml" | ||
m.file "app/helpers/application_helper.rb", "app/helpers/application_helper.rb" | ||
m.directory "app/views/common" | ||
m.file "app/views/common/403.html.erb", "app/views/common/403.html.erb" | ||
m.file "app/views/common/404.html.erb", "app/views/common/404.html.erb" | ||
m.file "app/views/common/_analytics.html.erb", "app/views/common/_analytics.html.erb" | ||
m.file "app/views/common/_flash.html.erb", "app/views/common/_flash.html.erb" | ||
m.file "app/views/common/_footer.html.erb", "app/views/common/_footer.html.erb" | ||
m.file "app/views/common/_head.html.erb", "app/views/common/_head.html.erb" | ||
m.file "app/views/common/_navigation.html.erb", "app/views/common/_navigation.html.erb" | ||
m.file "public/stylesheets/main.css", "public/stylesheets/main.css" | ||
m.file "public/stylesheets/print.css", "public/stylesheets/print.css" | ||
m.file "public/stylesheets/reset.css", "public/stylesheets/reset.css" | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# Methods added to this helper will be available to all templates in the application. | ||
module ApplicationHelper | ||
|
||
def body_class | ||
"#{controller.controller_name}_#{controller.action_name}" | ||
end | ||
|
||
def content_exists(name) | ||
instance_variable_defined?("@content_for_#{name.to_s}") | ||
end | ||
|
||
def page_header(text) | ||
content_for :page_header do | ||
content_tag(:h2, text) | ||
end | ||
end | ||
|
||
def page_title(text) | ||
content_for :page_title do | ||
text | ||
end | ||
end | ||
|
||
def page_title_or_header | ||
text = @content_for_page_title || @content_for_page_header || '' | ||
strip_tags(text) + (text.include?(APP_CONFIG["site_name"]) ? '' : " - #{APP_CONFIG["site_name"]}") | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<% page_header "Permission Error" %> | ||
<% content_for :main do %> | ||
<p> | ||
The link that you just clicked, or the form you submitted, has led you to | ||
a part of the site that we didn't intend for you to see. For the | ||
technically minded, this is a "403" error. | ||
</p> | ||
<% end %> | ||
<% content_for :side do %> | ||
<%= link_to_function "Go back", "history.go(-1)", :class => "back" %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<% page_header "Error - Not Found" %> | ||
<% content_for :main do %> | ||
<p> | ||
The link that you just clicked, or the form you submitted, has led you to a | ||
url that we don't have any content for. For the technically minded, this | ||
is a "404" error. | ||
</p> | ||
<% end %> | ||
<% content_for :side do %> | ||
<%= link_to_function "Go back", "history.go(-1)", :class => "back" %> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<script type="text/javascript"> | ||
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); | ||
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); | ||
</script> | ||
<script type="text/javascript"> | ||
var pageTracker = _gat._getTracker(APP_CONFIG["google_analytics_id"]); | ||
pageTracker._initData(); | ||
pageTracker._trackPageview(); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<div id="flash"> | ||
<% unless flash.empty? -%> | ||
<%= content_tag :div, flash[:notice], :id => "flash_message", :class => "notice" if flash[:notice] -%> | ||
<%= content_tag :div, flash[:warning], :id => "flash_message", :class => "warning" if flash[:warning] -%> | ||
<%= content_tag :div, flash[:error], :id => "flash_message", :class => "error" if flash[:error] -%> | ||
<script type="text/javascript"> | ||
<%= visual_effect :highlight, "flash" %> | ||
</script> | ||
<% end -%> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
<div id="footer"> | ||
<hr/> | ||
<noscript> | ||
<p> | ||
Some stuff won't work because you don't have Javascript enabled. | ||
</p> | ||
</noscript> | ||
</div> | ||
<%= render :partial => "common/analytics" if RAILS_ENV == "production" %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<link rel="shortcut icon" href="/favicon.ico"/> | ||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> | ||
<meta name="description" content="<%= yield(:meta_description).to_s.strip -%>"/> | ||
<meta name="keywords" content="<%= yield(:meta_keywords).to_s.strip -%>"/> | ||
<title><%= page_title_or_header -%></title> | ||
<%= stylesheet_link_tag 'reset', 'main', :media => "screen", :cache => "screen" %> | ||
<%= stylesheet_link_tag 'print', :media => "print" %> | ||
<!--[if IE]> | ||
<style type="text/css"> | ||
.clearfix {display:inline-block;} | ||
* html .clearfix {height: 1%;} | ||
</style> | ||
<![endif]--> | ||
<%= javascript_include_tag :all, :cache => true %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<ul id="navigation"> | ||
<%# if !logged_in? %> | ||
<li><%= link_to_unless_current 'Home', "#" %></li> | ||
<li><%= link_to_unless_current 'Join', "#" %></li> | ||
<li><%= link_to_unless_current 'Members', "#" %></li> | ||
<li><%= link_to_unless_current 'Login', "#" %></li> | ||
<%# else -%> | ||
<!-- <li><%= link_to_unless_current 'Home', "#" %></li> | ||
<li><%= link_to_unless_current 'Profile', "#" %></li> | ||
<li><%= link_to_unless_current 'Members', "#" %></li> | ||
<li><%= link_to 'Logout', "#" %> --> | ||
<%# end -%> | ||
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" | ||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> | ||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> | ||
<head> | ||
<% if content_exists :head %> | ||
<% yield :head %> | ||
<% else -%> | ||
<%= render :partial => "common/head" %> | ||
<% end -%> | ||
</head> | ||
<% content_tag :body, :class => body_class, :onload => @onload do %> | ||
<% content_tag :div, :id => "wrapper" do %> | ||
<% content_tag :div, :id => "all_content_wrapper" do %> | ||
<%= content_tag :h1, link_to(APP_CONFIG["site_name"], root_url) %> | ||
<% content_tag :div, :id => "page_content_wrapper", :class => "clearfix" do %> | ||
<% content_tag :div, :id => "main_content_wrapper" do %> | ||
<%= yield :page_header %> | ||
<%= render :partial => "common/flash", :locals => {:flash => flash} %> | ||
<%= yield :main %> | ||
<% end %> | ||
<% content_tag :div, :id => "side_content_wrapper" do %> | ||
<%= yield :side %> | ||
<% end %> | ||
<% end -%> | ||
<% if content_exists :navigation -%> | ||
<%= yield :navigation %> | ||
<% else -%> | ||
<%= render :partial => "common/navigation" %> | ||
<% end -%> | ||
<% if content_exists :footer -%> | ||
<%= yield :footer %> | ||
<% else -%> | ||
<%= render :partial => "common/footer" %> | ||
<% end -%> | ||
<% end %> | ||
<% end %> | ||
<% end %> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
development: &non_production_settings | ||
host: 0.0.0.0:3000 | ||
site_name: "My Site" | ||
|
||
test: | ||
<<: *non_production_settings | ||
|
||
production: | ||
host: example.org | ||
site_name: "My Site" | ||
# your analytics id code here (e.g. UA-11111111-11) | ||
google_analytics_id: "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
APP_CONFIG = YAML.load(File.read(RAILS_ROOT + "/config/application.yml"))[RAILS_ENV] | ||
# This will let you more easily use helpers based on url_for in your mailers. | ||
ActionMailer::Base.default_url_options[:host] = APP_CONFIG['host'] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* base html defaults */ | ||
html, body { font-family: "arial", sans-serif; line-height: 1.2em; | ||
background-color: #f0f0f0; font-size: 95% } | ||
hr { display: none;} | ||
p { margin: 0 0 10px 0;} | ||
ul { margin: 0 0 20px 0;} | ||
h1, h2, h3, h4, h5, h6 { font-family: "lucida grande", trebuchet, sans-serif; font-weight: bold; margin: 0 0 10px 0;} | ||
h2 { font-size: 120%; margin: 0 0 20px 0; } | ||
h3 { font-size: 100%; margin: 0 0 10px; } | ||
fieldset { margin-bottom: 20px;} | ||
legend { padding-bottom: 10px; } | ||
blockquote { width: 50%; margin: auto; font-style: italic; } | ||
h1 { position: absolute; top: 20px; font-size: 100%; font-family: "lucida grande", sans-serif; | ||
padding: 0 0 0 1px;} | ||
img.avatar { padding: 2px; border: 1px #c0c0c0 double; } | ||
a img, h2 img { vertical-align: middle; } | ||
textarea { font-family: arial, sans-serif;} | ||
h1 a, h1 a:visited, #navigation a { color: blue; text-decoration: none;} | ||
h1 a, a.app, #navigation a:visited { color: blue; text-decoration: none; } | ||
input[type=text], input[type=password], textarea { font-size: 18px; | ||
border: 1px #d0d0d0 inset; } | ||
select { border: 1px #d0d0d0 inset; } | ||
|
||
/* core utilities */ | ||
.clearfix:after { content: "."; display: block; height: 0; clear: both; | ||
visibility: hidden; } | ||
|
||
/* core layout */ | ||
#flash_message { margin-bottom: 10px;} | ||
#all_content_wrapper { width: 800px; margin: auto; position: relative; padding-top: 50px; } | ||
#page_content_wrapper { border: 1px #f0f0f0 solid; background-color: #fff; padding: 10px 0 10px 0;} | ||
#main_content_wrapper { width: 577px; margin: 0 0 0 0; padding: 0 10px 10px 10px; float: left; } | ||
#side_content_wrapper { width: 170px; margin: 0; padding: 0 10px 0 10px; float: left; } | ||
ul#navigation { padding: 0 1px 0 0; } | ||
#navigation li { display: inline; margin-left: 5px; } | ||
#navigation { position: absolute; top: 20px; right: 0; height: 30px; line-height: 30px;} | ||
#footer { margin: 10px 0 0 0; color: #c0c0c0; font-style: italic; font-size: 90%; | ||
text-align: right;} | ||
#footer a { color: #c0c0c0; } | ||
div.pagination { display: block; padding: 10px 0 10px 0; margin: 10px 0 10px 0; } | ||
div.pagination { color: #707070; font-size: .9em; text-align: right; } | ||
#side_content_wrapper ul, #side_content_wrapper p { font-size: .9em;} | ||
#side_content_wrapper li { margin: 2px 0 2px 0; } | ||
|
||
.meta { color: #707070; font-size: small; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#navigation { display: none; } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
:link,:visited { text-decoration:none } | ||
ul,ol { list-style:none } | ||
h1,h2,h3,h4,h5,h6,pre,code { font-size:1em; font-weight: normal; } | ||
ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,body,html,p,blockquote,fieldset | ||
{ margin:0; padding:0; border: none; } | ||
input { margin: 0; padding: 0;} | ||
a { outline-style:none; } | ||
a img,:link img,:visited img { border:none } | ||
address { font-style:normal } | ||
br, div.clearer {float: none; clear: both;} |