[Wikidata-bugs] [Maniphest] [Commented On] T216601: Allow download of Wikidata query results in GPS-friendly format(s)

2019-05-18 Thread Peb
Peb added a comment.


  any ideas on how to enable/unhide download menu item only when the query 
result containing geolocation? should i make separate task on the board?

TASK DETAIL
  https://phabricator.wikimedia.org/T216601

EMAIL PREFERENCES
  https://phabricator.wikimedia.org/settings/panel/emailpreferences/

To: Peb
Cc: Husky, Peb, Frettie, Geertivp, Salgo60, Pigsonthewing, Aklapper, 
darthmon_wmde, alaa_wmde, Ferenczy, sarhan.alaa, Samuditha24, IM3847, 
Dinadineke, Nandana, kostajh, tabish.shaikh91, Lahi, Gq86, 
Lucas_Werkmeister_WMDE, GoranSMilovanovic, Soteriaspace, Jayprakash12345, 
Chicocvenancio, JakeTheDeveloper, MichaelSchoenitzer_WMDE, QZanden, EBjune, 
merbst, LawExplorer, Jogi_don, _jensen, rosalieper, D3r1ck01, Jonas, Xmlizer, 
jkroll, Smalyshev, Wikidata-bugs, Jdouglas, Jdlrobson, aude, Tobias1984, 
Manybubbles, Lydia_Pintscher, TheDJ, Mbch331, Rxy
___
Wikidata-bugs mailing list
Wikidata-bugs@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikidata-bugs


[Wikidata-bugs] [Maniphest] [Commented On] T216601: Allow download of Wikidata query results in GPS-friendly format(s)

2019-05-18 Thread Peb
Peb added a comment.


  I have implemented for GeoJSON, GPX, and KML. here's the snippet. three small 
npm libraries are used : wicket (parsing WKT), togpx, tokml
  
/**
 * Get the result of the submitted query as GeoJSON
 *
 * @return {object}
 */
SELF.prototype._getResultAsGeoJson = function() {
var output = [],
data = this._rawData;
var wkt = new Wkt.Wkt();
output = this._processData( data, function( row, out ) {
var newRow = {};
for ( var rowVar in row ) {
var binding = ( row[rowVar] || {} );
if ( binding.type === 'literal' && 
binding.datatype && binding.datatype === 
'http://www.opengis.net/ont/geosparql#wktLiteral' ) {
wkt.read( binding.value );
newRow._lat = wkt.components[0].y;
newRow._lng = wkt.components[0].x;
} else { 
newRow[rowVar] = binding.value;
}
}
out.push( newRow );
return out;
}, output );
return GeoJSON.parse( output, { Point: ['_lat', '_lng'] } );
};

/**
 * Get the result of the submitted query as GeoJSON
 *
 * @return {string}
 */
SELF.prototype.getResultAsGeoJson = function() {
return JSON.stringify( this._getResultAsGeoJson() );
};

/**
 * Get the result of the submitted query as GPX
 *
 * @return {string}
 */
SELF.prototype.getResultAsGPX = function() {
var gj = this._getResultAsGeoJson();
return togpx( gj );
};

/**
 * Get the result of the submitted query as KML
 *
 * @return {string}
 */
SELF.prototype.getResultAsKML = function() {
var gj = this._getResultAsGeoJson();
return tokml( gj );
};

TASK DETAIL
  https://phabricator.wikimedia.org/T216601

EMAIL PREFERENCES
  https://phabricator.wikimedia.org/settings/panel/emailpreferences/

To: Peb
Cc: Husky, Peb, Frettie, Geertivp, Salgo60, Pigsonthewing, Aklapper, 
darthmon_wmde, alaa_wmde, Ferenczy, sarhan.alaa, Samuditha24, IM3847, 
Dinadineke, Nandana, kostajh, tabish.shaikh91, Lahi, Gq86, 
Lucas_Werkmeister_WMDE, GoranSMilovanovic, Soteriaspace, Jayprakash12345, 
Chicocvenancio, JakeTheDeveloper, MichaelSchoenitzer_WMDE, QZanden, EBjune, 
merbst, LawExplorer, Jogi_don, _jensen, rosalieper, D3r1ck01, Jonas, Xmlizer, 
jkroll, Smalyshev, Wikidata-bugs, Jdouglas, Jdlrobson, aude, Tobias1984, 
Manybubbles, Lydia_Pintscher, TheDJ, Mbch331, Rxy
___
Wikidata-bugs mailing list
Wikidata-bugs@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikidata-bugs


[Wikidata-bugs] [Maniphest] [Commented On] T211177: WDQ UI should support download of RDF formats

2019-05-18 Thread Peb
Peb added a comment.


  ignore the previous patch, i should have used existing `_renderValueTSV` 
