Skip to content

Commit

Permalink
Added a general config file with a slot for a Google Analytics key.
Browse files Browse the repository at this point in the history
  • Loading branch information
ghalusa committed Oct 18, 2014
1 parent 36dfc9f commit 8fcd72c
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
tests.txt
database.js
secret.js
configurations.js
4 changes: 4 additions & 0 deletions config/configurations_sample.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
// config/configurations.js
module.exports = {
'googleAnalyticsKey' : 'UA-xxxxxxx-xx'
};
8 changes: 6 additions & 2 deletions routes/index.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
var express = require('express')
, router = express.Router()
, auth = require('./auth.js')
, configurations = require('./configurations.js');
, configurations = require('./configurations.js')
, config = require('../config/configurations.js');

/*
* Non-authenticated routes.
*/

router.get('/', function(req, res) {
res.render('index', { title: 'Configurations REST API' });
res.render(
'index'
, { title: 'Configurations REST API', google_analytics_key: config.googleAnalyticsKey }
);
});

router.post('/login', auth.login);
Expand Down
8 changes: 8 additions & 0 deletions views/header.ejs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@
word-wrap: break-word;
}
</style>
<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','//www.google-analytics.com/analytics.js','ga');
ga('create', '<%= google_analytics_key %>', 'auto');
ga('send', 'pageview');
</script>
</head>
<body>
<div class="container">
Expand Down

0 comments on commit 8fcd72c

Please sign in to comment.