Module: YouthTree::Helpers::EmbedHelper

Defined in:
lib/youth_tree/helpers/embed_helper.rb

Instance Method Summary collapse

Instance Method Details

#has_share_this_jsObject

Share this embed js



25
26
27
28
29
30
# File 'lib/youth_tree/helpers/embed_helper.rb', line 25

def has_share_this_js
  if Settings.share_this.publisher?
    has_js "http://w.sharethis.com/button/sharethis.js#publisher=#{Settings.share_this.publisher}&type=website&button=false"
    has_jammit_js :share_this
  end
end

Link to share something.



33
34
35
36
37
38
39
# File 'lib/youth_tree/helpers/embed_helper.rb', line 33

def share_this_link(text, options = {})
  target = options.delete(:for)
  options.stringify_keys!
  options["data-share-this-target"] = target.to_s if target
  options[:class] = [options[:class], 'share-this'].join(" ").squeeze(" ")
  link_to(text, '#', options)
end

Links with added hinting to make them useful for social networking buttons.



6
7
8
# File 'lib/youth_tree/helpers/embed_helper.rb', line 6

def social_media_link(name, text, link)
  link_to text.html_safe, link, :title => text, :class => "social-media-link #{name.to_s.dasherize}"
end

Embed a sponsor logo



42
43
44
# File 'lib/youth_tree/helpers/embed_helper.rb', line 42

def sponsor_link(name, url)
  link_to image_tag("sponsors/#{name.underscore.gsub(/[\ \_]+/, "-")}-logo.jpg"), url, :title => name, :class => 'sponsor'
end

#youtube_video(video_id, opts = {}) ⇒ Object

YouTube Video Embed.



11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/youth_tree/helpers/embed_helper.rb', line 11

def youtube_video(video_id, opts = {})
  options = {:height => 360, :width => 480, :color1 => 'AAAAAA', :color2 => '999999'}.merge(opts)
  video_url = "http://www.youtube-nocookie.com/v/#{video_id}?hl=en_US&fs=1&rel=0&color1=0x#{options[:color1]}&color2=0x#{options[:color2]}"
  inner = ActiveSupport::SafeBuffer.new.tap do |i|
    i << tag(:param, :name => "movie", :value => video_url)
    i << tag(:param, :name => "allowFullScreen", :value => "true")
    i << tag(:param, :name => "allowscriptaccess", :value => "always")
    i << tag(:embed, :src => video_url, :height => options[:height], :width => options[:width], :allowfullscreen => "true",
      :type => "application/x-shockwave-flash", :allowscriptaccess => "always")
  end
  (:object, inner, :height => options[:height], :width => options[:width])
end