From 39c6ae1b80e0bd9bf3ca68db800b23ca2693d23c Mon Sep 17 00:00:00 2001 From: David Huynh Date: Thu, 17 Nov 2011 01:32:28 +0000 Subject: [PATCH] Consolidated the two different forms for public URLs together into one. Made sure we could still import public docs while signed in. git-svn-id: http://google-refine.googlecode.com/svn/trunk@2377 7d457c2a-affb-35e4-300a-418c747d4874 --- .../module/scripts/index/gdata-source-ui.js | 46 +++++----------- .../scripts/index/import-from-gdata-form.html | 54 +++++++++---------- .../scripts/index/importing-controller.js | 3 +- .../module/styles/importing-controller.less | 8 +++ .../gdata/GDataImportingController.java | 6 ++- 5 files changed, 55 insertions(+), 62 deletions(-) diff --git a/extensions/gdata/module/scripts/index/gdata-source-ui.js b/extensions/gdata/module/scripts/index/gdata-source-ui.js index a940a3e16..9d3656707 100644 --- a/extensions/gdata/module/scripts/index/gdata-source-ui.js +++ b/extensions/gdata/module/scripts/index/gdata-source-ui.js @@ -59,39 +59,21 @@ Refine.GDataSourceUI.prototype.attachUI = function(body) { self._elmts.signinPage.show(); }); - var importURL1 = function(evt) { - if ($.trim(self._elmts.urlInput1[0].value).length === 0) { - window.alert("You must specify a web address (URL) to import."); + this._elmts.urlNextButton.click(function(evt) { + var url = $.trim(self._elmts.urlInput[0].value); + if (url.length === 0) { + window.alert("You must specify a web address (URL) to import."); } else { - var doc={} - doc.docSelfLink = self._elmts.urlInput1[0].value; - if (doc.docSelfLink.contains('spreadsheet')) { // TODO: fragile? - doc.type = 'spreadsheet'; - } else { - doc.type = 'table'; - } - self._controller.startImportingDocument(doc); - } - } - // TODO: Consolidate these two URL input forms - var importURL2 = function(evt) { - if ($.trim(self._elmts.urlInput2[0].value).length === 0) { - window.alert("You must specify a web address (URL) to import."); - } else { - var doc={} - doc.docSelfLink = self._elmts.urlInput2[0].value; - if (doc.docSelfLink.contains('spreadsheet')) { // TODO: fragile? - doc.type = 'spreadsheet'; - } else { - doc.type = 'table'; - } - self._controller.startImportingDocument(doc); - } - } - - this._elmts.urlNextButton1.click(importURL1); - this._elmts.urlNextButton2.click(importURL2); - + var doc = { isPublic: true }; + doc.docSelfLink = url; + if (doc.docSelfLink.contains('spreadsheet')) { // TODO: fragile? + doc.type = 'spreadsheet'; + } else { + doc.type = 'table'; + } + self._controller.startImportingDocument(doc); + } + }); this._body.find('.gdata-page').hide(); this._elmts.signinPage.show(); diff --git a/extensions/gdata/module/scripts/index/import-from-gdata-form.html b/extensions/gdata/module/scripts/index/import-from-gdata-form.html index e0ab296a8..eb69291d1 100644 --- a/extensions/gdata/module/scripts/index/import-from-gdata-form.html +++ b/extensions/gdata/module/scripts/index/import-from-gdata-form.html @@ -1,31 +1,31 @@
-
-

Please - access to your Google data.

-
- - - - - -
Or enter web address (URL) of a public Google Spreadsheet or Fusion Table below and click Next:
+
+

Public Documents

+
+ + + + + +
Import a public Google Spreadsheet or Fusion Table by its URL:
-
-

Retrieving Google Docs documents ...

+ +
+

Authorized Documents

+ +
+

Please + access to your Google data.

+
+
+

Retrieving Google Docs documents ...

+
+
+ + + + + +
with another account
-
- - - - - - - - - - - -
Google Docs documents with another account
Click one of the documents below or enter the web address (URL) of a public Google Spreadsheet or Fusion Table and click "Next":
-
-
\ No newline at end of file diff --git a/extensions/gdata/module/scripts/index/importing-controller.js b/extensions/gdata/module/scripts/index/importing-controller.js index 0ceacb9f5..e941aa2f7 100644 --- a/extensions/gdata/module/scripts/index/importing-controller.js +++ b/extensions/gdata/module/scripts/index/importing-controller.js @@ -57,7 +57,8 @@ Refine.GDataImportingController.prototype.startImportingDocument = function(doc) "controller": "gdata/gdata-importing-controller", "subCommand": "initialize-parser-ui", "docUrl": doc.docSelfLink, - "docType": doc.type + "docType": doc.type, + "isPublic": (doc.isPublic) }), null, function(data2) { diff --git a/extensions/gdata/module/styles/importing-controller.less b/extensions/gdata/module/styles/importing-controller.less index 672f07dd3..2b55a7c90 100644 --- a/extensions/gdata/module/styles/importing-controller.less +++ b/extensions/gdata/module/styles/importing-controller.less @@ -33,6 +33,14 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. @import-less url("theme.less"); +.gdata-panel { + margin-bottom: 2em; +} +.gdata-panel > h1 { + font-size: 130%; + margin-bottom: 0.5em; +} + .gdata-extension-signin-iframe { border: 1px solid #aaa; width: 100%; diff --git a/extensions/gdata/src/com/google/refine/extension/gdata/GDataImportingController.java b/extensions/gdata/src/com/google/refine/extension/gdata/GDataImportingController.java index 9fbc3494d..17f4183b5 100644 --- a/extensions/gdata/src/com/google/refine/extension/gdata/GDataImportingController.java +++ b/extensions/gdata/src/com/google/refine/extension/gdata/GDataImportingController.java @@ -195,10 +195,12 @@ public class GDataImportingController implements ImportingController { HttpServletRequest request, HttpServletResponse response, Properties parameters) throws ServletException, IOException { - String token = TokenCookie.getToken(request); // authorization token, if logged in - String type = parameters.getProperty("docType"); String urlString = parameters.getProperty("docUrl"); + boolean isPublic = "true".equals(parameters.getProperty("isPublic")); + + String token = isPublic ? null : TokenCookie.getToken(request); // authorization token, if logged in + URL url = new URL(urlString); try { JSONObject result = new JSONObject();