mediawiki-gateway 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
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.2.2"
6
+ VERSION = "0.2.3"
7
7
  end
@@ -114,8 +114,12 @@ module MediaWiki
114
114
  # Options:
115
115
  # * [movesubpages] Move associated subpages
116
116
  # * [movetalk] Move associated talkpages
117
+ # * [noredirect] Do not create a redirect page from old name. Requires the 'suppressredirect' user right, otherwise MW will silently ignore the option and create the redirect anyway.
118
+ # * [reason] Reason for move
119
+ # * [watch] Add page and any redirect to watchlist
120
+ # * [unwatch] Remove page and any redirect from watchlist
117
121
  def move(from, to, options={})
118
- valid_options = %w(movesubpages movetalk)
122
+ valid_options = %w(movesubpages movetalk noredirect reason watch unwatch)
119
123
  options.keys.each{|opt| raise ArgumentError.new("Unknown option '#{opt}'") unless valid_options.include?(opt.to_s)}
120
124
 
121
125
  form_data = options.merge({'action' => 'move', 'from' => from, 'to' => to, 'token' => get_token('move', from)})
@@ -24,10 +24,12 @@ module MediaWiki
24
24
  title.split('/').last if title
25
25
  end
26
26
 
27
- # Convert URL-ized page name ("getting_there_%26_away") into Wiki display format page name ("getting there & away")
27
+ # Convert URL-ized page name ("getting_there_%26_away") into Wiki display format page name ("getting there & away").
28
+ # Also strips out any illegal characters (#<>[]|{}, cf. http://meta.wikimedia.org/wiki/Help:Page_name#Restrictions).
29
+ #
28
30
  # [wiki] Page name string in URL
29
31
  def uri_to_wiki(uri)
30
- CGI.unescape(uri).tr('_', ' ') if uri
32
+ CGI.unescape(uri).tr('_', ' ').tr('#<>[]|{}', '') if uri
31
33
  end
32
34
 
33
35
  # Convert a Wiki page name ("getting there & away") to URI-safe format ("getting_there_%26_away"),
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{mediawiki-gateway}
8
- s.version = "0.2.2"
8
+ s.version = "0.2.3"
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{2010-12-13}
12
+ s.date = %q{2010-12-15}
13
13
  s.description = %q{}
14
14
  s.email = %q{jpatokal@iki.fi}
15
15
  s.extra_rdoc_files = [
data/spec/utils_spec.rb CHANGED
@@ -68,6 +68,10 @@ describe MediaWiki do
68
68
  MediaWiki.uri_to_wiki('Ph%E1%BB%9F').should == 'Phở'
69
69
  end
70
70
 
71
+ it "should strip out illegal characters" do
72
+ MediaWiki.uri_to_wiki('A#B<C>D[E]F|G{H}I').should == 'ABCDEFGHI'
73
+ end
74
+
71
75
  it "should pass through nil" do
72
76
  MediaWiki.uri_to_wiki(nil).should be_nil
73
77
  end
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: 19
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 2
9
- - 2
10
- version: 0.2.2
9
+ - 3
10
+ version: 0.2.3
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: 2010-12-13 00:00:00 +11:00
18
+ date: 2010-12-15 00:00:00 +11:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency