File tree 7 files changed +43
-9
lines changed
7 files changed +43
-9
lines changed Original file line number Diff line number Diff line change 3
3
<meta charset="UTF-8">
4
4
<meta http-equiv="refresh" content="5; url=%{url}">
5
5
6
- %{google_analytics_universal }
6
+ %{google_analytics }
7
7
8
8
<script>
9
9
window.location.href = "%{url}"
Original file line number Diff line number Diff line change @@ -678,5 +678,5 @@ profiles:
678
678
enable_google_analytics : true
679
679
news_feed_root_url : https://in.relation.to/feeds
680
680
681
- google_analytics :
682
- account : UA-45270411-1
681
+ google_analytics :
682
+ id : G-6XDRJZ1Q1R
Original file line number Diff line number Diff line change
1
+ module Awestruct
2
+ module Extensions
3
+ module GoogleAnalytics4
4
+
5
+ def google_analytics ( options = { } )
6
+ options = defaults ( options )
7
+
8
+ html = ''
9
+ html += %Q(<!-- Google tag (gtag.js) -->\n )
10
+ html += %Q(<script async src="https://www.googletagmanager.com/gtag/js?id=#{ options [ :id ] } "></script>\n )
11
+ html += %Q(<script>\n )
12
+ html += %Q( window.dataLayer = window.dataLayer || [];\n )
13
+ html += %Q( function gtag(){dataLayer.push(arguments);}\n )
14
+ html += %Q( gtag('js', new Date());\n )
15
+ html += %Q(\n )
16
+ html += %Q( gtag('config', '#{ options [ :id ] } ');\n )
17
+ html += %Q(</script>\n )
18
+
19
+ html
20
+ end
21
+
22
+ private
23
+
24
+ def defaults ( options )
25
+ options = site . google_analytics . merge ( options ) if site . google_analytics . is_a? ( Hash )
26
+ options = Hash [ options . map { |k , v | [ k . to_sym , v ] } ]
27
+
28
+ options
29
+ end
30
+ end
31
+ end
32
+ end
Original file line number Diff line number Diff line change 1
1
require 'js_minifier'
2
2
require 'css_minifier'
3
3
require 'html_minifier'
4
+ require 'google_analytics_4'
4
5
require 'relative'
5
6
require 'releases'
6
7
require 'release_file_parser'
36
37
Awestruct ::Extensions ::Pipeline . new do
37
38
# register helpers to be used in templates
38
39
helper Awestruct ::Extensions ::Partial
39
- helper Awestruct ::Extensions ::GoogleAnalytics
40
+ helper Awestruct ::Extensions ::GoogleAnalytics4
40
41
helper Awestruct ::Extensions ::Relative
41
42
helper Awestruct ::Extensions ::Releases
42
43
helper Awestruct ::Extensions ::DirectoryListing
Original file line number Diff line number Diff line change 1
1
require 'awestruct/handlers/base_handler'
2
+ require 'google_analytics_4'
2
3
3
4
module Awestruct
4
5
module Extensions
@@ -32,7 +33,7 @@ def execute(site)
32
33
33
34
module Handlers
34
35
class RedirectCreationHandler < BaseHandler
35
- include Awestruct ::Extensions ::GoogleAnalytics
36
+ include Awestruct ::Extensions ::GoogleAnalytics4
36
37
37
38
Default_Redirect_Template = "redirects.template"
38
39
def initialize ( site , requested_url , target_url )
@@ -85,7 +86,7 @@ def load_template
85
86
file = File . open ( template_file , "rb" )
86
87
content = file . read
87
88
file . close
88
- content % { url : @target_url , google_analytics_universal : google_analytics_universal }
89
+ content % { url : @target_url , google_analytics : google_analytics }
89
90
end
90
91
end
91
92
end
Original file line number Diff line number Diff line change 2
2
%html (lang ="en" )
3
3
%head
4
4
= partial('head.html.haml', { " real_page" => page } )
5
+ - if site.enable_google_analytics
6
+ = google_analytics
5
7
6
8
%body .pushable
7
9
= partial( 'menu/mobile.html.haml', {" real_page" => page} )
29
31
%span.back-to-top.computer.only
30
32
%a{:href => " javascript: void(0)" } Back to top
31
33
32
- - if site.enable_google_analytics
33
- = google_analytics_universal
34
34
- if page.bottom_javascripts
35
35
- page.bottom_javascripts.each do |javascript|
36
36
%script{:src=>javascript, :type=>'text/javascript'}
Original file line number Diff line number Diff line change 11
11
%meta (charset ="utf-8" )
12
12
%meta (name ="viewport" content ="width=device-width, initial-scale=1.0" )
13
13
%meta (name ="author" content ="#{real_page.author}" )
14
- %meta (HTTP-EQUIV ="Content-Security-Policy" CONTENT ="default-src 'none'; font-src 'self' data: https://cdn.jsdelivr.net https://static.jboss.org https://in.relation.to https://staging.in.relation.to https://fonts.gstatic.com https://fonts.googleapis.com; style-src 'unsafe-inline' 'self' https://cdn.jsdelivr.net https://fonts.googleapis.com; script-src 'self' 'unsafe-inline' https://hibernate.atlassian.net https://in.relation.to https://staging.in.relation.to https://www.redhat.com https://cdn.jsdelivr.net https://code.jquery.com www.google-analytics.com; img-src 'self' data: https://*.githubusercontent.com www.google-analytics.com https://static.jboss.org https://cdn.jsdelivr.net; base-uri 'none'; form-action 'none'; object-src 'none'; connect-src 'self' https://api.github.com; frame-src https://hibernate.atlassian.net" )
14
+ %meta (HTTP-EQUIV ="Content-Security-Policy" CONTENT ="default-src 'none'; font-src 'self' data: https://cdn.jsdelivr.net https://static.jboss.org https://in.relation.to https://staging.in.relation.to https://fonts.gstatic.com https://fonts.googleapis.com; style-src 'unsafe-inline' 'self' https://cdn.jsdelivr.net https://fonts.googleapis.com; script-src 'self' 'unsafe-inline' https://hibernate.atlassian.net https://in.relation.to https://staging.in.relation.to https://www.redhat.com https://cdn.jsdelivr.net https://code.jquery.com https:// www.google-analytics.com https://www.googletagmanager .com; img-src 'self' data: https://*.githubusercontent.com www.google-analytics.com https://static.jboss.org https://cdn.jsdelivr.net; base-uri 'none'; form-action 'none'; object-src 'none'; connect-src 'self' https://api.github.com; frame-src https://hibernate.atlassian.net" )
15
15
%meta (HTTP-EQUIV ="X-XSS-Protection" content ="1; mode=block" )
16
16
%meta (HTTP-EQUIV ="X-Content-Type-Options" content ="nosniff" )
17
17
You can’t perform that action at this time.
0 commit comments