function. so far implemented for NTriples and JSON-LD. for JSON-LD (using 
`jsonld.js`), i need to modify the download function in the `ResultView.js` 
(the one calling handler function) to accomodate handler function returning 
Promise object instead of string.

TASK DETAIL
  https://phabricator.wikimedia.org/T211177

EMAIL PREFERENCES
  https://phabricator.wikimedia.org/settings/panel/emailpreferences/

To: Peb
Cc: Lucas_Werkmeister_WMDE, Peb, Smalyshev, Aklapper, VladimirAlexiev, 
darthmon_wmde, alaa_wmde, Ferenczy, sarhan.alaa, Samuditha24, IM3847, 
Dinadineke, Nandana, kostajh, tabish.shaikh91, Lahi, Gq86, GoranSMilovanovic, 
Soteriaspace, Jayprakash12345, Chicocvenancio, JakeTheDeveloper, 
MichaelSchoenitzer_WMDE, QZanden, EBjune, merbst, LawExplorer, Salgo60, 
Jogi_don, _jensen, rosalieper, D3r1ck01, Jonas, Xmlizer, jkroll, Wikidata-bugs, 
Jdouglas, Jdlrobson, aude, Tobias1984, Manybubbles, Lydia_Pintscher, TheDJ, 
Mbch331, Rxy
___
Wikidata-bugs mailing list
Wikidata-bugs@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikidata-bugs


[Wikidata-bugs] [Maniphest] [Commented On] T211177: WDQ UI should support download of RDF formats

2019-05-15 Thread Peb
Peb added a comment.


  made a starting code to download as NTriples by converting from 
SPARQL-Result-JSON. 
  The JSON-LD might be quite straightforward using jsonld.js 
<https://github.com/digitalbazaar/jsonld.js> `fromRdf` function given NT input
  
