Module: Facilbook::ApplicationHelperMethods
- Defined in:
- lib/facilbook.rb
Instance Method Summary collapse
- #facebook_image_tag(uid, options = {}) ⇒ Object
- #link_to_facebook(*args, &block) ⇒ Object
- #url_for_facebook(path) ⇒ Object
Instance Method Details
#facebook_image_tag(uid, options = {}) ⇒ Object
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/facilbook.rb', line 26 def facebook_image_tag(uid, = {}) .symbolize_keys! image_url = "https://graph.facebook.com/#{uid}/picture" if [:type] && (['square','small','large'].include? [:type]) image_url << "?type=#{type}" end src = image_url [:src] = src unless src =~ /^cid:/ [:alt] = .fetch(:alt){ File.basename(src, '.*').capitalize } end if size = .delete(:size) [:width], [:height] = size.split("x") if size =~ %{^\d+x\d+$} end tag("img", ) end |
#link_to_facebook(*args, &block) ⇒ Object
45 46 47 48 49 50 51 52 53 |
# File 'lib/facilbook.rb', line 45 def link_to_facebook(*args, &block) = args..symbolize_keys # logger.debug "OPTIONS: #{html_options.inspect}" name = args[0] path = block_given? ? update_page(&block) : args[1] || '' tag_class = [:class] ||= '' onclick = "window.top.location='#{FACILBOOK_CONFIG[:facebook_app_url]}#{path}'; return false;" content_tag(:a, name, .merge(:href => '#', :onclick => onclick, :class => tag_class)) end |
#url_for_facebook(path) ⇒ Object
55 56 57 |
# File 'lib/facilbook.rb', line 55 def url_for_facebook(path) "#{FACILBOOK_CONFIG[:facebook_app_url]}#{path}" end |