sunflower 0.5.12 → 0.5.13
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/sunflower/core.rb +6 -5
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2c752777781c61e50c735dc2ede810bb1d934f25
|
4
|
+
data.tar.gz: aa45d4aac33d32c148cd454fff5a2222e089a7ca
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8ce1e2507d1e3c6c2d82025f6d21d9b9ebabc4e60dec6752f72d2dba6b72e71eacf2b5983cf67acdafd966c6f1639d137a759bd6ef53940d4b347627c828d818
|
7
|
+
data.tar.gz: 9c506546f272aaaf26c16ec49c39793844443ca91f925f68e46be3cf7614c494be3696b8fc85d1f4cb2ac62c1742ab9e31edced683b91a40debe55604bd72c67
|
data/lib/sunflower/core.rb
CHANGED
@@ -40,7 +40,8 @@ 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.13'
|
44
|
+
USER_AGENT = "Sunflower #{VERSION} alpha <https://github.com/MatmaRex/Sunflower>"
|
44
45
|
|
45
46
|
INVALID_CHARS = %w(# < > [ ] | { })
|
46
47
|
INVALID_CHARS_REGEX = Regexp.union *INVALID_CHARS
|
@@ -225,7 +226,7 @@ class Sunflower
|
|
225
226
|
resp = RestClient.post(
|
226
227
|
@api_endpoint,
|
227
228
|
request,
|
228
|
-
{:user_agent =>
|
229
|
+
{:user_agent => USER_AGENT, :cookies => @cookies}
|
229
230
|
)
|
230
231
|
JSON.parse resp.to_str
|
231
232
|
end
|
@@ -296,20 +297,20 @@ class Sunflower
|
|
296
297
|
response = RestClient.post(
|
297
298
|
@api_endpoint,
|
298
299
|
"action=login&lgname=#{CGI.escape user}&lgpassword=#{CGI.escape password}&format=json",
|
299
|
-
{:user_agent =>
|
300
|
+
{:user_agent => USER_AGENT}
|
300
301
|
)
|
301
302
|
|
302
303
|
@cookies = response.cookies
|
303
304
|
raise Sunflower::Error, 'unable to log in (no cookies received)!' if !@cookies or @cookies.empty?
|
304
305
|
|
305
306
|
json = JSON.parse response.to_str
|
306
|
-
token
|
307
|
+
token = json['login']['lgtoken'] || json['login']['token']
|
307
308
|
|
308
309
|
# 2. actually log in
|
309
310
|
response = RestClient.post(
|
310
311
|
@api_endpoint,
|
311
312
|
"action=login&lgname=#{CGI.escape user}&lgpassword=#{CGI.escape password}&lgtoken=#{CGI.escape token}&format=json",
|
312
|
-
{:user_agent =>
|
313
|
+
{:user_agent => USER_AGENT, :cookies => @cookies}
|
313
314
|
)
|
314
315
|
|
315
316
|
json = JSON.parse response.to_str
|