cross-post 0.2.0 → 0.2.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/mastodon-register +22 -9
- data/lib/cross-post/config.rb +1 -1
- data/lib/cross-post/version.rb +1 -1
- 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: cad95c4752964bd36ca0abc3f8e0ab594089556c
|
4
|
+
data.tar.gz: cf5cff59a6e44a0087218ee0df288b0e284ea7b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0b581489f6274491dc1f10eab224825d38d2a8ad4b189e07bd8dbb4c32274abb74ae5fad0e947e47c7bec2164a8d1bc147ad0f49212d64ff31b4182f036e78e7
|
7
|
+
data.tar.gz: a674da5801615fe01c9284f365b455d3f4c37eec695e11042d0e4f4a2dcb8786dbe1c4c1bb9aea516136bbd60ee77bf827d7cbdcbd64cd237ca7045ac32083cf
|
data/bin/mastodon-register
CHANGED
@@ -6,15 +6,24 @@ require 'launchy'
|
|
6
6
|
require 'uri'
|
7
7
|
|
8
8
|
config = CrossPost::Config.new
|
9
|
-
|
9
|
+
settings = config[:settings]
|
10
|
+
|
11
|
+
url = settings['mastodon.url']
|
10
12
|
unless url
|
11
13
|
print 'Mastodon URL ? '
|
12
14
|
url = gets.chomp
|
13
15
|
url = "https://#{url}" if URI.parse(url).class == URI::Generic
|
14
|
-
|
16
|
+
settings['mastodon.url'] = url
|
17
|
+
end
|
18
|
+
|
19
|
+
user = settings['mastodon.user']
|
20
|
+
unless user
|
21
|
+
print 'Mastodon username ? '
|
22
|
+
user = gets.chomp
|
23
|
+
settings['mastodon.user'] = user
|
15
24
|
end
|
16
25
|
|
17
|
-
client_id, client_secret = unless
|
26
|
+
client_id, client_secret = unless settings['mastodon.consumer']
|
18
27
|
puts 'Creating new app'
|
19
28
|
token = SecureRandom.hex 64
|
20
29
|
redirect_url = 'urn:ietf:wg:oauth:2.0:oob'
|
@@ -22,19 +31,23 @@ client_id, client_secret = unless config['mastodon.consumer']
|
|
22
31
|
client = Mastodon::REST::Client.new base_url: url, bearer_token: token
|
23
32
|
app = client.create_app 'CrossPost', redirect_url,
|
24
33
|
'read write', 'https://git.imirhil.fr/aeris/cross-post/'
|
25
|
-
|
26
|
-
|
34
|
+
settings['mastodon.consumer.key'] = app.client_id
|
35
|
+
settings['mastodon.consumer.secret'] = app.client_secret
|
27
36
|
[app.client_id, app.client_secret]
|
28
37
|
else
|
29
|
-
[
|
38
|
+
[settings['mastodon.consumer.key'], settings['mastodon.consumer.secret']]
|
30
39
|
end
|
31
40
|
|
32
41
|
client = OAuth2::Client.new client_id, client_secret, site: url
|
33
42
|
url = client.auth_code.authorize_url redirect_uri: redirect_url
|
34
|
-
|
43
|
+
begin
|
44
|
+
Launchy.open url
|
45
|
+
rescue
|
46
|
+
puts "Open your browser at this URL: #{url}"
|
47
|
+
end
|
35
48
|
|
36
49
|
print 'Token ? '
|
37
50
|
token = gets.chomp
|
38
|
-
|
51
|
+
settings['mastodon.token'] = token
|
39
52
|
|
40
|
-
|
53
|
+
settings.save
|
data/lib/cross-post/config.rb
CHANGED
@@ -113,7 +113,7 @@ class CrossPost
|
|
113
113
|
def load(name, file = nil)
|
114
114
|
file ||= "#{name}.yml"
|
115
115
|
file = File.join @dir, file
|
116
|
-
|
116
|
+
File.write(file, YAML.dump({})) unless File.exist? file
|
117
117
|
self[name] = FileSubConfig.new file
|
118
118
|
end
|
119
119
|
end
|
data/lib/cross-post/version.rb
CHANGED