From 06f71a0da657b484479ec1d9dcce65d38bfa165c Mon Sep 17 00:00:00 2001 From: Ray Schamp Date: Tue, 6 Oct 2015 13:32:51 -0400 Subject: [PATCH] Update avatar thumbnailUrl per discussion --- server/index.js | 6 +++++- server/proxies.json | 3 ++- src/components/avatar/avatar.jsx | 27 +++++++----------------- src/components/navigation/navigation.jsx | 5 +---- src/session.json | 2 +- 5 files changed, 17 insertions(+), 26 deletions(-) diff --git a/server/index.js b/server/index.js index 8247e85d5..c313ce1f4 100644 --- a/server/index.js +++ b/server/index.js @@ -33,7 +33,11 @@ if ( process.env.NODE_ENV != 'production' ) { var proxyRoute = proxies[proxyId]; app.use(proxyRoute.root, proxy(proxyRoute.proxy || proxyHost, { filter: function (req) { - return proxyRoute.paths.indexOf(url.parse(req.url).path) > -1; + for (var pathId in proxyRoute.paths) { + var path = proxyRoute.paths[pathId]; + if (url.parse(req.url).path.indexOf(path) == 0) return true; + } + return false; }, forwardPath: function (req) { return url.parse(req.url).path; diff --git a/server/proxies.json b/server/proxies.json index e216b393e..442419fa2 100644 --- a/server/proxies.json +++ b/server/proxies.json @@ -4,7 +4,8 @@ "paths": [ "/session/", "/accounts/login/", - "/accounts/logout/" + "/accounts/logout/", + "/get_image/" ] } ] diff --git a/src/components/avatar/avatar.jsx b/src/components/avatar/avatar.jsx index 800e573b3..e25bd59e5 100644 --- a/src/components/avatar/avatar.jsx +++ b/src/components/avatar/avatar.jsx @@ -1,31 +1,20 @@ var React = require('react'); +var classNames = require('classnames'); module.exports = React.createClass({ propTypes: { - path: React.PropTypes.string, - userId: React.PropTypes.number, - size: React.PropTypes.number, - extension: React.PropTypes.string, - version: React.PropTypes.number + src: React.PropTypes.string }, getDefaultProps: function () { return { - path: '//cdn2.scratch.mit.edu/get_image/user/', - userId: 2584924, - size: 32, - extension: 'png', - version: 1438702210.96 + src: '//cdn2.scratch.mit.edu/get_image/user/2584924_24x24.png?v=1438702210.96' }; }, - getImageUrl: function () { - return ( - this.props.path + this.props.userId + '_' + - this.props.size + 'x' + this.props.size + '.' + - this.props.extension + '?v=' + this.props.version); - }, render: function () { - var url = this.getImageUrl(); - return ( - ); + var classes = classNames( + 'avatar', + this.props.className + ); + return ; } }); diff --git a/src/components/navigation/navigation.jsx b/src/components/navigation/navigation.jsx index a750e51f4..7a84c4b8a 100644 --- a/src/components/navigation/navigation.jsx +++ b/src/components/navigation/navigation.jsx @@ -95,10 +95,7 @@ module.exports = React.createClass({ ,
  • - + {this.state.session.user.username}