From 396388c037789e3e0a8f8580284cb5551728911d Mon Sep 17 00:00:00 2001 From: Marius Hoch Date: Wed, 12 Feb 2020 17:45:39 +0100 Subject: [PATCH 01/58] QuerySamples: Allow moderate server and client side caching Right now opening the examples is terribly slow. Change-Id: Ibf80bc548fab256ce730bbf72051a2477ad95b80 --- wikibase/queryService/api/QuerySamples.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/wikibase/queryService/api/QuerySamples.js b/wikibase/queryService/api/QuerySamples.js index ce239b76..43488677 100644 --- a/wikibase/queryService/api/QuerySamples.js +++ b/wikibase/queryService/api/QuerySamples.js @@ -64,6 +64,8 @@ wikibase.queryService.api.QuerySamples = ( function ( $ ) { wrapoutputclass: '', disablelimitreport: '1', disableeditsection: '1', + smaxage: '600', + maxage: '600', disabletoc: '1' } ); }; From 27df32fdc3ad4f118584f2e85e2d82ba3d6b55d1 Mon Sep 17 00:00:00 2001 From: Lucas Werkmeister Date: Wed, 4 Mar 2020 17:16:02 +0100 Subject: [PATCH 02/58] Chain promises better in GraphResultBrowserNodeBrowser Though the results are currently discarded anyways. Change-Id: I686ac96ffe8acb1f20dea9c5773ca0f5f2002069 --- .../GraphResultBrowserNodeBrowser.js | 40 +++++++------------ 1 file changed, 14 insertions(+), 26 deletions(-) diff --git a/wikibase/queryService/ui/resultBrowser/GraphResultBrowserNodeBrowser.js b/wikibase/queryService/ui/resultBrowser/GraphResultBrowserNodeBrowser.js index 5999a1af..c9a54c20 100644 --- a/wikibase/queryService/ui/resultBrowser/GraphResultBrowserNodeBrowser.js +++ b/wikibase/queryService/ui/resultBrowser/GraphResultBrowserNodeBrowser.js @@ -101,12 +101,11 @@ wikibase.queryService.ui.resultBrowser.GraphResultBrowserNodeBrowser = ( functio * @private */ SELF.prototype._getEntites = function( entityUri, propertyUri ) { - var self = this, - deferred = $.Deferred(); + var self = this; - this._sparql.query( + return this._sparql.query( SPARQL_ENTITES.replace( '{entityUri}', entityUri ).replace( '{propertyUri}', - propertyUri ) ).done( function() { + propertyUri ) ).then( function() { var data = self._sparql.getResultRawData(); var result = []; @@ -117,22 +116,19 @@ wikibase.queryService.ui.resultBrowser.GraphResultBrowserNodeBrowser = ( functio } ); } ); - deferred.resolve( result ); + return result; } ); - - return deferred; }; /** * @private */ SELF.prototype._getIncomingEntites = function( entityUri, propertyUri ) { - var self = this, - deferred = $.Deferred(); + var self = this; - this._sparql.query( + return this._sparql.query( SPARQL_ENTITES_INCOMING.replace( '{entityUri}', entityUri ).replace( '{propertyUri}', - propertyUri ) ).done( function() { + propertyUri ) ).then( function() { var data = self._sparql.getResultRawData(); var result = []; @@ -143,20 +139,17 @@ wikibase.queryService.ui.resultBrowser.GraphResultBrowserNodeBrowser = ( functio } ); } ); - deferred.resolve( result ); + return result; } ); - - return deferred; }; /** * @private */ SELF.prototype._getProperties = function( entityUri ) { - var self = this, - deferred = $.Deferred(); + var self = this; - this._sparql.query( SPARQL_PROPERTIES.replace( '{entityUri}', entityUri ) ).done( + return this._sparql.query( SPARQL_PROPERTIES.replace( '{entityUri}', entityUri ) ).then( function() { var data = self._sparql.getResultRawData(); var result = []; @@ -170,20 +163,17 @@ wikibase.queryService.ui.resultBrowser.GraphResultBrowserNodeBrowser = ( functio } ); } ); - deferred.resolve( result ); + return result; } ); - - return deferred; }; /** * @private */ SELF.prototype._getIncomingProperties = function( entityUri ) { - var self = this, - deferred = $.Deferred(); + var self = this; - this._sparql.query( SPARQL_PROPERTIES_INCOMING.replace( '{entityUri}', entityUri ) ).done( + return this._sparql.query( SPARQL_PROPERTIES_INCOMING.replace( '{entityUri}', entityUri ) ).then( function() { var data = self._sparql.getResultRawData(); var result = []; @@ -197,10 +187,8 @@ wikibase.queryService.ui.resultBrowser.GraphResultBrowserNodeBrowser = ( functio } ); } ); - deferred.resolve( result ); + return result; } ); - - return deferred; }; /** From 68af459018c4883c2a3c2aff5d2fb41b77728fb4 Mon Sep 17 00:00:00 2001 From: Lucas Werkmeister Date: Wed, 4 Mar 2020 17:18:33 +0100 Subject: [PATCH 03/58] Handle promise rejection in GraphResultBrowserNodeBrowser MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It’s a pretty terrible way to handle the error, but at least it’s better than nothing at all. This could also be seen as a small step in the long journey of migrating this code base from jQuery’s deferred style (done/fail) to native Promise style (then) – jQuery is compatible with either, but I think the native Promise style is much better. Change-Id: I613826f89d99a0100519b90a679738ba1dc9e9d6 --- .../GraphResultBrowserNodeBrowser.js | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/wikibase/queryService/ui/resultBrowser/GraphResultBrowserNodeBrowser.js b/wikibase/queryService/ui/resultBrowser/GraphResultBrowserNodeBrowser.js index c9a54c20..40791923 100644 --- a/wikibase/queryService/ui/resultBrowser/GraphResultBrowserNodeBrowser.js +++ b/wikibase/queryService/ui/resultBrowser/GraphResultBrowserNodeBrowser.js @@ -233,7 +233,7 @@ wikibase.queryService.ui.resultBrowser.GraphResultBrowserNodeBrowser = ( functio node = this._temporaryNodes[nodeId]; var expandedNode = self._nodes.get( nodeId ); - this._getEntites( node.entityId, node.id ).done( function( entites ) { + this._getEntites( node.entityId, node.id ).then( function( entites ) { $.each( entites, function( i, e ) { if ( self._nodes.get( e.id ) === null ) { @@ -256,7 +256,7 @@ wikibase.queryService.ui.resultBrowser.GraphResultBrowserNodeBrowser = ( functio if ( expandedNode.label > 50 ) { self._getRemainingOutgoingNodes( node, expandedNode ); } - } ); + }, window.console.error ); }; /** @@ -288,7 +288,7 @@ wikibase.queryService.ui.resultBrowser.GraphResultBrowserNodeBrowser = ( functio node = this._incomingTemporaryNodes[nodeId]; var expandedNode = self._incomingNodes.get( nodeId ); - this._getIncomingEntites( node.entityId, node.id ).done( function( entites ) { + this._getIncomingEntites( node.entityId, node.id ).then( function( entites ) { $.each( entites, function( i, e ) { if ( self._incomingNodes.get( e.id ) === null ) { self._incomingNodes.add( { @@ -310,7 +310,7 @@ wikibase.queryService.ui.resultBrowser.GraphResultBrowserNodeBrowser = ( functio if ( expandedNode.label > 50 ) { self._getRemainingIncomingNodes( node, expandedNode ); } - } ); + }, window.console.error ); }; /** @@ -340,7 +340,7 @@ wikibase.queryService.ui.resultBrowser.GraphResultBrowserNodeBrowser = ( functio SELF.prototype._expandEntityNode = function( nodeId ) { var self = this; - this._getProperties( nodeId ).done( function( properties ) { + this._getProperties( nodeId ).then( function( properties ) { $.each( properties, function( i, p ) { //if already expanded skip if ( self._edges.get( { @@ -374,7 +374,7 @@ wikibase.queryService.ui.resultBrowser.GraphResultBrowserNodeBrowser = ( functio self._temporaryEdges[edge.id] = edge; self._edges.add( edge ); } ); - } ); + }, window.console.error ); }; /** @@ -383,7 +383,7 @@ wikibase.queryService.ui.resultBrowser.GraphResultBrowserNodeBrowser = ( functio SELF.prototype._expandIncomingEntityNode = function( nodeId ) { var self = this; - this._getIncomingProperties( nodeId ).done( function( properties ) { + this._getIncomingProperties( nodeId ).then( function( properties ) { $.each( properties, function( i, p ) { // if already expanded skip if ( self._incomingEdges.get( { @@ -417,7 +417,7 @@ wikibase.queryService.ui.resultBrowser.GraphResultBrowserNodeBrowser = ( functio self._incomingTemporaryEdges[edge.id] = edge; self._incomingEdges.add( edge ); } ); - } ); + }, window.console.error ); }; /** From f964a8c62c2972e1003f8a03f5f1754ee5f9d2c1 Mon Sep 17 00:00:00 2001 From: Translation updater bot Date: Mon, 20 Apr 2020 17:04:12 +0200 Subject: [PATCH 04/58] Localisation updates from https://translatewiki.net. Change-Id: I64b33abdcf89dd0dcae89cb46f511f66590ac79e --- i18n/lv.json | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/i18n/lv.json b/i18n/lv.json index b4fb7665..eaa7231a 100644 --- a/i18n/lv.json +++ b/i18n/lv.json @@ -35,7 +35,9 @@ "wdqs-app-help-queryhelper": "Vaicājumu palīgs", "wdqs-app-tools-edit-items": "Ierakstu labošanai", "wdqs-app-tools-query-data": "Vaicājuma dati", + "wdqs-app-tools-enhance-ui": "Lietotāja saskarnes papildinājumi", "wdqs-app-tools-visualize-data": "Datu vizualizācija", + "wdqs-app-tools-list-properties": "Īpašību saraksts", "wdqs-app-tools-lexicographical-data": "Leksikogrāfiskie dati", "wdqs-app-tools-for-programmers": "Programmētājiem", "wdqs-app-footer-help": "Nospied [CTRL-SPACE], lai aktivizētu automātisko pabeigšanu.", @@ -46,6 +48,7 @@ "wdqs-app-result-rawgraphs-title": "Izveidot grafiku no esošajiem rezultātu datiem ar RAWGraphs.io", "wdqs-app-result-embed": "Iegult rezultātu", "wdqs-app-result-endpoint": "SPARQL galapunkts", + "wdqs-app-result-endpoint-title": "Saite uz SPARQL galapunktu, kas atgriež rezultātu", "wdqs-app-result-formatter-title-datetime": "Neapstrādāts ISO laika zīmogs", "wdqs-app-result-json": "JSON fails", "wdqs-app-result-json-verbose": "JSON fails (izvērsti)", @@ -66,6 +69,7 @@ "wdqs-app-resultbrowser-timeline": "Laika skala", "wdqs-app-resultbrowser-dimensions": "Izmēri", "wdqs-app-toast-leave-fullscreen": "Nospied [esc], lai izietu no pilnekrāna režīma", + "wdqs-app-urlshortener-bad-service": "Nederīgs URL saīsinātājs konfigurācijā", "wdqs-app-urlshortener-failed": "URL saīsināšana neizdevās", "wdqs-app-urlshortener-loading": "Ielādē…", "wdqs-dialog-examples-preview-query": "Priekšskatīt vaicājumu", From 5638ac9ae5116386d1509621073537352af48419 Mon Sep 17 00:00:00 2001 From: Seb35 Date: Sat, 13 Jul 2019 17:38:06 +0200 Subject: [PATCH 05/58] Hint for permissible SPARQL variables inside BMP Bug: T227952 Change-Id: Ide688bc7e753f783b61735c2a0f78e409829a8dc --- .../queryService/ui/editor/hint/Sparql.js | 22 ++++++-- wikibase/tests/index.html | 2 + .../ui/editor/hint/Sparql.test.js | 51 +++++++++++++++++++ 3 files changed, 72 insertions(+), 3 deletions(-) create mode 100644 wikibase/tests/queryService/ui/editor/hint/Sparql.test.js diff --git a/wikibase/queryService/ui/editor/hint/Sparql.js b/wikibase/queryService/ui/editor/hint/Sparql.js index 72c47535..8f36f8cd 100755 --- a/wikibase/queryService/ui/editor/hint/Sparql.js +++ b/wikibase/queryService/ui/editor/hint/Sparql.js @@ -80,6 +80,22 @@ wikibase.queryService.ui.editor.hint = wikibase.queryService.ui.editor.hint || { 'dct:language' ]; + // This regex matches VARNAME from SPARQL 1.1 spec (minus \u10000-\uEFFFF because Blazegraph currently doesn’t support astral planes) + // VARNAME = FIRST_LETTER NEXT_LETTERS* + // FIRST_LETTER = PN_CHARS_BASE | '_' | [0-9] + // NEXT_LETTERS = PN_CHARS_BASE | '_' | [0-9] | #x00B7 | [#x0300-#x036F] | #x203F | #x2040 + // PN_CHARS_BASE = [A-Z] | [a-z] | [#x00C0-#x00D6] | [#x00D8-#x00F6] | [#x00F8-#x02FF] | [#x0370-#x037D] | + // [#x037F-#x1FFF] | #x200C | #x200D | [#x2070-#x218F] | [#x2C00-#x2FEF] | [#x3001-#xD7FF] | + // [#xF900-#xFDCF] | [#xFDF0-#xFFFD] (officially also [#x10000-#xEFFFF] but removed here) + // Also, in NEXT_LETTERS, the three ranges [#x00F8-#x02FF] | [#x0300-#x036F] | [#x0370-#x037D] are simplified as [#x00F8-#x037D] + var VARNAME = /\?[A-Za-z0-9_\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD][A-Za-z0-9_\u00B7\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u037D\u037F-\u1FFF\u200C\u200D\u203F\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]*/g; + + // This regex is used to move back to the beginning of a word. It matches NEXT_LETTERS, plus ?, #, and :, because those are also relevant for autocompletion. + var WORD_BEGIN = /[A-Za-z0-9_\u00B7\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u037D\u037F-\u1FFF\u200C\u200D\u203F\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD?#:]/; + + // This regex is used to move forward to the end of a word. It matches NEXT_LETTERS plus : because that is also relevant for autocompletion. + var WORD_END = /[A-Za-z0-9_\u00B7\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u037D\u037F-\u1FFF\u200C\u200D\u203F\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD:]/; + /** * Code completion for Wikibase entities RDF prefixes in SPARQL completes SPARQL keywords and ?variables * @@ -137,7 +153,7 @@ wikibase.queryService.ui.editor.hint = wikibase.queryService.ui.editor.hint || { SELF.prototype._getDefinedVariables = function( text ) { var variables = {}; - $.each( text.match( /\?\w+/g ), function( key, word ) { + $.each( text.match( VARNAME ), function( key, word ) { variables[ word ] = true; } ); @@ -184,7 +200,7 @@ wikibase.queryService.ui.editor.hint = wikibase.queryService.ui.editor.hint || { pos = 0; } - while ( /[\w?#:]/.test( line.charAt( pos ) ) ) { + while ( WORD_BEGIN.test( line.charAt( pos ) ) ) { pos--; if ( pos < 0 ) { break; @@ -193,7 +209,7 @@ wikibase.queryService.ui.editor.hint = wikibase.queryService.ui.editor.hint || { var left = pos + 1; pos = position; - while ( /[\w:]/.test( line.charAt( pos ) ) ) { + while ( WORD_END.test( line.charAt( pos ) ) ) { pos++; if ( pos >= line.length ) { break; diff --git a/wikibase/tests/index.html b/wikibase/tests/index.html index de8656eb..016db3fe 100644 --- a/wikibase/tests/index.html +++ b/wikibase/tests/index.html @@ -44,6 +44,7 @@ + @@ -69,6 +70,7 @@ + diff --git a/wikibase/tests/queryService/ui/editor/hint/Sparql.test.js b/wikibase/tests/queryService/ui/editor/hint/Sparql.test.js new file mode 100644 index 00000000..028c3704 --- /dev/null +++ b/wikibase/tests/queryService/ui/editor/hint/Sparql.test.js @@ -0,0 +1,51 @@ +( function( $, QUnit, sinon, wb ) { + 'use strict'; + + QUnit.module( 'wikibase.queryService.ui.editor.hint.Sparql' ); + var Sparql = wb.queryService.ui.editor.hint.Sparql; + + var VALID_SCENARIOS = [ + { scenario:'New variable', content:'?a', line:'?a', y:1, x:2, + result: {'from':{'char':0,'line':1},'to':{'char':2,'line':1},'list':['?a']}}, + + { scenario:'Existing variable with the same first characters', content:'?a ?aa ?a', line:'?a ?aa ?a', y:1, x:9, + result: {'from':{'char':7,'line':1},'to':{'char':9,'line':1},'list':['?a', '?aa']}}, + + { scenario:'Existing variable with the same first characters (non-ASCII version)', content:'?a ?aé ?a', line:'?a ?aé ?a', y:1, x:9, + result: {'from':{'char':7,'line':1},'to':{'char':9,'line':1},'list':['?a', '?aé']}}, + + ]; + + QUnit.test( 'is constructable', function( assert ) { + assert.expect( 1 ); + assert.ok( new Sparql() instanceof Sparql ); + } ); + + QUnit.test( 'When there is nothing to autocomplete', function( assert ) { + assert.expect( 1 ); + var done = assert.async(); + + var sparql = new Sparql(); + sparql.getHint('XXX', 'XXX', 1, 3).then( + function( hint ) { + assert.notOk( true, 'Hinting should not succeed'); + }, + function() { + assert.ok( true, 'Hinting must fail' ); + } + ).always( done ); + } ); + + $.each( VALID_SCENARIOS, function( key, test) { + + QUnit.test( 'When running valid scenario: ' + this.scenario, function( assert ) { + assert.expect( 1 ); + var done = assert.async(); + + var sparql = new Sparql(); + sparql.getHint( test.content, test.line, test.y, test.x ).done( function( hint ) { + assert.deepEqual( hint, test.result , 'Hint must return valid hint'); + } ).always( done ); + } ); + } ); +}( jQuery, QUnit, sinon, wikibase ) ); From 97a8ff30b0ce846d7178fdeee4d3f547eba184e5 Mon Sep 17 00:00:00 2001 From: Jakob Warkotsch Date: Wed, 29 Apr 2020 14:00:53 +0200 Subject: [PATCH 06/58] Add feedback banner for query builder discovery Change-Id: I96686991885ba16df46624e9d604bf0bd543abeb --- index.html | 9 +++++++++ style.less | 17 +++++++++++++++++ wikibase/feedbackBannerInit.js | 18 ++++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 wikibase/feedbackBannerInit.js diff --git a/index.html b/index.html index e84e7c48..787e3d1b 100644 --- a/index.html +++ b/index.html @@ -429,6 +429,14 @@