Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Include google analytics in docs and generate index.html rather than …

…home.html.
  • Loading branch information...
commit ae207b76baa78630e8e6957667d463c02ba943c8 1 parent 07f7f4a
@chrisdone chrisdone authored
Showing with 23 additions and 5 deletions.
  1. +1 −0  .gitignore
  2. +13 −0 docs/analytics.js
  3. +9 −5 src/Docs.hs
View
1  .gitignore
@@ -4,6 +4,7 @@ examples/*.js
examples/*.html
tests/*.js
TAGS
+docs/index.html
docs/home.html
*.hi
*.o
View
13 docs/analytics.js
@@ -0,0 +1,13 @@
+<script type="text/javascript">
+if (window.location.href.match(/fay\-lang\.org/)) {
+ var _gaq = _gaq || [];
+ _gaq.push(['_setAccount', 'UA-33582139-1']);
+ _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>
View
14 src/Docs.hs
@@ -25,7 +25,7 @@ import Text.Blaze.Renderer.Utf8 (renderMarkup)
-- | Main entry point.
main :: IO ()
main = do
- let file = "docs" </> "home.html"
+ let file = "docs" </> "index.html"
generate >>= L.writeFile file
putStrLn $ "Documentation file written to " ++ file
@@ -33,7 +33,10 @@ generate = do
sources <- mapM readFile examples
javascripts <- mapM compile examples
now <- getCurrentTime
- return $ renderMarkup $ page now (zip3 (map titlize examples) sources javascripts)
+ analytics <- readFile $ "docs" </> "analytics.js"
+ return $ renderMarkup $ page now
+ analytics
+ (zip3 (map titlize examples) sources javascripts)
where compile file = do
contents <- readFile file
@@ -49,11 +52,11 @@ generate = do
(map (++".hs")
(words "declarations conditions functions lists data enums patterns ffi dom"))
-page now examples = do
+page now analytics examples = do
docType
html $ do
head $ thehead
- body $ thebody now examples
+ body $ thebody now analytics examples
thehead = do
title $ "The Fay Programming Language — A Haskell subset"
@@ -64,7 +67,7 @@ thehead = do
script ! src "beautify.js" $ return ()
script ! src "home.js" $ return ()
-thebody now examples = do
+thebody now analytics examples = do
fork
div !. "wrap" $ do
theheading
@@ -75,6 +78,7 @@ thebody now examples = do
theexamples examples
thereference
thefooter now
+ preEscapedToMarkup analytics
fork =
a ! href "https://github.com/chrisdone/fay" $
Please sign in to comment.
Something went wrong with that request. Please try again.