Module: SocialIcons::ViewHelpers
- Defined in:
- lib/social_icons/view_helpers.rb
Constant Summary collapse
{ :icon_set => 'default' }
Instance Method Summary collapse
- #facebook_like_button(opts = {}) ⇒ Object
- #print_social_icons(opts = {}) ⇒ Object
-
#social_icon_delicious(opts) ⇒ Object
<a href=“delicious.com/save?url=<?php urlencode(the_permalink()); ?>&title=<?php urlencode(the_title()); ?>” onclick=“window.open(‘delicious.com/save?v=5&noui&jump=close&url=<?php urlencode(the_permalink()); ?>&title=<?php urlencode(the_title()); ?>’, ‘delicious’, ‘toolbar=no,width=550,height=550’); return false;” title=“Bookmark this post on del.icio.us”> </a>.
-
#social_icon_digg(opts) ⇒ Object
<a title=“Digg this post” href=“digg.com/submit?phase=2&url=http%3A%2F%2Fwww.weddingbee.com%2F2009%2F03%2F11%2Fadd-share-icons-for-social-media%2F” rel=“nofollow” target=“_blank”><img alt=“Digg this post” src=“” style=“border: medium none ;”></a>.
-
#social_icon_facebook(opts = {}) ⇒ Object
<a name=“fb_share” type=“button_count” share_url=“google.com” href=“www.facebook.com/sharer.php”>Share</a><script src=“static.ak.fbcdn.net/connect.php/js/FB.Share” type=“text/javascript”></script>.
-
#social_icon_reddit(opts) ⇒ Object
<a href=“reddit.com/submit?url=<?php the_permalink(); ?>” rel=“nofollow” title=“Submit to Reddit” target=“_blank”> </a>.
-
#social_icon_twitter(opts = {}) ⇒ Object
<a title=“Click to share this post on Twitter” href=“twitter.com/home?status=Currently reading <?php the_permalink(); ?>” target=“_blank” class=“twitter”>Share on Twitter</a>.
Instance Method Details
#facebook_like_button(opts = {}) ⇒ Object
30 31 32 33 34 |
# File 'lib/social_icons/view_helpers.rb', line 30 def (opts = {}) url = opts[:link] out = '<iframe src="http://www.facebook.com/plugins/like.php?href=' + url + '&layout=standard&show_faces=true&width=272&action=like&colorscheme=light&height=80" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:272px; height:80px;" allowTransparency="true"></iframe>' out end |
#print_social_icons(opts = {}) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/social_icons/view_helpers.rb', line 11 def (opts = {}) link = "http://" + request.env["HTTP_HOST"] + request.request_uri default_opts = {:size => 48, :link => link, :title => "", :icon_set => "default"} opts = default_opts.merge(opts) opts[:icon_path] = "social_icons/#{opts[:icon_set]}/#{opts[:size]}" out = "" out << "<div class=\"social_icons_container\">" out << "<div class=\"facebook_like_button\">#{(opts)}</div>" out << "<div class=\"social_icons\">" out << "<span class=\"social_icon_twitter\">#{(opts)}</span>" out << "<span class=\"social_icon_facebook\">#{(opts)}</span>" out << "<span class=\"social_icon_delicious\">#{(opts)}</span>" out << "<span class=\"social_icon_digg\">#{(opts)}</span>" out << "<span class=\"social_icon_reddit\">#{(opts)}</span>" out << "</div>" out << "</div>" out end |
#social_icon_delicious(opts) ⇒ Object
<a href=“delicious.com/save?url=<?php urlencode(the_permalink()); ?>&title=<?php urlencode(the_title()); ?>” onclick=“window.open(‘delicious.com/save?v=5&noui&jump=close&url=<?php urlencode(the_permalink()); ?>&title=<?php urlencode(the_title()); ?>’, ‘delicious’, ‘toolbar=no,width=550,height=550’); return false;” title=“Bookmark this post on del.icio.us”> </a>
79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/social_icons/view_helpers.rb', line 79 def (opts) icon_label = t("social_icons.delicious") default_opts = {:title => "", :desc => "", :link => ""} opts = default_opts.merge(opts) out = '<a href="http://delicious.com/save?url=' + opts[:link] + '&title=' + opts[:title] + '" onclick="' + "window.open('http://delicious.com/save?v=5&noui&jump=close&url=" + opts[:link] + '&title=' + opts[:title] + "', 'delicious', 'toolbar=no,width=550,height=550'); return false;\" title=\"" + "Bookmark this post on del.icio.us" + '"> ' + image_tag("#{opts[:icon_path]}/delicious.png", :alt => icon_label, :title => icon_label) + '</a>' end |
#social_icon_digg(opts) ⇒ Object
<a title=“Digg this post” href=“digg.com/submit?phase=2&url=http%3A%2F%2Fwww.weddingbee.com%2F2009%2F03%2F11%2Fadd-share-icons-for-social-media%2F” rel=“nofollow” target=“_blank”><img alt=“Digg this post” src=“” style=“border: medium none ;”></a>
63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/social_icons/view_helpers.rb', line 63 def (opts) icon_label = t("social_icons.digg") default_opts = {:title => "", :desc => "", :link => ""} opts = default_opts.merge(opts) out = '<a title="' + icon_label + '" href="http://digg.com/submit?phase=2&url=' + opts[:link] + '&title=' + opts[:title] + '" rel="nofollow" target="_blank">' + image_tag("#{opts[:icon_path]}/digg.png", :alt => icon_label, :title => icon_label) + '</a>' end |
#social_icon_facebook(opts = {}) ⇒ Object
<a name=“fb_share” type=“button_count” share_url=“google.com” href=“www.facebook.com/sharer.php”>Share</a><script src=“static.ak.fbcdn.net/connect.php/js/FB.Share” type=“text/javascript”></script>
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/social_icons/view_helpers.rb', line 46 def (opts = {}) default_opts = {:title => "", :desc => "", :link => ""} opts = default_opts.merge(opts) link = "http://www.facebook.com/sharer.php?u=" + CGI.unescape(opts[:link]) + "&t=#{opts[:title]}" out = "<a onclick=\"window.open('#{link}'" + ",'sharer','toolbar=0,status=0,width=626,height=436');return false;\"" + '" href="' + link + '">' + image_tag("#{opts[:icon_path]}/facebook.png", :alt => t("social_icons.facebook"), :title => t("social_icons.facebook")) + '</a>' out end |
#social_icon_reddit(opts) ⇒ Object
<a href=“reddit.com/submit?url=<?php the_permalink(); ?>” rel=“nofollow” title=“Submit to Reddit” target=“_blank”> </a>
100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/social_icons/view_helpers.rb', line 100 def (opts) icon_label = t("social_icons.reddit") default_opts = {:title => "", :desc => "", :link => ""} opts = default_opts.merge(opts) out = '<a href="http://reddit.com/submit?url=' + opts[:link] + '&title=' + opts[:title] + '" rel="nofollow" title="' + opts[:title] + '" target="_blank">' + image_tag("#{opts[:icon_path]}/reddit.png", :alt => icon_label, :title => icon_label) + '</a>' end |
#social_icon_twitter(opts = {}) ⇒ Object
<a title=“Click to share this post on Twitter”
href="http://twitter.com/home?status=Currently reading <?php the_permalink(); ?>" target="_blank" class="twitter">Share on Twitter</a>
39 40 41 42 43 |
# File 'lib/social_icons/view_helpers.rb', line 39 def (opts = {}) url = "http://twitter.com/home?status=#{opts[:title]}+#{opts[:link]}" out = link_to(image_tag("#{opts[:icon_path]}/twitter.png", :alt => t('social_icons.twitter')), url, :title => t('social_icons.twitter'), :target => "_blank") out end |