module Exvo module ViewHelpers # Returns `javascript_include_tag` with link to js bundles (based on env) 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 # Returns `stylesheet_link_tag` with link to css on themes (based on env) def themes_stylesheet_link_tag(path, options = {}) path = '/' + path unless path.start_with?('/') path = path + '.css' unless path.end_with?('.css') stylesheet_link_tag(Exvo::Helpers.themes_uri + '/stylesheets/themes' + path, options) end # Returns `image_tag` with link to image on themes (based on env) def themes_image_tag(path, options = {}) path = '/' + path unless path.start_with?('/') image_tag(Exvo::Helpers.themes_uri + '/stylesheets/images' + path, options) end def google_analytics(account, opts = {}) domain = opts.delete(:domain) track_hash_changes = opts.delete(:track_hash_changes) out = < var _gaq = _gaq || []; _gaq.push(['_setAccount', '#{account}']); END if domain out += < END if Exvo::Helpers.env.to_sym == :production out.respond_to?(:html_safe) ? out.html_safe : out end end def kissmetrics out = < var _kmq = _kmq || []; function _kms(u) { setTimeout(function() { var s = document.createElement('script'); var f = document.getElementsByTagName('script')[0]; s.type = 'text/javascript'; s.async = true; s.src = u; f.parentNode.insertBefore(s, f); }, 1); } _kms('//i.kissmetrics.com/i.js'); _kms('//doug1izaerwt3.cloudfront.net/#{ENV['KISSMETRICS_KEY']}.1.js'); END if current_user && current_user.email out += < END out.respond_to?(:html_safe) ? out.html_safe : out end end end