{"id":189,"date":"2014-04-10T14:44:23","date_gmt":"2014-04-10T13:44:23","guid":{"rendered":"http:\/\/blog.magnusmanske.de\/?p=189"},"modified":"2014-04-10T14:44:23","modified_gmt":"2014-04-10T13:44:23","slug":"post-scriptum","status":"publish","type":"post","link":"http:\/\/magnusmanske.de\/wordpress\/archives\/189","title":{"rendered":"Post scriptum"},"content":{"rendered":"<p>I am running a lot of tools on Labs. As with most software, the majority of feedback I get for those tools falls into one of two categories: bug reports and feature requests, the latter often in the form &#8220;can the tool get input from\/filter on\/output to&#8230;&#8221;. In many cases, that is quick to implement; others are more tricky. Besides increasing the complexity of tools, and filling up the interface with rarely-used buttons and input fields, the combinations (&#8220;&#8230;as you did in that other tool&#8230;&#8221;) would eventually exceed my coding bandwidth. And with &#8220;eventually&#8221;, I mean some time ago.<\/p>\n<p>Wouldn&#8217;t it be better if users could &#8220;connect&#8221; tools on their own? Take the output of tool X and use it as the input of tool Y? About two years ago, I tried to let users <a href=\"http:\/\/magnusmanske.de\/wordpress\/?p=46\">pipeline some tools<\/a> on their own; the uptake, however, was rather underwhelming, which might have been due to the early stage of this &#8220;meta-tool&#8221;, and its somewhat limited flexibility.<\/p>\n<div id=\"attachment_190\" style=\"width: 310px\" class=\"wp-caption alignright\"><a href=\"http:\/\/magnusmanske.de\/wordpress\/wp-content\/uploads\/2014\/04\/Screen-Shot-2014-04-10-at-11.20.30.png\"><img decoding=\"async\" aria-describedby=\"caption-attachment-190\" class=\"size-medium wp-image-190\" alt=\"A script and its output\" src=\"http:\/\/magnusmanske.de\/wordpress\/wp-content\/uploads\/2014\/04\/Screen-Shot-2014-04-10-at-11.20.30-300x126.png\" width=\"300\" srcset=\"http:\/\/magnusmanske.de\/wordpress\/wp-content\/uploads\/2014\/04\/Screen-Shot-2014-04-10-at-11.20.30-300x126.png 300w, http:\/\/magnusmanske.de\/wordpress\/wp-content\/uploads\/2014\/04\/Screen-Shot-2014-04-10-at-11.20.30.png 996w\" sizes=\"(max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-190\" class=\"wp-caption-text\">A script and its output.<\/p><\/div>\n<p>So today, I present a new approach to the issue: scripting! Using <a href=\"http:\/\/tools.wmflabs.org\/toolscript\/index.html\">toolscript<\/a>, users can now take results from other tools such as <a href=\"http:\/\/tools.wmflabs.org\/catscan2\/quick_intersection.php\">category intersection<\/a> and <a href=\"http:\/\/wdq.wmflabs.org\/\">Wikidata Query<\/a>, filter and combine the results, and display the results or even use tools like <a href=\"http:\/\/magnusmanske.de\/wordpress\/?p=128\">WiDaR<\/a> to perform on-wiki actions. Many of these actions come &#8220;packaged&#8221; with this new tool, and the user has almost unlimited flexibility in operating on the data. This flexibility, however, is bought by the scary word <em>programming<\/em> (an euphemism for &#8220;scripting&#8221;). In essence, the tool runs JavaScript code that the user types or pastes into a text box.<\/p>\n<p>Still here? Good! Because, first, there are some examples you can copy, run, and play with; if people can learn MediaWiki markup this way, JavaScript should pose little challenge. Second, I am working on a built-in script storage, which should add many more example scripts, ready to run (in the meantime, I recommend a wiki or <a href=\"http:\/\/pastebin.com\/\">pastebin<\/a>). Third, all build-in functions use <em>synchronous<\/em> data access (no callbacks!), which makes JavaScript a lot more &#8230; scriptable, as in &#8220;logical linear flow&#8221;.<\/p>\n<p>The basic approach is to generate one or more page lists (on a single Wikimedia project), and then operate on those. One can merge lists, filter them, &#8220;flip&#8221; from Wikipedia to associated Wikidata items and back, etc. Consider this script, which I wrote for my dutiful beta tester <a href=\"http:\/\/ultimategerardm.blogspot.nl\/\">Gerard<\/a>:<\/p>\n<pre style=\"font-size: 9pt;\">all_items = ts.getNewList('','wikidata');\r\ncat = ts.getNewList('it','wikipedia').addPage('Category:Morti nel 2014') ;\r\ncat_item = cat.getWikidataItems().loadWikidataInfo();\r\n$.each ( cat_item.pages[0].wd.sitelinks , function ( site , sitelink ) {\r\n\u00a0 var s = ts.getNewList(site).addPage(sitelink.title);\r\n\u00a0 if ( s.pages[0].page_namespace != 14 ) return ;\r\n  var tree = ts.categorytree({language:s.language,project:s.project,root:s.pages[0].page_title,redirects:'none'}) ;\r\n\u00a0 var items = tree.getWikidataItems().hasProperty(\"P570\",false);\r\n\u00a0 all_items = all_items.join(items);\r\n} )\r\nall_items.show();<\/pre>\n<p>This short script will display a list of all Wikidata items that are in a &#8220;died 2014&#8221; category tree on any Wikipedia, that do not have a death date yet. The steps are as follows:<\/p>\n<ul>\n<li>Takes the &#8220;Category:Morti nel 2014&#8221; from it.wikipedia<\/li>\n<li>Finds the associated Wikidata item<\/li>\n<li>Gets the item data for that item<\/li>\n<li>For all of the site links into different projects on this item:\n<ul>\n<li>Checks if the link is a category<\/li>\n<li>Gets the pages in the category tree for that category, on that site<\/li>\n<li>Gets the associated Wikidata items for those pages<\/li>\n<li>Removes those items that already have a death date<\/li>\n<li>Adds the ones without a death date to a &#8220;collection list&#8221;<\/li>\n<\/ul>\n<\/li>\n<li>Finally, displays that list of Wikidata items with missing death dates<\/li>\n<\/ul>\n<p>Thus, with a handful of straightforward functions (like &#8220;get Wikidata items for these pages&#8221;), one can ask complex questions of Wikimedia sites. A slight modification could, for example, create Wikidata items the pages in these categories. All functions are documented in the tool. Many more can be added on request; and, as with adding Wikidata labels, a single added function can enable many more use-cases.<\/p>\n<p>I hope that this tool can become a hub for users who want more than the &#8220;simple&#8221; tools, to answer complex questions, or automate tedious actions.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I am running a lot of tools on Labs. As with most software, the majority of feedback I get for those tools falls into one of two categories: bug reports and feature requests, the latter often in the form &#8220;can the tool get input from\/filter on\/output to&#8230;&#8221;. In many cases, that is quick to implement; [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9,7],"tags":[],"class_list":["post-189","post","type-post","status-publish","format-standard","hentry","category-wikidata","category-wikimedia-2"],"_links":{"self":[{"href":"http:\/\/magnusmanske.de\/wordpress\/wp-json\/wp\/v2\/posts\/189","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/magnusmanske.de\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/magnusmanske.de\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/magnusmanske.de\/wordpress\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/magnusmanske.de\/wordpress\/wp-json\/wp\/v2\/comments?post=189"}],"version-history":[{"count":6,"href":"http:\/\/magnusmanske.de\/wordpress\/wp-json\/wp\/v2\/posts\/189\/revisions"}],"predecessor-version":[{"id":196,"href":"http:\/\/magnusmanske.de\/wordpress\/wp-json\/wp\/v2\/posts\/189\/revisions\/196"}],"wp:attachment":[{"href":"http:\/\/magnusmanske.de\/wordpress\/wp-json\/wp\/v2\/media?parent=189"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/magnusmanske.de\/wordpress\/wp-json\/wp\/v2\/categories?post=189"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/magnusmanske.de\/wordpress\/wp-json\/wp\/v2\/tags?post=189"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}