mediawiki-butt 1.1.1 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/lib/mediawiki/butt.rb +2 -0
- data/lib/mediawiki/purge.rb +57 -0
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6ac2473bbed75da107401d8c5dceeca3e2ed6b3c
|
4
|
+
data.tar.gz: 36463ff0c4f70d87ce6d6f62994d7ff03cf4b47a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 208c930ffa7dc8913b4c2b51bc6a82a46f1f55319d2ba92bf33eb139579dfbb8dff5b17327636df5235e651f63381ae4c808f84263868ca931a0cf1c9232035e
|
7
|
+
data.tar.gz: ef133085ca55bd92f603d43430c4c100d17011c0d64427950463c4e18856da642c2f2270df33e722c1efda9b971484d5a6e416767ed2b487e719ee444001acfc
|
data/CHANGELOG.md
CHANGED
data/lib/mediawiki/butt.rb
CHANGED
@@ -4,6 +4,7 @@ require_relative 'constants'
|
|
4
4
|
require_relative 'edit'
|
5
5
|
require_relative 'administration'
|
6
6
|
require_relative 'watch'
|
7
|
+
require_relative 'purge'
|
7
8
|
require 'httpclient'
|
8
9
|
require 'json'
|
9
10
|
|
@@ -20,6 +21,7 @@ module MediaWiki
|
|
20
21
|
include MediaWiki::Edit
|
21
22
|
include MediaWiki::Administration
|
22
23
|
include MediaWiki::Watch
|
24
|
+
include MediaWiki::Purge
|
23
25
|
|
24
26
|
attr_accessor :query_limit_default
|
25
27
|
attr_accessor :use_continuation
|
@@ -0,0 +1,57 @@
|
|
1
|
+
module MediaWiki
|
2
|
+
module Purge
|
3
|
+
# Purges the provided pages, without updating link tables. This will warn for every invalid purge with the reason
|
4
|
+
# it is invalid, as provided by the MediaWiki API.
|
5
|
+
# @param *titles [Array<String>] A list of the pages to purge.
|
6
|
+
# @return [Hash<String, Boolean>] The key is the page title, and the value is whether it was a successful purge.
|
7
|
+
# @see https://www.mediawiki.org/wiki/API:Purge MediaWiki API Docs
|
8
|
+
# @note This creates a warning for every invalid purge with the reason it is invalid, as provided by the MediaWiki
|
9
|
+
# API, as well as the title of the invalid page.
|
10
|
+
def purge(*titles)
|
11
|
+
purge_request({}, titles)
|
12
|
+
end
|
13
|
+
|
14
|
+
# Purges the provided pages and updates their link tables.
|
15
|
+
# @param (see #purge)
|
16
|
+
# @return (see #purge)
|
17
|
+
# @see (see #purge)
|
18
|
+
# @note (see #purge)
|
19
|
+
def purge_link_update(*titles)
|
20
|
+
purge_request({ forcelinkupdate: 1 }, titles)
|
21
|
+
end
|
22
|
+
|
23
|
+
# Purges the provided pages and recursively updates the link tables.
|
24
|
+
# @param (see #purge)
|
25
|
+
# @return (see #purge)
|
26
|
+
# @see (see #purge)
|
27
|
+
# @note (see #purge)
|
28
|
+
def purge_recursive_link_update(*titles)
|
29
|
+
purge_request({ forcerecursivelinkupdate: 1 }, titles)
|
30
|
+
end
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
# Sends a purge API request, and handles the return value and warnings.
|
35
|
+
# @param params [Hash<Object, Object>] The parameter hash to begin with. Cannot include the titles or action keys.
|
36
|
+
# @param (see #purge)
|
37
|
+
# @return (see #purge)
|
38
|
+
# @see (see #purge)
|
39
|
+
# @note (see #purge)
|
40
|
+
def purge_request(params, *titles)
|
41
|
+
params[:action] = 'purge'
|
42
|
+
params[:titles] = titles.join('|')
|
43
|
+
|
44
|
+
response = post(params)
|
45
|
+
|
46
|
+
ret = {}
|
47
|
+
|
48
|
+
response['purge'].each do |hash|
|
49
|
+
title = hash['title']
|
50
|
+
ret[title] = hash.key?('purged') && !hash.key?('missing')
|
51
|
+
warn "Invalid purge (#{title}) #{hash['invalidreason']}" if hash.key?('invalid')
|
52
|
+
end
|
53
|
+
|
54
|
+
ret
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mediawiki-butt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Eli Foster
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2016-
|
12
|
+
date: 2016-09-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: httpclient
|
@@ -42,6 +42,7 @@ files:
|
|
42
42
|
- lib/mediawiki/constants.rb
|
43
43
|
- lib/mediawiki/edit.rb
|
44
44
|
- lib/mediawiki/exceptions.rb
|
45
|
+
- lib/mediawiki/purge.rb
|
45
46
|
- lib/mediawiki/query/lists/all.rb
|
46
47
|
- lib/mediawiki/query/lists/backlinks.rb
|
47
48
|
- lib/mediawiki/query/lists/categories.rb
|