sunflower 0.5.6 → 0.5.7
Sign up to get free protection for your applications and to get access to all the features.
- data/README +1 -1
- data/lib/sunflower/commontasks.rb +10 -0
- data/lib/sunflower/core.rb +14 -4
- metadata +2 -2
data/README
CHANGED
@@ -110,4 +110,14 @@ class Sunflower::Page
|
|
110
110
|
"[[#{self.sunflower.ns_local_for 'Category'}:#{to}#{rest}"
|
111
111
|
}
|
112
112
|
end
|
113
|
+
|
114
|
+
# Remove the category from page wikitext.
|
115
|
+
#
|
116
|
+
# Input can be either with the Category: prefix (or localised version) or without.
|
117
|
+
def remove_category cat
|
118
|
+
cat_regex = self.sunflower.ns_regex_for 'Category'
|
119
|
+
cat = self.sunflower.cleanup_title(cat).sub(/^#{cat_regex}:/, '')
|
120
|
+
|
121
|
+
self.text.gsub!(/\[\[ *#{cat_regex} *: *#{Regexp.escape cat} *(\|[^\]]*)?\]\](\r?\n)?/, '')
|
122
|
+
end
|
113
123
|
end
|
data/lib/sunflower/core.rb
CHANGED
@@ -40,7 +40,7 @@ end
|
|
40
40
|
#
|
41
41
|
# You can use multiple Sunflowers at once, to work on multiple wikis.
|
42
42
|
class Sunflower
|
43
|
-
VERSION = '0.5.
|
43
|
+
VERSION = '0.5.7'
|
44
44
|
|
45
45
|
INVALID_CHARS = %w(# < > [ ] | { })
|
46
46
|
INVALID_CHARS_REGEX = Regexp.union *INVALID_CHARS
|
@@ -154,8 +154,18 @@ class Sunflower
|
|
154
154
|
end
|
155
155
|
end
|
156
156
|
|
157
|
-
|
158
|
-
|
157
|
+
# find out the base URL for this wiki and its API endpoint
|
158
|
+
# we joyfully assume that all URLs contain at least a single dot, which is incorrect, but oh well
|
159
|
+
if url.include?('.')
|
160
|
+
# a regular external wiki; use the RSD discovery mechanism to find out the endpoint
|
161
|
+
@wikiURL = url
|
162
|
+
# let's not pull in a HTML parsing library, this regex will do
|
163
|
+
@api_endpoint = opts[:api_endpoint] || RestClient.get(@wikiURL).to_str[/<link rel="EditURI" type="application\/rsd\+xml" href="([^"]+)\?action=rsd"/, 1]
|
164
|
+
else
|
165
|
+
# probably a Wikimedia wiki shorthand
|
166
|
+
@wikiURL = Sunflower.resolve_wikimedia_id(url)
|
167
|
+
@api_endpoint = opts[:api_endpoint] || 'http://'+@wikiURL+'/w/api.php'
|
168
|
+
end
|
159
169
|
|
160
170
|
@warnings = true
|
161
171
|
@log = false
|
@@ -317,7 +327,7 @@ class Sunflower
|
|
317
327
|
|
318
328
|
# 4. check bot rights
|
319
329
|
r=self.API('action=query&list=allusers&aulimit=1&augroup=bot&aufrom='+(CGI.escape user))
|
320
|
-
unless r['query']['allusers'][0]['name']==user
|
330
|
+
unless r['query']['allusers'][0] && r['query']['allusers'][0]['name']==user
|
321
331
|
warn 'Sunflower - this user does not have bot rights!' if @warnings
|
322
332
|
@is_bot=false
|
323
333
|
else
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sunflower
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.7
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2013-01-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: json
|