Prettify the UI and add a token to the edit summaries

This commit is contained in:
Antonin Delpeuch 2018-03-04 10:55:47 +00:00
parent 999b1d4920
commit 3a58c6824d
12 changed files with 89 additions and 73 deletions

View File

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" version="1.2" width="1052.36" height="744.09003">
<path d="m 119.4207,543.01679 h 29.16277 V 43.052497 H 119.4207 V 543.01679 z m 60.27256,0 h 89.42926 V 43.052497 H 179.69326 V 543.01679 z M 298.29136,43.052497 V 542.99895 h 89.42926 V 43.052497 h -89.42926 z" style="fill:#990000" />
<path d="m 838.97933,543.0524 h 29.16883 V 43.052437 H 838.97933 V 543.0524 z M 899.25795,43.052437 V 543.0524 h 29.16277 V 43.052437 H 899.25795 z M 417.85387,543.05247 h 29.16277 V 43.052497 H 417.85387 V 543.05247 z M 478.13249,43.052497 V 543.03463 h 29.16884 V 43.052497 h -29.16884 z" style="fill:#339966" />
<path d="m 537.42244,543.05247 h 89.4414 V 43.052497 h -89.4414 V 543.05247 z m 118.5981,0 h 31.10372 V 43.052497 H 656.02054 V 543.05247 z M 716.2931,43.052497 V 543.03463 h 89.42926 V 43.052497 H 716.2931 z" style="fill:#006699" />
<path d="m 883.98859,598.08811 46.01562,103.68359 -27.75781,0 -8.53516,-20.48438 -46.38672,0 -7.71875,20.48438 -27.38672,0 41.78516,-103.68359 29.98438,0 m 2.07812,65.08984 -16.69922,-40.30078 -15.21484,40.30078 31.91406,0 m -60.26562,-65.08984 0,19 -37.55469,0 0,84.68359 -25.82813,0 0,-84.68359 -37.55468,0 0,-19 100.9375,0 m -133.59375,0 46.01562,103.68359 -27.75781,0 -8.53516,-20.48438 -46.38672,0 -7.71875,20.48438 -27.38672,0 41.78516,-103.68359 29.98438,0 m 2.07812,65.08984 -16.69922,-40.30078 -15.21484,40.30078 31.91406,0 m -176.56641,-65.08984 45.71875,0 c 17.66399,10e-5 31.6171,4.84905 41.85938,14.54687 10.29156,9.64852 15.43739,22.142 15.4375,37.48047 -1.1e-4,16.08076 -5.22016,28.72268 -15.66016,37.92578 -10.39071,9.15365 -25.23444,13.73047 -44.53125,13.73047 l -42.82422,0 0,-103.68359 m 25.82813,19 0,65.68359 16.84766,0 c 10.93483,2e-5 19.2968,-2.99347 25.08593,-8.98047 5.78898,-6.03642 8.68351,-13.97782 8.6836,-23.82422 -9e-5,-10.19264 -2.9441,-18.20826 -8.83203,-24.04687 -5.83862,-5.88794 -14.25007,-8.83195 -25.23438,-8.83203 l -16.55078,0 m -49.72656,-19 0,103.68359 -25.82813,0 0,-103.68359 25.82813,0 m -48.91016,0 -33.76953,48.6875 45.79297,54.99609 -32.35938,0 -41.04297,-48.61328 0,48.61328 -25.82812,0 0,-103.68359 25.82812,0 0,46.68359 32.95313,-46.68359 28.42578,0 m -111.10547,0 0,103.68359 -25.82812,0 0,-103.68359 25.82812,0 m -127.21094,37.40625 -32.0625,67.61328 -11.13281,0 -45.57031,-105.01953 27.38672,0 24.41797,57.29687 26.64453,-57.29687 20.78125,0 26.64453,57.29687 24.26953,-57.29687 27.38672,0 -45.42188,105.01953 -11.13281,0 -32.21094,-67.61328" style="fill:#484848;fill-opacity:1;stroke:none;font-family:Gill Sans MT" />
</svg>

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

View File

@ -48,7 +48,7 @@
}, },
"wikidata-account": { "wikidata-account": {
"dialog-header": "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 <a href=\"https://www.wikidata.org/\" target=\"_blank\">Wikidata</a> lets you to perform edits directly from OpenRefine.",
"username-label": "Username:", "username-label": "Username:",
"username-placeholder": "Enter your username", "username-placeholder": "Enter your username",
"password-label": "Password:", "password-label": "Password:",
@ -57,20 +57,23 @@
"close": "Close", "close": "Close",
"log-in": "Log in", "log-in": "Log in",
"logged-in-as": "You are logged in as:", "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": { "perform-wikidata-edits": {
"dialog-header": "Perform edits on Wikidata", "dialog-header": "Perform edits on Wikidata",
"review-your-edits": "Please review your edits before pushing them to Wikidata. Consider requesting feedback at the <a href=\"https://www.wikidata.org/wiki/Wikidata:Data_Import_Hub\">Data Import Hub</a> for large datasets.", "review-your-edits": "Please check your edits carefully before pushing them to Wikidata. Large edit batches should be submitted for <a href=\"https://www.wikidata.org/wiki/Wikidata:Requests_for_permissions/Bot\" target=\"_blank\">bot review</a> first.",
"logged-in-as": "You are logged in as", "logged-in-as": "You are logged in as",
"edit-summary-label": "Edit summary:", "edit-summary-label": "Edit summary:",
"edit-summary-placeholder": "a few words to describe your edits",
"perform-edits": "Perform edits", "perform-edits": "Perform edits",
"cancel": "Cancel" "cancel": "Cancel",
"analyzing-edits": "Analyzing your edits..."
}, },
"warnings-messages": { "warnings-messages": {
"new-item-created": { "new-item-created": {
"title": "This batch will create new Wikidata items.", "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 <a href=\"https://www.wikidata.org/wiki/Wikidata:Notability\" target=\"_blank\">suitable for inclusion in Wikidata</a>."
}, },
"new-item-without-labels-or-aliases": { "new-item-without-labels-or-aliases": {
"title": "New items created without any label or alias.", "title": "New items created without any label or alias.",

View File

@ -1,6 +1,10 @@
<div class="dialog-frame" style="width: 800px;"> <div class="dialog-frame" style="width: 800px;">
<div class="dialog-header" bind="dialogHeader"></div> <div class="dialog-header" bind="dialogHeader"></div>
<div class="dialog-body" bind="dialogBody"> <div class="dialog-body" bind="dialogBody">
<a href="https://www.wikidata.org/" target="_blank">
<img src="extension/wikidata/images/wikidata.png" class="wikidata-logo" alt="Wikidata logo" />
</a>
<div class="right-of-logo">
<p class="body-text" bind="explainLogIn"> <p class="body-text" bind="explainLogIn">
</p> </p>
<div class="wikibase-user-management-area"> <div class="wikibase-user-management-area">
@ -29,7 +33,7 @@
</div> </div>
<div class="wikibase-user-logout" bind="logoutArea"> <div class="wikibase-user-logout" bind="logoutArea">
<p><span bind="loggedInAs"></span> <p><span bind="loggedInAs"></span>
<span bind="loggedInUsername"></span></p> <a bind="loggedInUsername" target="_blank"></a></p>
<form bind="logoutForm" method="post"> <form bind="logoutForm" method="post">
<input type="hidden" name="wb-username" value="null" /> <input type="hidden" name="wb-username" value="null" />
<input name="wb-password" type="hidden" value="null" /> <input name="wb-password" type="hidden" value="null" />
@ -42,3 +46,4 @@
</div> </div>
</div> </div>
</div> </div>
</div>

View File

@ -1,12 +1,6 @@
var ManageAccountDialog = {}; var ManageAccountDialog = {};
/*
$.post( ManageAccountDialog.firstLogin = true;
"command/core/get-all-preferences",
null,
populatePreferences,
"json"
);
*/
ManageAccountDialog.launch = function(logged_in_username, callback) { ManageAccountDialog.launch = function(logged_in_username, callback) {
$.post( $.post(
@ -23,10 +17,10 @@ ManageAccountDialog.display = function(logged_in_username, saved_credentials, ca
var self = this; var self = this;
var frame = $(DOM.loadHTML("wikidata", "scripts/dialogs/manage-account-dialog.html")); var frame = $(DOM.loadHTML("wikidata", "scripts/dialogs/manage-account-dialog.html"));
var elmts = this._elmts = DOM.bind(frame); 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.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.usernameLabel.text($.i18n._('wikidata-account')["username-label"]);
this._elmts.usernameInput.attr("placeholder", $.i18n._('wikidata-account')["username-placeholder"]); this._elmts.usernameInput.attr("placeholder", $.i18n._('wikidata-account')["username-placeholder"]);
this._elmts.passwordLabel.text($.i18n._('wikidata-account')["password-label"]); 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.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() { frame.find('.cancel-button').click(function() {
dismiss(); dismiss();
@ -88,9 +84,15 @@ ManageAccountDialog.display = function(logged_in_username, saved_credentials, ca
}; };
ManageAccountDialog.isLoggedIn = function(callback) { ManageAccountDialog.isLoggedIn = function(callback) {
var discardWaiter = function() { };
if(ManageAccountDialog.firstLogin) {
discardWaiter = DialogSystem.showBusy($.i18n._('wikidata-account')["connecting-to-wikidata"]);
}
$.get( $.get(
"command/wikidata/login", "command/wikidata/login",
function(data) { function(data) {
discardWaiter();
ManageAccountDialog.firstLogin = false;
callback(data.username); callback(data.username);
}); });
}; };

View File

@ -6,7 +6,7 @@
<div class="perform-edits-warnings-area" bind="warningsArea"> <div class="perform-edits-warnings-area" bind="warningsArea">
</div> </div>
<div class="wikibase-perform-edits-area"> <div class="wikibase-perform-edits-area">
<p><span bind="loggedInAs"></span> <span bind="loggedInUsername"></span>.</p> <p><span bind="loggedInAs"></span> <a bind="loggedInUsername" target="_blank"></a>.</p>
<p><span bind="editSummaryLabel"></span> <input type="text" name="editSummary" bind="editSummary" class="edit-summary" value="" /></p> <p><span bind="editSummaryLabel"></span> <input type="text" name="editSummary" bind="editSummary" class="edit-summary" value="" /></p>
<div class="wikibase-login-buttons"> <div class="wikibase-login-buttons">
<button class="button cancel-button" bind="cancelButton"></button> <button class="button cancel-button" bind="cancelButton"></button>

View File

@ -1,11 +1,10 @@
var PerformEditsDialog = {}; var PerformEditsDialog = {};
PerformEditsDialog.launch = function(logged_in_username) { PerformEditsDialog.launch = function(logged_in_username, max_severity) {
var self = this; var self = this;
var elmts = this._elmts; var elmts = this._elmts;
var frame = this.frame; var frame = this.frame;
console.log(this.missingSchema);
if (this.missingSchema) { if (this.missingSchema) {
return; return;
} }
@ -16,6 +15,7 @@ PerformEditsDialog.launch = function(logged_in_username) {
this._elmts.reviewYourEdits.html($.i18n._('perform-wikidata-edits')["review-your-edits"]); this._elmts.reviewYourEdits.html($.i18n._('perform-wikidata-edits')["review-your-edits"]);
this._elmts.loggedInAs.text($.i18n._('perform-wikidata-edits')["logged-in-as"]); this._elmts.loggedInAs.text($.i18n._('perform-wikidata-edits')["logged-in-as"]);
this._elmts.editSummaryLabel.text($.i18n._('perform-wikidata-edits')["edit-summary-label"]); 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.performEditsButton.text($.i18n._('perform-wikidata-edits')["perform-edits"]);
this._elmts.cancelButton.text($.i18n._('perform-wikidata-edits')["cancel"]); this._elmts.cancelButton.text($.i18n._('perform-wikidata-edits')["cancel"]);
@ -23,12 +23,17 @@ PerformEditsDialog.launch = function(logged_in_username) {
DialogSystem.dismissUntil(self._level - 1); 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() { frame.find('.cancel-button').click(function() {
dismiss(); dismiss();
}); });
if (max_severity === 'CRITICAL') {
elmts.performEditsButton.prop("disabled",true).addClass("button-disabled");
} else {
elmts.performEditsButton.click(function() { elmts.performEditsButton.click(function() {
Refine.postProcess( Refine.postProcess(
"wikidata", "wikidata",
@ -44,6 +49,7 @@ PerformEditsDialog.launch = function(logged_in_username) {
} }
}); });
}); });
}
}; };
PerformEditsDialog._updateWarnings = function(data) { PerformEditsDialog._updateWarnings = function(data) {
@ -68,13 +74,15 @@ PerformEditsDialog.checkAndLaunch = function () {
ManageAccountDialog.ensureLoggedIn(function(logged_in_username) { ManageAccountDialog.ensureLoggedIn(function(logged_in_username) {
if (logged_in_username) { if (logged_in_username) {
var discardWaiter = DialogSystem.showBusy($.i18n._('perform-wikidata-edits')["analyzing-edits"]);
$.post( $.post(
"command/wikidata/preview-wikibase-schema?" + $.param({ project: theProject.id }), "command/wikidata/preview-wikibase-schema?" + $.param({ project: theProject.id }),
{ engine: JSON.stringify(ui.browsingEngine.getJSON()) }, { engine: JSON.stringify(ui.browsingEngine.getJSON()) },
function(data) { function(data) {
discardWaiter();
if(data['status'] != 'error') { if(data['status'] != 'error') {
PerformEditsDialog._updateWarnings(data); PerformEditsDialog._updateWarnings(data);
PerformEditsDialog.launch(logged_in_username); PerformEditsDialog.launch(logged_in_username, data['max_severity']);
} else { } else {
SchemaAlignmentDialog.launch( SchemaAlignmentDialog.launch(
PerformEditsDialog.checkAndLaunch); PerformEditsDialog.checkAndLaunch);

View File

@ -279,10 +279,14 @@ SchemaAlignmentDialog._addNameDesc = function(item, json) {
.text($.i18n._('wikidata-schema')["alias"]) .text($.i18n._('wikidata-schema')["alias"])
.appendTo(type_input); .appendTo(type_input);
type_input.val(type); type_input.val(type);
type_input.on('change', function(e) {
SchemaAlignmentDialog._hasChanged();
});
var toolbar = $('<div></div>').addClass('wbs-toolbar').appendTo(namedesc); var toolbar = $('<div></div>').addClass('wbs-toolbar').appendTo(namedesc);
SchemaAlignmentDialog._makeDeleteButton().click(function() { SchemaAlignmentDialog._makeDeleteButton().click(function() {
namedesc.remove(); namedesc.remove();
SchemaAlignmentDialog._hasChanged();
}).appendTo(toolbar); }).appendTo(toolbar);
var right = $('<div></div>').addClass('wbs-right').appendTo(namedesc); var right = $('<div></div>').addClass('wbs-right').appendTo(namedesc);

View File

@ -6,7 +6,8 @@ WarningsRenderer._renderEntity = function(entity) {
entity.id = entity.value.id; entity.id = entity.value.id;
} }
var id = entity.id; var id = entity.id;
var is_new = id == "Q0"; console.log(entity);
var is_new = entity.siteIri == "http://localhost/entity/";
if (is_new) { if (is_new) {
id = $.i18n._('wikidata-preview')['new-id']; id = $.i18n._('wikidata-preview')['new-id'];
} }

View File

@ -53,3 +53,12 @@ OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
padding-left: 10px; padding-left: 10px;
text-align: left; text-align: left;
} }
.wikidata-logo {
float: left;
margin: -10px;
}
.right-of-logo {
margin-left: 110px;
}

View File

@ -21,38 +21,6 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE. * 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; package org.openrefine.wikidata.commands;
@ -137,6 +105,10 @@ public class PreviewWikibaseSchemaCommand extends Command {
} }
writer.endArray(); 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, // this is not the length of the warnings array written before,
// but the total number of issues raised (before deduplication) // but the total number of issues raised (before deduplication)
writer.key("nb_warnings"); writer.key("nb_warnings");

View File

@ -28,6 +28,7 @@ import java.io.LineNumberReader;
import java.io.Writer; import java.io.Writer;
import java.util.List; import java.util.List;
import java.util.Properties; import java.util.Properties;
import java.util.Random;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
@ -187,12 +188,16 @@ public class PerformWikibaseEditsOperation extends EngineDependentOperation {
WikibaseDataFetcher wbdf = new WikibaseDataFetcher(connection, _schema.getBaseIri()); WikibaseDataFetcher wbdf = new WikibaseDataFetcher(connection, _schema.getBaseIri());
WikibaseDataEditor wbde = new WikibaseDataEditor(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 // Evaluate the schema
List<ItemUpdate> itemDocuments = _schema.evaluate(_project, _engine); List<ItemUpdate> itemDocuments = _schema.evaluate(_project, _engine);
// Prepare the edits // Prepare the edits
NewItemLibrary newItemLibrary = new NewItemLibrary(); NewItemLibrary newItemLibrary = new NewItemLibrary();
EditBatchProcessor processor = new EditBatchProcessor(wbdf, wbde, itemDocuments, newItemLibrary, _summary, EditBatchProcessor processor = new EditBatchProcessor(wbdf, wbde, itemDocuments, newItemLibrary, summary,
50); 50);
// Perform edits // Perform edits