diff --git a/extensions/wikidata/module/images/Wikidata-logo-en.svg b/extensions/wikidata/module/images/Wikidata-logo-en.svg new file mode 100644 index 000000000..fbb40e4d0 --- /dev/null +++ b/extensions/wikidata/module/images/Wikidata-logo-en.svg @@ -0,0 +1,7 @@ + + + + + + + diff --git a/extensions/wikidata/module/images/wikidata.png b/extensions/wikidata/module/images/wikidata.png new file mode 100644 index 000000000..d0aa6d802 Binary files /dev/null and b/extensions/wikidata/module/images/wikidata.png differ diff --git a/extensions/wikidata/module/langs/translation-en.json b/extensions/wikidata/module/langs/translation-en.json index 3a339637f..a8d3b5cd5 100644 --- a/extensions/wikidata/module/langs/translation-en.json +++ b/extensions/wikidata/module/langs/translation-en.json @@ -48,7 +48,7 @@ }, "wikidata-account": { "dialog-header": "Wikidata account", - "explain-log-in": "Logging in to Wikidata will allow you to perform edits directly from OpenRefine.", + "explain-log-in": "Logging in to Wikidata lets you to perform edits directly from OpenRefine.", "username-label": "Username:", "username-placeholder": "Enter your username", "password-label": "Password:", @@ -57,20 +57,23 @@ "close": "Close", "log-in": "Log in", "logged-in-as": "You are logged in as:", - "log-out": "Log out" + "log-out": "Log out", + "connecting-to-wikidata": "Connecting to Wikidata..." }, "perform-wikidata-edits": { "dialog-header": "Perform edits on Wikidata", - "review-your-edits": "Please review your edits before pushing them to Wikidata. Consider requesting feedback at the Data Import Hub for large datasets.", + "review-your-edits": "Please check your edits carefully before pushing them to Wikidata. Large edit batches should be submitted for bot review first.", "logged-in-as": "You are logged in as", "edit-summary-label": "Edit summary:", + "edit-summary-placeholder": "a few words to describe your edits", "perform-edits": "Perform edits", - "cancel": "Cancel" + "cancel": "Cancel", + "analyzing-edits": "Analyzing your edits..." }, "warnings-messages": { "new-item-created": { "title": "This batch will create new Wikidata items.", - "body": "Please make sure that these items do not exist yet and are suitable for inclusion in Wikidata." + "body": "Please make sure that these items do not exist yet and are suitable for inclusion in Wikidata." }, "new-item-without-labels-or-aliases": { "title": "New items created without any label or alias.", diff --git a/extensions/wikidata/module/scripts/dialogs/manage-account-dialog.html b/extensions/wikidata/module/scripts/dialogs/manage-account-dialog.html index cb9356eed..0a5679b65 100644 --- a/extensions/wikidata/module/scripts/dialogs/manage-account-dialog.html +++ b/extensions/wikidata/module/scripts/dialogs/manage-account-dialog.html @@ -1,8 +1,12 @@
-

-

+ + + + +
diff --git a/extensions/wikidata/module/scripts/dialogs/manage-account-dialog.js b/extensions/wikidata/module/scripts/dialogs/manage-account-dialog.js index 915e86536..f319f1158 100644 --- a/extensions/wikidata/module/scripts/dialogs/manage-account-dialog.js +++ b/extensions/wikidata/module/scripts/dialogs/manage-account-dialog.js @@ -1,12 +1,6 @@ var ManageAccountDialog = {}; -/* - $.post( - "command/core/get-all-preferences", - null, - populatePreferences, - "json" - ); -*/ + +ManageAccountDialog.firstLogin = true; ManageAccountDialog.launch = function(logged_in_username, callback) { $.post( @@ -23,10 +17,10 @@ ManageAccountDialog.display = function(logged_in_username, saved_credentials, ca var self = this; var frame = $(DOM.loadHTML("wikidata", "scripts/dialogs/manage-account-dialog.html")); var elmts = this._elmts = DOM.bind(frame); - console.log(saved_credentials); + ManageAccountDialog.firstLaunch = false; this._elmts.dialogHeader.text($.i18n._('wikidata-account')["dialog-header"]); - this._elmts.explainLogIn.text($.i18n._('wikidata-account')["explain-log-in"]); + this._elmts.explainLogIn.html($.i18n._('wikidata-account')["explain-log-in"]); this._elmts.usernameLabel.text($.i18n._('wikidata-account')["username-label"]); this._elmts.usernameInput.attr("placeholder", $.i18n._('wikidata-account')["username-placeholder"]); this._elmts.passwordLabel.text($.i18n._('wikidata-account')["password-label"]); @@ -51,7 +45,9 @@ ManageAccountDialog.display = function(logged_in_username, saved_credentials, ca elmts.logoutArea.hide(); } - elmts.loggedInUsername.text(logged_in_username); + elmts.loggedInUsername + .text(logged_in_username) + .attr('href', 'https://www.wikidata.org/wiki/User:'+logged_in_username); frame.find('.cancel-button').click(function() { dismiss(); @@ -88,9 +84,15 @@ ManageAccountDialog.display = function(logged_in_username, saved_credentials, ca }; ManageAccountDialog.isLoggedIn = function(callback) { + var discardWaiter = function() { }; + if(ManageAccountDialog.firstLogin) { + discardWaiter = DialogSystem.showBusy($.i18n._('wikidata-account')["connecting-to-wikidata"]); + } $.get( "command/wikidata/login", function(data) { + discardWaiter(); + ManageAccountDialog.firstLogin = false; callback(data.username); }); }; diff --git a/extensions/wikidata/module/scripts/dialogs/perform-edits-dialog.html b/extensions/wikidata/module/scripts/dialogs/perform-edits-dialog.html index 1ca7d1f88..32b2e2e40 100644 --- a/extensions/wikidata/module/scripts/dialogs/perform-edits-dialog.html +++ b/extensions/wikidata/module/scripts/dialogs/perform-edits-dialog.html @@ -6,7 +6,7 @@
-

.

+

.

diff --git a/extensions/wikidata/module/scripts/dialogs/perform-edits-dialog.js b/extensions/wikidata/module/scripts/dialogs/perform-edits-dialog.js index 9eb4882fd..3509cbead 100644 --- a/extensions/wikidata/module/scripts/dialogs/perform-edits-dialog.js +++ b/extensions/wikidata/module/scripts/dialogs/perform-edits-dialog.js @@ -1,11 +1,10 @@ var PerformEditsDialog = {}; -PerformEditsDialog.launch = function(logged_in_username) { +PerformEditsDialog.launch = function(logged_in_username, max_severity) { var self = this; var elmts = this._elmts; var frame = this.frame; - console.log(this.missingSchema); if (this.missingSchema) { return; } @@ -16,6 +15,7 @@ PerformEditsDialog.launch = function(logged_in_username) { this._elmts.reviewYourEdits.html($.i18n._('perform-wikidata-edits')["review-your-edits"]); this._elmts.loggedInAs.text($.i18n._('perform-wikidata-edits')["logged-in-as"]); this._elmts.editSummaryLabel.text($.i18n._('perform-wikidata-edits')["edit-summary-label"]); + this._elmts.editSummary.attr('placeholder', $.i18n._('perform-wikidata-edits')["edit-summary-placeholder"]); this._elmts.performEditsButton.text($.i18n._('perform-wikidata-edits')["perform-edits"]); this._elmts.cancelButton.text($.i18n._('perform-wikidata-edits')["cancel"]); @@ -23,27 +23,33 @@ PerformEditsDialog.launch = function(logged_in_username) { DialogSystem.dismissUntil(self._level - 1); }; - elmts.loggedInUsername.text(logged_in_username); + elmts.loggedInUsername + .text(logged_in_username) + .attr('href','https://www.wikidata.org/wiki/User:'+logged_in_username); frame.find('.cancel-button').click(function() { dismiss(); }); - elmts.performEditsButton.click(function() { - Refine.postProcess( - "wikidata", - "perform-wikibase-edits", - {}, - { - summary: elmts.editSummary.val(), - }, - { includeEngine: true, cellsChanged: true, columnStatsChanged: true }, - { onDone: - function() { - dismiss(); - } - }); - }); + if (max_severity === 'CRITICAL') { + elmts.performEditsButton.prop("disabled",true).addClass("button-disabled"); + } else { + elmts.performEditsButton.click(function() { + Refine.postProcess( + "wikidata", + "perform-wikibase-edits", + {}, + { + summary: elmts.editSummary.val(), + }, + { includeEngine: true, cellsChanged: true, columnStatsChanged: true }, + { onDone: + function() { + dismiss(); + } + }); + }); + } }; PerformEditsDialog._updateWarnings = function(data) { @@ -68,13 +74,15 @@ PerformEditsDialog.checkAndLaunch = function () { ManageAccountDialog.ensureLoggedIn(function(logged_in_username) { if (logged_in_username) { + var discardWaiter = DialogSystem.showBusy($.i18n._('perform-wikidata-edits')["analyzing-edits"]); $.post( "command/wikidata/preview-wikibase-schema?" + $.param({ project: theProject.id }), { engine: JSON.stringify(ui.browsingEngine.getJSON()) }, function(data) { + discardWaiter(); if(data['status'] != 'error') { PerformEditsDialog._updateWarnings(data); - PerformEditsDialog.launch(logged_in_username); + PerformEditsDialog.launch(logged_in_username, data['max_severity']); } else { SchemaAlignmentDialog.launch( PerformEditsDialog.checkAndLaunch); diff --git a/extensions/wikidata/module/scripts/dialogs/schema-alignment-dialog.js b/extensions/wikidata/module/scripts/dialogs/schema-alignment-dialog.js index d8af0027a..5fe0700cc 100644 --- a/extensions/wikidata/module/scripts/dialogs/schema-alignment-dialog.js +++ b/extensions/wikidata/module/scripts/dialogs/schema-alignment-dialog.js @@ -279,10 +279,14 @@ SchemaAlignmentDialog._addNameDesc = function(item, json) { .text($.i18n._('wikidata-schema')["alias"]) .appendTo(type_input); type_input.val(type); + type_input.on('change', function(e) { + SchemaAlignmentDialog._hasChanged(); + }); var toolbar = $('
').addClass('wbs-toolbar').appendTo(namedesc); SchemaAlignmentDialog._makeDeleteButton().click(function() { namedesc.remove(); + SchemaAlignmentDialog._hasChanged(); }).appendTo(toolbar); var right = $('
').addClass('wbs-right').appendTo(namedesc); diff --git a/extensions/wikidata/module/scripts/warningsrenderer.js b/extensions/wikidata/module/scripts/warningsrenderer.js index 120ef1f0e..3e5ab59b1 100644 --- a/extensions/wikidata/module/scripts/warningsrenderer.js +++ b/extensions/wikidata/module/scripts/warningsrenderer.js @@ -6,7 +6,8 @@ WarningsRenderer._renderEntity = function(entity) { entity.id = entity.value.id; } var id = entity.id; - var is_new = id == "Q0"; + console.log(entity); + var is_new = entity.siteIri == "http://localhost/entity/"; if (is_new) { id = $.i18n._('wikidata-preview')['new-id']; } diff --git a/extensions/wikidata/module/styles/dialogs/manage-account-dialog.less b/extensions/wikidata/module/styles/dialogs/manage-account-dialog.less index 210c83e71..024fc8ed0 100644 --- a/extensions/wikidata/module/styles/dialogs/manage-account-dialog.less +++ b/extensions/wikidata/module/styles/dialogs/manage-account-dialog.less @@ -53,3 +53,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. padding-left: 10px; text-align: left; } + +.wikidata-logo { + float: left; + margin: -10px; +} + +.right-of-logo { + margin-left: 110px; +} diff --git a/extensions/wikidata/src/org/openrefine/wikidata/commands/PreviewWikibaseSchemaCommand.java b/extensions/wikidata/src/org/openrefine/wikidata/commands/PreviewWikibaseSchemaCommand.java index 74373c974..51a88c6a2 100644 --- a/extensions/wikidata/src/org/openrefine/wikidata/commands/PreviewWikibaseSchemaCommand.java +++ b/extensions/wikidata/src/org/openrefine/wikidata/commands/PreviewWikibaseSchemaCommand.java @@ -21,38 +21,6 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. ******************************************************************************/ -/* - -Copyright 2010, Google Inc. -All rights reserved. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are -met: - - * Redistributions of source code must retain the above copyright -notice, this list of conditions and the following disclaimer. - * Redistributions in binary form must reproduce the above -copyright notice, this list of conditions and the following disclaimer -in the documentation and/or other materials provided with the -distribution. - * Neither the name of Google Inc. nor the names of its -contributors may be used to endorse or promote products derived from -this software without specific prior written permission. - -THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS -"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT -LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR -A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT -OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT -LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, -DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY -THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT -(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE -OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - -*/ package org.openrefine.wikidata.commands; @@ -136,6 +104,10 @@ public class PreviewWikibaseSchemaCommand extends Command { warning.write(writer, new Properties()); } writer.endArray(); + + // Add max warning level + writer.key("max_severity"); + writer.value(warningStore.getMaxSeverity().toString()); // this is not the length of the warnings array written before, // but the total number of issues raised (before deduplication) diff --git a/extensions/wikidata/src/org/openrefine/wikidata/operations/PerformWikibaseEditsOperation.java b/extensions/wikidata/src/org/openrefine/wikidata/operations/PerformWikibaseEditsOperation.java index 05e798cac..8dee66f32 100644 --- a/extensions/wikidata/src/org/openrefine/wikidata/operations/PerformWikibaseEditsOperation.java +++ b/extensions/wikidata/src/org/openrefine/wikidata/operations/PerformWikibaseEditsOperation.java @@ -28,6 +28,7 @@ import java.io.LineNumberReader; import java.io.Writer; import java.util.List; import java.util.Properties; +import java.util.Random; import org.json.JSONException; import org.json.JSONObject; @@ -186,13 +187,17 @@ public class PerformWikibaseEditsOperation extends EngineDependentOperation { WikibaseDataFetcher wbdf = new WikibaseDataFetcher(connection, _schema.getBaseIri()); WikibaseDataEditor wbde = new WikibaseDataEditor(connection, _schema.getBaseIri()); + + // Generate batch token + long token = (new Random()).nextLong(); + String summary = _summary + " #OR:"+(Long.toHexString(token).substring(0, 7)); // Evaluate the schema List itemDocuments = _schema.evaluate(_project, _engine); // Prepare the edits NewItemLibrary newItemLibrary = new NewItemLibrary(); - EditBatchProcessor processor = new EditBatchProcessor(wbdf, wbde, itemDocuments, newItemLibrary, _summary, + EditBatchProcessor processor = new EditBatchProcessor(wbdf, wbde, itemDocuments, newItemLibrary, summary, 50); // Perform edits