Skip to content

Commit

Permalink
render: add Google Analytics and async js src
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Vaghin committed Sep 4, 2016
1 parent 58cc95b commit 61bf26f
Show file tree
Hide file tree
Showing 3 changed files with 135 additions and 3 deletions.
2 changes: 1 addition & 1 deletion claat/VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
0.6.0
0.6.1
30 changes: 30 additions & 0 deletions claat/render/template-offline.html
Original file line number Diff line number Diff line change
Expand Up @@ -74,5 +74,35 @@ <h2>{{.StepNum}}. {{.Current.Title}}</h2>
</div>

</div><!-- codelab__toc -->

<script>
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');

{{if .GlobalGA}}ga('create', '{{.GlobalGA}}', 'auto');{{end}}

(function() {
var gaCodelab = '{{.Meta.GA}}';
if (gaCodelab) {
ga('create', gaCodelab, 'auto', {name: 'codelab'});
}

var gaView;
var parts = location.search.substring(1).split('&');
for (var i = 0; i < parts.length; i++) {
var param = parts[i].split('=');
if (param[0] === 'viewga') {
gaView = param[1];
break;
}
}
if (gaView && gaView !== gaCodelab) {
ga('create', gaView, 'auto', {name: 'view'});
}
})();
</script>
<script src="{{.Prefix}}scripts/codelab.js" async></script>
</body>
</html>
106 changes: 104 additions & 2 deletions claat/render/tmpldata.go
Original file line number Diff line number Diff line change
Expand Up @@ -631,8 +631,110 @@ var tmpldata = map[string]*template{
0xa,0xa,0x20,0x20,0x3c,0x2f,0x64,0x69,0x76,0x3e,
0x3c,0x21,0x2d,0x2d,0x20,0x63,0x6f,0x64,0x65,0x6c,
0x61,0x62,0x5f,0x5f,0x74,0x6f,0x63,0x20,0x2d,0x2d,
0x3e,0xa,0x3c,0x2f,0x62,0x6f,0x64,0x79,0x3e,0xa,
0x3c,0x2f,0x68,0x74,0x6d,0x6c,0x3e,0xa,
0x3e,0xa,0xa,0x20,0x20,0x3c,0x73,0x63,0x72,0x69,
0x70,0x74,0x3e,0xa,0x20,0x20,0x20,0x20,0x28,0x66,
0x75,0x6e,0x63,0x74,0x69,0x6f,0x6e,0x28,0x69,0x2c,
0x73,0x2c,0x6f,0x2c,0x67,0x2c,0x72,0x2c,0x61,0x2c,
0x6d,0x29,0x7b,0x69,0x5b,0x27,0x47,0x6f,0x6f,0x67,
0x6c,0x65,0x41,0x6e,0x61,0x6c,0x79,0x74,0x69,0x63,
0x73,0x4f,0x62,0x6a,0x65,0x63,0x74,0x27,0x5d,0x3d,
0x72,0x3b,0x69,0x5b,0x72,0x5d,0x3d,0x69,0x5b,0x72,
0x5d,0x7c,0x7c,0x66,0x75,0x6e,0x63,0x74,0x69,0x6f,
0x6e,0x28,0x29,0x7b,0xa,0x20,0x20,0x20,0x20,0x28,
0x69,0x5b,0x72,0x5d,0x2e,0x71,0x3d,0x69,0x5b,0x72,
0x5d,0x2e,0x71,0x7c,0x7c,0x5b,0x5d,0x29,0x2e,0x70,
0x75,0x73,0x68,0x28,0x61,0x72,0x67,0x75,0x6d,0x65,
0x6e,0x74,0x73,0x29,0x7d,0x2c,0x69,0x5b,0x72,0x5d,
0x2e,0x6c,0x3d,0x31,0x2a,0x6e,0x65,0x77,0x20,0x44,
0x61,0x74,0x65,0x28,0x29,0x3b,0x61,0x3d,0x73,0x2e,
0x63,0x72,0x65,0x61,0x74,0x65,0x45,0x6c,0x65,0x6d,
0x65,0x6e,0x74,0x28,0x6f,0x29,0x2c,0xa,0x20,0x20,
0x20,0x20,0x6d,0x3d,0x73,0x2e,0x67,0x65,0x74,0x45,
0x6c,0x65,0x6d,0x65,0x6e,0x74,0x73,0x42,0x79,0x54,
0x61,0x67,0x4e,0x61,0x6d,0x65,0x28,0x6f,0x29,0x5b,
0x30,0x5d,0x3b,0x61,0x2e,0x61,0x73,0x79,0x6e,0x63,
0x3d,0x31,0x3b,0x61,0x2e,0x73,0x72,0x63,0x3d,0x67,
0x3b,0x6d,0x2e,0x70,0x61,0x72,0x65,0x6e,0x74,0x4e,
0x6f,0x64,0x65,0x2e,0x69,0x6e,0x73,0x65,0x72,0x74,
0x42,0x65,0x66,0x6f,0x72,0x65,0x28,0x61,0x2c,0x6d,
0x29,0xa,0x20,0x20,0x20,0x20,0x7d,0x29,0x28,0x77,
0x69,0x6e,0x64,0x6f,0x77,0x2c,0x64,0x6f,0x63,0x75,
0x6d,0x65,0x6e,0x74,0x2c,0x27,0x73,0x63,0x72,0x69,
0x70,0x74,0x27,0x2c,0x27,0x68,0x74,0x74,0x70,0x73,
0x3a,0x2f,0x2f,0x77,0x77,0x77,0x2e,0x67,0x6f,0x6f,
0x67,0x6c,0x65,0x2d,0x61,0x6e,0x61,0x6c,0x79,0x74,
0x69,0x63,0x73,0x2e,0x63,0x6f,0x6d,0x2f,0x61,0x6e,
0x61,0x6c,0x79,0x74,0x69,0x63,0x73,0x2e,0x6a,0x73,
0x27,0x2c,0x27,0x67,0x61,0x27,0x29,0x3b,0xa,0xa,
0x20,0x20,0x20,0x20,0x7b,0x7b,0x69,0x66,0x20,0x2e,
0x47,0x6c,0x6f,0x62,0x61,0x6c,0x47,0x41,0x7d,0x7d,
0x67,0x61,0x28,0x27,0x63,0x72,0x65,0x61,0x74,0x65,
0x27,0x2c,0x20,0x27,0x7b,0x7b,0x2e,0x47,0x6c,0x6f,
0x62,0x61,0x6c,0x47,0x41,0x7d,0x7d,0x27,0x2c,0x20,
0x27,0x61,0x75,0x74,0x6f,0x27,0x29,0x3b,0x7b,0x7b,
0x65,0x6e,0x64,0x7d,0x7d,0xa,0xa,0x20,0x20,0x20,
0x20,0x28,0x66,0x75,0x6e,0x63,0x74,0x69,0x6f,0x6e,
0x28,0x29,0x20,0x7b,0xa,0x20,0x20,0x20,0x20,0x20,
0x20,0x76,0x61,0x72,0x20,0x67,0x61,0x43,0x6f,0x64,
0x65,0x6c,0x61,0x62,0x20,0x3d,0x20,0x27,0x7b,0x7b,
0x2e,0x4d,0x65,0x74,0x61,0x2e,0x47,0x41,0x7d,0x7d,
0x27,0x3b,0xa,0x20,0x20,0x20,0x20,0x20,0x20,0x69,
0x66,0x20,0x28,0x67,0x61,0x43,0x6f,0x64,0x65,0x6c,
0x61,0x62,0x29,0x20,0x7b,0xa,0x20,0x20,0x20,0x20,
0x20,0x20,0x20,0x20,0x67,0x61,0x28,0x27,0x63,0x72,
0x65,0x61,0x74,0x65,0x27,0x2c,0x20,0x67,0x61,0x43,
0x6f,0x64,0x65,0x6c,0x61,0x62,0x2c,0x20,0x27,0x61,
0x75,0x74,0x6f,0x27,0x2c,0x20,0x7b,0x6e,0x61,0x6d,
0x65,0x3a,0x20,0x27,0x63,0x6f,0x64,0x65,0x6c,0x61,
0x62,0x27,0x7d,0x29,0x3b,0xa,0x20,0x20,0x20,0x20,
0x20,0x20,0x7d,0xa,0xa,0x20,0x20,0x20,0x20,0x20,
0x20,0x76,0x61,0x72,0x20,0x67,0x61,0x56,0x69,0x65,
0x77,0x3b,0xa,0x20,0x20,0x20,0x20,0x20,0x20,0x76,
0x61,0x72,0x20,0x70,0x61,0x72,0x74,0x73,0x20,0x3d,
0x20,0x6c,0x6f,0x63,0x61,0x74,0x69,0x6f,0x6e,0x2e,
0x73,0x65,0x61,0x72,0x63,0x68,0x2e,0x73,0x75,0x62,
0x73,0x74,0x72,0x69,0x6e,0x67,0x28,0x31,0x29,0x2e,
0x73,0x70,0x6c,0x69,0x74,0x28,0x27,0x26,0x27,0x29,
0x3b,0xa,0x20,0x20,0x20,0x20,0x20,0x20,0x66,0x6f,
0x72,0x20,0x28,0x76,0x61,0x72,0x20,0x69,0x20,0x3d,
0x20,0x30,0x3b,0x20,0x69,0x20,0x3c,0x20,0x70,0x61,
0x72,0x74,0x73,0x2e,0x6c,0x65,0x6e,0x67,0x74,0x68,
0x3b,0x20,0x69,0x2b,0x2b,0x29,0x20,0x7b,0xa,0x20,
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x76,0x61,0x72,
0x20,0x70,0x61,0x72,0x61,0x6d,0x20,0x3d,0x20,0x70,
0x61,0x72,0x74,0x73,0x5b,0x69,0x5d,0x2e,0x73,0x70,
0x6c,0x69,0x74,0x28,0x27,0x3d,0x27,0x29,0x3b,0xa,
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x69,0x66,
0x20,0x28,0x70,0x61,0x72,0x61,0x6d,0x5b,0x30,0x5d,
0x20,0x3d,0x3d,0x3d,0x20,0x27,0x76,0x69,0x65,0x77,
0x67,0x61,0x27,0x29,0x20,0x7b,0xa,0x20,0x20,0x20,
0x20,0x20,0x20,0x20,0x20,0x20,0x20,0x67,0x61,0x56,
0x69,0x65,0x77,0x20,0x3d,0x20,0x70,0x61,0x72,0x61,
0x6d,0x5b,0x31,0x5d,0x3b,0xa,0x20,0x20,0x20,0x20,
0x20,0x20,0x20,0x20,0x20,0x20,0x62,0x72,0x65,0x61,
0x6b,0x3b,0xa,0x20,0x20,0x20,0x20,0x20,0x20,0x20,
0x20,0x7d,0xa,0x20,0x20,0x20,0x20,0x20,0x20,0x7d,
0xa,0x20,0x20,0x20,0x20,0x20,0x20,0x69,0x66,0x20,
0x28,0x67,0x61,0x56,0x69,0x65,0x77,0x20,0x26,0x26,
0x20,0x67,0x61,0x56,0x69,0x65,0x77,0x20,0x21,0x3d,
0x3d,0x20,0x67,0x61,0x43,0x6f,0x64,0x65,0x6c,0x61,
0x62,0x29,0x20,0x7b,0xa,0x20,0x20,0x20,0x20,0x20,
0x20,0x20,0x20,0x67,0x61,0x28,0x27,0x63,0x72,0x65,
0x61,0x74,0x65,0x27,0x2c,0x20,0x67,0x61,0x56,0x69,
0x65,0x77,0x2c,0x20,0x27,0x61,0x75,0x74,0x6f,0x27,
0x2c,0x20,0x7b,0x6e,0x61,0x6d,0x65,0x3a,0x20,0x27,
0x76,0x69,0x65,0x77,0x27,0x7d,0x29,0x3b,0xa,0x20,
0x20,0x20,0x20,0x20,0x20,0x7d,0xa,0x20,0x20,0x20,
0x20,0x7d,0x29,0x28,0x29,0x3b,0xa,0x20,0x20,0x3c,
0x2f,0x73,0x63,0x72,0x69,0x70,0x74,0x3e,0xa,0x20,
0x20,0x3c,0x73,0x63,0x72,0x69,0x70,0x74,0x20,0x73,
0x72,0x63,0x3d,0x22,0x7b,0x7b,0x2e,0x50,0x72,0x65,
0x66,0x69,0x78,0x7d,0x7d,0x73,0x63,0x72,0x69,0x70,
0x74,0x73,0x2f,0x63,0x6f,0x64,0x65,0x6c,0x61,0x62,
0x2e,0x6a,0x73,0x22,0x20,0x61,0x73,0x79,0x6e,0x63,
0x3e,0x3c,0x2f,0x73,0x63,0x72,0x69,0x70,0x74,0x3e,
0xa,0x3c,0x2f,0x62,0x6f,0x64,0x79,0x3e,0xa,0x3c,
0x2f,0x68,0x74,0x6d,0x6c,0x3e,0xa,
},
},
}

0 comments on commit 61bf26f

Please sign in to comment.