Last active
August 29, 2015 13:57
-
-
Save mgroebner/9913865 to your computer and use it in GitHub Desktop.
Tickaroo Button Integration (Ruby)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ApplicationHelper | |
def tickaroo_button(opts) | |
opts[:button_type] ||= :default | |
sig = TikButtonSignature.new.signature(opts) | |
s = "" | |
s += "width='#{opts[:width]}' " if opts[:width].present? | |
s += "height='#{opts[:height]}' " if opts[:height].present? | |
s += "lang='#{opts[:lang]}' " if opts[:lang].present? | |
s += "data-title='#{opts[title]}' " if opts[:title].present? | |
s += "data-home-team='#{opts[:home_team]}' " if opts[:home_team].present? | |
s += "data-away-team='#{opts[:away_team]}' " if opts[:away_team].present? | |
s += "data-starts-at='#{opts[:starts_at]}' " if opts[:starts_at].present? | |
s += "data-tournament='#{opts[:tournament]}' " if opts[:tournament].present? | |
s += "data-sportstype='#{opts[:sportstype]}' " if opts[:sportstype].present? | |
s += "data-lanme='#{opts[:lanme]}' " if opts[:lanme].present? | |
s += "data-laddress='#{opts[:laddress]}' " if opts[:laddress].present? | |
s += "data-lcity='#{opts[:lcity]}' " if opts[:lcity].present? | |
s += "data-lzip='#{opts[:lzip]}' " if opts[:lzip].present? | |
s += "data-external-id='#{opts[:external_id]}' " if opts[:external_id].present? | |
s += "data-auth-token='#{opts[:auth_token]}' " if opts[:auth_token].present? | |
s += "data-auth-signature='#{sig}'" | |
if opts[:button_type] == :score | |
"<a class='tickaroo-score-button' #{s}></a>".html_safe | |
else | |
"<a class='tickaroo-button' #{s}></a>".html_safe | |
end | |
end | |
end | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
... | |
<%= tickaroo_button(:width => '120', :height => '32', :home_team => "FC Bayern", :away_team => "Dortmund", :starts_at => "#{(Time.now+2.weeks).to_i}", :sportstype => "soccer", :external_id => "123") %> | |
... | |
<script>(function(e,j,i,h,f,c,b){e[f]=e[f]||function(){(e[f].q=e[f].q||[]).push(arguments)},e[f].l=1*new Date();c=j.createElement(i),b=j.getElementsByTagName(i)[0];c.async=1;c.src=h;b.parentNode.insertBefore(c,b)})(window,document,"script","//widgets.tickaroo.com/widgets/tickaroo-button.js","_tbq");_tbq("load");</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment