<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Typo Theme Contest: Update Your Typo Blog With Capistrano</title>
    <link>http://typogarden.com/articles/2006/04/25/update-your-typo-blog-with-capistrano</link>
    <language>en-us</language>
    <ttl>40</ttl>
    <description>Misspellings, with style</description>
    <item>
      <title>Update Your Typo Blog With Capistrano</title>
      <description>&lt;p&gt;This blog may seem a little vacant, but there are still some people hiding &lt;a href="http://www.imdb.com/title/tt0105121/"&gt;under the stairs&lt;/a&gt; who are working on a new theme directory. If you have made a theme recently, &lt;a href="mailto:boss@topfunky.com"&gt;send it in&lt;/a&gt;!&lt;/p&gt;


	&lt;p&gt;Several people have asked about how to deploy and maintain a Typo blog. It&amp;#8217;s tough since the whole point of a Ruby on Rails blog is to have something customizable, yet synchronized. You want to keep up with revisions in the Typo trunk, but also update your own pieces of it.&lt;/p&gt;


	&lt;p&gt;Initially I did this manually but have recently automated it with &lt;a href="http://manuals.rubyonrails.com/read/book/17"&gt;Capistrano&lt;/a&gt;. Some names have been changed to protect the innocent.&lt;/p&gt;


	&lt;p&gt;First, I &lt;strong&gt;checkout a copy of the Typo trunk onto my server&lt;/strong&gt; and set the DocumentRoot to &amp;#8220;mysite.com/public.&amp;#8221;&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
svn checkout svn://typosphere.org/typo/trunk mysite.com
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Next, I &lt;strong&gt;make my custom theme and import it&lt;/strong&gt; into my own Subversion repository. I then do a checkout on the server so it will be in the themes directory with all the Subversion info intact.&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
svn checkout http://topfunky.net/svn/themes/nuby mysite.com/themes/nuby
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;There it is! The rest is easy.&lt;/p&gt;


	&lt;p&gt;If I want to update the theme, I need to&lt;/p&gt;


	&lt;ul&gt;
	&lt;li&gt;&lt;code&gt;svn update&lt;/code&gt; the folder on the server&lt;/li&gt;
		&lt;li&gt;Delete cached &lt;span class="caps"&gt;CSS&lt;/span&gt; files so Typo will regenerate them from my theme&lt;/li&gt;
	&lt;/ul&gt;


	&lt;p&gt;In the pursuit of absolute automation, I do this with a Capistrano task. I save this in Subversion inside the custom theme directory. If you save it as &amp;#8220;config/deploy.rb&amp;#8221;, it will be easier to call from the command line. (NOTE: This is separate from where a Rails app&amp;#8217;s deployment file would be. It&amp;#8217;s only used to deploy the theme.)&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
# This is the entire contents of nuby/config/deploy.rb
set :typo_directory, "mysite.com" 
role :web, "mysite.com" 

desc "Svn update the theme and delete cached CSS files." 
task :theme_update, :roles =&amp;gt; :web do
  run "svn update #{typo_directory}/themes/nuby" 
  run "svn update #{typo_directory}/vendor/plugins/nuby_typo_tasks" 
  run "rm #{typo_directory}/public/stylesheets/theme/*.css" 
end
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;I deploy this with a single command:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;
topfunky$ cap -a theme_update
   loading configuration /usr/local/lib/ruby/gems/1.8/gems/capistrano-1.1.0/lib/capistrano/recipes/standard.rb
    loading configuration ./deploy.rb
  * executing task theme_update
  * executing "svn update mysite.com/themes/nuby" 
    servers: ["topfunky.com"]
Password: 
    [topfunky.com] executing command
 ** [out :: topfunky.com] U  mysite.com/themes/nuby/layouts/default.rhtml
 ** [out :: topfunky.com] U  mysite.com/themes/nuby/deploy.rb
 ** [out :: topfunky.com] Updated to revision 35.
    command finished
  * executing "svn update mysite.com/vendor/plugins/nuby_typo_tasks" 
    servers: ["topfunky.com"]
    [topfunky.com] executing command
 ** [out :: topfunky.com] At revision 30.
    command finished
  * executing "rm mysite.com/public/stylesheets/theme/*.css" 
    servers: ["topfunky.com"]
    [topfunky.com] executing command
    command finished
&lt;/code&gt;&lt;/pre&gt;

	&lt;p&gt;Capistrano automatically looks for a &amp;#8220;config/deploy.rb&amp;#8221; recipe file, so we don&amp;#8217;t have to specify that.&lt;/p&gt;


	&lt;p&gt;If you want to have all changes take effect immediately, you&amp;#8217;ll have to add a line that calls the reaper script in &amp;#8220;script/process/reaper&amp;#8221; so your FastCGI processes will be restarted.&lt;/p&gt;


	&lt;p&gt;You may also notice that I wrote a plugin with the rake tasks I want to execute for my site. I use cron to do these daily. They are available as the &lt;a href="http://topfunky.net/svn/plugins/nuby_typo_tasks/"&gt;nuby_typo_tasks&lt;/a&gt; plugin and will be updated as I add more functionality to the site.&lt;/p&gt;


	&lt;p&gt;Enjoy!&lt;/p&gt;


&lt;center&gt;&lt;a href="http://carsonworkshops.com"&gt;&lt;img src="http://topfunky.com/clients/carson/2006_nyc_sf.png" alt="Ruby on Rails Workshops in New York City and San Francisco" /&gt;&lt;/a&gt;&lt;/center&gt;</description>
      <pubDate>Tue, 25 Apr 2006 16:17:00 -0500</pubDate>
      <guid isPermaLink="false">urn:uuid:b2504a71-6dc1-42cf-b5bd-5e1338948203</guid>
      <author>Geoffrey Grosenbach</author>
      <link>http://typogarden.com/articles/2006/04/25/update-your-typo-blog-with-capistrano</link>
      <category>deployment</category>
    </item>
  </channel>
</rss>
