mediawiki-gateway 0.3.6 → 0.3.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/lib/media_wiki.rb CHANGED
@@ -3,5 +3,5 @@ require File.dirname(__FILE__) + '/media_wiki/utils'
3
3
  require File.dirname(__FILE__) + '/media_wiki/gateway'
4
4
 
5
5
  module MediaWiki
6
- VERSION = "0.3.6"
6
+ VERSION = "0.3.7"
7
7
  end
@@ -66,6 +66,19 @@ module MediaWiki
66
66
  end
67
67
  end
68
68
 
69
+ # Fetch latest revision ID of a MediaWiki page. Does not follow redirects.
70
+ #
71
+ # [page_title] Page title to fetch
72
+ #
73
+ # Returns revision ID as a string, nil if the page does not exist.
74
+ def revision(page_title)
75
+ form_data = {'action' => 'query', 'prop' => 'revisions', 'rvprop' => 'ids', 'rvlimit' => 1, 'titles' => page_title}
76
+ page = make_api_request(form_data).first.elements["query/pages/page"]
77
+ if valid_page? page
78
+ page.elements["revisions/rev"].attributes["revid"]
79
+ end
80
+ end
81
+
69
82
  # Render a MediaWiki page as HTML
70
83
  #
71
84
  # [page_title] Page title to fetch
@@ -470,6 +483,20 @@ module MediaWiki
470
483
  userrights(user, token, groups_to_add, groups_to_remove, comment)
471
484
  end
472
485
 
486
+ # Review current revision of an article (requires FlaggedRevisions extension, see http://www.mediawiki.org/wiki/Extension:FlaggedRevs)
487
+ #
488
+ # [title] Title of article to review
489
+ # [flags] Hash of flags and values to set, eg. { "accuracy" => "1", "depth" => "2" }
490
+ # [comment] Comment to add to review (optional)
491
+ def review(title, flags, comment = "Reviewed by MediaWiki::Gateway")
492
+ raise "No article found" unless revid = revision(title)
493
+ form_data = {'action' => 'review', 'revid' => revid, 'token' => get_token('edit', title), 'comment' => comment}
494
+ form_data.merge!( Hash[flags.map {|k,v| ["flag_#{k}", v]}] )
495
+ puts form_data.inspect
496
+ res, dummy = make_api_request(form_data)
497
+ res
498
+ end
499
+
473
500
  private
474
501
 
475
502
  # Fetch token (type 'delete', 'edit', 'import', 'move')
@@ -528,7 +555,7 @@ module MediaWiki
528
555
  res, dummy = make_api_request(form_data)
529
556
  res
530
557
  end
531
-
558
+
532
559
  # Make generic request to API
533
560
  #
534
561
  # [form_data] hash or string of attributes to post
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{mediawiki-gateway}
8
- s.version = "0.3.6"
8
+ s.version = "0.3.7"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Jani Patokallio"]
12
- s.date = %q{2011-03-30}
12
+ s.date = %q{2011-04-14}
13
13
  s.description = %q{}
14
14
  s.email = %q{jpatokal@iki.fi}
15
15
  s.extra_rdoc_files = [
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mediawiki-gateway
3
3
  version: !ruby/object:Gem::Version
4
- hash: 31
4
+ hash: 29
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 3
9
- - 6
10
- version: 0.3.6
9
+ - 7
10
+ version: 0.3.7
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jani Patokallio
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-03-30 00:00:00 +11:00
18
+ date: 2011-04-14 00:00:00 +10:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency