I recently did a one pager called emoji-cheat-sheet.com. The background to why I made this site is pretty simple, I like those little emoji emoticons. Both 37signals Campfire and GitHub supports emojis by using a syntax like
:cake: which will generate a . The problem is that there are quite a few emojis that you can use on these services and they support a different set of emoticons.
I created a little cheat sheet that just lists which ones are supported on each service and put it online if someone else would be interested in it. If you got flash enabled you can just click the emoji code and it will be copied to your clipboard using zClip.
As someone who usually writes ruby all day it’s a pretty fun to do a small project where you are forced to think a bit about and try to do the web design for a site.
S3 for hosting
As emoji-cheat-sheet.com is just a static site I decided to try out using Amazon’s S3 for hosting it. There was basically two tiny issues I encountered:
- You can’t use naked domains S3 only works with CNAME records and I had to add a redirect for http://emoji-cheat-sheet.com that goes to http://www.emoji-cheat-sheet.com.
- S3 defaults some files to
binary/octet-streamIf a browser get this mime-type for a file it expects it to be a binary file that should be downloaded to disk.
How to do the S3 setup
Log into your AWS account and create a bucket that has the the same name as the domain your want to host on S3. The domain must include a ”www.” or be a subdomain. Select your newly created bucket and click ”Properties” in the ”Action” popup menu. Choose the ”Website” tab, enable it and enter ”index.html” as the index document filename. Copy the the endpoint url and create a CNAME record for your domain that points to the endpoint. Now you just need to upload the files to the bucket.
Making it easy to deploy with ruby
I did some quick googling trying to find a simple automated solution for uploading and minimizing files to S3 for sites like this but I didn’t really find any solution. I ended up hacking together a little rake task using the excellent fog gem for S3 interaction, detecting mime types with the old mime-types gem and minimizing the css and js with yuicompressor (you can install it using homebrew these days).
The rake task:
You can checkout the source code for this on GitHub. It’s pretty basic stuff that has room for improvements and tests, but it makes deploying a static site like emoji-cheat-sheet.com to S3 much easier.
I think S3 is a pretty neat solution for hosting static sites, I like how easy it is to specify http headers for files and setting up a new site. The only downside is that it isn’t super fast, but that is easy to fix by creating a CloudFront distribution that uses the S3 bucket as origin and pointing your domain the CloudFront distribution instead.