<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Ben Sternthal &#38; Friends &#187; drupal</title>
	<atom:link href="http://blog.sternthal.org/category/drupal/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.sternthal.org</link>
	<description>I am a freelance American Web Engineer and Information Architect living and working in Portland, Oregon.</description>
	<lastBuildDate>Mon, 14 Jun 2010 05:17:21 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Amazing Video On Failure of Ma.gnolia</title>
		<link>http://blog.sternthal.org/2009/02/17/amazing-video-on-failure-of-magnolia/</link>
		<comments>http://blog.sternthal.org/2009/02/17/amazing-video-on-failure-of-magnolia/#comments</comments>
		<pubDate>Tue, 17 Feb 2009 10:27:28 +0000</pubDate>
		<dc:creator>ben</dc:creator>
				<category><![CDATA[drupal]]></category>
		<category><![CDATA[startup]]></category>

		<guid isPermaLink="false">http://blog.sternthal.org/?p=433</guid>
		<description><![CDATA[Really great video on the technical problems that caused ma.gnolia to go down, and continue to be down. I learned some great lessons from working at John Wiley, i think we actually had to restore from tape a few times.
tellmetwin.com is backed up automatically to two different countries and yes the backups are tested. 



http://factoryjoe.com/blog/2009/02/16/what-really-happened-at-magnolia-and-lessons-learned/
]]></description>
			<content:encoded><![CDATA[<p>Really great video on the technical problems that caused ma.gnolia to go down, and continue to be down. I learned some great lessons from working at John Wiley, i think we actually had to restore from tape a few times.</p>
<p><a href="http://tellmetwin.com">tellmetwin.com</a> is backed up automatically to two different countries and yes the backups are tested. </p>
<div style="background-color:white">
<a href="http://blog.sternthal.org/wp-content/uploads/2009/02/logo_3002.gif" rel="lightbox[433]"><img src="http://blog.sternthal.org/wp-content/uploads/2009/02/logo_3002.gif" alt="logo_3002" title="logo_3002" width="300" height="145" class="aligncenter size-full wp-image-441" /></a>
</div>
<p><a href="http://factoryjoe.com/blog/2009/02/16/what-really-happened-at-magnolia-and-lessons-learned/">http://factoryjoe.com/blog/2009/02/16/what-really-happened-at-magnolia-and-lessons-learned/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sternthal.org/2009/02/17/amazing-video-on-failure-of-magnolia/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Halfway through the big rewrite</title>
		<link>http://blog.sternthal.org/2009/02/16/halfway-through-the-big-rewrite/</link>
		<comments>http://blog.sternthal.org/2009/02/16/halfway-through-the-big-rewrite/#comments</comments>
		<pubDate>Mon, 16 Feb 2009 14:21:33 +0000</pubDate>
		<dc:creator>ben</dc:creator>
				<category><![CDATA[drupal]]></category>

		<guid isPermaLink="false">http://blog.sternthal.org/?p=425</guid>
		<description><![CDATA[So far I&#8217;m loving developing in a normal php framework. The constant swearing associated with drupal has died down, and im left with just the swearing associated with IE6. Woo!
]]></description>
			<content:encoded><![CDATA[<p>So far I&#8217;m loving developing in a normal php framework. The constant swearing associated with drupal has died down, and im left with just the swearing associated with IE6. Woo!</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sternthal.org/2009/02/16/halfway-through-the-big-rewrite/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Helvítis Fokking Fokk</title>
		<link>http://blog.sternthal.org/2009/01/16/helvitis-fokking-fokk/</link>
		<comments>http://blog.sternthal.org/2009/01/16/helvitis-fokking-fokk/#comments</comments>
		<pubDate>Fri, 16 Jan 2009 13:35:21 +0000</pubDate>
		<dc:creator>ben</dc:creator>
				<category><![CDATA[drupal]]></category>
		<category><![CDATA[iceland]]></category>

		<guid isPermaLink="false">http://blog.sternthal.org/?p=373</guid>
		<description><![CDATA[I learned a new kitchy phrase today. Without speaking Icelandic I think you can figure out what it means and why its important from the video.
http://www.youtube.com/watch?v=Ik66THWLlM4

]]></description>
			<content:encoded><![CDATA[<p>I learned a new kitchy phrase today. Without speaking Icelandic I think you can figure out what it means and why its important from the video.</p>
<p><a href="http://www.youtube.com/watch?v=Ik66THWLlM4">http://www.youtube.com/watch?v=Ik66THWLlM4</a></p>
<p><a href='http://www.youtube.com/watch?v=Ik66THWLlM4' ><img src="http://blog.sternthal.org/wp-content/uploads/2009/01/youtube1.png" alt="youtube1" title="youtube1" width="450" height="358" class="alignnone size-full wp-image-376" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sternthal.org/2009/01/16/helvitis-fokking-fokk/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>CSS Cache Busting And Drupal</title>
		<link>http://blog.sternthal.org/2008/12/23/css-cache-busting-and-drupal/</link>
		<comments>http://blog.sternthal.org/2008/12/23/css-cache-busting-and-drupal/#comments</comments>
		<pubDate>Tue, 23 Dec 2008 09:37:48 +0000</pubDate>
		<dc:creator>ben</dc:creator>
				<category><![CDATA[drupal]]></category>

		<guid isPermaLink="false">http://blog.sternthal.org/?p=360</guid>
		<description><![CDATA[I realized in my last post i alluded to a strategy for build based CSS cache busting with Drupal but did not explain it, so here goes.
With Drupal or any other similar system you are going to wind up with a lot of CSS, and for the most part you want this to be cached [...]]]></description>
			<content:encoded><![CDATA[<p>I realized in my last post i alluded to a strategy for build based CSS cache busting with Drupal but did not explain it, so here goes.</p>
<p>With Drupal or any other similar system you are going to wind up with a lot of CSS, and for the most part you want this to be cached by the user to speed up load times. However when you deploy new code, you definitely want the CSS to be refreshed.</p>
<p>To address this issue we take advantage of a browsers default behavior of not caching files with different names by adding a query to the end of the css call.</p>
<p>Our basic approach is to have the build number or revision somewhere and insert that into our CSS calls.<br />
We first define a variable in index.php at the root of the project with a token that ANT will replace with a build number.</p>
<p>This is what is in my index.php file:<br />
<code>define('BUILD_REVISION', '@build-revision@');</code></p>
<p>The ant task looks like this:</p>

<div class="wp_syntax"><div class="code"><pre class="xml" style="font-family:monospace;">replace file=&quot;${temp.dir}${cache.buster.file.path}&quot; 
            token=&quot;@build-revision@&quot; 
            value=&quot;${Revision}&quot;</pre></div></div>

<p>Revision is from Subversion.</p>
<p>Whenever we call a CSS file we need to reference the constant we just defined for example:<br />
<code><br />
&lt;link rel="stylesheet" href="&lt;?= base_path() . path_to_theme() ?&gt;/css/sugababes.css?&lt; ?=BUILD_REVISION?&gt;" type="text/css" media="screen" /&gt;<br />
&lt;/link&gt;<br />
</code></p>
<p>Now whenever you do a build a revision is added to the end of the CSS call.<br />
<code>/css/sugababes.css?420247</code></p>
<p>The browsers will now update the CSS file whenever you deploy a new version of the project.</p>
<p>If you just do a SVN checkout or do not use ANT on your workstation copy, everything will still work fine you will just have the token rather than the build number appended to your CSS.</p>
<p>There may be an alternative method where you extend <strong>drupal_add_css</strong> to automatically append the token and if you are using Drupal long term you should probably investigate that <img src='http://blog.sternthal.org/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sternthal.org/2008/12/23/css-cache-busting-and-drupal/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using ANT To Deploy Drupal</title>
		<link>http://blog.sternthal.org/2008/12/19/using-ant-to-deploy-drupal/</link>
		<comments>http://blog.sternthal.org/2008/12/19/using-ant-to-deploy-drupal/#comments</comments>
		<pubDate>Fri, 19 Dec 2008 14:52:23 +0000</pubDate>
		<dc:creator>ben</dc:creator>
				<category><![CDATA[drupal]]></category>

		<guid isPermaLink="false">http://blog.sternthal.org/?p=352</guid>
		<description><![CDATA[So you&#8217;ve decided to use Drupal&#8230; awww. Well I really dislike drupal, but thats another article. For now I would like to discuss my strategy for doing ANT based builds of Drupal.
Doing ANT deployments is a great way to leverage some XP programming methodologies, but most importantly it allows you to do deployments to different [...]]]></description>
			<content:encoded><![CDATA[<p>So you&#8217;ve decided to use Drupal&#8230; awww. Well I really dislike drupal, but thats another article. For now I would like to discuss my strategy for doing ANT based builds of Drupal.</p>
<p>Doing ANT deployments is a great way to leverage some XP programming methodologies, but most importantly it allows you to do deployments to different environments in one step, making screw ups less likely. </p>
<p>Let&#8217;s assume you have some developers with a full version of the application on their workstations and you have a qa and production environment. You also store all your files in version control (we&#8217;ll use subversion because its the most common). If your not using version control&#8230; well you really should do that before you do any builds!!!!</p>
<p>We want ANT to do everything for us, checkout from subversion, do some configuring, then copy everything to target server. So lets get started.</p>
<p>Here is an outline of what we are going to do:</p>
<ol>
<li>Get Drupal Ready</li>
<li>Get ANT Ready &#8211; set up with dependencies</li>
<li>Create environment specific property files for ANT</li>
<li>Create ANT build.xml file</li>
</ol>
<h2>Get Drupal Ready</h2>
<p>First thing we need to do, is add a folder <strong>build</strong> to the root of our drupal project. This folder will hold our properties files and the build.xml file. We will also need to create the necessary <strong>settings.php</strong> files for each environment. I like to store these in version control and have ANT deal with copying/renaming the right one. Below is a screenshot of what my Drupal project looks like:</p>
<p><a href='http://blog.sternthal.org/wp-content/uploads/2008/12/drupal-file-system.png' rel="lightbox[352]"><img src="http://blog.sternthal.org/wp-content/uploads/2008/12/drupal-file-system.png" alt="" title="drupal-file-system" width="249" height="587" class="alignnone size-full wp-image-358" /></a></p>
<p>The <strong>setting.php</strong> files have all the environment specific settings. settings.php should not be entered into version control as each developer will have specific settings. As part of their local workstation setup they should copy <strong>settings.php.example</strong> to <strong>settings.php</strong> and customize as they need to.</p>
<h2>Get Ant Ready</h2>
<p>Go ahead and install ANT from the apache website, you will also need these libraries:</p>
<ol>
<li><a href="http://subclipse.tigris.org/svnant.html">SVN ANT</a> &#8211; allows you to checkout from subversion from ANT</li>
<li><a href="http://www.jcraft.com/jsch/">JSCH JARS</a> &#8211; allows you to SCP and do other nifty things </li>
</ol>
<h2>Make Your Properites File</h2>
<p>We are going to use property files to store all the values that ANT will use for the project. Use a different one for each environment (see above screenshot). Here are the values contained in mine:</p>
<p><code><br />
# -----------------------------------------------------------------------------<br />
# build.properties<br />
# This file is referenced by the  build.xml file.<br />
# -----------------------------------------------------------------------------</p>
<p># -----------------------------------------------------------------------------<br />
# External jars needed for Subversion<br />
# Example:<br />
# lib.dir=/usr/local/ant/lib<br />
# svnant.jar=${lib.dir}/svnant.jar<br />
# svnClientAdapter.jar=${lib.dir}/svnClientAdapter.jar<br />
# svnjavahl.jar=${lib.dir}/svnjavahl.jar<br />
# -----------------------------------------------------------------------------</p>
<p>lib.dir=<br />
svnant.jar=<br />
svnClientAdapter.jar=<br />
svnjavahl.jar=</p>
<p># -----------------------------------------------------------------------------<br />
# Subversion Login and URL<br />
# Example:<br />
# svnant.repository.user=username<br />
# svnant.repository.passwd=password<br />
# svnant.project.url=svn://XXX.XXX.XX.XX/path/to/project<br />
# -----------------------------------------------------------------------------</p>
<p>svnant.repository.user=<br />
svnant.repository.passwd=<br />
svnant.project.url=</p>
<p># -----------------------------------------------------------------------------<br />
# Build Folder Locations<br />
# Example:<br />
# temp.dir=temp<br />
# build.dir=release<br />
# -----------------------------------------------------------------------------</p>
<p>temp.dir=<br />
build.dir=</p>
<p># -----------------------------------------------------------------------------<br />
# Comment File Location, Where we output revision information requires tokens<br />
# in file<br />
# Example:/themes/xxx/parts/basic_footer.inc<br />
#<br />
# CSS Cache Busting File Location, where we output revision to bust CSS cache<br />
#<br />
# -----------------------------------------------------------------------------</p>
<p>comment.file.path=<br />
cache.buster.file.path=</p>
<p># -----------------------------------------------------------------------------<br />
# Deploy Location<br />
# Example:<br />
# deploy.server=sugababes.com<br />
# deploy.path=/path/to/directory<br />
#<br />
# -----------------------------------------------------------------------------</p>
<p>deploy.server=<br />
deploy.path=</p>
<p></code></p>
<h2>Create your build.xml file</h2>
<p>Here is a basic outline of what we want ANT to do:</p>
<p>We will want our ANT build script to do the following:</p>
<ol>
<li>Checkout Project from Subversion</li>
<li>Cleanup Project &#038; Configure For Target Environment</li>
<li>Add A Revision Number &#038; Timestamp To A Specific File</li>
<li>Zip Up The Build</li>
<li>Securely Transfer and Extract The Build On Target Server</li>
</ol>
<p>To be slick, we will pass the following paramters into ANT on the command line:</p>
<ol>
<li>Target Environment</li>
<li>Subversion Revision For Build (or HEAD)</li>
<li>Username and Password for Target Environment &#8211; dont store this info in the properties file.</li>
</ol>
<p>For ANT, this is an example of what I want to type in:</p>
<p>ant build-drupal -Denv=qa  -Drevision=HEAD  -Duser=benny  -Dpass=xxpassxx</p>
<p>That should be all to do a build, what environment do you want to deploy too, what revision do you want deployed, what is the username and password to login.</p>
<p>Here is my ANT target to checkout from subversion:</p>
<p>	&lt;property file=&#8221;build.properties.${env}&#8221; /&gt; </p>
<p>	&lt;path id=&#8221;project.classpath&#8221;&gt;<br />
		&lt;pathelement location=&#8221;${svnjavahl.jar}&#8221; /&gt;<br />
		&lt;pathelement location=&#8221;${svnant.jar}&#8221; /&gt;<br />
		&lt;pathelement location=&#8221;${svnClientAdapter.jar}&#8221; /&gt;<br />
	&lt;/path&gt;<br />
   &lt;typedef resource=&#8221;org/tigris/subversion/svnant/svnantlib.xml&#8221;  classpathref=&#8221;project.classpath&#8221;  /&gt;<br />
	&lt;target name=&#8221;checkout&#8221;&gt;<br />
		&lt;svn username=&#8221;${svnant.repository.user}&#8221; password=&#8221;${svnant.repository.passwd}&#8221;&gt;<br />
			&lt;checkout url=&#8221;${svnant.project.url}&#8221; revision=&#8221;${revision}&#8221; destPath=&#8221;${temp.dir}&#8221; /&gt;<br />
		&lt;/svn&gt;<br />
	&lt;/target&gt;</p>
<p>Note the ${env} syntax, this is how you pull in values from the command line. For example I want to type the following to ant <i>ant deploy-drupal -Denv=qa</i> and then will use the qa value to get the right properties file.</p>
<p>Below is the task to insert the build number into the footer and to bust any CSS cache:</p>
<p>   &lt;target name=&#8221;revisionnumber&#8221;&gt;<br />
      &lt;svn&gt;<br />
         &lt;status path=&#8221;${temp.dir}&#8221; revisionProperty=&#8221;Revision&#8221; /&gt;<br />
      &lt;/svn&gt;</p>
<p>      &lt;tstamp /&gt;<br />
&lt;!&#8211; For CSS Cache Busting Constant in index.php &#8211;&gt;<br />
      &lt;replace file=&#8221;${temp.dir}${cache.buster.file.path}&#8221; token=&#8221;@@@&#8221; value=&#8221;${Revision}&#8221;/&gt;<br />
&lt;!&#8211; For Info In Footer &#8211;&gt;<br />
      &lt;replace file=&#8221;${temp.dir}${comment.file.path}&#8221; token=&#8221;@@@&#8221; value=&#8221;Revision: ${Revision}, Build Date: ${DSTAMP} : ${TSTAMP}&#8221;/&gt;<br />
   &lt;/target&gt;</p>
<p>Below is the target to copy the correct settings file:</p>
<p>    &lt;target name=&#8221;populateRelease&#8221;&gt;<br />
        &lt;move file=&#8221;${temp.dir}/sites/default/settings.php.${env}&#8221; tofile=&#8221;${temp.dir}/sites/default/settings.php&#8221;/&gt;<br />
    &lt;/target&gt;</p>
<p>These two targets zip and scp the file:</p>
<p>	&lt;target name=&#8221;zipRelease&#8221;&gt;<br />
		&lt;mkdir dir=&#8221;${build.dir}&#8221;/&gt;<br />
		&lt;zip destfile=&#8221;${build.dir}/FILE-NAME_${revision}.zip&#8221; basedir=&#8221;${temp.dir}&#8221; /&gt;<br />
		&lt;antcall target=&#8221;clean&#8221;/&gt;<br />
	&lt;/target&gt;</p>
<p>	&lt;target name=&#8221;deploy&#8221;&gt;<br />
		&lt;scp file=&#8221;${build.dir}/FILE-NAME_${revision}.zip&#8221;<br />
			todir=&#8221;${user}@${deploy.server}:${deploy.path}&#8221;<br />
			password=&#8221;${pass}&#8221;<br />
			trust=&#8221;true&#8221;<br />
		/&gt;<br />
	&lt;/target&gt;</p>
<p>Most importantly is this task that extracts the files on the target server, note that the Uploads and Files folders are not touched, since these contain user created data they are not stored in subversion and are not included in the build.</p>
<p>	&lt;target name=&#8221;extractConfigure&#8221;&gt;<br />
        &lt;sshexec host=&#8221;${deploy.server}&#8221;<br />
                 username=&#8221;${user}&#8221;<br />
	             password=&#8221;${pass}&#8221;<br />
	             trust=&#8221;yes&#8221;<br />
	             command=&#8221;cd ${deploy.path};<br />
	                      rm -R includes;<br />
	                      rm -R misc;<br />
	                      rm -R modules;<br />
	                      rm -R profiles;<br />
                         rm -R scripts;<br />
                         rm -R sites;<br />
                         rm -R themes;<br />
                         rm .htaccess;<br />
                         rm robots.txt;<br />
                         rm cron.php;<br />
                         rm index.php;<br />
                         rm xmlrpc.php;<br />
	                      unzip -o FILE-NAME_${revision}.zip;<br />
	                      rm FILE-Name_${revision}.zip;&#8221;/&gt;<br />
	&lt;/target&gt;	</p>
<p>And thats pretty much all the pieces you need, the rest of the plumbing is standard ANT. </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sternthal.org/2008/12/19/using-ant-to-deploy-drupal/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
