Module: Exvo::ViewHelpers
- Defined in:
- lib/exvo_helpers/view_helpers.rb
Instance Method Summary collapse
- #bugherd(apikey) ⇒ Object
- #google_analytics(account, opts = {}) ⇒ Object
-
#javascript_bundle_include_tag(bundle) ⇒ Object
Returns
javascript_include_tagwith link to js bundles (based on env). - #kissmetrics ⇒ Object
-
#themes_image_tag(path, options = {}) ⇒ Object
Returns
image_tagwith link to image on themes (based on env). -
#themes_stylesheet_link_tag(path, options = {}) ⇒ Object
Returns
stylesheet_link_tagwith link to css on themes (based on env).
Instance Method Details
#bugherd(apikey) ⇒ Object
108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
# File 'lib/exvo_helpers/view_helpers.rb', line 108 def bugherd(apikey) out = "<script type='text/javascript'>\n(function (d, t) {\n var bh = d.createElement(t), s = d.getElementsByTagName(t)[0];\n bh.type = 'text/javascript';\n bh.src = '//www.bugherd.com/sidebarv2.js?apikey=\#{ apikey }';\n s.parentNode.insertBefore(bh, s);\n })(document, 'script');\n</script>\n" out.respond_to?(:html_safe) ? out.html_safe : out end |
#google_analytics(account, opts = {}) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 |
# File 'lib/exvo_helpers/view_helpers.rb', line 28 def google_analytics(account, opts = {}) domain = opts.delete(:domain) track_hash_changes = opts.delete(:track_hash_changes) out = "<script type=\"text/javascript\">\n var _gaq = _gaq || [];\n _gaq.push(['_setAccount', '\#{account}']);\n" if domain out += " _gaq.push(['_setDomainName', '\#{domain}']);\n" end out += " _gaq.push(['_setAllowLinker', true]);\n _gaq.push(['_trackPageview']);\n\n (function() {\nvar ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;\nga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';\nvar s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);\n })();\n" if track_hash_changes out += "\n var current_location_hash = window.location.hash;\n var update_hash = function() {\nif (current_location_hash != window.location.hash) {\n current_location_hash = window.location.hash;\n _gaq.push(['_trackPageview', current_location_hash]);\n}\n }\n setInterval(update_hash, 500);\n" end out += "</script>\n" if Exvo::Helpers.env.to_sym == :production out.respond_to?(:html_safe) ? out.html_safe : out end end |
#javascript_bundle_include_tag(bundle) ⇒ Object
Returns javascript_include_tag with link to js bundles (based on env)
6 7 8 9 10 11 12 13 |
# File 'lib/exvo_helpers/view_helpers.rb', line 6 def javascript_bundle_include_tag(bundle) case Exvo::Helpers.env.to_sym when :production, :staging javascript_include_tag "#{Exvo::Helpers.cdn_uri}/javascripts/#{bundle}.js" else javascript_include_tag "#{Exvo::Helpers.cdn_uri}/javascripts/bundles/#{bundle}.js" end end |
#kissmetrics ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 |
# File 'lib/exvo_helpers/view_helpers.rb', line 78 def kissmetrics out = "<script type=\"text/javascript\">\n var _kmq = _kmq || [];\n function _kms(u) {\nsetTimeout(function() {\n var s = document.createElement('script');\n var f = document.getElementsByTagName('script')[0];\n s.type = 'text/javascript';\n s.async = true;\n s.src = u;\n f.parentNode.insertBefore(s, f);\n}, 1);\n }\n _kms('//i.kissmetrics.com/i.js');\n _kms('//doug1izaerwt3.cloudfront.net/\#{ENV['KISSMETRICS_KEY']}.1.js');\n" if current_user && current_user.email out += " _kmq.push(['identify', '\#{current_user.email}']);\n" end out += "</script>\n" out.respond_to?(:html_safe) ? out.html_safe : out end |
#themes_image_tag(path, options = {}) ⇒ Object
Returns image_tag with link to image on themes (based on env)
23 24 25 26 |
# File 'lib/exvo_helpers/view_helpers.rb', line 23 def themes_image_tag(path, = {}) path = '/' + path unless path.start_with?('/') image_tag(Exvo::Helpers.themes_uri + '/stylesheets/images' + path, ) end |
#themes_stylesheet_link_tag(path, options = {}) ⇒ Object
Returns stylesheet_link_tag with link to css on themes (based on env)
16 17 18 19 20 |
# File 'lib/exvo_helpers/view_helpers.rb', line 16 def themes_stylesheet_link_tag(path, = {}) path = '/' + path unless path.start_with?('/') path = path + '.css' unless path.end_with?('.css') stylesheet_link_tag(Exvo::Helpers.themes_uri + '/stylesheets/themes' + path, ) end |