<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0"
    xmlns:dc="http://purl.org/dc/elements/1.1/"
    xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
    xmlns:admin="http://webns.net/mvcb/"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:content="http://purl.org/rss/1.0/modules/content/">

    <channel>
    
    <title><![CDATA[Matthew Fordham]]></title>
    <link>http://www.matthewfordham.com</link>
    <description></description>
    <dc:language>en</dc:language>
    <dc:creator>matt@wintr.us</dc:creator>
    <dc:rights>Copyright 2013</dc:rights>
    <dc:date>2013-03-10T04:54:13+00:00</dc:date>
    <admin:generatorAgent rdf:resource="http://expressionengine.com/" />
    

    <item>
      <title><![CDATA[Introducing Strap]]></title>
      <link>http://www.matthewfordham.com/blog/strap</link>
      <guid>http://www.matthewfordham.com/blog/strap#When:04:54:13Z</guid>
      <description><![CDATA[<p>
	I&#39;ve been working on building tool called Strap for a few months now, and am happy to finally share it. Strap is a simple tool for bootstrapping new projects based on a template Git repo. With a couple commands, it will check out the specified repo into a new project directory, do some stuff (create a database, import SQL, rename files, change file permissions, etc), initialize a new Git repo and push to the project&#39;s remote repo.&nbsp;</p>
<p>
	I made a tutorial video (below) and have some documentation here:&nbsp;<a href="http://mattfordham.github.com/Strap/">http://mattfordham.github.com/strap</a>. If you find it useful, I&#39;d love to hear about it. Anyone interesting in contributing to development is more than welcome to as well. Enjoy!</p>
<p>
	<iframe allowfullscreen="" frameborder="0" height="444" mozallowfullscreen="" src="http://player.vimeo.com/video/61434005?title=0&amp;byline=0&amp;portrait=0&amp;color=ffffff" webkitallowfullscreen="" width="710"></iframe></p>
<p>
	<a href="http://vimeo.com/61434005">Strap</a> from <a href="http://vimeo.com/mfordham">Matt Fordham</a> on <a href="http://vimeo.com">Vimeo</a>.</p>
]]></description>
      <dc:subject><![CDATA[Ruby]]></dc:subject>
      <dc:date>2013-03-10T04:54:13+00:00</dc:date>
    </item>

    <item>
      <title><![CDATA[Automated MySQL S3 Backups on PagodaBox]]></title>
      <link>http://www.matthewfordham.com/blog/pagodabox-backup</link>
      <guid>http://www.matthewfordham.com/blog/pagodabox-backup#When:21:27:43Z</guid>
      <description><![CDATA[<p>
	I&rsquo;ve recently been spending a bit of time kicking the tires over at <a href="http://www.pagodabox.com">PagodaBox</a>, a PHP hosting &ldquo;platform-as-a-service&rdquo;. So far, the service is very impressive (very similar to <a href="http://heroku.com">Heroku</a>, which I love) and I&rsquo;m looking forward to getting some client ExpressionEngine projects running there and beginning the move away from the traditional VPS madness.</p>
<p>
	One of the final pieces I&rsquo;ve needed to figure out has been automated nightly MySQL and user upload backups to S3, which I typically setup for all projects. PagodaBox provides both <a href="http://help.pagodabox.com/customer/portal/articles/333772">Cron</a> functionality and <a href="https://pagodabox.com/features/shared-writable-storage">shared writable directories</a>, so it seemed doable. The only question remaining was what commands were available to run via Cron. That question was answered by a <a href="https://gist.github.com/1756086">Gist on Github</a>.</p>
<p>
	The backup process has two steps. First, dump the database to a shared writable directory. Second, sync that directory to an S3 bucket. <a href="http://sourceforge.net/projects/automysqlbackup/">My usual MySQL dump script</a> worked great. My <a href="http://s3sync.net/">go-to S3 sync tool</a>, however, wasn&rsquo;t an option, as Ruby doesn&rsquo;t run on PagodaBox (I guess nothing is perfect). So, after a little hunting around, I found a <a href="https://github.com/yellowandy/s3sync">PHP S3 sync option</a> that did something similar. I tweaked the script a little, as it was using hashes for file naming, which didn&rsquo;t work for me. Finally, here is the Boxfile needed to make this happen (your app will probably need more configuration than this).</p>
<script src="https://gist.github.com/3471042.js?file=Boxfile"></script>
<p>
	I&rsquo;ve got the <a href="https://github.com/mattfordham/PagodaBox-Backup/">whole package on Github</a>, including my tweaks and some instructions. There you go, one step closer to PHP hosting nirvana.</p>
]]></description>
      <dc:subject><![CDATA[PHP]]></dc:subject>
      <dc:date>2012-08-25T21:27:43+00:00</dc:date>
    </item>

    <item>
      <title><![CDATA[Deploying ExpressionEngine with Capistrano]]></title>
      <link>http://www.matthewfordham.com/blog/deploying-expressionengine</link>
      <guid>http://www.matthewfordham.com/blog/deploying-expressionengine#When:15:50:53Z</guid>
      <description><![CDATA[<p>
	Anyone who has ever deployed any slighty-more-complex-than-really-simple website via FTP has felt the pain. Some of the cooler FTP clients out there, such as <a href="http://panic.com/transmit/">Transmit</a>, offer &ldquo;synchronize&rdquo; features, which help a bit, but it is still makes for a potentially messy transaction. Deploying directly via Git (or some other version control system) is a definite step in the right direction, but that requires ssh&rsquo;ing in to the server every time to run some tedious commands.</p>
<p>
	Enter <a href="https://github.com/capistrano/capistrano">Capistrano</a>. Capistrano is a Ruby tool that makes deploying any kind of website (including ExpressionEngine) a piece of cake. Put simply, it allows you to run a simple command in your local dev environment that in turn executes a more complex series of commands on a remote server (via SSH), such as deploying a website. Capistrano also makes rolling back to a previous version of the site a relatively easy thing.</p>
<p>
	As great as Capistrano is, it can be tough to get started with it. In this post, I&rsquo;ll cover getting it setup and configured for an average ExpressionEngine site. Also, I made a little video walking through the process:</p>
<p>
	<iframe allowfullscreen="" frameborder="0" height="281" mozallowfullscreen="" src="http://player.vimeo.com/video/46668744" webkitallowfullscreen="" width="500"></iframe></p>
<h3 id="localdependencies">
	Local dependencies</h3>
<p>
	As Capistrano is a Ruby tool, you&rsquo;ll need Ruby running on your machine. For most OSX users, it should be there already. If not, try installing with <a href="https://rvm.io/">RVM</a>. Along with Ruby, you&rsquo;ll need <a href="http://rubygems.org/">RubyGems</a>, which will allow you to easily install Ruby projects.</p>
<p>
	Next up is <a href="http://git-scm.com/">Git</a>. You&rsquo;ll need to have Git running and have your project pushing to a remote repository. If you don&rsquo;t already have a remote Git repo for your projects, give the free plan at <a href="https://bitbucket.org/">BitBucket</a> a try. BTW, Subversion works too if that&rsquo;s your thing (Gods help you).</p>
<p>
	With Ruby and RubyGems in place, installing Capistrano is as simple as running &ldquo;gem install capistrano&rdquo; from the command-line. We&rsquo;ll also be using the Railsless Deploy gem, which removes some Rails specific stuff from the default Capistrano deploy process (Capistrano was originally created with Ruby on Rails in mind). To install run &ldquo;gem install railsless-deploy&rdquo;.</p>
<h3 id="serverdependencies">
	Server dependencies</h3>
<p>
	The server that you are deploying to will also need a little setup. I am assuming you have SSH access to the server and can install whatever you like.</p>
<p>
	The server, like your dev machine, will also require Git. Installing will depend on the specifics of your server, but a quick Google search should turn up the right commands to run. Also, you&rsquo;ll need to add your server&rsquo;s key to your repo host&rsquo;s list of allowed keys (this is usually handled in the service&rsquo;s &ldquo;account&rdquo; settings). Your repo hosting service should also provide docs on how to do this. Here is <a href="https://help.github.com/articles/generating-ssh-keys">Github&rsquo;s help docs on the topic</a>, for example.</p>
<p>
	The server does NOT need to run Ruby, BTW. From the server&rsquo;s point-of-view, Capistrano will seem like a regular SSH user logging in and running some commands. You will need to create a user for Capistrano to login as. You could also use the &ldquo;root&rdquo; user, but that is a little less secure. Finally, if you add your local dev machine&rsquo;s ssh key to the server&rsquo;s list of allowed keys, you won&rsquo;t have to enter your password every time.</p>
<h3 id="capify">
	Capify</h3>
<p>
	Ok, down to business. In the terminal, &lsquo;cd&rsquo; into the directory of your project and run the following command:</p>
<script src="https://gist.github.com/3213592.js?file=gistfile1.txt"></script>
<p>
	Running this command will create the following:</p>
<script src="https://gist.github.com/3213595.js?file=gistfile1.txt"></script>
<p>
	The &ldquo;Capfile&rdquo; is the overall config for Capistrano. There will only be a few commands in there and they are basically &ldquo;set it and forget it&rdquo; type of things. For an ExpressionEngine project using the the railsless-deploy gem, I change my Capfile to look like this:</p>
<script src="https://gist.github.com/3213597.js?file=gistfile1.txt"></script>
<p>
	The &ldquo;config/deploy.rb&rdquo; file contains the specifics of your deployment, such as your server address, the Git repo and any custom tasks you want to run. We&rsquo;ll come back to this file, as it contains the meat of the deployment.</p>
<p>
	Now, back in the terminal, run the &lsquo;cap -T&rsquo; command and you&rsquo;ll see the available default Capistrano &ldquo;tasks&rdquo;:</p>
<script src="https://gist.github.com/3213598.js?file=gistfile1.txt"></script>
<p>
	These are all the commands currently available. Some of the commands, such as &ldquo;cap deploy&rdquo; run a few of the other ones for you in series. OK, let&rsquo;s pop open that deploy.rb file and replace ALL of the contents with the following:</p>
<script src="https://gist.github.com/3213602.js?file=deploy.rb"></script>
<p>
	So, those are all the basic settings I usually use. There are others, but I don&rsquo;t often have to mess with them for a simple ExpressionEngine deploy.</p>
<p>
	For the deploy to work, Capistrano expects a certain structure within your application&rsquo;s directory on the server. The &ldquo;cap deploy:setup&rdquo; command is supposed to get this prepared for you, but I have had issues getting it to work in the past, so I usually do it myself. On the remote server, run the following commands (change the paths for the specifics of your app):</p>
<script src="https://gist.github.com/3213603.js?file=gistfile1.txt"></script>
<p>
	That&rsquo;s it. Capistrano expects a &ldquo;releases&rdquo; and a &ldquo;shared&rdquo; directory to be there. Now, run the following command from your local machine:</p>
<script src="https://gist.github.com/3213605.js?file=gistfile1.txt"></script>
<p>
	If your &ldquo;deploy.rb&rdquo; is configured up correctly, running this command will have Capistrano log in to your server and make sure it has everything it needs (permissions, the required directories, access to the Remote Git repo, etc). It&rsquo;ll tell you if it was successful or not, and if not, why.</p>
<h3 id="expressionenginespecificcapistranotasks">
	ExpressionEngine specific Capistrano tasks</h3>
<p>
	Add the following to your deploy.rb file, making sure to adjust for your specific setup where noted:</p>
<script src="https://gist.github.com/3213612.js?file=deploy.rb"></script>
<p>
	When Capistrano runs a deploy, it checks out the latest code from the remote repo to a timestamped directory within the &ldquo;/var/www/example.com/releases&rdquo; directory. It then creates a <a href="http://en.wikipedia.org/wiki/Symbolic_link">symlink</a> called &ldquo;current&rdquo; from the main deploy directory to the latest release. <strong>The &ldquo;current&rdquo; symlink is what you would point your server to</strong>. This way, the current release is what is served when someone visits your site.</p>
<p>
	The &ldquo;create_symlinks&rdquo; custom task above will create a symlink from the &ldquo;images&rdquo; directory in the &ldquo;/var/www/example.com/shared&rdquo; directory (which you will need to upload manually from your local environment) to the current release. The &ldquo;images&rdquo; directory is where any uploads via EE are stored. As uploads should not be in the repo, and they will need to be shared by each release, we create the &ldquo;create_symlinks&rdquo; task to ensure each release has access to the same shared files. You might also symlink some config files to the current release, if you are not wanting them to reside in the repo. The same thing is done for the &ldquo;database.php&rdquo; config file. Because the server database has different credentials than the local dev database, we symlink this file too (it too should not be in the repo). That said, I typically use a <a href="http://ee-garage.com/nsm-config-bootstrap">config bootstrap file</a> instead of symlinking &ldquo;database.php&rdquo;, but I&rsquo;m trying to keep things simple here.</p>
<p>
	The &ldquo;set_permissions&rdquo; task will ensure that some key ExpressionEngine files have the appropriate permissions with each deploy.</p>
<h3 id="deploying">
	Deploying</h3>
<p>
	Okay, we are now ready to deploy. First, commit local code changes and push to the remote repo:</p>
<script src="https://gist.github.com/3213614.js?file=gistfile1.txt"></script>
<p>
	Now run the deploy:</p>
<script src="https://gist.github.com/3213615.js?file=gistfile1.txt"></script>
<p>
	You should now see Capistrano do its thing. If any errors are encountered it will attempt to &ldquo;rollback&rdquo; to the previous deploy, making sure your site doesn&rsquo;t go down. Congrats, you&rsquo;ve deployed a new version of your site!</p>
<h3 id="conclusion">
	Conclusion</h3>
<p>
	To sum up, our Capistrano deploy now basically does the following:</p>
<ol>
	<li>
		ssh into the remote server</li>
	<li>
		Check out the latest code from the remote repo to a time-stamped directory in &ldquo;/var/www/example.com/releases&rdquo;</li>
	<li>
		Create a symlink from &ldquo;/var/www/example.com/current&rdquo; to the latest release</li>
	<li>
		Create symlinks for &ldquo;images&rdquo; and &ldquo;database.php&rdquo;</li>
	<li>
		Sets the permissions of a few EE files and directories</li>
</ol>
<p>
	<a href="https://gist.github.com/3213617">Here is the complete deploy.rb file</a></p>
<p>
	Getting setup obviously takes a little bit of work (although it only takes 10 minutes once you&rsquo;ve done it a couple times), but once its done, deploying couldn&rsquo;t be much easier!</p>
]]></description>
      <dc:subject><![CDATA[Capistrano, ExpressionEngine]]></dc:subject>
      <dc:date>2012-07-31T15:50:53+00:00</dc:date>
    </item>

    <item>
      <title><![CDATA[My ExpressionEngine Project Template]]></title>
      <link>http://www.matthewfordham.com/blog/ee-template</link>
      <guid>http://www.matthewfordham.com/blog/ee-template#When:03:28:24Z</guid>
      <description><![CDATA[<p>
	Lately I&rsquo;ve been working on back-to-back ExpressionEngine projects and have found a great workflow boost by creating, maintaining and using a boilerplate project template. Not only is starting new projects significantly faster, but going through the process has helped me to focus my thoughts on organizational best-practices. Below, I will discuss my general workflow for using this template and will go over its contents.</p>
<h3 id="thegitrepo">
	The Git Repo</h3>
<p>
	The first step to a successful template for any software project is a version controlled repository. I, like many folks out there, use <a href="http://git-scm.com/">Git</a> for this task. I have repos on <a href="http://www.github.com">Github</a>, <a href="http://www.beanstalkapp.com">Beanstalk</a> and <a href="https://bitbucket.org/">BitBucket</a>. I&rsquo;ve had great experiences with all these services, but BitBucket provides free private repos for small teams, so you may want to check that out if you are just getting started. With my EE template under version control, I can make alterations to it and try out new things without the fear of losing anything. <strong>Note:</strong> As ExpressionEngine is a commercial product your template repo needs to be private.</p>
<p>
	The first step when starting new project with this system always involves updates to the template itself. With a clean copy of the template, I&rsquo;ll make these updates and push the changes back to the main template repo. The updates may include updating the version of ExpressionEngine, updating an add-on I always use, adding some cool new goodness to the config bootstrap file, etc, etc. Usually experiences or troubles with the last project inform how the template gets tweaked (often times I&rsquo;ll attempt to update the template in the midst of another project while such improvements are on my mind).</p>
<p>
	After the template itself is updated and feels as current as it can be, I&rsquo;ll check out a new copy of the template and then kill the hidden Git directory that comes with it. By deleting the hidden Git directory (it is called <em>.git</em> and will be in the root directory of the project) I am breaking the connection with the template&rsquo;s repo. I will then initialize a new Git repo in the directory for the project itself and can start committing project specific stuff.</p>
<h3 id="thedetails">
	The Details</h3>
<p>
	As mentioned above, due to EE&rsquo;s commercial license, I cannot share the repo itself. That said, below is a description of the overall layout and some additions and alterations of note. I&rsquo;ll list out the structure first, and will then go over each piece (I have ordered things below for clarity&hellip;not for alphabetical perfection).</p>
<ul class="block">
	<li>
		__DISABLED.gitignore</li>
	<li>
		README</li>
	<li>
		Gemfile</li>
	<li>
		Guardfile</li>
	<li>
		Capfile</li>
	<li>
		<strong>ee_installs</strong> &rarr;
		<ul>
			<li>
				<em>EE add-on zips go here</em></li>
		</ul>
	</li>
	<li>
		<strong>ee_system</strong> &rarr;
		<ul>
			<li>
				<strong>codeigniter</strong> &rarr;
				<ul>
					<li>
						<em>codeigniter stuff goes here&hellip; unchanged from the default install</em></li>
				</ul>
			</li>
			<li>
				<strong>expressionengine</strong> &rarr;
				<ul>
					<li>
						<em>EE stuff goes here&hellip; mostly unchanged from the default install</em></li>
				</ul>
			</li>
			<li>
				index.html</li>
			<li>
				index.php</li>
			<li>
				config_bootstrap.php</li>
		</ul>
	</li>
	<li>
		<strong>templates</strong> &rarr;
		<ul>
			<li>
				<strong>default_site</strong> &rarr;
				<ul>
					<li>
						<strong>main.group</strong> &rarr;
						<ul>
							<li>
								index.html</li>
							<li>
								404.html</li>
						</ul>
					</li>
					<li>
						<strong>shared.group</strong> &rarr;
						<ul>
							<li>
								_layout.html</li>
							<li>
								styleguide.html</li>
						</ul>
					</li>
				</ul>
			</li>
		</ul>
	</li>
	<li>
		<strong>public</strong>
		<ul>
			<li>
				<strong>static</strong> &rarr;
				<ul>
					<li>
						<strong>css</strong> &rarr;</li>
					<li>
						<strong>img</strong> &rarr;</li>
					<li>
						<strong>js</strong> &rarr;</li>
					<li>
						<strong>fonts</strong> &rarr;</li>
					<li>
						<strong>ee_images</strong> &rarr;</li>
				</ul>
			</li>
			<li>
				<strong>themes</strong> &rarr;</li>
			<li>
				admin.php</li>
			<li>
				index.php</li>
			<li>
				.htaccess</li>
		</ul>
	</li>
	<li>
		<strong>data</strong> &rarr;
		<ul>
			<li>
				ee-template_2012-07-08.sql</li>
		</ul>
	</li>
	<li>
		<strong>config</strong> &rarr;
		<ul>
			<li>
				<strong>server config</strong> &rarr;
				<ul>
					<li>
						<em>Some server scripts (automated backups, etc)</em></li>
				</ul>
			</li>
			<li>
				compass.rb</li>
			<li>
				deploy.rb</li>
		</ul>
	</li>
	<li>
		<strong>sass</strong> &rarr;
		<ul>
			<li>
				<em>SCSS files</em></li>
		</ul>
	</li>
	<li>
		<strong>coffeescript</strong> &rarr;
		<ul>
			<li>
				<em>Coffeescript files</em></li>
		</ul>
	</li>
</ul>
<h4 id="disabled.gitignore">
	__DISABLED.gitignore</h4>
<p>
	Including a <em>.gitignore</em> in a Git project will tell Git to not track certain files (<a href="https://github.com/github/gitignore/blob/master/ExpressionEngine.gitignore">here is a good start for EE</a> ). In this case, I name the file &ldquo;__DISABLED.gitignore&rdquo; so that the template repo includes that stuff, so I don&rsquo;t have to manually create it all at the beginning of every project. Prior to creating the repo for the actual project, I simply remove the &ldquo;__DISABLED&rdquo; part.</p>
<h4 id="readme">
	README</h4>
<p>
	The README file contains some general usage notes about the template. This includes the above note about the .gitignore file and also the login credentials for a default admin user in the template&rsquo;s database dump.</p>
<h4 id="gemfile">
	Gemfile</h4>
<p>
	Many of the tools I use for development (more on the specifics below), regardless of the type of project, are Ruby tools. In the case of an EE project, none of the tools are used in production, they are just to aid in development. The Gemfile is used by <a href="http://gembundler.com/">Bundler</a> to manage Ruby dependencies. By specifying all of my dependencies in the Gemfile, another developer can install them all with one command (as long as they have Ruby and Bundler installed).</p>
<h4 id="guardfile">
	Guardfile</h4>
<p>
	<a href="https://github.com/guard/guard/">Guard</a> is a super-awesome tool for easily handling events on file system modifications, and the Guardfile is its config file. In the case of EE projects, it does the following for me:</p>
<ul>
	<li>
		<a href="https://github.com/guard/guard-livereload">Reload the browser whenever I save a file</a></li>
	<li>
		<a href="https://github.com/guard/guard-compass">Compile CSS files whenever I save a SCSS file</a></li>
	<li>
		<a href="https://github.com/guard/guard-coffeescript">Compile JS files whenever I save a Coffeescript file</a></li>
</ul>
<p>
	The specifics of setting up and using Guard is out of the scope of this post, but check out the docs and maybe check back here for more related articles in the future. BTW, <a href="http://livereload.com/">LiveReload</a> and <a href="http://incident57.com/codekit/">Codekit</a> also accomplish similar things, if the command-line isn&rsquo;t your thing.</p>
<h4 id="capfile">
	Capfile</h4>
<p>
	Yup, another config file for another Ruby tool. This time it is <a href="https://github.com/capistrano/capistrano">Capistrano</a>. Capistrano is a tool for automating deployment of web projects. It was built for use with Rails, but it works great for any type of project. I can&rsquo;t imagine deploying these types of projects without it (or something similar), and using FTP to deploy seems totally insane to me at this point (no offense).</p>
<h4 id="ee_installs">
	ee_installs</h4>
<p>
	This is simply a place to put zip files of EE add-ons. By keeping them in the template repo, I can ensure I always have the latest in a convenient spot when starting a project. I typically do not have them installed by default in the template (with a few exceptions), as every project calls for something different here.</p>
<h4 id="ee_system">
	ee_system</h4>
<p>
	This is the default &ldquo;system&rdquo; directory with some tweaks. Firstly, it has been renamed. Renaming it is a good security measure and I prefer a less vague name. Secondly, it has been moved above webroot (which is the &ldquo;public&rdquo; directory), also for security and organizational purposes. The official EE docs describe <a href="http://expressionengine.com/user_guide/installation/best_practices.html">how to do both of these things</a>.</p>
<p>
	The &ldquo;ee_system&rdquo; directory also contains the &ldquo;config_bootstrap.php&rdquo; file. Mine is based on the <a href="http://ee-garage.com/nsm-config-bootstrap">NSM Config Bootsrap</a>. This file allows for environment specific settings, such as database credentials for your dev environment vs. production. Not having to make any adjustments to settings upon deploying is a HUGE time-saver.</p>
<h4 id="templates">
	templates</h4>
<p>
	This templates directory is pretty much what you&rsquo;d expect, except that I&rsquo;ve moved it to the root of my project directory structure&hellip; &lsquo;cause I hate digging for it. Some basic starter templates are in the repo. The &ldquo;_layout.html&rdquo; template contains typical header and footer stuff. I use <a href="http://devot-ee.com/add-ons/stash">Stash</a> and the <a href="http://johndwells.com/blog/homegrown-plugin-to-create-template-partials-for-expressionengine">template partials concept</a> to pull this off.</p>
<p>
	The &ldquo;styleguide.html&rdquo; template contains some placeholder mark-up for most common HTML elements. The first step of my front-end development process includes creating the styles for these basic elements. I&rsquo;d also throw other &ldquo;modules&rdquo; into this template too&hellip; basically chunks of design that will show up in multiple places.</p>
<h4 id="public">
	public</h4>
<p>
	This directory is where the web server points. &ldquo;index.php&rdquo;, &ldquo;admin.php&rdquo; and &ldquo;themes&rdquo; are the usual EE ones (edited slightly due to the move of the &ldquo;system&rdquo; directory). The &ldquo;.htaccess&rdquo; file <a href="http://expressionengine.com/user_guide/general/remove_index.php.html">removes &ldquo;index.php&rdquo; from URLs</a> and does some other handy things.</p>
<p>
	I put all static assets under a &ldquo;static&rdquo; directory for a couple of reasons. First, it is a little cleaner. Second, it would make the move to a CDN, such as CloudFront, a little more straight-forward, if and when that happens. Generally, these directories should speak for themselves. The &ldquo;ee_images&rdquo; is the &ldquo;images&rdquo; directory provided by EE, but renamed in order to distinguish it from the &ldquo;img&rdquo; directory, which contains images used in the general design (as opposed to EE uploads, etc).</p>
<h4 id="data">
	data</h4>
<p>
	This directory starts out with one file only, an SQL dump of the database. The dump was created after running through the EE installer the first time and setting some basic preferences. The database dump is imported into a new database at the beginning of each project (I use <a href="http://www.sequelpro.com/">SequelPro</a> for such tasks). New dumps are added to this directory periodically once a project is started when importing/exporting from the development database to production.</p>
<h4 id="config">
	config</h4>
<p>
	This &ldquo;config&rdquo; directory is not the same as the one in the expressionengine directory. This one is for configuring some stuff outside of EE. The &ldquo;server config&rdquo; directory is a handy place to keep some scripts that usually end up on the server, but outside of the project. Among these are scripts for running automated nightly backups of the database and uploads to Amazon S3.</p>
<p>
	&ldquo;compass.rb&rdquo; is for setting some Compass preferences. <a href="http://compass-style.org/">Compass</a> is a CSS authoring framework for creating stylesheets with <a href="http://sass-lang.com/">SASS</a>.</p>
<p>
	&ldquo;deploy.rb&rdquo; is the Capistrano deploy script for the project. It defines where the project gets deployed to, and what other deployment related tasks should be run and when, such as setting permissions and creating symlinks.</p>
<h4 id="sass">
	sass</h4>
<p>
	As mentioned above, I typically use Compass for stylesheet development. SCSS (A SASS filetype) files are compiled into CSS files the &ldquo;public/static/css&rdquo; directory automatically whenever they are saved (thanks to Guard&hellip; mentioned above). A discussion of all the benefits of Compass and SASS is outside the scope of this post, but generally, SASS adds indispensable features such as variables, mixins and nesting to CSS.</p>
<h4 id="coffeescript">
	coffeescript</h4>
<p>
	Finally, we come to the Coffeescript directory. <a href="http://coffeescript.org/">Coffeescript</a> is kinda like SASS but for Javascript. It is an alternative way of writing Javascript that is MUCH cleaner, faster and way more fun. Guard automatically compiles the .coffee files into .js couterparts in the &ldquo;public/static/js&rdquo; whenever they are saved. <strong>Sidenote:</strong> I use Christian Johansen&rsquo;s <a href="http://cjohansen.no/en/ruby/juicer_a_css_and_javascript_packaging_tool/">Juicer</a> for combining and minifying all Javascripts prior to deploying.</p>
<h3 id="conclusion">
	Conclusion</h3>
<p>
	Phew&hellip; are you still reading?&hellip; really? I glossed over a lot of the details, so be sure to post comments if there are pieces you&rsquo;d like to hear more about. This template/workflow works really well for me, but I&rsquo;ll be the first to admit that there may be some room for improvement&hellip; so please let me know what you think!</p>
]]></description>
      <dc:subject><![CDATA[ExpressionEngine]]></dc:subject>
      <dc:date>2012-07-14T03:28:24+00:00</dc:date>
    </item>

    <item>
      <title><![CDATA[csv_validator]]></title>
      <link>http://www.matthewfordham.com/blog/csv-validator</link>
      <guid>http://www.matthewfordham.com/blog/csv-validator#When:22:33:15Z</guid>
      <description><![CDATA[<p>
	For one reason or another, many of the Rails projects I work on require the uploading of CSV files and the importing of their contents. In each of these situations, the format of the CSV files must adhere to certain parameters in order for things to work as expected. I wrote <a href="https://github.com/mattfordham/csv_validator">csv_validator</a>, a Rails validator Gem, to ensure the validity of uploaded CSV files and the data they contain.</p>
<h3 id="usage">
	Usage</h3>
<p>
	Add the following to your Gemfile:</p>
<script src="https://gist.github.com/3113421.js?file=Gemfile"></script>
<p>
	Then run:</p>
<script src="https://gist.github.com/3113447.js?file=gistfile1.txt"></script>
<p>
	Then add the following to your model:</p>
<script src="https://gist.github.com/3113448.js?file=model.rb"></script>
<p>
	This will check to see if it is a properly formed CSV file.</p>
<p>
	In this case, csv_validator expects :my_csv_file to be an instance of ActionDispatch::Http::UploadedFile, which is created by default for Rails uploads.</p>
<h3 id="othervalidationoptions">
	Other validation options</h3>
<p>
	There are a handful of other options for more specific validation too. A complete list is below&hellip; note that you wouldn&rsquo;t use all simultaneously.</p>
<script src="https://gist.github.com/3113450.js?file=model.rb"></script>
<p>
	Check it out <a href="https://github.com/mattfordham/csv_validator">on Github</a></p>
]]></description>
      <dc:subject><![CDATA[Ruby on Rails]]></dc:subject>
      <dc:date>2012-07-12T22:33:15+00:00</dc:date>
    </item>

    
    </channel>
</rss>