Page MenuHomePhabricator

Implement a base endpoint, controlled by query string parameters
Closed, ResolvedPublic

Description

Right now the translation server only returns an HTML results page (whether using the standard, debug or sandbox endpoint) with embedded citation metadata. This way, the results can be inspected visually, and can be interpreted by Citoid, which is the only way we currently have to link Wikipedia's automatic citation generator with our Web2Cit-Server.

To better integrate Web2Cit with Wikipedia (T305751), we would need to have an endpoint that returns the citation using a JSON format.

Event Timeline

We currently have /, /debug/, /sandbox/username/ and /debug/sandbox/username/ endpoints for convenience, because having debug and sandbox as query string parameters would require passing the target URL as a query string parameter as well (because target URLs may include query strings and URL fragments themselves), and this would require URL-encoding the target URL, which would be impractical for users simply prepending the server's address before their target URLs.

However, for internal or advanced use (such as the use we would give to this JSON endpoint) we may have a single /translate endpoint (we may have a /test endpoint for T302724), accepting parameters such as:

  • format:
    • html: the standard HTML + embedded metadata output returned by our shorthand endpoints above
    • json (or mediawiki, mimicking Citiod API): the JSON output referred to in this task
  • debug: boolean, whether present or not; output debugging information (can we fit this into the JSON output?)
  • storage: where to get configuration files from; defaults to https://meta.wikimedia.org/Web2Cit/data/. More general-use than our sandbox endpoints above.
  • citoid: as described in T306133, we may use this to tell the server to always include the citation returned by Citoid along with the Web2Cit citation.
  • test: whether tests (expected outputs and test scores) should be included along translation outputs. Supported by both formats (mediawiki/json and html).
  • other parameters use to configure the Domain object.
diegodlh renamed this task from Implement a JSON endpoint to Implement a general "translate" endpoint, including JSON output.Apr 13 2022, 12:51 PM
diegodlh renamed this task from Implement a general "translate" endpoint, including JSON output to Implement a base endpoint, controlled by query string parameters.Apr 13 2022, 8:31 PM

Make sure that the configuration switcher (main vs sandbox) in the html results page is compatible with urls using the translate endpoint.

Likewise, consider removing the need to pass debugHref and nodebugHref parameters to the HTML renderer.

For both cases we may use the translate endpoint, and have this endpoint decide whether to redirect to one of our shorthand endpoints.

diegodlh claimed this task.
diegodlh moved this task from Doing to Done on the Web2Cit-Server board.

Implemented in the translate-endpoint branch (last commit: 62c19a29).