Module: SocialEngineHelper

Defined in:
app/helpers/social_engine_helper.rb

Instance Method Summary collapse

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,*options)
  options = options.to_options_hash
  defaults = get_defaults(:comment_form)
  options.optional_reverse_merge!(defaults, [:comment])
  render "comments/form", commentable: commentable, comment: Comment.new, options: 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, options={})
  defaults = get_defaults(:comment_list)
  options.reverse_merge!(defaults)
  comments = commentable.comments.order("id #{options[:order]}")
  comments = comments.limit(options[:display_limit]) if options[:display_limit].is_a? Fixnum
  render "comments/list", commentable: commentable, options: 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 favorites_widget(favoriteable,options={})
  if current_user
    defaults = get_defaults(:favorites_widget)
    options.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: 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(options={})
  defaults = get_defaults(:fb_friend_box)            
  options.reverse_merge!(defaults)
  render "third_party/fb_friend_box", options: 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(options={})
  defaults = get_defaults(:fb_javascript_sdk)
  options.reverse_merge!(defaults)
  render "third_party/fb_javascript_sdk", options: options
end

#fb_like(options = {}) ⇒ Object



8
9
10
11
12
13
# File 'app/helpers/social_engine_helper.rb', line 8

def fb_like(options={})
  defaults = get_defaults(:fb_like)
  options.reverse_merge!(defaults)
  options.reverse_merge!(:url=>request.url)
  render "third_party/fblike", options: options
end

#fb_og_tags(options = {}) ⇒ Object



21
22
23
24
25
# File 'app/helpers/social_engine_helper.rb', line 21

def fb_og_tags(options={})
  defaults = get_defaults(:fb_og_tags)
  options.reverse_merge!(defaults)
  render "third_party/fb_og_tags", options: 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 rating_form(rateable,options={})
  defaults = get_defaults(:rating_form)
  options.reverse_merge!(defaults)
  render "ratings/form",  rateable: rateable, rating: Rating.new, options: options
end

#tweetme(options = {}) ⇒ Object



2
3
4
5
6
# File 'app/helpers/social_engine_helper.rb', line 2

def tweetme(options={})
  defaults = {count: SocialEngineYetting.tweetme["count"], url: request.url, div_class: SocialEngineYetting.tweetme["div_class"]}
  options.reverse_merge!(defaults)
  render "third_party/tweetme", options: options
end

#vote_widget(voteable, options = {}) ⇒ Object



57
58
59
60
61
# File 'app/helpers/social_engine_helper.rb', line 57

def vote_widget(voteable,options={})
  defaults = get_defaults(:vote_widget)
  options.reverse_merge!(defaults)
  render "votes/widget", voteable: voteable, options: options
end