Little Fyr Media

It only takes a Little Fyr

to set the world ablaze

Rails 2.3 Template for Dreamhost

I’ve started playing with Rails 2.3 after a bit of a break (Ruby hasn’t been my main programming language until very recently) and I have to say that Templates ROCK!

Working from Casper Fabricus’ script to setup a new git repository on Dreamhost and John Nunemaker’s tutorial on getting your rails app running on dreamhost with passenger and combined them into one template:

#Get the applicaiton name from the current working directory
app_name = File.basename( FileUtils.pwd )

#Ask some leading questions
ssh_domain = ask( "What is the domain of you git repository (ie. example.com)?")
ssh_user = ask( "What is the shell user name to access your git repository?" )
ssh_location = "#{ssh_user}@#{ssh_domain}"
#There is probably a better way to write these two lines
project_domain = app_name
project_domain = ask( "What is the domain to which your application will be deployed?" ) if no?( "Use #{app_name} as the deployment domain for your application?") 

#Setup Capistrano
capify!

#Need an odd mixture of variable substitution.
deploy_file = "default_run_options[:pty] = true
# be sure to change these
set :user, '#{ssh_user}'
set :ssh_domain, '#{ssh_domain}'
set :application, '#{app_name}'
set :domain, '#{project_domain}'
"
deploy_file <<
%q{ # the rest should be good
set :repository,  "#{user}@#{ssh_domain}:git/#{application}.git" 
set :deploy_to, "/home/#{user}/#{domain}" 
set :deploy_via, :remote_cache
set :scm, 'git'
set :branch, 'master'
set :git_shallow_clone, 1
set :scm_verbose, true
set :use_sudo, false

server domain, :app, :web
role :db, domain, :primary => true

namespace :deploy do
  task :restart do
    run "touch #{current_path}/tmp/restart.txt" 
  end
end
}
file 'config/deploy.rb', deploy_file

# rails:rm_tmp_dirs
["./tmp/pids", "./tmp/sessions", "./tmp/sockets", "./tmp/cache"].each do |f|
  run("rmdir ./#{f}")
end

run "ssh #{ssh_location} 'mkdir -p ~/git/'#{app_name}'.git && cd ~/git/'#{app_name}'.git && git --bare init'"
git :init
git :remote => "add origin ssh://#{ssh_location}/~/git/#{app_name}.git"

initializer '.gitignore', <<-CODE
log/\\*.log
log/\\*.pid
db/\\*.db
db/\\*.sqlite3
db/schema.rb
tmp/\\*\\*/\\*
.DS_Store
doc/api
doc/app
config/database.yml
CODE

git :add => "."
git :commit => "-a -m 'Created #{app_name}'" 
git :push => "origin master"

initializer '.git/config', <<-CODE
[branch "master"]
  remote = origin
  merge = refs/heads/master
CODE

Comments

Ashish Dixit said on Saturday, March 21, 2009:

I can't see anything on the site. I am using Mozilla Firefox for Ubuntu Version 3.07.

Little Fyr said on Saturday, March 21, 2009:

OOPS. I accidentally deleted the content of the page… Its back now.

thanks for the heads up.

Brandon Martinez said on Saturday, March 21, 2009:

If only you came a day sooner! I just spent a ton of time writing one of these. Check it out:

http://files.brandon-martinez.com/basic.rb

This creates SSH keys to enable passwordless logins as well.

Louis St-Amour said on Wednesday, September 23, 2009:

This script may have been written to use Shoes, or something like it. You can swap it to use Highline by doing a sudo gem install highline, then adding require 'rubygems' and require 'highline/import'. You will also need to change the if no? method to unless agree. Ah ... I can't figure out where the "capify!" command came from, however, so I'm at a loss at how to run this.

Miata said on Sunday, September 27, 2009:

У данной статьи неформальный, информативный стиль, спасибо Вам.

txvpxn said on Tuesday, November 03, 2009:

AVlwOf <a href="http://rymaowieogzk.com/">rymaowieogzk</a>, [url=http://jeiyetigahuh.com/]jeiyetigahuh[/url], [link=http://nillzlsswrfe.com/]nillzlsswrfe[/link], http://hbajgghqxxyb.com/

Post a comment

Why does your site look funny?

There is a good chance that if you're using Internet Explorer of any generation, or FireFox 2 or pretty much any older browser, that this site is going to look very funny. Broken even.

That's because there is an experiment going on here; this site is built using HTML5 markup. In paid professional work, I have to "make it work everywhere" which typically means the lowest common denominator. But this is my place. I can afford to try out different things. I believe that the semantic value of <section>, <article> and <header> tags is huge. The calculation of the header level will be a great boon when including content in many different, and unexpected, in the content hierarchy of a page.

This site is also using the latest CSS specifications where possible. Some browsers do better with that than others. IE6 will probably always be a basket case but with its individual market share at 15% and dropping like a stone, its probably time for you to upgrade to IE7 or try IE8.

I make no apologies for not checking this site against multiple browsers. Tweaking out every browser is a lot of work that I would rather spend writing articles. However, feel free to send be bug reports; I'll get to them as I can

Who and What is Little Fyr?

I am a Web Architect and Little Fyr is where I talk about how to build applications and content sites on the Web. It is also the name I use for giving presentations at user group meetings and conferences. I have more than 8 years of experience developing web sites and applications and I have learned a lot of interesting disciplines along the way. In general, people in our line of work are either visual/UI/grapic designers, back-end system developers (Java, .Net, Ruby), or front end ui developer (HTML, CSS, JavaScript). I fall into that group of people who is knowledgeable in all these disciplines and more besides.

Like me, this site is a work in progress. I hope to publish something every two weeks. We shall see.

View Adam van den Hoven's profile on LinkedIn