diff --git a/wikibase/queryService/api/Sparql.js 
b/wikibase/queryService/api/Sparql.js
index 9a4e5e1..7003587 100644
--- a/wikibase/queryService/api/Sparql.js
+++ b/wikibase/queryService/api/Sparql.js
@@ -422,6 +422,60 @@ wikibase.queryService.api.Sparql = ( function( $ ) {
};
 
/**
+* Get the result of the submitted query as N-Triples
+*
+* @return {string}
+*/
+   SELF.prototype.getResultAsNTriples = function() {
+   var output = '',
+   data = this._rawData;
+
+   output = this._processData( data, function( row, out ) {
+   var rowOut = '';
+   var rowVar = 'subject';
+   if ( ( row[rowVar] || {} ).type === 'uri' ) {
+   rowOut += '<';
+   rowOut += ( row[rowVar] || {} ).value;
+   rowOut += '> ';
+   } else if ( ( row[rowVar] || {} ).type === 'bnode' ) {
+   rowOut += '_:';
+   rowOut += ( row[rowVar] || {} ).value;
+   rowOut += ' ';
+   }
+   //predicate MUST be of type uri
+   rowVar = 'predicate';
+   rowOut += '<';
+   rowOut += ( row[rowVar] || {} ).value;
+   rowOut += '> ';
+   //object
+   rowVar = 'object';
+   if ( ( row[rowVar] || {} ).type === 'uri' ) {
+   rowOut += '<';
+   rowOut += ( row[rowVar] || {} ).value;
+   rowOut += '> ';
+   } else if ( ( row[rowVar] || {} ).type === 'literal' ) {
+   var obj = ( row[rowVar] || {} );
+   var escapedObj = JSON.stringify( String( 
obj.value ) );
+   escapedObj = escapedObj.substring( 1, 
escapedObj.length - 1 );
+   rowOut += '"';
+   rowOut += escapedObj;
+   rowOut += '"';
+   if ( 'datatype' in obj ) {
+   rowOut += '^^<';
+   rowOut += obj.datatype;
+   rowOut += '>';
+   } else if ( 'xml:lang' in obj ) {
+   rowOut += '@';
+   rowOut += obj['xml:lang'];
+   }
+   }
+   rowOut += ' .\n';
+   return out + rowOut;
+   }, output );
+   return output;
+   };
+
+   /**
 * Render value as per 
http://www.w3.org/TR/sparql11-results-csv-tsv/#tsv
 *
 * @param {Object} binding

TASK DETAIL
  https://phabricator.wikimedia.org/T211177

EMAIL PREFERENCES
  https://phabricator.wikimedia.org/settings/panel/emailpreferences/

To: Peb
Cc: Lucas_Werkmeister_WMDE, Peb, Smalyshev, Aklapper, VladimirAlexiev, 
darthmon_wmde, alaa_wmde, Ferenczy, sarhan.alaa, Samuditha24, IM3847, 
Dinadineke, Nandana, kostajh, tabish.shaikh91, Lahi, Gq86, GoranSMilovanovic, 
Soteriaspace, Jayprakash12345, Chicocvenancio, JakeTheDeveloper, QZanden, 
EBjune, merbst, LawExplorer, Salgo60, Jogi_don, _jensen, rosalieper, D3r1ck01, 
Jonas, Xmlizer, Samwilson, jkroll, Wikidata-bugs, Jdouglas, Jdlrobson, aude, 
Tobias1984, Manybubbles, Lydia_Pintscher, TheDJ, Mbch331, Rxy
___
Wikidata-bugs mailing list
Wikidata-bugs@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikidata-bugs


[Wikidata-bugs] [Maniphest] [Commented On] T216601: Allow download of Wikidata query results in GPS-friendly format(s)

2019-05-15 Thread Peb
Peb added a comment.


  I can  help with this too along with RDF download task 
<https://phabricator.wikimedia.org/T211177>

TASK DETAIL
  https://phabricator.wikimedia.org/T216601

EMAIL PREFERENCES
  https://phabricator.wikimedia.org/settings/panel/emailpreferences/

To: Peb
Cc: Peb, Frettie, Geertivp, Salgo60, Pigsonthewing, Aklapper, darthmon_wmde, 
alaa_wmde, Ferenczy, sarhan.alaa, Samuditha24, IM3847, Nandana, kostajh, Lahi, 
Gq86, Lucas_Werkmeister_WMDE, GoranSMilovanovic, Jayprakash12345, 
Chicocvenancio, QZanden, EBjune, merbst, LawExplorer, Jogi_don, _jensen, 
rosalieper, D3r1ck01, Jonas, Xmlizer, Samwilson, jkroll, Smalyshev, 
Wikidata-bugs, Jdouglas, Jdlrobson, aude, Tobias1984, Manybubbles, 
Lydia_Pintscher, Mbch331, Rxy
___
Wikidata-bugs mailing list
Wikidata-bugs@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikidata-bugs


[Wikidata-bugs] [Maniphest] [Commented On] T211177: WDQ UI should support download of RDF formats

2019-05-15 Thread Peb
Peb added a comment.


  According to blazegraph documentation 
<https://wiki.blazegraph.com/wiki/index.php/REST_API#MIME_Types>, the endpoint 
supports various formats. 
  I tried using my sparql query app <https://pebbie.org/mashup/gensparql> and 
all listed formats there are returned.

TASK DETAIL
  https://phabricator.wikimedia.org/T211177

EMAIL PREFERENCES
  https://phabricator.wikimedia.org/settings/panel/emailpreferences/

To: Peb
Cc: Peb, Smalyshev, Aklapper, VladimirAlexiev, darthmon_wmde, alaa_wmde, 
Ferenczy, sarhan.alaa, Samuditha24, IM3847, Dinadineke, Nandana, kostajh, 
tabish.shaikh91, Lahi, Gq86, Lucas_Werkmeister_WMDE, GoranSMilovanovic, 
Soteriaspace, Jayprakash12345, Chicocvenancio, JakeTheDeveloper, QZanden, 
EBjune, merbst, LawExplorer, Salgo60, Jogi_don, _jensen, rosalieper, D3r1ck01, 
Jonas, Xmlizer, Samwilson, jkroll, Wikidata-bugs, Jdouglas, Jdlrobson, aude, 
Tobias1984, Manybubbles, Lydia_Pintscher, TheDJ, Mbch331, Rxy
___
Wikidata-bugs mailing list
Wikidata-bugs@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikidata-bugs


[Wikidata-bugs] [Maniphest] [Claimed] T211177: WDQ UI should support download of RDF formats

2019-05-15 Thread Peb
Peb claimed this task.

TASK DETAIL
  https://phabricator.wikimedia.org/T211177

EMAIL PREFERENCES
  https://phabricator.wikimedia.org/settings/panel/emailpreferences/

To: Peb
Cc: Peb, Smalyshev, Aklapper, VladimirAlexiev, darthmon_wmde, alaa_wmde, 
Ferenczy, sarhan.alaa, Samuditha24, IM3847, Dinadineke, Nandana, kostajh, 
tabish.shaikh91, Lahi, Gq86, Lucas_Werkmeister_WMDE, GoranSMilovanovic, 
Soteriaspace, Jayprakash12345, Chicocvenancio, JakeTheDeveloper, QZanden, 
EBjune, merbst, LawExplorer, Salgo60, Jogi_don, _jensen, rosalieper, D3r1ck01, 
Jonas, Xmlizer, Samwilson, jkroll, Wikidata-bugs, Jdouglas, Jdlrobson, aude, 
Tobias1984, Manybubbles, Lydia_Pintscher, TheDJ, Mbch331, Rxy
___
Wikidata-bugs mailing list
Wikidata-bugs@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/wikidata-bugs