Sha256: d0b22c6d184a84ccdab1616e9f48f1d342a189484a615a758bb6949f763f7dd1

Contents?: true

Size: 1.62 KB

Versions: 9

Compression:

Stored size: 1.62 KB

Contents

# -*- encoding : utf-8 -*-
class Card; module Set; class All
# Set: All cards (GoogleAnalytics)
#
module GoogleAnalytics;
extend Card::Set
def self.source_location; "/Users/ethan/dev/decko/gem/card/mod/google_analytics/set/all/google_analytics.rb"; end

module HtmlFormat; parent.send :register_set_format, Card::Format::HtmlFormat, self; extend Card::Set::AbstractFormat
  def views_in_head
    super << :google_analytics_snippet
  end

  view :google_analytics_snippet, unknown: true, perms: :none do
    return unless google_analytics_key
    javascript_tag { google_analytics_snippet_javascript }
  end

  def google_analytics_key
    @google_analytics_key ||= Card.global_setting :google_analytics_key
  end

  def google_analytics_snippet_vars
    [[:_setAccount, google_analytics_key],
     [:_trackPageview]]
  end

  def google_analytics_snippet_vars_string
    google_analytics_snippet_vars.map do |array|
      <<-JAVASCRIPT
      _gaq.push([#{array.map { |i| "'#{i}'" }.join ', '}]);
      JAVASCRIPT
    end.join
  end

  def google_analytics_snippet_javascript
    <<-JAVASCRIPT
      var _gaq = _gaq || [];#{"\n" + google_analytics_snippet_vars_string}
      (function() {
        var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
        ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
        var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
      })();
    JAVASCRIPT
  end
end
end;end;end;end;
# ~~ generated from /Users/ethan/dev/decko/gem/card/mod/google_analytics/set/all/google_analytics.rb ~~

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
card-1.99.4 tmpsets/set/mod027-google_analytics/all/google_analytics.rb
card-1.99.3 tmpsets/set/mod027-google_analytics/all/google_analytics.rb
card-1.99.2 tmpsets/set/mod027-google_analytics/all/google_analytics.rb
card-1.99.1 tmpsets/set/mod027-google_analytics/all/google_analytics.rb
card-1.99.0 tmpsets/set/mod027-google_analytics/all/google_analytics.rb
card-1.98.3 tmpsets/set/mod027-google_analytics/all/google_analytics.rb
card-1.98.2 tmpsets/set/mod027-google_analytics/all/google_analytics.rb
card-1.98.1 tmpsets/set/mod027-google_analytics/all/google_analytics.rb
card-1.98.0 tmpsets/set/mod027-google_analytics/all/google_analytics.rb