Skip to content

Instantly share code, notes, and snippets.

@joelturnbull
Created July 9, 2012 03:54
Show Gist options
  • Save joelturnbull/3074150 to your computer and use it in GitHub Desktop.
Save joelturnbull/3074150 to your computer and use it in GitHub Desktop.
Adding a Share by Email Button to Your Tumblr Posts
require 'open-uri'
def main
image_url = "https://s3.amazonaws.com/gaslight-blog/email_button.png"
subject = "{Title}"
body = <<-eos
Check out this article...
{Title} <{ShortURL}>
eos
puts "<a href='mailto: ?subject=#{subject}&body=#{encode(body)}'><img src='#{image_url}'></a>"
end
def encode(string)
string = URI::encode(string)
string.gsub!('%7B','{')
string.gsub!('%7D','}')
string
end
main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment