-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add FilesGenerator * FilesGenerator should use imimages instead of imtitles
- Loading branch information
1 parent
f99a048
commit 94b9c6c
Showing
4 changed files
with
85 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using System.Collections.Generic; | ||
using WikiClientLibrary.Generators.Primitive; | ||
using WikiClientLibrary.Infrastructures; | ||
using WikiClientLibrary.Pages; | ||
using WikiClientLibrary.Sites; | ||
|
||
namespace WikiClientLibrary.Generators | ||
{ | ||
/// <summary> | ||
/// Generates pages from all used files on the provided page. | ||
/// (<a href="https://www.mediawiki.org/wiki/API:Links">mw:API:Links</a>, MediaWiki 1.11+) | ||
/// </summary> | ||
/// <see cref="TransclusionsGenerator"/> | ||
/// <see cref="BacklinksGenerator"/> | ||
/// <see cref="LinksGenerator"/> | ||
public class FilesGenerator : WikiPagePropertyGenerator | ||
{ | ||
/// <inheritdoc /> | ||
public FilesGenerator(WikiSite site) : base(site) | ||
{ | ||
} | ||
|
||
/// <inheritdoc /> | ||
public FilesGenerator(WikiSite site, WikiPageStub pageStub) : base(site, pageStub) | ||
{ | ||
} | ||
|
||
/// <summary> | ||
/// Only list these files. Useful for checking whether a certain page has a certain file. | ||
/// (MediaWiki 1.17+) | ||
/// </summary> | ||
/// <value>a sequence of page titles, or <c>null</c> to list all the used files.</value> | ||
public IEnumerable<string>? MatchingTitles { get; set; } | ||
|
||
/// <summary> | ||
/// Gets/sets a value that indicates whether the links should be listed in | ||
/// the descending order. (MediaWiki 1.19+) | ||
/// </summary> | ||
public bool OrderDescending { get; set; } | ||
|
||
/// <inheritdoc /> | ||
public override string PropertyName => "images"; | ||
|
||
/// <inheritdoc /> | ||
public override IEnumerable<KeyValuePair<string, object?>> EnumListParameters() | ||
{ | ||
return new Dictionary<string, object?> | ||
{ | ||
{"imlimit", PaginationSize}, | ||
{"imimages", MatchingTitles == null ? null : MediaWikiHelper.JoinValues(MatchingTitles)}, | ||
{"imdir", OrderDescending ? "descending" : "ascending"} | ||
}; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters