Page MenuHomePhabricator

Allow namespace narrowing of selection in prop=links
Closed, ResolvedPublic

Description

Please add new feature to allow to choose namespace(s) of links on such page.

Eg. get all links to Help ns only on Wikipedia:Foo page.

Thanks


Version: unspecified
Severity: enhancement

Details

Reference
bz10275

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 21 2014, 9:52 PM
bzimport set Reference to bz10275.
bzimport added a subscriber: Unknown Object (MLST).

Some examples of possible code:

api.php? ... &plnamespaces=10 -- show only links to the pages in namespace 10

api.php? ... &plnamespaces=1|3|5|7|9|11 show only links to all talks

etc...

I'll work on it some time this weekend, patch should be ready by Monday (possibly earlier if I have time).

Created attachment 3791
Implements filtering by namespace for prop=links and prop=templatelinks

Miraculously, I've actually found time to do this today. The attached patch (tested and found to work) implements a plnamespace parameter just like you asked for. Because prop=links and prop=templatelinks share code, prop=templatelinks now also has a tlnamespace parameter which does exactly the same thing. Help text from the patched version:

  • prop=links (pl) * Returns all links from the given page(s)

Parameters:

plnamespace    - Show links in this namespace(s) only
                 Values (separate with '|'): 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15

Examples:

Get links from the [[Main Page]]:
  api.php?action=query&prop=links&titles=Main%20Page
Get information about the link pages in the [[Main Page]]:
  api.php?action=query&generator=links&titles=Main%20Page&prop=info
Get links from the Main Page in the User and Template namespaces:
  api.php?action=query&prop=links&titles=Main%20Page&plnamespace=2|10

Generator:

This module may be used as a generator
  • prop=templates (tl) * Returns all templates from the given page(s)

Parameters:

tlnamespace    - Show templates in this namespace(s) only
                 Values (separate with '|'): 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15

Examples:

Get templates from the [[Main Page]]:
  api.php?action=query&prop=templates&titles=Main%20Page
Get information about the template pages in the [[Main Page]]:
  api.php?action=query&generator=templates&titles=Main%20Page&prop=info
Get templates from the Main Page in the User and Template namespaces:
  api.php?action=query&prop=templates&titles=Main%20Page&tlnamespace=2|10

Generator:

This module may be used as a generator

It may take some time for this patch to be accepted into the code, but if you really want to try it you can of course set up your own test wiki and apply this patch to it.

Hope this helps,

Roan Kattouw

Attached:

Change 312721 had a related patch set uploaded (by Vyeshwanth):
pywikibot.Page.put: checking the changes before saving

https://gerrit.wikimedia.org/r/312721

Sorry I wrote a wrong bug no. This is supposed to be for Bug: T122715
I changed the bug number in the commit message now.
Sorry!