<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/css" href="/stylesheets/rss.css"?>
<rss xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">
  <channel>
    <title>Matt Fawcett : Tag html, everything about html</title>
    <link>http://matthewfawcett.co.uk</link>
    <atom:link type="application/rss+xml" rel="self" href="http://matthewfawcett.co.uk/tag/html.rss"/>
    <language>en-us</language>
    <ttl>40</ttl>
    <description></description>
    <item>
      <title>s3ify gem - put the assets for a HTML email online</title>
      <description>&lt;p&gt;I often have to deal with setting up email sends, which usually involves getting a zip file from a designer containing a html file and some images. I usually unzip, convert all the image references to point to an S3 path, upload the whole folder to S3 using S3fox, and change the permissions to be publicly readable.&lt;/p&gt;

&lt;p&gt;This is a bit repetitive and manual for my liking so I wrote a small ruby gem to make it a bit simpler. It uses &lt;a href="http://github.com/tenderlove/nokogiri/tree/master"&gt;Nokogiri&lt;/a&gt; to parse the HTML (so you will need a recent version of libxml) and the &lt;a href="http://amazon.rubyforge.org/"&gt;aws-s3 gem&lt;/a&gt;  to upload everything to S3. I used the &lt;a href="http://github.com/visionmedia/commander/tree/master"&gt;commander gem&lt;/a&gt; to create a command line interface to use it.&lt;/p&gt;

&lt;p&gt;So first, get it installed&lt;/p&gt;

&lt;div class="CodeRay"&gt;&lt;pre&gt;&lt;span class="CodeRay"&gt;sudo gem install mattfawcett-s3ify&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;br/&gt;


&lt;p&gt;You will need to have your Amazon web services access information set in your path, if you don&amp;#8217;t have this already, your best bet is to create a hidden file in your home directory called .amazon_keys with the contents&lt;/p&gt;

&lt;div class="CodeRay"&gt;&lt;pre&gt;&lt;span class="CodeRay"&gt;export AMAZON_ACCESS_KEY_ID='abcdefghijklmnop'
export AMAZON_SECRET_ACCESS_KEY='1234567891012345'&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;br/&gt;


&lt;p&gt;then add the following to your shell&amp;#8217;s rc file (usually .bashrc)&lt;/p&gt;

&lt;div class="CodeRay"&gt;&lt;pre&gt;&lt;span class="CodeRay"&gt;if [[ -f &amp;quot;$HOME/.amazon_keys&amp;quot; ]]; then
    source &amp;quot;$HOME/.amazon_keys&amp;quot;;
fi&lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;br/&gt;


&lt;p&gt;Then to use it simply open up a shell and type&lt;/p&gt;

&lt;div class="CodeRay"&gt;&lt;pre&gt;&lt;span class="CodeRay"&gt;s3ify -b my_bucket -p my_folder_in_bucket ~/Desktop/my-email/ &lt;/span&gt;&lt;/pre&gt;&lt;/div&gt;


&lt;p&gt;The -b flag is the bucket you wish to upload to, the -p flag is the path in the bucket that you want to upload to and finally you declare the path to the folder where your HTML email is on the file system. For each HTML file, the gem will create an additional file with the prefix of &amp;#8220;_s3&amp;#8221; which will have the image references pointing to S3.&lt;/p&gt;

&lt;p&gt;The code is on &lt;a href="http://github.com/mattfawcett/s3ify/tree/master"&gt;Github&lt;/a&gt;&lt;/p&gt;</description>
      <pubDate>Sat, 27 Jun 2009 12:35:00 +0000</pubDate>
      <guid isPermaLink="false">urn:uuid:c260bf98-fcba-48d9-b24c-5c49819a2018</guid>
      <comments>http://matthewfawcett.co.uk/2009/06/27/s3ify-gem-put-the-assets-for-a-html-email-online#comments</comments>
      <category>s3ify</category>
      <category>ryby</category>
      <category>gems</category>
      <category>rubygems</category>
      <category>html</category>
      <category>email</category>
      <trackback:ping>http://matthewfawcett.co.uk/trackbacks?article_id=9</trackback:ping>
      <link>http://matthewfawcett.co.uk/2009/06/27/s3ify-gem-put-the-assets-for-a-html-email-online</link>
    </item>
  </channel>
</rss>

