diff --git a/src/main/java/com/metaweb/gridworks/browsing/facets/ScatterplotFacet.java b/src/main/java/com/metaweb/gridworks/browsing/facets/ScatterplotFacet.java index d1165a3fd..2ebd5736b 100644 --- a/src/main/java/com/metaweb/gridworks/browsing/facets/ScatterplotFacet.java +++ b/src/main/java/com/metaweb/gridworks/browsing/facets/ScatterplotFacet.java @@ -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 { diff --git a/src/main/java/com/metaweb/gridworks/commands/auth/AuthorizeCommand.java b/src/main/java/com/metaweb/gridworks/commands/auth/AuthorizeCommand.java index b31941fa1..2c1ea053e 100644 --- a/src/main/java/com/metaweb/gridworks/commands/auth/AuthorizeCommand.java +++ b/src/main/java/com/metaweb/gridworks/commands/auth/AuthorizeCommand.java @@ -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(); + } } diff --git a/src/main/java/com/metaweb/gridworks/oauth/Credentials.java b/src/main/java/com/metaweb/gridworks/oauth/Credentials.java index 9d65cb54b..64aa2c563 100644 --- a/src/main/java/com/metaweb/gridworks/oauth/Credentials.java +++ b/src/main/java/com/metaweb/gridworks/oauth/Credentials.java @@ -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) { diff --git a/src/main/java/com/metaweb/gridworks/util/CookiesUtilities.java b/src/main/java/com/metaweb/gridworks/util/CookiesUtilities.java index 9fe3ba9de..4c2395f0b 100644 --- a/src/main/java/com/metaweb/gridworks/util/CookiesUtilities.java +++ b/src/main/java/com/metaweb/gridworks/util/CookiesUtilities.java @@ -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 ; + } } diff --git a/src/main/webapp/scripts/dialogs/freebase-loading-dialog.js b/src/main/webapp/scripts/dialogs/freebase-loading-dialog.js index 841c0ba78..ab4611604 100644 --- a/src/main/webapp/scripts/dialogs/freebase-loading-dialog.js +++ b/src/main/webapp/scripts/dialogs/freebase-loading-dialog.js @@ -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( '
' + '

' + data.result.added + ' triples successfully scheduled for loading

' + diff --git a/src/main/webapp/scripts/dialogs/scatterplot-dialog.js b/src/main/webapp/scripts/dialogs/scatterplot-dialog.js index 6eed443e6..03d9c3628 100644 --- a/src/main/webapp/scripts/dialogs/scatterplot-dialog.js +++ b/src/main/webapp/scripts/dialogs/scatterplot-dialog.js @@ -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, diff --git a/src/main/webapp/scripts/facets/scatterplot-facet.js b/src/main/webapp/scripts/facets/scatterplot-facet.js index dc1ccbdc5..f92409516 100644 --- a/src/main/webapp/scripts/facets/scatterplot-facet.js +++ b/src/main/webapp/scripts/facets/scatterplot-facet.js @@ -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; diff --git a/src/main/webapp/styles/project/browsing.css b/src/main/webapp/styles/project/browsing.css index 7697fa6f9..1187d2d9d 100644 --- a/src/main/webapp/styles/project/browsing.css +++ b/src/main/webapp/styles/project/browsing.css @@ -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; } diff --git a/src/server/java/com/metaweb/gridworks/Gridworks.java b/src/server/java/com/metaweb/gridworks/Gridworks.java index f981a3250..5c416c2e3 100644 --- a/src/server/java/com/metaweb/gridworks/Gridworks.java +++ b/src/server/java/com/metaweb/gridworks/Gridworks.java @@ -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 {