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.
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 Nokogiri to parse the HTML (so you will need a recent version of libxml) and the aws-s3 gem to upload everything to S3. I used the commander gem to create a command line interface to use it.
So first, get it installed
sudo gem install mattfawcett-s3ify
You will need to have your Amazon web services access information set in your path, if you don’t have this already, your best bet is to create a hidden file in your home directory called .amazon_keys with the contents
export AMAZON_ACCESS_KEY_ID='abcdefghijklmnop' export AMAZON_SECRET_ACCESS_KEY='1234567891012345'
then add the following to your shell’s rc file (usually .bashrc)
if [[ -f "$HOME/.amazon_keys" ]]; then source "$HOME/.amazon_keys"; fi
Then to use it simply open up a shell and type
s3ify -b my_bucket -p my_folder_in_bucket ~/Desktop/my-email/
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 “_s3” which will have the image references pointing to S3.
The code is on Github
For the last few weeks Iv been working on a new website in my spare time. Its now live and is at runslikeclockwork.com. Its a server monitoring tool where you add your sites and you will get an SMS alert when a site goes down / comes back up again.
Its slightly different from most other services because it checks the rendered HTML of a page for a keyword or phrase specific to that site. This covers you when you misconfigure an Apache/Nginx Virtualhost which can sometimes leave you with the wrong site being served on a domain, but of course the server is still giving out 200 status headers.
At the moment its very simple but I am planning on adding some more features over the next few weeks.