-
-
Notifications
You must be signed in to change notification settings - Fork 16
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add apprtype and apprlevel to AllPagesGenerator #105
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,6 @@ | ||
using System; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Newtonsoft.Json.Linq; | ||
using WikiClientLibrary.Generators.Primitive; | ||
using WikiClientLibrary.Pages; | ||
using WikiClientLibrary.Sites; | ||
|
||
namespace WikiClientLibrary.Generators | ||
|
@@ -68,9 +61,19 @@ public AllPagesGenerator(WikiSite site) : base(site) | |
/// </summary> | ||
public int? MaxPageContentLength { get; set; } | ||
|
||
/// <summary> | ||
/// Limit to protected pages only. | ||
/// </summary> | ||
public List<ProtectionType>? ProtectionType { get; set; } | ||
|
||
/// <summary> | ||
/// Filter protections based on protection level (must be used with ProtectionType). | ||
/// </summary> | ||
public List<ProtectionLevel>? ProtectionLevel { get; set; } | ||
|
||
/// <inheritdoc/> | ||
public override string ListName => "allpages"; | ||
|
||
/// <inheritdoc/> | ||
public override IEnumerable<KeyValuePair<string, object?>> EnumListParameters() | ||
{ | ||
|
@@ -85,6 +88,8 @@ public AllPagesGenerator(WikiSite site) : base(site) | |
{"apfilterlanglinks", LanguageLinkFilter.ToString("withlanglinks", "withoutlanglinks")}, | ||
{"apminsize", MinPageContentLength}, | ||
{"apmaxsize", MaxPageContentLength}, | ||
{"apprtype", ProtectionType != null && ProtectionType.Count != 0 ? string.Join('|', ProtectionType.Select(x => x.ToString().ToLower())) : null}, | ||
{"apprlevel", ProtectionLevel != null && ProtectionLevel.Count != 0 ? string.Join('|', ProtectionLevel.Select(x => x.ToString().ToLower())) : null}, | ||
// TODO add other filters | ||
}; | ||
} | ||
|
@@ -110,4 +115,19 @@ public enum PropertyFilterOption | |
/// </summary> | ||
WithoutProperty, | ||
} | ||
|
||
public enum ProtectionType | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as |
||
{ | ||
Edit, | ||
Move, | ||
Upload | ||
} | ||
|
||
public enum ProtectionLevel | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Some wikis may have more level. I used the English Wikipedia as a reference, the enum can be extended later. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've checked DB table and In the future we might consider introducing some utility structures like |
||
{ | ||
Autoconfirmed, | ||
ExtendedConfirmed, | ||
TemplateEditor, | ||
Sysop, | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use
MediaWikiHelper.JoinValues
instead ofstring.Join('|', ...)
.