commit 6c9c7746ea77946178c54137e25151a6b5bc32db
parent 26c6cb2b84c5390b9c537be7625bc173850ae09e
Author: Greg Hendershott <greghendershott@gmail.com>
Date: Fri, 26 Oct 2012 09:00:25 -0400
Add GA code to HTML.
Diffstat:
3 files changed, 36 insertions(+), 1 deletion(-)
diff --git a/.gitignore b/.gitignore
@@ -1 +1,2 @@
.DS_Store
+main.html
diff --git a/add-ga.rkt b/add-ga.rkt
@@ -0,0 +1,33 @@
+#lang racket
+
+;; Realm of kludge:
+;;
+;; AFIK no way via Scribble to put something into the <head> section.
+;;
+;; This takes "main.html", adds some GA code, and outputs "index.html".
+
+(define _subst
+#<<EOF
+<script type="text/javascript">
+var _gaq = _gaq || [];
+_gaq.push(['_setAccount', 'UA-29709446-1']);
+_gaq.push(['_setDomainName', 'greghendershott.com']);
+_gaq.push(['_trackPageview']);
+(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);
+})();
+</script>
+</head>
+EOF
+)
+
+(define subst (regexp-replace* "\n" _subst "")) ;minify
+
+(define old (file->string "main.html"))
+(define new (regexp-replace "</head>" old subst))
+(with-output-to-file (build-path 'same "index.html")
+ (lambda () (display new))
+ #:mode 'text
+ #:exists 'replace)
diff --git a/make-doc.sh b/make-doc.sh
@@ -1 +1,2 @@
-scribble --html ++style gh.css ++xref-in setup/xref load-collections-xref --redirect-main "http://docs.racket-lang.org/" --dest-name index.html main.rkt
+scribble --html ++style gh.css ++xref-in setup/xref load-collections-xref --redirect-main "http://docs.racket-lang.org/" main.rkt
+racket add-ga.rkt