Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restore ex:converter-type functionality to exhibit3 #113

Open
karger opened this issue Dec 6, 2013 · 1 comment
Open

Restore ex:converter-type functionality to exhibit3 #113

karger opened this issue Dec 6, 2013 · 1 comment

Comments

@karger
Copy link
Contributor

karger commented Dec 6, 2013

E2 allowed a link tag to specify an ex:converter, which named a javascript function that would transform fetched data (into exhibit format) before loading it into the database. In particular, google spreadsheets data was imported into exhibit using such a converter. In E3, the converter argument has been removed; now there is a google spreadsheets importer registered to a google spreadsheets link type.

With this new approach, anyone who wants to import json data of an unusual schema needs to create and register their own importer. This requires far deeper understanding of exhibit than just writing a js function and passing it as a converter argument.

I'd like to bring back the converter option. In particular, I propose 3 optional arguments in a link tag: getter, parser, and converter. The getter is either json or jsonp, representing the two ways exhibit can fetch a text blob from a source. A parser takes a text blob and returns a js object. And a converter takes a json object and produces a different one (presumably exhibit compatible). An importer is a combination of getter, parser, and converter associated with a particular data type, so e.g. application/json has importer=json, parser=json.parse, and converter null. But any one of the three elements can be overridden by an explicit argument, and if all three are explicitly given then no type needs to be specified.

In absence of objection, I'll plan to implement this in the simile-widgets branch.

@pitchke
Copy link

pitchke commented May 13, 2015

I'd like to import some Semantic Mediawiki (SMW) content via SMW's API.php [1] ->JSON and convert it to an Exhibit database (items). Not being an expert I would like to know where to start for such solution: write an importer/parser/converter code ? is this argument/function implemented in E3 ? is there an example which can be reused (i.e. importing from other sources to JSON Exhibit) ?

Background:

  • I used to work (years ago) with Exhibit SRF [2] which no more works in MediaWiki. So the alternative seems to load JSON/items by calling the MediaWiki API from an exhibit HTML file.
  • SMW provide cool ways to maintain your source information in forms, additional text, etc.
  • I made an Excel-to-JSON(Exhibit) macro which exports worksheets as file.tsv (in UTF-8). This works but:
    ** it can't handle multiple values per fields
    ** A (Media)Wiki contains lot more infromation and link between all knowledge compared to Excel-sheets.

[1] http://www.mediawiki.org/wiki/API:Main_page
[2] http://www.mediawiki.org/wiki/Extension_talk:Semantic_Result_Formats/exhibit_format

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants