Skip to content

Instantly share code, notes, and snippets.

@stereosupersonic
Created June 22, 2009 06:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save stereosupersonic/133842 to your computer and use it in GitHub Desktop.
Save stereosupersonic/133842 to your computer and use it in GitHub Desktop.
rails template
#template
#Constants
app_name = `pwd`.split('/').last.strip
rails_version = '2.3.2'
jquery_version = '1.3.2'
##### remove files #################
run "rm README"
run "rm -rf test"
run "rm public/index.html"
run "rm public/favicon.ico"
run "rm public/robots.txt"
run "rm public/images/rails.png"
run "rm -f public/javascripts/*"
run "rm -f test"
############## files commands ##################
# environment
file 'config/environment.rb', <<-FILE
RAILS_GEM_VERSION = '#{rails_version}' unless defined? RAILS_GEM_VERSION
require File.join(File.dirname(__FILE__), 'boot')
Rails::Initializer.run do |config|
# config.load_paths += %W( \#{RAILS_ROOT}/extras )
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
# config.frameworks -= [ :active_record, :active_resource, :action_mailer ]
# config.active_record.observers = :cacher, :garbage_collector, :forum_observer
# config.time_zone = 'UTC'
config.i18n.default_locale = :de
end
FILE
# application layout
file 'app/views/layouts/application.html.haml', <<-FILE
!!!
%html{ "xml:lang" => "en", :lang => "en", :xmlns => "http://www.w3.org/1999/xhtml" }
%head
%meta{ :content => "text/html; charset=utf-8", "http-equiv" => "Content-type" }
%title
= yield (:title) || '#{app_name}'
= stylesheet_link_tag 'screen', 'datePicker', :media => 'screen, projection'
= stylesheet_link_tag 'print', :media => 'print'
= stylesheet_link_tag 'application'
= javascript_include_tag 'jquery', 'jquery.form.js', 'date', 'application', 'jquery.datePicker.js', :cache => true
= yield(:head)
%body#start
#wrapper
= render :partial => "layouts/login"
= render :partial => "layouts/navi"
= render :partial => "layouts/header"
#content
%h2
= yield (:title)
- flash.each do |name, msg|
= content_tag :div, msg, :id => "flash_\#{name}"
= yield
#sidebar
%h2
Lorem ipsum dolor sit amet
%p
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.
%h3
Lorem ipsum dolor sit amet
%p
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.
%h4
Lorem ipsum dolor sit amet
%p
Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.
= render :partial => "layouts/footer"
FILE
file 'app/views/layouts/_footer.html.haml', <<-FILE
#footer
%p
hier steht der footer
FILE
file 'app/views/layouts/_navi.html.haml', <<-FILE
#navigation
%ul
%li
= link_to 'Home', root_path
%li
= link_to 'About', '/about'
%li
= link_to 'Contact', '/contact'
%li
= link_to 'Impressum', '/impressum'
%li
= link_to 'CSS-test', '/css_test'
- if admin_logged_in?
%li
= link_to 'Admin', root_path
FILE
file 'app/views/layouts/_login.html.haml', <<-FILE
<div id="login">
#login
- anonymous_only do
= link_to "Register", new_account_path
= link_to "Login", new_user_session_path
- authenticated_only do
= link_to "Logout", user_session_path, :method => :delete, :confirm => "Are you sure you want to logout?"
FILE
file 'app/views/layouts/_header.html.haml', <<-FILE
#header
%h1
Header
FILE
file 'app/controllers/application_controller.rb', <<-END
# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.
class ApplicationController < ActionController::Base
helper :all # include all helpers, all the time
# make methods available to views
helper_method :logged_in?, :admin_logged_in?, :current_user_session, :current_user
protect_from_forgery
# See ActionController::Base for details
# Uncomment this to filter the contents of submitted sensitive data parameters
# from your application log (in this case, all fields with names like "password").
filter_parameter_logging :password, :confirm_password, :password_confirmation, :creditcard
def logged_in?
!current_user_session.nil?
end
def admin_required
unless current_user && current_user.admin?
flash[:error] = "Sorry, you don't have access to that."
redirect_to root_url and return false
end
end
def admin_logged_in?
logged_in? && current_user.admin?
end
private
def current_user_session
return @current_user_session if defined?(@current_user_session)
@current_user_session = UserSession.find
end
def current_user
return @current_user if defined?(@current_user)
@current_user = current_user_session && current_user_session.user
end
def require_user
unless current_user
store_location
flash[:notice] = "You must be logged in to access this page"
redirect_to new_user_session_url
return false
end
end
def require_no_user
if current_user
store_location
flash[:notice] = "You must be logged out to access this page"
redirect_to account_url
return false
end
end
def store_location
session[:return_to] = request.request_uri
end
def redirect_back_or_default(default)
redirect_to(session[:return_to] || default)
session[:return_to] = nil
end
end
END
file 'app/helpers/application_helper.rb', <<-END
# Methods added to this helper will be available to all templates in the application.
module ApplicationHelper
def title(page_title)
content_for(:title) { page_title }
end
# Block method that creates an area of the view that
# is only rendered if the request is coming from an
# anonymous user.
def anonymous_only(&block)
if !logged_in?
block.call
end
end
# Block method that creates an area of the view that
# only renders if the request is coming from an
# authenticated user.
def authenticated_only(&block)
if logged_in?
block.call
end
end
# Block method that creates an area of the view that
# only renders if the request is coming from an
# administrative user.
def admin_only(&block)
role_only("admin", &block)
end
private
def role_only(rolename, &block)
if not current_user.blank? and current_user.has_role?(rolename)
block.call
end
end
end
END
##############################css########################################################
file 'public/stylesheets/application.css', <<-END
/* Farbschema
--------------------------------------------------------------------------------------- */
/*
Farbton (Element): #xxxxxx
Farbton (Element): #xxxxxx
Farbton (Element): #xxxxxx
Farbton (Element): #xxxxxx
Farbton (Element): #xxxxxx
*/
/* Reset
--------------------------------------------------------------------------------------- */
* {
padding: 0;
margin: 0;
border: 0;
}
/* Globals und Typo
--------------------------------------------------------------------------------------- */
html {
/* Wahlweise Grid-Hintergrund
Rasterhintergrund, der die Breite bis 100 Pixel und eine Höhe bis 950 Pixel anzeigt. Die Breite von 960 Pixel ist markiert. Der Hintergrund ist transparent, muss also nicht nur mit #fff verwendet werden. Es wird eine Schriftgröße von 75% oder 12px festgelegt.
background: #fff url(bilder/grid.png) top left no-repeat;
*/
background: #fff;
}
body {
/* Wahlweise Linienhintergrund
Linienhintergrund abgestimmt auf eine Schriftgröße von 12px.
background: transparent url(../images/line-height.gif) top left;
*/
background: #fff;
font-size: 75%;
}
html>body {
font-size: 12px;
}
a:link {
color: #0066FF;
text-decoration: none;
}
a:visited {
color: #FF9B00;
text-decoration: none;
}
a:hover {
text-decoration: underline;
}
/* Macht die gepunktete Linie um geklickte Links unsichtbar
--------------------------------------------------------------------------------------- */
a:focus {
outline: none;
}
/* Vertikaler Rhythmus basierend auf 12px Basisgröße für den Fließtext
--------------------------------------------------------------------------------------- */
p {
font: 1em/1.5em Arial, Tahoma, Verdana, sans-serif;
margin-top: 1.5em;
margin-bottom: 1.5em;
}
h1 {
font: 1.67em/0.9em Georgia, "Times New Roman", Times, serif;
margin-top: 0.9em;
margin-bottom: 0.9em;
}
h2 {
font: 1.5em/1em Georgia, "Times New Roman", Times, serif;
margin-top: 1em;
margin-bottom: 1em;
}
h3 {
font: 1.33em/1.13em Georgia, "Times New Roman", Times, serif;
margin-top: 1.13em;
margin-bottom: 1.13em;
}
h4 {
font: 1.17em/1.29em Georgia, "Times New Roman", Times, serif;
margin-top: 1.29em;
margin-bottom: 1.29em;
}
/* Bilder und verlinkte Bilder ohne Rahmen
--------------------------------------------------------------------------------------- */
img, a img {
border: 0;
}
/* Links- bzw. Rechtsausrichtung für Elemente
--------------------------------------------------------------------------------------- */
.links {
float: left;
margin: 0 0.5em 0.5em 0;
}
.rechts {
float: right;
margin: 0 0 0.5em 0.5em;
}
/* Layoutelemente
Verwenden Sie overflow: hidden; um nötige Foats aufzulösen.
--------------------------------------------------------------------------------------- */
#wrapper {
margin: 0 auto;
width: 80em;
max-width: 100%;
}
#header {
clear: both;
background: #FEBE7E;
}
#navi {
clear: both;
}
#content {
clear: both;
float: left;
display: inline;
width: 49.2em;
max-width: 70%;
background: #C1EAFF;
}
#sidebar {
float: right;
display: inline;
width: 29.2em;
max-width: 28%;
background: #DDFFA6;
}
#footer {
clear: both;
background: #FF8ACD;
}
.clear {
clear: both;
}
/* Rails spezifisches
--------------------------------------------------------------------------------------- */
.flash {
margin-bottom: 10px;
text-align: center;
font-size: 18pt;
padding: 10px;
color: #000;
background: #7eb97d;
}
.flash.warning {
background: #FF9933;
}
#flash_error {
background: #D8585C;
}
#flash_notice {
background: #7eb97d;
}
#flash_error {
background: #d77b47;
}
div.fieldWithErrors {
border: #d77b47 solid 2px;
display: inline;
}
#login {
float: right;
font-size: 20px;
}
/* JQuery */
.jLoadingOverlayContent {
font-weight: bold;
color: #ddd;
}
/* @end */
END
# authlogic setup
generate("session user_session")
generate("rspec_controller user_sessions") #TDD on rails
generate("rspec_controller users") #TDD on rails
file 'app/controllers/user_sessions_controller.rb', <<-END
class UserSessionsController < ApplicationController
before_filter :require_no_user, :only => [:new, :create]
before_filter :require_user, :only => :destroy
def new
@page_title = "Login"
@user_session = UserSession.new
end
def create
@user_session = UserSession.new(params[:user_session])
if @user_session.save
flash[:notice] = "Login successful!"
redirect_back_or_default root_url
else
render :action => :new
end
end
def destroy
current_user_session.destroy
flash[:notice] = "Logout successful!"
redirect_back_or_default root_url
end
end
END
file 'app/controllers/users_controller.rb', <<-END
class UsersController < ApplicationController
before_filter :require_no_user, :only => [:new, :create]
before_filter :require_user, :only => [:show, :edit, :update]
before_filter :admin_required, :only => [:index, :destroy]
def index
@users = User.all
@page_title = "All Users"
end
def new
@user = User.new
@page_title = "Create Account"
end
def create
@user = User.new(params[:user])
if @user.save
flash[:notice] = "Account registered!"
redirect_back_or_default account_url
else
render :action => :new
end
end
def show
find_user
@page_title = "\#{@user.login} details"
end
def edit
find_user
@page_title = "Edit \#{@user.login}"
end
def update
find_user
if @user.update_attributes(params[:user])
flash[:notice] = "Account updated!"
redirect_to account_url
else
render :action => :edit
end
end
def destroy
find_user
@user.destroy
flash[:notice] = 'User was deleted.'
redirect_to(users_url)
end
private
def find_user
if @current_user.admin? && params[:id]
@user = User.find(params[:id])
else
@user = @current_user
end
end
end
END
file 'app/models/user.rb', <<-END
class User < ActiveRecord::Base
acts_as_authentic
serialize :roles, Array
before_validation_on_create :make_default_roles
attr_accessible :login, :password, :password_confirmation, :email, :first_name, :last_name
def admin?
has_role?("admin")
end
def has_role?(role)
roles.include?(role)
end
def add_role(role)
self.roles << role
end
def remove_role(role)
self.roles.delete(role)
end
def clear_roles
self.roles = []
end
private
def make_default_roles
clear_roles if roles.nil?
end
end
END
file 'app/models/user_session.rb', <<-END
class UserSession < Authlogic::Session::Base
end
END
file 'app/views/user_sessions/new.html.haml', <<-END
%h1
Login
- form_for @user_session, :url => user_session_path, :live_validations => true do |f|
= f.error_messages
= f.label :login
%br
= f.text_field :login
%br
%br
= f.label :password
%br
= f.password_field :password
%br
%br
= f.check_box :remember_me
= f.label :remember_me
%br
%br
= f.submit "Login"
END
file 'app/views/users/index.html.haml', <<-END
%h1
Listing users
%table
%tr
%th
Login
%th{ :colspan => "3" }
- @users.each do |user|
%tr
%td
= h user.login
%td
= link_to 'Show', user
%td
= link_to 'Edit', edit_user_path(user)
%td
= link_to 'Destroy', user, :confirm => 'Are you sure?', :method => :delete
%br
= link_to 'New user', new_user_path
END
file 'app/views/users/_form.html.haml', <<-END
= form.label :first_name
%br
= form.text_field :first_name
%br
%br
= form.label :last_name
%br
= form.text_field :last_name
%br
%br
= form.label :login
%br
= form.text_field :login
%br
%br
= form.label :password, form.object.new_record? ? nil : "Change password"
%br
= form.password_field :password
%br
%br
= form.label :password_confirmation
%br
= form.password_field :password_confirmation
%br
%br
= form.label :email
%br
= form.text_field :email
%br
%br
END
file 'app/views/users/edit.html.haml', <<-END
%h1
Edit My Account
- form_for @user, :url => account_path, :live_validations => true do |f|
= f.error_messages
= render :partial => "form", :object => f
= f.submit "Update"
%br
= link_to "My Profile", account_path
END
file 'app/views/users/new.html.haml', <<-END
%h1
Register
- form_for @user, :url => account_path, :live_validations => true do |f|
= f.error_messages
= render :partial => "form", :object => f
= f.submit "Register"
END
file 'app/views/users/show.html.haml', <<-END
%p
%b
Login:
= h @user.login
%p
%b
Email:
= h @user.email
%p
%b
Login count:
= h @user.login_count
%p
%b
Last request at:
= h @user.last_request_at
%p
%b
Last login at:
= h @user.last_login_at
%p
%b
Current login at:
= h @user.current_login_at
%p
%b
Last login ip:
= h @user.last_login_ip
%p
%b
Current login ip:
= h @user.current_login_ip
= link_to 'Edit', edit_account_path
END
file 'db/migrate/01_create_users.rb', <<-END
class CreateUsers < ActiveRecord::Migration
def self.up
create_table :users do |t|
t.timestamps
t.string :login, :null => false
t.string :crypted_password, :null => false
t.string :password_salt, :null => false
t.string :persistence_token, :null => false
t.integer :login_count, :default => 0, :null => false
t.datetime :last_request_at
t.datetime :last_login_at
t.datetime :current_login_at
t.string :last_login_ip
t.string :current_login_ip
t.string :roles
t.string :first_name
t.string :last_name
t.string :perishable_token, :default => "", :null => false
t.string :email, :default => "", :null => false
end
add_index :users, :login
add_index :users, :persistence_token
add_index :users, :last_request_at
add_index :users, :perishable_token
add_index :users, :email
end
def self.down
drop_table :users
end
end
END
file 'db/migrate/02_create_sessions.rb', <<-END
class CreateSessions < ActiveRecord::Migration
def self.up
create_table :sessions do |t|
t.string :session_id, :null => false
t.text :data
t.timestamps
end
add_index :sessions, :session_id
add_index :sessions, :updated_at
end
def self.down
drop_table :sessions
end
end
END
############## jquery #################
run "curl -L http://jqueryjs.googlecode.com/files/jquery-#{jquery_version}.min.js > public/javascripts/jquery.js"
run "curl -L http://jqueryjs.googlecode.com/svn/trunk/plugins/form/jquery.form.js > public/javascripts/jquery.form.js"
# Copy database.yml for distribution use
run "rm config/database.yml"
file "config/database.yml", <<-END
development:
adapter: mysql
database: #{app_name}_development
encoding: utf8
test:
adapter: mysql
database: #{app_name}_test
encoding: utf8
production:
username: rails
password:
adapter: mysql
database: #{app_name}_production
pool: 5
encoding: utf8
END
run "cp config/database.yml config/database.yml.example"
############## plugin commands #################
# RSpec is the original Behaviour Driven Development framework for Ruby.
plugin 'rspec', :git => "git://github.com/dchelimsky/rspec.git"
# RSpec's official Ruby on Rails plugin
plugin 'rspec-rails', :git => "git://github.com/dchelimsky/rspec-rails.git"
# BDD that talks to domain experts first and code 2nd
plugin 'cucumber', :git => "git://github.com/aslakhellesoy/cucumber.git"
# Rails RESTful controller abstraction plugin.
plugin 'resource_controller',:git => "git://github.com/giraffesoft/resource_controller.git"
# Attachments with no extra database tables, only one library to install for image processing
plugin 'paperclip',:git => "git://github.com/thoughtbot/paperclip.git"
plugin 'limerick_rake', :git => "git://github.com/thoughtbot/limerick_rake.git"
############## gems #################
#will_paginat
gem 'mislav-will_paginate', :version => '~> 2.2.3', :lib => 'will_paginate', :source => 'http://gems.github.com'
gem "authlogic", :version => ">= 2.0.11"
gem "haml"
gem "haml"
gem "rcov", :source => "git://github.com/relevance/rcov.git"
rake 'gems:install', :sudo => true
############## generate commands #################
generate("rspec")
generate("rspec-rails")
run "rm -rf stories"
generate("cucumber")
#run "rm features/step_definitions/webrat_steps.rb"
#generate("culerity")
# routes
file 'config/routes.rb', <<-FILE
ActionController::Routing::Routes.draw do |map|
map.resource :account, :controller => "users"
map.resources :users
map.resource :user_session
map.login 'login', :controller => "user_sessions", :action => "new"
map.login 'logout', :controller => "user_sessions", :action => "destroy"
map.register 'register', :controller => "users", :action => "new"
map.root :controller => "pages", :action => "home"
map.site ':name', :controller => 'pages', :action => 'show'
end
FILE
# static pages
file 'app/controllers/pages_controller.rb', <<-END
class PagesController < ApplicationController
verify :params => :name, :only => :show, :redirect_to => :root_url
before_filter :ensure_valid, :only => :show
def show
render :template => "pages/\#{current_page}"
end
protected
def current_page
params[:name].to_s.downcase
end
def ensure_valid
unless %w(home about impressum css_test contact).include? current_page
render :nothing => true, :status => 404 and return false
end
end
end
END
file 'app/views/pages/home.html.haml', <<-END
%h1
Welcome to #{app_name}
%p
Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
END
file 'app/views/pages/about.html.haml', <<-END
%h2
About me
%p
and so on
END
file 'app/views/pages/contact.html.haml', <<-END
%h2
contact me
%p
and so on
END
file 'app/views/pages/impressum.html.haml', <<-END
%h2
impressum
%p
and so on
END
file 'app/views/pages/css_test.html.haml', <<-END
%h1
CSS Basic Elements
%p
The purpose of this HTML is to help determine what default settings are with CSS and to make sure that all possible HTML Elements are included in this HTML so as to not miss any possible Elements when designing a site.
%hr
%h1#headings
Headings
%h1
Heading 1
%h2
Heading 2
%h3
Heading 3
%h4
Heading 4
%h5
Heading 5
%h6
Heading 6
%small
%a{ :href => "#wrapper" }
[top]
%hr
%h1#paragraph
Paragraph
%p
Lorem ipsum dolor sit amet,
%a{ :href => "#", :title => "test link" }
test link
adipiscing elit. Nullam dignissim convallis est. Quisque aliquam. Donec faucibus. Nunc iaculis suscipit dui. Nam sit amet sem. Aliquam libero nisi, imperdiet at, tincidunt nec, gravida vehicula, nisl. Praesent mattis, massa quis luctus fermentum, turpis mi volutpat justo, eu volutpat enim diam eget metus. Maecenas ornare tortor. Donec sed tellus eget sapien fringilla nonummy. Mauris a ante. Suspendisse quam sem, consequat at, commodo vitae, feugiat in, nunc. Morbi imperdiet augue quis tellus.
%p
Lorem ipsum dolor sit amet,
%em
emphasis
consectetuer adipiscing elit. Nullam dignissim convallis est. Quisque aliquam. Donec faucibus. Nunc iaculis suscipit dui. Nam sit amet sem. Aliquam libero nisi, imperdiet at, tincidunt nec, gravida vehicula, nisl. Praesent mattis, massa quis luctus fermentum, turpis mi volutpat justo, eu volutpat enim diam eget metus. Maecenas ornare tortor. Donec sed tellus eget sapien fringilla nonummy. Mauris a ante. Suspendisse quam sem, consequat at, commodo vitae, feugiat in, nunc. Morbi imperdiet augue quis tellus.
%small
%a{ :href => "#wrapper" }
[top]
%hr
%h1#list_types
List Types
%h3
Definition List
%dl
%dt
Definition List Title
%dd
This is a definition list division.
%h3
Ordered List
%ol
%li
List Item 1
%li
List Item 2
%li
List Item 3
%h3
Unordered List
%ul
%li
List Item 1
%li
List Item 2
%li
List Item 3
%small
%a{ :href => "#wrapper" }
[top]
%hr
%h1#form_elements
Fieldsets, Legends, and Form Elements
%fieldset
%legend
Legend
%p
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nullam dignissim convallis est. Quisque aliquam. Donec faucibus. Nunc iaculis suscipit dui. Nam sit amet sem. Aliquam libero nisi, imperdiet at, tincidunt nec, gravida vehicula, nisl. Praesent mattis, massa quis luctus fermentum, turpis mi volutpat justo, eu volutpat enim diam eget metus.
%form
%h2
Form Element
%p
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nullam dignissim convallis est. Quisque aliquam. Donec faucibus. Nunc iaculis suscipit dui.
%p
%label{ :for => "text_field" }
Text Field:
%br
%input#text_field{ :type => "text" }
%p
%label{ :for => "text_area" }
Text Area:
%br
%textarea#text_area
%p
%label{ :for => "select_element" }
Select Element:
%br
%select{ :name => "select_element" }
%optgroup{ :label => "Option Group 1" }
%option{ :value => "1" }
Option 1
%option{ :value => "2" }
Option 2
%option{ :value => "3" }
Option 3
%optgroup{ :label => "Option Group 2" }
%option{ :value => "1" }
Option 1
%option{ :value => "2" }
Option 2
%option{ :value => "3" }
Option 3
%p
%label{ :for => "radio_buttons" }
Radio Buttons:
%br
%input.radio{ :name => "radio_button", :type => "radio", :value => "radio_1" }
Radio 1
%br
%input.radio{ :name => "radio_button", :type => "radio", :value => "radio_2" }
Radio 2
%br
%input.radio{ :name => "radio_button", :type => "radio", :value => "radio_3" }
Radio 3
%br
%p
%label{ :for => "checkboxes" }
Checkboxes:
%br
%input.checkbox{ :name => "checkboxes", :type => "checkbox", :value => "check_1" }
Radio 1
%br
%input.checkbox{ :name => "checkboxes", :type => "checkbox", :value => "check_2" }
Radio 2
%br
%input.checkbox{ :name => "checkboxes", :type => "checkbox", :value => "check_3" }
Radio 3
%br
%p
%label{ :for => "password" }
Password:
%br
%input.password{ :name => "password", :type => "password" }
%p
%label{ :for => "file" }
File Input:
%br
%input.file{ :name => "file", :type => "file" }
%p
%input.button{ :type => "reset", :value => "Clear" }
%input.button{ :type => "submit", :value => "Submit" }
%small
%a{ :href => "#wrapper" }
[top]
%hr
%h1#tables
Tables
%table{ :cellspacing => "0", :cellpadding => "0" }
%tr
%th
Table Header 1
%th
Table Header 2
%th
Table Header 3
%tr
%td
Division 1
%td
Division 2
%td
Division 3
%tr.even
%td
Division 1
%td
Division 2
%td
Division 3
%tr
%td
Division 1
%td
Division 2
%td
Division 3
%small
%a{ :href => "#wrapper" }
[top]
%hr
%h1#misc
Misc Stuff - abbr, acronym, pre, code, sub, sup, etc.
%p
Lorem
%sup
superscript
dolor
%sub
subscript
amet, consectetuer adipiscing elit. Nullam dignissim convallis est. Quisque aliquam.
%cite
cite
Nunc iaculis suscipit dui. Nam sit amet sem. Aliquam libero nisi, imperdiet at, tincidunt nec, gravida vehicula, nisl. Praesent mattis, massa quis luctus fermentum, turpis mi volutpat justo, eu volutpat enim diam eget metus. Maecenas ornare tortor. Donec sed tellus eget sapien fringilla nonummy.
%acronym{ :title => "National Basketball Association" }
NBA
Mauris a ante. Suspendisse quam sem, consequat at, commodo vitae, feugiat in, nunc. Morbi imperdiet augue quis tellus.
%abbr{ :title => "Avenue" }
AVE
%pre
%p
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Nullam dignissim convallis est. Quisque aliquam. Donec faucibus. Nunc iaculis suscipit dui. Nam sit amet sem. Aliquam libero nisi, imperdiet at, tincidunt nec, gravida vehicula, nisl. Praesent mattis, massa quis luctus fermentum, turpis mi volutpat justo, eu volutpat enim diam eget metus. Maecenas ornare tortor. Donec sed tellus eget sapien fringilla nonummy.
%acronym{ :title => "National Basketball Association" }
NBA
Mauris a ante. Suspendisse quam sem, consequat at, commodo vitae, feugiat in, nunc. Morbi imperdiet augue quis tellus.
%abbr{ :title => "Avenue" }
AVE
%blockquote
"This stylesheet is going to help so freaking much."
%br
%small
%a{ :href => "#wrapper" }
[top]
END
# rakefile for metric_fu
file 'Rakefile', <<-END
# Add your own tasks in files placed in lib/tasks ending in .rake,
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
require(File.join(File.dirname(__FILE__), 'config', 'boot'))
require 'rake'
require 'rake/testtask'
require 'rake/rdoctask'
require 'tasks/rails'
require 'metric_fu'
MetricFu::Configuration.run do |config|
# not doing saikuro at the moment
config.metrics = [:churn, :stats, :flog, :flay, :reek, :roodi, :rcov]
config.rcov[:rcov_opts] << "-Itest"
# config.flay = { :dirs_to_flay => ['app', 'lib'] }
# config.flog = { :dirs_to_flog => ['app', 'lib'] }
# config.reek = { :dirs_to_reek => ['app', 'lib'] }
# config.roodi = { :dirs_to_roodi => ['app', 'lib'] }
# config.saikuro = { :output_directory => 'scratch_directory/saikuro',
# :input_directory => ['app', 'lib'],
# :cyclo => "",
# :filter_cyclo => "0",
# :warn_cyclo => "5",
# :error_cyclo => "7",
# :formater => "text"} #this needs to be set to "text"
# config.churn = { :start_date => "1 year ago", :minimum_churn_count => 10}
# config.rcov = { :test_files => ['test/**/*_test.rb',
# 'spec/**/*_spec.rb'],
# :rcov_opts => ["--sort coverage",
# "--no-html",
# "--text-coverage",
# "--no-color",
# "--profile",
# "--rails",
# "--exclude /gems/,/Library/,spec"]}
end
END
####cucumber
#file 'features/support/env.rb', <<-FILE
#ENV["RAILS_ENV"] = "test"
#require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
#require 'cucumber/rails/world'
#require 'cucumber/formatters/unicode'
#
#require 'culerity'
#
#FILE
#
# deployment
capify!
file 'config/deploy.rb', <<-END
#############################################################
# Application
#############################################################
set :application, "#{app_name}"
set :deploy_to, "/home/xxx/xxx.com/apps/\#{application}"
#############################################################
# Subversion
#############################################################
#set :repository, "http://svn.xxx.com/projects/xxxx/trunk"
#set :svn_username, "hh"
#set :svn_password, "hh"
set :checkout, "export"
set :deploy_via, "export"
#############################################################
# Settings
#############################################################
default_run_options[:pty] = true
set :use_sudo, false # Verwende kein sudo
#############################################################
# Servers
#############################################################
role :app, "www.xyz.com"
role :web, "www.xyz.com"
role :db, "www.xyz.com", :primary => true
set :user, "deimel"
#############################################################
# Passenger
#############################################################
namespace :passenger do
desc "Restart Application"
task :restart do
run "touch \#{current_path}/tmp/restart.txt"
end
end
after :deploy, "passenger:restart"
after 'deploy:symlink', 'deploy:cleanup'
END
file 'config/deploy/production.rb', <<-END
set :host, "111.111.111.111"
set :branch, "master"
END
file 'config/deploy/staging.rb', <<-END
set :host, "111.111.111.111"
set :branch, "staging"
END
# databases
rake('db:create:all')
rake('db:migrate')
#Success!
puts "SUCCESS!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment