Created
April 24, 2012 22:26
-
-
Save tuzz/2484316 to your computer and use it in GitHub Desktop.
Generate an Unboxed email signature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Run this: ruby <(curl --silent https://raw.github.com/gist/2484316/signature.rb) | |
require 'erb' | |
def format_phone_number(string) | |
string.gsub!(/^0/, '+44') | |
string.gsub!(/(...)(..)(....)(....)/, '\1 \2 \3 \4') | |
end | |
def blank?(string) | |
string.to_s.scan(/[^\s]/).empty? | |
end | |
print 'Full name: ' | |
name = gets.strip | |
print 'Mobile: ' | |
mobile = format_phone_number(gets.strip) | |
print 'Phone (optional): ' | |
phone = format_phone_number(gets.strip) | |
phone = mobile if blank?(phone) | |
print 'Fax (optional): ' | |
fax = format_phone_number(gets.strip) | |
fax = mobile if blank?(fax) | |
email = name.split.join('.').downcase + '@unboxedconsulting.com' | |
template = ERB.new <<-HTML | |
<table cellpadding="0" cellspacing="0" border="0" style="width: 98%; margin-top: 10px; font-family: arial, sans;"><tbody><tr><td style="border-bottom: solid 1px black; font-size: 20px; line-height: 28px; font-family: Trebuchet MS, arial, sans" valign="bottom"> | |
<%= name %> | |
</td><td style="border-bottom: solid 1px black;" align="right"><table width="145px" border="0" cellpadding="0" cellspacing="0" style="width: 145px;" align="right"><tbody><tr><td style="font-family: Trebuchet MS, arial, sans; font-weight: bold; font-size: 35px; color: #000000; letter-spacing: -1px; height: 27px; line-height: 27px;" height="27px" valign="top" align="right">Unboxed</td></tr><tr><td style="font-family: Trebuchet MS, arial, sans; font-weight: bold; font-size: 30px; color: #92278F; letter-spacing: -1px; height: 42px; line-height: 27px;" height="42px;" valign="top" align="right">Consulting</td></tr></tbody></table></td></tr><tr><td align="left" valign="top" style="border-top: solid 4px white;"><table cellpadding="0" cellspacing="0" border="0" style="font-size: 12px; font-family: arial;" align="left"><tbody> | |
<tr><td style="width: 16px; color: #92278F;">E:</td><td><a href="mailto:<%= email%>" style="color: black; text-decoration: none;"><%= email %></a></td></tr> | |
<tr><td style="width: 16px; color: #92278F;">M:</td><td><%= mobile %></td></tr> | |
<tr><td style="width: 16px; color: #92278F;">T:</td><td><%= phone %></td></tr> | |
<tr><td style="width: 16px; color: #92278F;">F:</td><td><%= fax %></td></tr> | |
</tbody></table></td><td align="right" style="font-size: 12px; font-family: arial; border-top: solid 4px white;" valign="top"><table cellpadding="0" cellspacing="0" border="0" style="font-size: 12px; font-family: arial;" align="right"><tbody><tr><td align="right">17 Blossom Street</td></tr><tr><td align="right">London, E1 6PL</td></tr><tr><td align="right">United Kingdom</td></tr><tr><td align="right"><a style="color: #92278F; text-decoration: none;" href="http://www.unboxedconsulting.com">www.unboxedconsulting.com</a></td></tr></tbody></table></td></tr></tbody></table> | |
HTML | |
File.open('/tmp/signature.html', 'w') { |f| f.puts template.result(binding) } | |
`open /tmp/signature.html` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment