Skip to content

Commit

Permalink
代理 ga 文件
Browse files Browse the repository at this point in the history
  • Loading branch information
alsotang committed Apr 4, 2015
1 parent 4ab2d4c commit 8836cf9
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 2 deletions.
2 changes: 2 additions & 0 deletions common/cache.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
var redis = require('./redis');
var _ = require('lodash');

var get = function (key, callback) {
redis.get(key, function (err, data) {
Expand All @@ -21,6 +22,7 @@ var set = function (key, value, time, callback) {
callback = time;
time = null;
}
callback = callback || _.noop;
value = JSON.stringify(value);
if (!time) {
redis.set(key, value, callback);
Expand Down
4 changes: 4 additions & 0 deletions common/render_helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,4 +89,8 @@ exports.tabName = function (tab) {
}
};

exports.proxy = function (url) {
return '"/agent?&url=' + encodeURIComponent(url) + '"';
};

exports._ = _;
2 changes: 1 addition & 1 deletion middlewares/proxy.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var request = require('request');

var ALLOW_HOSTNAME = [
'avatars.githubusercontent.com', 'www.gravatar.com',
'gravatar.com'
'gravatar.com', 'www.google-analytics.com',
];
exports.proxy = function (req, res, next) {
var url = decodeURIComponent(req.query.url);
Expand Down
Binary file added public/img/glyphicons-halflings-white.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/img/glyphicons-halflings.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion views/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@
(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');
})(window,document,'script',<%- proxy('https://www.google-analytics.com/analytics.js') %>,'ga');

ga('create', '<%-config.google_tracker_id%>', 'auto');
ga('send', 'pageview');
Expand Down

0 comments on commit 8836cf9

Please sign in to comment.