jekyll-analytics 0.1.5 → 0.1.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: e77f50301b7e5c6574b6d2ed984e5ba312b15e13
4
- data.tar.gz: c3416cd45e26a60cfef1e371aec168d254f93e3b
2
+ SHA256:
3
+ metadata.gz: 8a2865fc5600cdc26b695b8ae043821b89fc8ecc251f98b95c89f36fb1d0ed70
4
+ data.tar.gz: 1d258967285ee8bcca489d7ffa75f04577b6aa49a8e4a398ae36457248375adf
5
5
  SHA512:
6
- metadata.gz: 019ae9eaa341d4c4df8bc97d6d71b88f0225b6e2dc986785ea9f1fbb05f98869ea7fd6b99e8c52d67d42a148e4d6e2509df86e50415bdadea94b5f77879b5d66
7
- data.tar.gz: fd84172210e04b583877c9eb0f95be76a979d64a1d3cf07b6a9bfd2bedd4f22f0720ee826062d7a06217b1d2c9b331923da49e697e4b60b0823cb1c820cdee71
6
+ metadata.gz: 2d83c8ca9fb85b779b6fdb6c56bddc6dde46fe9a5f621a36442c9d1329af9f4c547d8e86bd8d029bb760f59f9ff3f1d80d93b202c431214cf8326e6027dbc48b
7
+ data.tar.gz: 6855a893620afeb76c4698ee6d8bea2b0fe627389c42f812589d0a9d5f64f63493e95732b4dc876551b8b9efbce044e054ca34d8c6c5e62a75c6f66f21571b72
@@ -38,6 +38,6 @@ class GoogleAnalytics
38
38
  private
39
39
 
40
40
  def _get_other_commands(config)
41
- @commands.push(ANONYMIZE_IP_CODE % config.fetch(:anonymizeIp, false))
41
+ @commands.push(ANONYMIZE_IP_CODE % config.fetch("anonymizeIp", false))
42
42
  end
43
43
  end
@@ -0,0 +1,63 @@
1
+ class MPulse
2
+ #source: https://docs.soasta.com/boomerang/#mpulse-loader-snippet
3
+ MPULSE_LOADER = """
4
+ <!-- mPulse -->
5
+ <script>
6
+ (function(API_KEY){
7
+ if (window.BOOMR && window.BOOMR.version) { return; }
8
+ var dom, doc, where, iframe = document.createElement(\"iframe\"), win = window;
9
+
10
+ function boomerangSaveLoadTime(e) {
11
+ win.BOOMR_onload=(e && e.timeStamp) || new Date().getTime();
12
+ }
13
+
14
+ if (win.addEventListener) {
15
+ win.addEventListener(\"load\", boomerangSaveLoadTime, false);
16
+ } else if (win.attachEvent) {
17
+ win.attachEvent(\"onload\", boomerangSaveLoadTime);
18
+ }
19
+
20
+ iframe.src = \"javascript:void(0)\";
21
+ iframe.title = \"\";
22
+ iframe.role = \"presentation\";
23
+ (iframe.frameElement || iframe).style.cssText = \"width:0;height:0;border:0;display:none;\";
24
+ where = document.getElementsByTagName(\"script\")[0];
25
+ where.parentNode.insertBefore(iframe, where);
26
+
27
+ try {
28
+ doc = iframe.contentWindow.document;
29
+ } catch(e) {
30
+ dom = document.domain;
31
+ iframe.src = \"javascript:var d=document.open();d.domain='\"+dom+\"';void(0);\";
32
+ doc = iframe.contentWindow.document;
33
+ }
34
+
35
+ doc.open()._l = function() {
36
+ var js = this.createElement(\"script\");
37
+ if (dom) { this.domain = dom; }
38
+ js.id = \"boomr-if-as\";
39
+ js.src = \"https://s.go-mpulse.net/boomerang/\" + API_KEY;
40
+ BOOMR_lstart = new Date().getTime();
41
+ this.body.appendChild(js);
42
+ };
43
+ doc.write('<body onload=\"document._l();\">');
44
+ doc.close();
45
+ })(\"%s\");
46
+ </script>
47
+ <!-- End mPulse -->
48
+ """
49
+
50
+ APIKEY_RE = /^[a-zA-Z2-9]{5}-[a-zA-Z2-9]{5}-[a-zA-Z2-9]{5}-[a-zA-Z2-9]{5}-[a-zA-Z2-9]{5}$/
51
+
52
+ def initialize(config)
53
+ if !(APIKEY_RE.match(config["apikey"]))
54
+ raise ArgumentError, 'Invalid mPulse API key. Id must look like XXXXX-XXXXX-XXXXX-XXXXX-XXXXX'
55
+ end
56
+
57
+ @apikey = config["apikey"]
58
+ end
59
+
60
+ def render()
61
+ return MPULSE_LOADER % @apikey
62
+ end
63
+ end
@@ -0,0 +1,51 @@
1
+ class Matomo
2
+ SETUP_CODE = """
3
+ <!-- Matomo -->
4
+
5
+ <!-- Matomo Image Tracker -->
6
+ <noscript>
7
+ <img src=\"//%{url}?idsite=%{siteId}&amp;rec=1\" style=\"border:0\" alt=\"\" />
8
+ </noscript>
9
+ <!-- End Matomo -->
10
+
11
+
12
+ <script type=\"text/javascript\">
13
+ var _paq = _paq || [];
14
+ _paq.push(['trackPageView']);
15
+ _paq.push(['enableLinkTracking']);
16
+ (function() {
17
+ var u='//'+\"%{url}\";
18
+ _paq.push(['setTrackerUrl', u+'/piwik.php']);
19
+ _paq.push(['setSiteId', '%{siteId}']);
20
+ var d=document, g=d.createElement('script'), s=d.getElementsByTagName('script')[0];
21
+ g.type='text/javascript'; g.async=true; g.defer=true; g.src=u+'/piwik.js'; s.parentNode.insertBefore(g,s);
22
+ })();
23
+ </script>
24
+ <!-- End Matomo Code -->
25
+ """
26
+
27
+
28
+ # domain name (characters separated by a dot), optional port, optional URI path, no slash
29
+ DOMAINPATH_RE = /^(([^.\/?#@:]+\.)*[^.\/?#@:]+)+(:[0-9]+)?(\/[^\/?#@:]+)*$/
30
+
31
+ # numeric ID
32
+ SITEID_RE = /^\d+$/
33
+
34
+ def initialize(config)
35
+
36
+ if !(DOMAINPATH_RE.match(config['url']))
37
+ raise ArgumentError, 'Invalid url. Must be a domain name, optionally followed by an URI path, no trailing slash (e.g. matomo.example.com or my.matomo.server/path)'
38
+ end
39
+
40
+ if !(SITEID_RE.match(config['siteId']))
41
+ raise ArgumentError, 'Invalid site id. Must be a number.'
42
+ end
43
+
44
+ @config = Hash[config.map{ |k, v| [k.to_sym, v.to_s] }]
45
+
46
+ end
47
+
48
+ def render
49
+ return SETUP_CODE % @config
50
+ end
51
+ end
@@ -3,7 +3,7 @@ Dir[File.dirname(__FILE__) + '/analytics/*.rb'].each {|file| require file[0..-4]
3
3
  CONFIG_KEY = "jekyll_analytics"
4
4
 
5
5
  def inject(site)
6
- if ENV['JEKYLL_ENV']
6
+ if ENV['JEKYLL_ENV'] and site.site.config.has_key? CONFIG_KEY
7
7
  site.site.config[CONFIG_KEY].keys().each{ |a|
8
8
  analyzerClass = Module.const_get(a)
9
9
  config = site.site.config[CONFIG_KEY][a]
@@ -17,11 +17,11 @@ Jekyll::Hooks.register :pages, :post_render do |page|
17
17
  inject(page)
18
18
  end
19
19
 
20
- Jekyll::Hooks.register :post, :post_render do |post|
20
+ Jekyll::Hooks.register :posts, :post_render do |post|
21
21
  inject(post)
22
22
  end
23
23
 
24
24
  Jekyll::Hooks.register :site, :post_render do |site|
25
25
  #puts site.config
26
26
  #inject(site)
27
- end
27
+ end
metadata CHANGED
@@ -1,23 +1,25 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-analytics
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.14
5
5
  platform: ruby
6
6
  authors:
7
7
  - Hendrik Schneider
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-06 00:00:00.000000000 Z
11
+ date: 2018-05-04 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: Plugin to easily add web analytics to your jekyll site without modifying
14
- your templates
13
+ description: 'Plugin to easily add web analytics to your jekyll site without modifying
14
+ your templates. Supported are: Google Analytics, Piwik, Matomo, MPulse'
15
15
  email: ''
16
16
  executables: []
17
17
  extensions: []
18
18
  extra_rdoc_files: []
19
19
  files:
20
20
  - lib/analytics/GoogleAnalytics.rb
21
+ - lib/analytics/MPulse.rb
22
+ - lib/analytics/Matomo.rb
21
23
  - lib/analytics/Piwik.rb
22
24
  - lib/jekyll-analytics.rb
23
25
  homepage: https://github.com/hendrikschneider/jekyll-analytics
@@ -39,8 +41,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
39
41
  - !ruby/object:Gem::Version
40
42
  version: '0'
41
43
  requirements: []
42
- rubyforge_project:
43
- rubygems_version: 2.5.1
44
+ rubygems_version: 3.1.2
44
45
  signing_key:
45
46
  specification_version: 4
46
47
  summary: Jekyll plugin