Module: Octopress::Social::Email
Defined Under Namespace
Classes: Tag
Constant Summary collapse
- DEFAULTS =
{ 'share_subject' => ':title by :author', 'share_message' => ':title by :author - :url', 'share_link_text' => 'Email', 'share_link_title' => 'Share via email', 'contact_link_text' => 'Email :author', 'contact_link_title' => 'Email :author', 'address' => nil }
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
-
#url ⇒ Object
Returns the value of attribute url.
Instance Method Summary collapse
- #author(item = {}) ⇒ Object
- #contact_link_text(item) ⇒ Object
- #contact_link_title(item) ⇒ Object
- #email_contact_link(site, item) ⇒ Object
- #email_share_link(site, item) ⇒ Object
- #message(site, item) ⇒ Object
- #set_config(site) ⇒ Object
- #set_url(site, item) ⇒ Object
- #subject(site, item) ⇒ Object
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
7 8 9 |
# File 'lib/octopress-social/email.rb', line 7 def config @config end |
#url ⇒ Object
Returns the value of attribute url.
7 8 9 |
# File 'lib/octopress-social/email.rb', line 7 def url @url end |
Instance Method Details
#author(item = {}) ⇒ Object
42 43 44 |
# File 'lib/octopress-social/email.rb', line 42 def (item={}) item['author'] || item['site']['author'] || '' end |
#contact_link_text(item) ⇒ Object
30 31 32 |
# File 'lib/octopress-social/email.rb', line 30 def contact_link_text(item) config['contact_link_text'].sub(':author', (item)) end |
#contact_link_title(item) ⇒ Object
34 35 36 |
# File 'lib/octopress-social/email.rb', line 34 def contact_link_title(item) config['contact_link_title'].sub(':author', (item)) end |
#email_contact_link(site, item) ⇒ Object
71 72 73 74 75 76 |
# File 'lib/octopress-social/email.rb', line 71 def email_contact_link(site, item) %Q{<a class="email-contact-link" href="mailto:#{config['address']}" title="#{contact_link_title(item)}">#{contact_link_text(item)}</a>} end |
#email_share_link(site, item) ⇒ Object
65 66 67 68 69 |
# File 'lib/octopress-social/email.rb', line 65 def email_share_link(site, item) %Q{<a class="email-share-link" href="mailto:?subject=#{subject(site, item)}&body=#{(site, item)}" title="#{config['share_link_title']}">#{config['share_link_text']}</a>} end |
#message(site, item) ⇒ Object
55 56 57 58 59 60 61 62 63 |
# File 'lib/octopress-social/email.rb', line 55 def (site, item) name = (item) = (name.empty? ? 'by :author' : ':author') ERB::Util.url_encode (item['email_share_message'] || config['share_message']) .sub(':title', item['title'] || '') .sub(, name) .sub(':url', url) .strip end |
#set_config(site) ⇒ Object
19 20 21 22 23 24 25 26 27 28 |
# File 'lib/octopress-social/email.rb', line 19 def set_config(site) @config ||= begin config = site['octopress_social'] || site if config['email'] && config['email'].is_a?(String) && config['email'].include?('@') DEFAULTS.merge({'address' => config['email']} || {}) else DEFAULTS.merge(config['email'] || {}) end end end |
#set_url(site, item) ⇒ Object
38 39 40 |
# File 'lib/octopress-social/email.rb', line 38 def set_url(site, item) @url = Social.full_url(site, item) end |
#subject(site, item) ⇒ Object
46 47 48 49 50 51 52 53 |
# File 'lib/octopress-social/email.rb', line 46 def subject(site, item) name = (item) = (name.empty? ? 'by :author' : ':author') ERB::Util.url_encode (item['email_share_subject'] || config['share_subject']) .sub(':title', item['title'] || '') .sub(, name) .strip end |