File tree Expand file tree Collapse file tree 7 files changed +43
-9
lines changed Expand file tree Collapse file tree 7 files changed +43
-9
lines changed Original file line number Diff line number Diff line change 33<meta charset="UTF-8">
44<meta http-equiv="refresh" content="5; url=%{url}">
55
6- %{google_analytics_universal }
6+ %{google_analytics }
77
88<script>
99window.location.href = "%{url}"
Original file line number Diff line number Diff line change @@ -678,5 +678,5 @@ profiles:
678678 enable_google_analytics : true
679679 news_feed_root_url : https://in.relation.to/feeds
680680
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 11require 'js_minifier'
22require 'css_minifier'
33require 'html_minifier'
4+ require 'google_analytics_4'
45require 'relative'
56require 'releases'
67require 'release_file_parser'
3637Awestruct ::Extensions ::Pipeline . new do
3738 # register helpers to be used in templates
3839 helper Awestruct ::Extensions ::Partial
39- helper Awestruct ::Extensions ::GoogleAnalytics
40+ helper Awestruct ::Extensions ::GoogleAnalytics4
4041 helper Awestruct ::Extensions ::Relative
4142 helper Awestruct ::Extensions ::Releases
4243 helper Awestruct ::Extensions ::DirectoryListing
Original file line number Diff line number Diff line change 11require 'awestruct/handlers/base_handler'
2+ require 'google_analytics_4'
23
34module Awestruct
45 module Extensions
@@ -32,7 +33,7 @@ def execute(site)
3233
3334 module Handlers
3435 class RedirectCreationHandler < BaseHandler
35- include Awestruct ::Extensions ::GoogleAnalytics
36+ include Awestruct ::Extensions ::GoogleAnalytics4
3637
3738 Default_Redirect_Template = "redirects.template"
3839 def initialize ( site , requested_url , target_url )
@@ -85,7 +86,7 @@ def load_template
8586 file = File . open ( template_file , "rb" )
8687 content = file . read
8788 file . close
88- content % { url : @target_url , google_analytics_universal : google_analytics_universal }
89+ content % { url : @target_url , google_analytics : google_analytics }
8990 end
9091 end
9192 end
Original file line number Diff line number Diff line change 22%html (lang ="en" )
33 %head
44 = partial('head.html.haml', { " real_page" => page } )
5+ - if site.enable_google_analytics
6+ = google_analytics
57
68 %body .pushable
79 = partial( 'menu/mobile.html.haml', {" real_page" => page} )
2931 %span.back-to-top.computer.only
3032 %a{:href => " javascript: void(0)" } Back to top
3133
32- - if site.enable_google_analytics
33- = google_analytics_universal
3434 - if page.bottom_javascripts
3535 - page.bottom_javascripts.each do |javascript|
3636 %script{:src=>javascript, :type=>'text/javascript'}
Original file line number Diff line number Diff line change 1111%meta (charset ="utf-8" )
1212%meta (name ="viewport" content ="width=device-width, initial-scale=1.0" )
1313%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" )
1515%meta (HTTP-EQUIV ="X-XSS-Protection" content ="1; mode=block" )
1616%meta (HTTP-EQUIV ="X-Content-Type-Options" content ="nosniff" )
1717
You can’t perform that action at this time.
0 commit comments