Skip to content

Instantly share code, notes, and snippets.

@halldb02
Created April 1, 2011 19:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save halldb02/898666 to your computer and use it in GitHub Desktop.
Save halldb02/898666 to your computer and use it in GitHub Desktop.
description of edits to enhance server.js for node-boilerplate
<script>SOCKET_IO_PORT = <%= port %>;</script>
<script src="/js/socket.io.js"></script>
...
<!-- mathiasbynens.be/notes/async-analytics-snippet Change UA-XXXXX-X to be your site's ID -->
<script>
var _gaq=[["_setAccount","<%= googleAnalyticsSiteId %>"],["_trackPageview"]];
(function(d,t){var g=d.createElement(t),s=d.getElementsByTagName(t)[0];g.async=1;
g.src=("https:"==location.protocol?"//ssl":"//www")+".google-analytics.com/ga.js";
s.parentNode.insertBefore(g,s)}(document,"script"));
</script>
...
//io.setPath('/client/');
socket = new io.Socket(null, {
port: SOCKET_IO_PORT
,transports: ['websocket', 'htmlfile', 'xhr-multipart', 'xhr-polling']
,path: '/client/'
});
...
// at the top of the file, or in a site config file:
var googleAnalyticsSiteId = 'UA-XXXXX-X';
...
// THREE PLACES: 404, 500, index, etc. Consider using a default "locals" object that is extended for each instance.
res.render('VARIOUS TEMPLATES', {locals: {
...
googleAnalyticsSiteId: googleAnalyticsSiteId,
port: port // only needed for the index.ejs route
}});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment