From 6c9c7746ea77946178c54137e25151a6b5bc32db Mon Sep 17 00:00:00 2001 From: Greg Hendershott Date: Fri, 26 Oct 2012 09:00:25 -0400 Subject: [PATCH] Add GA code to HTML. --- .gitignore | 1 + add-ga.rkt | 33 +++++++++++++++++++++++++++++++++ make-doc.sh | 3 ++- 3 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 add-ga.rkt diff --git a/.gitignore b/.gitignore index e43b0f9..f8a06ea 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ .DS_Store +main.html diff --git a/add-ga.rkt b/add-ga.rkt new file mode 100644 index 0000000..aa2d262 --- /dev/null +++ b/add-ga.rkt @@ -0,0 +1,33 @@ +#lang racket + +;; Realm of kludge: +;; +;; AFIK no way via Scribble to put something into the section. +;; +;; This takes "main.html", adds some GA code, and outputs "index.html". + +(define _subst +#< +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); +})(); + + +EOF +) + +(define subst (regexp-replace* "\n" _subst "")) ;minify + +(define old (file->string "main.html")) +(define new (regexp-replace "" 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 index f2c2db2..45cbde5 100755 --- 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