Module: SocialEngineHelper
- Defined in:
- app/helpers/social_engine_helper.rb
Instance Method Summary collapse
- #comment_form(commentable, *options) ⇒ Object
- #comments_list(commentable, options = {}) ⇒ Object
- #div_id(klass) ⇒ Object
- #favorites_widget(favoriteable, options = {}) ⇒ Object
- #fb_friend_box(options = {}) ⇒ Object
- #fb_javascript_sdk(options = {}) ⇒ Object
- #fb_like(options = {}) ⇒ Object
- #fb_og_tags(options = {}) ⇒ Object
- #get_defaults(key) ⇒ Object
- #rating_form(rateable, options = {}) ⇒ Object
- #tweetme(options = {}) ⇒ Object
- #vote_widget(voteable, options = {}) ⇒ Object
Instance Method Details
#comment_form(commentable, *options) ⇒ Object
33 34 35 36 37 38 |
# File 'app/helpers/social_engine_helper.rb', line 33 def comment_form(commentable,*) = . defaults = get_defaults(:comment_form) .optional_reverse_merge!(defaults, [:comment]) render "comments/form", commentable: commentable, comment: Comment.new, options: end |
#comments_list(commentable, options = {}) ⇒ Object
40 41 42 43 44 45 46 |
# File 'app/helpers/social_engine_helper.rb', line 40 def comments_list(commentable, ={}) defaults = get_defaults(:comment_list) .reverse_merge!(defaults) comments = commentable.comments.order("id #{[:order]}") comments = comments.limit([:display_limit]) if [:display_limit].is_a? Fixnum render "comments/list", commentable: commentable, options: , comments: comments end |
#div_id(klass) ⇒ Object
79 80 81 |
# File 'app/helpers/social_engine_helper.rb', line 79 def div_id(klass) "se-#{klass.class.to_s.underscore.gsub('_','-')}#{klass.id}" end |
#favorites_widget(favoriteable, options = {}) ⇒ Object
48 49 50 51 52 53 54 55 |
# File 'app/helpers/social_engine_helper.rb', line 48 def (favoriteable,={}) if current_user defaults = get_defaults(:favorites_widget) .reverse_merge!(defaults) favorite = Favorite.where(favoriteable_type:favoriteable.class.to_s, favoriteable_id: favoriteable.id, user_id: current_user.id).first rescue Favorite.new render "favorites/widget", favoriteable: favoriteable, favorite: favorite, options: end end |
#fb_friend_box(options = {}) ⇒ Object
15 16 17 18 19 |
# File 'app/helpers/social_engine_helper.rb', line 15 def fb_friend_box(={}) defaults = get_defaults(:fb_friend_box) .reverse_merge!(defaults) render "third_party/fb_friend_box", options: end |
#fb_javascript_sdk(options = {}) ⇒ Object
27 28 29 30 31 |
# File 'app/helpers/social_engine_helper.rb', line 27 def fb_javascript_sdk(={}) defaults = get_defaults(:fb_javascript_sdk) .reverse_merge!(defaults) render "third_party/fb_javascript_sdk", options: end |
#fb_like(options = {}) ⇒ Object
8 9 10 11 12 13 |
# File 'app/helpers/social_engine_helper.rb', line 8 def fb_like(={}) defaults = get_defaults(:fb_like) .reverse_merge!(defaults) .reverse_merge!(:url=>request.url) render "third_party/fblike", options: end |
#fb_og_tags(options = {}) ⇒ Object
21 22 23 24 25 |
# File 'app/helpers/social_engine_helper.rb', line 21 def (={}) defaults = get_defaults(:fb_og_tags) .reverse_merge!(defaults) render "third_party/fb_og_tags", options: end |
#get_defaults(key) ⇒ Object
70 71 72 73 74 75 76 77 |
# File 'app/helpers/social_engine_helper.rb', line 70 def get_defaults(key) begin SocialEngineYetting.send(key).symbolize_keys! rescue puts "WARNING: Defaults not found for #{key} in SocialEngineYettings. This key is missing from config/yettings/social_engine.yml" return {} end end |
#rating_form(rateable, options = {}) ⇒ Object
64 65 66 67 68 |
# File 'app/helpers/social_engine_helper.rb', line 64 def (rateable,={}) defaults = get_defaults(:rating_form) .reverse_merge!(defaults) render "ratings/form", rateable: rateable, rating: Rating.new, options: end |
#tweetme(options = {}) ⇒ Object
2 3 4 5 6 |
# File 'app/helpers/social_engine_helper.rb', line 2 def tweetme(={}) defaults = {count: SocialEngineYetting.tweetme["count"], url: request.url, div_class: SocialEngineYetting.tweetme["div_class"]} .reverse_merge!(defaults) render "third_party/tweetme", options: end |
#vote_widget(voteable, options = {}) ⇒ Object
57 58 59 60 61 |
# File 'app/helpers/social_engine_helper.rb', line 57 def (voteable,={}) defaults = get_defaults(:vote_widget) .reverse_merge!(defaults) render "votes/widget", voteable: voteable, options: end |