Jump to content

Mobile web projects/Collections Backend

From mediawiki.org

Overview

[edit]

This documentation should correspond with the http://localhost:8080/w/api.php?action=help&modules=editlist%7Cquery+lists%7Cquery+listpages

action=editlist

[edit]

Create, edit, or delete a list. If list ID is given, treat this as an edit request. If only label is given, treat as a creation request. All other parameters are optional. If given, they set/modify list information. If missing, no changes are done to them. To delete an existing list, use the deletelist=1 parameter.

This action also allows pages to be added or removed from the list. Just like action=watch, it supports titles, pagids, revids, and generator queries.

Create new list 'Heroes'
Result
{
    "editlist": {
        "id": "12345",
        "status": "created"
    }
}
Add two pages to a list
Result
{
    "editlist": {
        "id": "12345",
        "status": "updated"
    }
}


Parameters

[edit]
  • id: List ID of the existing list you want to edit.
  • label: Title of the list you want to create (if id is not given), or new label if it already exists.
  • description: List description (optional)
  • remove: If set, pages will be removed rather than added (optional, id must be present)
  • deletelist: Boolean - if given, the list will be deleted (optional, id must be present)
  • token: A "watch" token retrieved from action=query&meta=tokens (TBD)
  • To specify titles for addition (or removal with remove=), use any of the title querying methods like titles, pageids, or generator.

Notes

[edit]
  • Each list must have a non-empty label
  • Legacy watchlist's label is always the localized word "Watchlist" and cannot be changed
  • Legacy watchlist ID is a regular non-zero list ID, but can also be accessed by setting id=0

Statuses

[edit]
  • created: new list was created
  • updated: existing list was updated. This status is returned even if no actual changes were done to the list
  • unchanged: the new values are the same as existing, no changes were made
  • deleted: list was deleted

Errors

[edit]
  • badid: list id does not exist
  • exists: a list with this label already exists
  • noidlabel: either label or id must be given
  • noid: id must be given

action=query & list=lists

[edit]

List all available lists. For now, lists only lists that belong to a current user. Eventually might make it possible to enumerate lists of other users.

Get available lists
Result
{
    "query": {
        "lists": [
            {
              "id": 12345,
              "label": "Heroes",
              "desc": "Some description"
            },
            ...
        ]
    }
}

Parameters

[edit]
  • lstprop: Optional list of values to get in addition to id. Default = label. Can be label, desc, eventually - flags, etc.
  • lstids: Optional list id to limit info to just these lists
  • lstlabel: Optional list label to limit info to just one list

action=query & list=listpages

[edit]

List all pages in a list. This list can be used as a generator. Eventually this module may support the same parameters as in query/allpages, and/or replace the query/watchlistraw.

Get all pages that are part of the given list
Result
{
    "query": {
        "listpages": [
            {
              "pageid": 5678902,
              "ns": 0,
              "title": "Superman"
            },
            ...
        ]
    }
}

Parameters

[edit]
  • lspid: Which list to show. By default shows list 0 (watchlist)
  • lsplabel: Optional list label to limit info to just one list


Archive

[edit]

This is a draft space for Collections, spring zero backend spike results

Non-MVP Collections schema draft

[edit]

Collections table:

  • collection_id ( auto increment )
  • user_id ( index )
  • label
  • description
  • private flag ( default false )
  • timestamp ( time created )

Collection_pages table

  • item id ( auto increment )
  • collection id ( index )
  • page id
  • order ( default 0 )
  • timestamp ( time added )