- fixed oauth problem with non-127.0.0.1 hosts

- fixed scatterfacet filtering consistency
- increased size of scatterplot in the scatterfacet


git-svn-id: http://google-refine.googlecode.com/svn/trunk@573 7d457c2a-affb-35e4-300a-418c747d4874
This commit is contained in:
Stefano Mazzocchi 2010-04-30 06:12:42 +00:00
parent 0fb4af4813
commit ce40122754
9 changed files with 41 additions and 27 deletions

View File

@ -251,10 +251,7 @@ public class ScatterplotFacet implements Facet {
protected boolean checkValues(double x, double y) {
Point2D.Double p = new Point2D.Double(x,y);
p = translateCoordinates(p, dim_x, dim_y, rotation, l, min_x, max_x, min_y, max_y);
boolean value = p.x >= from_x && p.x < to_x && p.y >= from_y && p.y < to_y;
return value;
return p.x >= from_x && p.x <= to_x && p.y >= from_y && p.y <= to_y;
};
};
} else {

View File

@ -32,7 +32,7 @@ public class AuthorizeCommand extends Command {
// prepare the continuation URL that the OAuth provider will redirect the user to
// (we need to make sure this URL points back to this code or the dance will never complete)
String callbackURL = Gridworks.getURL() + "/command/authorize/" + provider.getHost();
String callbackURL = getBaseURL(request,provider);
if (access_credentials == null) {
// access credentials are not available so we need to check
@ -54,7 +54,7 @@ public class AuthorizeCommand extends Command {
request_credentials = new Credentials(consumer.getToken(), consumer.getTokenSecret(), provider);
// and set them to that we can retrieve them later in the second part of the dance
Credentials.setCredentials(response, request_credentials, Credentials.Type.REQUEST, 3600);
Credentials.setCredentials(request, response, request_credentials, Credentials.Type.REQUEST, 3600);
// now redirect the user to the Authorize URL where she can authenticate against the
// service provider and authorize us.
@ -88,7 +88,7 @@ public class AuthorizeCommand extends Command {
response.sendRedirect(callbackURL);
} else {
Credentials.setCredentials(response, access_credentials, Credentials.Type.ACCESS, 30 * 24 * 3600);
Credentials.setCredentials(request, response, access_credentials, Credentials.Type.ACCESS, 30 * 24 * 3600);
}
finish(response);
@ -121,4 +121,10 @@ public class AuthorizeCommand extends Command {
);
writer.flush();
}
private String getBaseURL(HttpServletRequest request, Provider provider) {
String host = request.getHeader("host");
if (host == null) host = Gridworks.getFullHost();
return "http://" + host + "/command/authorize/" + provider.getHost();
}
}

View File

@ -35,10 +35,10 @@ public class Credentials {
return (cookie == null) ? null : makeCredentials(cookie.getValue(), provider);
}
public static void setCredentials(HttpServletResponse response, Credentials credentials, Type type, int max_age) {
public static void setCredentials(HttpServletRequest request, HttpServletResponse response, Credentials credentials, Type type, int max_age) {
String name = type.getCookieName(credentials.getProvider());
String value = credentials.toString();
CookiesUtilities.setCookie(response, name, value, max_age);
CookiesUtilities.setCookie(request, response, name, value, max_age);
}
public static void deleteCredentials(HttpServletRequest request, HttpServletResponse response, Provider provider, Type type) {

View File

@ -23,9 +23,9 @@ public class CookiesUtilities {
return cookie;
}
public static void setCookie(HttpServletResponse response, String name, String value, int max_age) {
public static void setCookie(HttpServletRequest request, HttpServletResponse response, String name, String value, int max_age) {
Cookie c = new Cookie(name, value);
c.setDomain(DOMAIN);
c.setDomain(getDomain(request));
c.setPath(PATH);
c.setMaxAge(max_age);
response.addCookie(c);
@ -33,10 +33,16 @@ public class CookiesUtilities {
public static void deleteCookie(HttpServletRequest request, HttpServletResponse response, String name) {
Cookie c = new Cookie(name, "");
c.setDomain(DOMAIN);
c.setDomain(getDomain(request));
c.setPath(PATH);
c.setMaxAge(0);
response.addCookie(c);
}
public static String getDomain(HttpServletRequest request) {
String host = request.getHeader("Host");
if (host == null) return DOMAIN;
int index = host.indexOf(':');
return (index > -1) ? host.substring(0,index) : host ;
}
}

View File

@ -197,7 +197,7 @@ FreebaseLoadingDialog.prototype._load = function() {
},
function(data) {
var body = $(".dialog-body");
if ("status" in data && "code" in data.status && data.status.code == 200) {
if ("status" in data && typeof data.status == "object" && "code" in data.status && data.status.code == 200) {
body.html(
'<div class="freebase-loading-tripleloader-message">' +
'<h2>' + data.result.added + ' triples successfully scheduled for loading</h2>' +

View File

@ -175,7 +175,7 @@ ScatterplotDialog.prototype._renderMatrix = function() {
"name" : $(this).attr("title"),
"cx" : $(this).attr("cx"),
"cy" : $(this).attr("cy"),
"l" : 120,
"l" : 150,
"ex" : "value",
"ey" : "value",
"dot" : self._dot_size,

View File

@ -39,11 +39,16 @@ ScatterplotFacet.prototype.getUIState = function() {
ScatterplotFacet.prototype.getJSON = function() {
this._config.type = "scatterplot";
var dot = this._config.dot;
if (typeof dot == 'number') this._config.dot.toFixed(2);
return this._config;
};
ScatterplotFacet.prototype.hasSelection = function() {
return ("from_x" in this._config);
return ("from_x" in this._config && this._config.from_x != 0) ||
("from_y" in this._config && this._config.from_y != 0) ||
("to_x" in this._config && this._config.to_x != this._config.l) ||
("to_y" in this._config && this._config.to_y != this._config.l);
};
ScatterplotFacet.prototype._initializeUI = function() {
@ -208,7 +213,7 @@ ScatterplotFacet.prototype._formulateImageUrl = function(engineConfig, conf) {
};
ScatterplotFacet.prototype.updateState = function(data) {
if ("min_x" in data && "max_x" in data && "max_x" in data && "min_x" in data) {
if ("min_x" in data && "max_x" in data && "max_y" in data && "min_y" in data) {
this._error = false;
this._config.min_x = data.min_x;
@ -216,18 +221,18 @@ ScatterplotFacet.prototype.updateState = function(data) {
this._config.min_y = data.min_y;
this._config.max_y = data.max_y;
this._config.from_x = Math.max(data.from_x, this._config.min_x);
if ("from_x" in data) {
this._config.from_x = Math.max(data.from_x, 0);
}
if ("to_x" in data) {
this._config.to_x = Math.min(data.to_x, this._config.max_x);
} else {
this._config.to_x = data.max_x;
this._config.to_x = Math.min(data.to_x, this._config.l);
}
this._config.from_y = Math.max(data.from_y, this._config.min_x);
if ("from_y" in data) {
this._config.from_y = Math.max(data.from_y, 0);
}
if ("to_y" in data) {
this._config.to_y = Math.min(data.to_y, this._config.max_x);
} else {
this._config.to_y = data.max_x;
this._config.to_y = Math.min(data.to_y, this._config.l);
}
} else {
this._error = true;

View File

@ -206,7 +206,7 @@ img.facet-choice-link {
}
.facet-scatterplot-plot-container {
margin: 5px 5px 5px 5px;
margin: 5px 0px 5px 5px;
border: 1px solid #bbb;
}

View File

@ -61,8 +61,8 @@ public class Gridworks {
return Configurations.getInteger("gridworks.max_upload_size",MAX_UPLOAD_SIZE);
}
public static String getURL() {
return "http://" + Configurations.get("gridworks.host",DEFAULT_HOST) + ":" + Configurations.getInteger("gridworks.port",DEFAULT_PORT);
public static String getFullHost() {
return host + ":" + port;
}
public static void main(String[] args) throws Exception {