Jump to content

Flow/Architecture/API: Difference between revisions

From mediawiki.org
Content deleted Content added
SPage (WMF) (talk | contribs)
add "Finding links"
SPage (WMF) (talk | contribs)
Current API: remove references to the future, reorganize
Line 1: Line 1:
== Current API ==

Flow has an extensive API that's heavily exercised by one client – the JavaScript on Flow boards – as you can see if you interact with a Flow board with JavaScript enabled and watch the API requests in your browser's developer tools > Network tab.
Flow has an extensive API that's heavily exercised by one client – the JavaScript on Flow boards – as you can see if you interact with a Flow board with JavaScript enabled and watch the API requests in your browser's developer tools > Network tab.

Most URL (HTTP <code>GET</code>) and form (HTTP <code>POST</code>) actions are mirrored in the Flow API.


You can drive the API from [[Special:ApiSandbox]].
You can drive the API from [[Special:ApiSandbox]].


=== Write API ===
== action=flow API ==


The write API consists of submodules of <code>action=flow</code>, you can see them on the API page [//www.mediawiki.org/w/api.php www.mediawiki.org/w/api.php].
The read and write API consists of submodules of <code>action=flow</code>, you can see them on the API page [//www.mediawiki.org/w/api.php www.mediawiki.org/w/api.php].


=== Read API ===
=== Read API ===
JS in the browser calls the API to
JS in the browser calls the API to
* paginate in the next 10 topics
* paginate in the next 10 topics
* request topics in different sort orders
* get the wikitext for
* get the wikitext when editing existing posts
==== Currently ====
etc.
<code>action=flow</code> with either



; <code>list=flow</code>
<code>action=flow</code> with <code>submodule=</code> topiclist-view, post-view, topic-view, header-view, topic-summary-view, etc.


; ''obsolete'' <code>list=flow</code>
: any <code>flowaction</code> is passed on to WorkflowLoader, which will create multiple block objects and pass the flowaction onto them. flowaction can be view, header-view, and topic-summary-view. Each of these they take different parameters.
: any <code>flowaction</code> is passed on to WorkflowLoader, which will create multiple block objects and pass the flowaction onto them. flowaction can be view, header-view, and topic-summary-view. Each of these they take different parameters.


; <code>prop=flowinfo</code>
; <code>prop=flowinfo</code>
: returns <code>enabled</code> if Flow is enabled on a page, see {{gerrit|111255}}. No parameters
: returns <code>enabled</code> if Flow is enabled on a page, see {{gerrit|111255}}. No parameters

==== Coming soon read API ====
Patches in gerrit change the read API to be more like the write API, so there will be specific actions for flow.

There will be different submodules for view, topic summary, and header, maybe post view.

==== flow-parsoid-utils ====
Requests conversion between html and wikitext. If the wiki isn't running Parsoid, conversions from html to wikitext will fail.

This is meant to be an "internal" API for Flow to be able to communicate with Parsoid client-side. If you want to convert wikitext<-->html using Parsoid, you should use it's own [[Parsoid#The_Parsoid_web_API|API]].


=== Sketch of write API ===
=== Sketch of write API ===
Line 61: Line 55:


On WMF wikis, Flow stores post content as HTML with embedded Parsoid markup so that the original wikitext can be reconstituted for editing. ''This will not be the case on all wikis, others might store as wikitext.''
On WMF wikis, Flow stores post content as HTML with embedded Parsoid markup so that the original wikitext can be reconstituted for editing. ''This will not be the case on all wikis, others might store as wikitext.''


=== flow-parsoid-utils ===
Requests conversion between html and wikitext. If the wiki isn't running Parsoid, conversions from html to wikitext will fail.

This is meant to be an "internal" API for Flow to be able to communicate with Parsoid client-side. If you want to convert wikitext<-->html using Parsoid, you should use it's own [[Parsoid#The_Parsoid_web_API|API]].


== Future API changes ==
== Future API changes ==

Revision as of 19:41, 23 June 2014

Flow has an extensive API that's heavily exercised by one client – the JavaScript on Flow boards – as you can see if you interact with a Flow board with JavaScript enabled and watch the API requests in your browser's developer tools > Network tab.

Most URL (HTTP GET) and form (HTTP POST) actions are mirrored in the Flow API.

You can drive the API from Special:ApiSandbox.

action=flow API

The read and write API consists of submodules of action=flow, you can see them on the API page www.mediawiki.org/w/api.php.

Read API

JS in the browser calls the API to

  • paginate in the next 10 topics
  • request topics in different sort orders
  • get the wikitext when editing existing posts

etc.


action=flow with submodule= topiclist-view, post-view, topic-view, header-view, topic-summary-view, etc.


obsolete list=flow
any flowaction is passed on to WorkflowLoader, which will create multiple block objects and pass the flowaction onto them. flowaction can be view, header-view, and topic-summary-view. Each of these they take different parameters.
prop=flowinfo
returns enabled if Flow is enabled on a page, see Gerrit change 111255. No parameters

Sketch of write API

In a reply you're replying to a particular post in a workflow (a topic). See Flow/Nomenclature for an explanation of the terms. Flow objects are identified by UUIDs see Flow/Architecture.

To reply to a topic

  • you'll need a token. Flow recently switched to using the regular 'edit' token for most operations, so you can use mw.api.postWithEditToken to get the editing token if it hasn't been cached yet in the session. it's cached.
  • Issue a flow API request with flowaction=reply, identifying the topic workflow. The parameters for a reply include the topic and the post.
action=flow
submodule=reply
format=json
repreplyTo=050fed5dc6bd5085237590b11c2fa805
repcontent=My reply, with ''wikitext''.

render=true
token=43a71deb105e7c0be7e8eeab4bdff4f7+\
workflow=050f698e3f6e5624fa1590b11c27932f
  • Set render=true if you want the server to respond with the "fully-decorated" HTML to interact with the new post (preview buttons, actions, etc.).
  • UUID format will soon change to be more compact, using 88-bit represented as alphadecimal.
  • Obviously you get the topic and post to respond by making API queries, rather than hardcoding these numbers.

Note that a wiki may store Flow content with $wgFlowContentFormat 'html' or 'wikitext', but in any edit submission you must (?) submit wikitext.

If successful, the server responds with the post-id of the new post, and the HTML to insert into the DOM.

Note this API request doesn't name the page on which the topic appears. Users interact with topics on a Flow board with a wiki page name, but a topic might (eventually) appear on multiple pages, e.g. a user's "subscription feed".

On WMF wikis, Flow stores post content as HTML with embedded Parsoid markup so that the original wikitext can be reconstituted for editing. This will not be the case on all wikis, others might store as wikitext.


flow-parsoid-utils

Requests conversion between html and wikitext. If the wiki isn't running Parsoid, conversions from html to wikitext will fail.

This is meant to be an "internal" API for Flow to be able to communicate with Parsoid client-side. If you want to convert wikitext<-->html using Parsoid, you should use it's own API.

Future API changes

Eventually move to a service-oriented architecture. Might look like proposed Content API.

Other API issues

  • Should existing API calls to edit to a page "just work" on a Flow-enabled "page"?
  • What should happen to regular page API requests made to a Flow-enabled page, bug 60808.
    • This will change somewhat when a Flow board becomes a content type.
  • post editing rights for bots.
    • ordinarily only the poster can edit his or her reply, unlike a regular wiki page.

Missing APIs?

  • Do people need an API to enumerate pages / namespaces that are using Flow?
    • currently, would just return values of $wgFlowOccupyPages and $wgFlowOccupyNamespaces. When a Flow board becomes a content type, the former could be replaced by a query for pages with the flowboard contentmodel, though there does not seem to be a generator for this.
  • API to generate a link to a post/topic/board given a UUID

Use cases

please update, especially with links to bots

Bots patrolling new content

  • ? have to watch for changes
  • ask for new and changed topics and posts

Bots making edits

  • Adding topics (and/or posts)
  • Correcting old posts
  • Modifying talkpage headers
  • Checking if the bot has already made a particular post to a particular page
    • Often implemented by a subject line check, or a check for a particular <!-- comment -->.
    • Ability for users to remove or otherwise signal that the bot-raised issue is taken care of, so the bot can know to repost it if it recurs.
  • Opting out of bot messages (eg. Enwiki's template:nobots).

Tools showing count of edits

  • Contributions with Flow at some wiki aren't included in X!'s Edit Counter for that wiki, maybe because Flow is in a separate database. See bug 61887, though this is more a DB tool than a bot.

In bug 57512 comment 22] bug 57512 [comment 22] Brad Jorsch commented:

And there are also a number of API modules that query the existing links tables; there should at least be some way to (1) identify that a page is Flow and (2) search these flow-specific links tables to find the actual "thing(s)" doing the linking in the particular page.

Flow/Architecture#Link handling sketches the implementation.

?

Non-issues

No need to check for unsigned edits, replies are known.

See also