legion_mastodon_client 0.1.0 → 0.1.1
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.
- checksums.yaml +4 -4
- data/.env.sample +1 -1
- data/.gitignore +17 -12
- data/Gemfile +14 -13
- data/Gemfile.lock +84 -78
- data/LICENSE +21 -21
- data/README.md +64 -26
- data/bin/legion +6 -6
- data/lib/legion/legion.rb +68 -123
- data/lib/legion/mastodon.rb +71 -71
- data/lib/legion/ui.rb +106 -0
- data/lib/legion/version.rb +1 -1
- metadata +4 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: dd45906fe3d5c1e0efa624dc6484489188fc0bb8b5b440ce28f18e561c2c1fd6
|
|
4
|
+
data.tar.gz: ffb4371c000b14127cef76f392256515479ba0f1627676afdaf5847050bb53a7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 80e4c2498d4b7d16645a633758734b0119252eee6031362fe43fc0ad1462b70d6f38f8815ed68355c6e0cb593ce852f71e65030da1956507ba7a763a0fe8b974
|
|
7
|
+
data.tar.gz: 63d6267fd3b12561a4e7b0f7a57fe91c4fbb6c56d0f4a12ca44a80cc1f4800bdf51b54e4ff9dedb6d1ae7ebd489707aff81e0f4d902650ba4306289c3acee2b7
|
data/.env.sample
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
MASTODON_URL=
|
|
1
|
+
MASTODON_URL=
|
|
2
2
|
MASTODON_TOKEN=
|
data/.gitignore
CHANGED
|
@@ -1,12 +1,17 @@
|
|
|
1
|
-
.env
|
|
2
|
-
/.bundle/
|
|
3
|
-
/.yardoc
|
|
4
|
-
/_yardoc/
|
|
5
|
-
/coverage/
|
|
6
|
-
/doc/
|
|
7
|
-
/pkg/
|
|
8
|
-
/spec/reports/
|
|
9
|
-
/tmp/
|
|
10
|
-
|
|
11
|
-
# rspec failure tracking
|
|
12
|
-
.rspec_status
|
|
1
|
+
.env
|
|
2
|
+
/.bundle/
|
|
3
|
+
/.yardoc
|
|
4
|
+
/_yardoc/
|
|
5
|
+
/coverage/
|
|
6
|
+
/doc/
|
|
7
|
+
/pkg/
|
|
8
|
+
/spec/reports/
|
|
9
|
+
/tmp/
|
|
10
|
+
|
|
11
|
+
# rspec failure tracking
|
|
12
|
+
.rspec_status
|
|
13
|
+
|
|
14
|
+
/lib/legion/.env
|
|
15
|
+
/lib/legion/test.rb
|
|
16
|
+
/lib/legion/Gemfile
|
|
17
|
+
/lib/legion/Gemfile.lock
|
data/Gemfile
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
|
-
source "https://rubygems.org"
|
|
2
|
-
|
|
3
|
-
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
|
4
|
-
|
|
5
|
-
gem 'mastodon-api', git: 'https://github.com/tootsuite/mastodon-api.git', ref: '189deb8'
|
|
6
|
-
gem 'dotenv'
|
|
7
|
-
gem "highline"
|
|
8
|
-
gem 'nokogiri'
|
|
9
|
-
gem 'rmagick'
|
|
10
|
-
gem 'parallel'
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
gemspec
|
|
1
|
+
source "https://rubygems.org"
|
|
2
|
+
|
|
3
|
+
git_source(:github) {|repo_name| "https://github.com/#{repo_name}" }
|
|
4
|
+
|
|
5
|
+
gem 'mastodon-api', git: 'https://github.com/tootsuite/mastodon-api.git', ref: '189deb8'
|
|
6
|
+
gem 'dotenv'
|
|
7
|
+
gem "highline"
|
|
8
|
+
gem 'nokogiri'
|
|
9
|
+
gem 'rmagick'
|
|
10
|
+
gem 'parallel'
|
|
11
|
+
gem 'tk'
|
|
12
|
+
|
|
13
|
+
# Specify your gem's dependencies in legion.gemspec
|
|
14
|
+
gemspec
|
data/Gemfile.lock
CHANGED
|
@@ -1,78 +1,84 @@
|
|
|
1
|
-
GIT
|
|
2
|
-
remote: https://github.com/tootsuite/mastodon-api.git
|
|
3
|
-
revision: 189deb8219ae1ce7c34386d9ad1ca7e4a5fec62c
|
|
4
|
-
ref: 189deb8
|
|
5
|
-
specs:
|
|
6
|
-
mastodon-api (1.2.0)
|
|
7
|
-
addressable (~> 2.5)
|
|
8
|
-
buftok
|
|
9
|
-
http (~> 3.0)
|
|
10
|
-
oj (~> 3.3)
|
|
11
|
-
|
|
12
|
-
PATH
|
|
13
|
-
remote: .
|
|
14
|
-
specs:
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
GEM
|
|
18
|
-
remote: https://rubygems.org/
|
|
19
|
-
specs:
|
|
20
|
-
addressable (2.5.2)
|
|
21
|
-
public_suffix (>= 2.0.2, < 4.0)
|
|
22
|
-
buftok (0.2.0)
|
|
23
|
-
diff-lcs (1.3)
|
|
24
|
-
domain_name (0.5.20180417)
|
|
25
|
-
unf (>= 0.0.5, < 1.0.0)
|
|
26
|
-
dotenv (2.4.0)
|
|
27
|
-
highline (1.7.10)
|
|
28
|
-
http (3.3.0)
|
|
29
|
-
addressable (~> 2.3)
|
|
30
|
-
http-cookie (~> 1.0)
|
|
31
|
-
http-form_data (~> 2.0)
|
|
32
|
-
http_parser.rb (~> 0.6.0)
|
|
33
|
-
http-cookie (1.0.3)
|
|
34
|
-
domain_name (~> 0.5)
|
|
35
|
-
http-form_data (2.1.1)
|
|
36
|
-
http_parser.rb (0.6.0)
|
|
37
|
-
mini_portile2 (2.3.0)
|
|
38
|
-
nokogiri (1.8.2
|
|
39
|
-
mini_portile2 (~> 2.3.0)
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
rspec-
|
|
49
|
-
|
|
50
|
-
rspec-
|
|
51
|
-
rspec-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
1
|
+
GIT
|
|
2
|
+
remote: https://github.com/tootsuite/mastodon-api.git
|
|
3
|
+
revision: 189deb8219ae1ce7c34386d9ad1ca7e4a5fec62c
|
|
4
|
+
ref: 189deb8
|
|
5
|
+
specs:
|
|
6
|
+
mastodon-api (1.2.0)
|
|
7
|
+
addressable (~> 2.5)
|
|
8
|
+
buftok
|
|
9
|
+
http (~> 3.0)
|
|
10
|
+
oj (~> 3.3)
|
|
11
|
+
|
|
12
|
+
PATH
|
|
13
|
+
remote: .
|
|
14
|
+
specs:
|
|
15
|
+
legion_mastodon_client (0.1.0)
|
|
16
|
+
|
|
17
|
+
GEM
|
|
18
|
+
remote: https://rubygems.org/
|
|
19
|
+
specs:
|
|
20
|
+
addressable (2.5.2)
|
|
21
|
+
public_suffix (>= 2.0.2, < 4.0)
|
|
22
|
+
buftok (0.2.0)
|
|
23
|
+
diff-lcs (1.3)
|
|
24
|
+
domain_name (0.5.20180417)
|
|
25
|
+
unf (>= 0.0.5, < 1.0.0)
|
|
26
|
+
dotenv (2.4.0)
|
|
27
|
+
highline (1.7.10)
|
|
28
|
+
http (3.3.0)
|
|
29
|
+
addressable (~> 2.3)
|
|
30
|
+
http-cookie (~> 1.0)
|
|
31
|
+
http-form_data (~> 2.0)
|
|
32
|
+
http_parser.rb (~> 0.6.0)
|
|
33
|
+
http-cookie (1.0.3)
|
|
34
|
+
domain_name (~> 0.5)
|
|
35
|
+
http-form_data (2.1.1)
|
|
36
|
+
http_parser.rb (0.6.0)
|
|
37
|
+
mini_portile2 (2.3.0)
|
|
38
|
+
nokogiri (1.8.2)
|
|
39
|
+
mini_portile2 (~> 2.3.0)
|
|
40
|
+
nokogiri (1.8.2-x86-mingw32)
|
|
41
|
+
mini_portile2 (~> 2.3.0)
|
|
42
|
+
oj (3.6.2)
|
|
43
|
+
parallel (1.12.1)
|
|
44
|
+
public_suffix (3.0.2)
|
|
45
|
+
rake (10.5.0)
|
|
46
|
+
rmagick (2.16.0)
|
|
47
|
+
rspec (3.7.0)
|
|
48
|
+
rspec-core (~> 3.7.0)
|
|
49
|
+
rspec-expectations (~> 3.7.0)
|
|
50
|
+
rspec-mocks (~> 3.7.0)
|
|
51
|
+
rspec-core (3.7.1)
|
|
52
|
+
rspec-support (~> 3.7.0)
|
|
53
|
+
rspec-expectations (3.7.0)
|
|
54
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
55
|
+
rspec-support (~> 3.7.0)
|
|
56
|
+
rspec-mocks (3.7.0)
|
|
57
|
+
diff-lcs (>= 1.2.0, < 2.0)
|
|
58
|
+
rspec-support (~> 3.7.0)
|
|
59
|
+
rspec-support (3.7.1)
|
|
60
|
+
tk (0.2.0)
|
|
61
|
+
unf (0.1.4)
|
|
62
|
+
unf_ext
|
|
63
|
+
unf_ext (0.0.7.5)
|
|
64
|
+
unf_ext (0.0.7.5-x86-mingw32)
|
|
65
|
+
|
|
66
|
+
PLATFORMS
|
|
67
|
+
ruby
|
|
68
|
+
x86-mingw32
|
|
69
|
+
|
|
70
|
+
DEPENDENCIES
|
|
71
|
+
bundler (~> 1.16)
|
|
72
|
+
dotenv
|
|
73
|
+
highline
|
|
74
|
+
legion_mastodon_client!
|
|
75
|
+
mastodon-api!
|
|
76
|
+
nokogiri
|
|
77
|
+
parallel
|
|
78
|
+
rake (~> 10.0)
|
|
79
|
+
rmagick
|
|
80
|
+
rspec (~> 3.0)
|
|
81
|
+
tk
|
|
82
|
+
|
|
83
|
+
BUNDLED WITH
|
|
84
|
+
1.16.2
|
data/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2018 S.H.
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2018 S.H.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
data/README.md
CHANGED
|
@@ -1,26 +1,64 @@
|
|
|
1
|
-
# Legion
|
|
2
|
-
## 概要
|
|
3
|
-
Ruby/Tk を使用して制作されたMastodonクライアントアプリっぽいものです。
|
|
4
|
-
|
|
5
|
-
## 使い方
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
```
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
ruby
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
1
|
+
# Legion
|
|
2
|
+
## 概要
|
|
3
|
+
Ruby/Tk を使用して制作されたMastodonクライアントアプリっぽいものです。
|
|
4
|
+
|
|
5
|
+
## 使い方
|
|
6
|
+
|
|
7
|
+
以下のコマンドでLegionをインストールします。
|
|
8
|
+
|
|
9
|
+
```
|
|
10
|
+
gem install legion_mastodon_client
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
そして、以下のファイルを作成します。
|
|
14
|
+
|
|
15
|
+
legion.rb
|
|
16
|
+
``` ruby:legion.rb
|
|
17
|
+
require 'bundler/setup'
|
|
18
|
+
Bundler.require(:default)
|
|
19
|
+
|
|
20
|
+
require 'legion'
|
|
21
|
+
|
|
22
|
+
Legion.exec
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
Gemfile
|
|
26
|
+
``` ruby:Gemfile
|
|
27
|
+
source "https://rubygems.org"
|
|
28
|
+
|
|
29
|
+
gem 'legion_mastodon_client', '~> 0.1.0'
|
|
30
|
+
gem 'mastodon-api', git: 'https://github.com/tootsuite/mastodon-api.git', ref: '189deb8'
|
|
31
|
+
gem 'dotenv'
|
|
32
|
+
gem "highline"
|
|
33
|
+
gem 'nokogiri'
|
|
34
|
+
gem 'rmagick'
|
|
35
|
+
gem 'parallel'
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
その後、bundle install でgemをインストール
|
|
39
|
+
|
|
40
|
+
```
|
|
41
|
+
bundle install
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
後は、`.env` を作成し、必要な環境変数を記入していくだけです。
|
|
45
|
+
|
|
46
|
+
``` :.env
|
|
47
|
+
MASTODON_URL=<インスタンスのURL>
|
|
48
|
+
MASTODON_TOKEN=<インスタンスで発行したアクセストークン>
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
最後に以下のコマンドでLegionのUIを起動させるだけです。
|
|
52
|
+
|
|
53
|
+
```
|
|
54
|
+
ruby legion.rb
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
基本的にMastodonインスタンスはLetsencryptを使用しているので、SSL証明書を使用する端末に導入しておく必要があります。
|
|
58
|
+
その点だけご注意ください
|
|
59
|
+
|
|
60
|
+
## 参考
|
|
61
|
+
|
|
62
|
+
[Ruby/Tk Beginner's tutorial ](https://www.dumbo.ai.kyutech.ac.jp/nomura-ken/kajiyama/ruby_tk/contents.html)
|
|
63
|
+
|
|
64
|
+
[mastodon-api](https://github.com/tootsuite/mastodon-api)
|
data/bin/legion
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
#!/usr/bin/env ruby
|
|
2
|
-
|
|
3
|
-
require 'legion'
|
|
4
|
-
Dotenv.load
|
|
5
|
-
|
|
6
|
-
puts legion.exec
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
|
|
3
|
+
require 'legion'
|
|
4
|
+
Dotenv.load
|
|
5
|
+
|
|
6
|
+
puts legion.exec
|
data/lib/legion/legion.rb
CHANGED
|
@@ -1,124 +1,69 @@
|
|
|
1
|
-
require 'mastodon'
|
|
2
|
-
require 'highline/import'
|
|
3
|
-
require 'dotenv'
|
|
4
|
-
require 'tk'
|
|
5
|
-
require_relative 'mastodon'
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
local_timeline.
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
client = Mastodon::REST::Client.new(base_url: ENV["MASTODON_URL"], bearer_token: ENV["MASTODON_TOKEN"])
|
|
70
|
-
mastodon = MastodonAPI.new(client)
|
|
71
|
-
|
|
72
|
-
stream = Mastodon::Streaming::Client.new(base_url: ENV["MASTODON_URL"], bearer_token: ENV["MASTODON_TOKEN"])
|
|
73
|
-
streaming = MastodonStreaming.new(stream)
|
|
74
|
-
|
|
75
|
-
visibility = TkVariable.new('public')
|
|
76
|
-
sensitive = TkVariable.new('false')
|
|
77
|
-
spoiler_text = TkVariable.new("")
|
|
78
|
-
|
|
79
|
-
text = TkText.new(tootFrame, 'width' => '50', 'height'=> '30')
|
|
80
|
-
text.pack('side' => 'top', 'fill' => 'both')
|
|
81
|
-
|
|
82
|
-
button = TkButton.new(tootFrame, 'text' => 'toot',
|
|
83
|
-
'command' => proc{mastodon.Toot(text.value, visibility.value, sensitive.value, spoiler_text.value);text.value=""})
|
|
84
|
-
button.pack('side' => 'left', 'fill' => 'both')
|
|
85
|
-
|
|
86
|
-
mediabutton = TkButton.new(tootFrame, 'text' => 'media',
|
|
87
|
-
'command' => proc{mastodon.MediaUpload(Tk.getOpenFile)})
|
|
88
|
-
mediabutton.pack('side' => 'left', 'fill' => 'both')
|
|
89
|
-
|
|
90
|
-
public_button = TkButton.new(tootFrame, 'text' => 'public',
|
|
91
|
-
'command' => proc{visibility.value = 'public' })
|
|
92
|
-
public_button.pack('side' => 'left', 'fill' => 'both')
|
|
93
|
-
|
|
94
|
-
unlisted_button = TkButton.new(tootFrame, 'text' => 'unlisted',
|
|
95
|
-
'command' => proc{visibility.value = 'unlisted' })
|
|
96
|
-
unlisted_button.pack('side' => 'left', 'fill' => 'both')
|
|
97
|
-
|
|
98
|
-
private_button = TkButton.new(tootFrame, 'text' => 'private',
|
|
99
|
-
'command' => proc{visibility.value = 'private' })
|
|
100
|
-
private_button.pack('side' => 'left', 'fill' => 'both')
|
|
101
|
-
|
|
102
|
-
direct_button = TkButton.new(tootFrame, 'text' => 'direct',
|
|
103
|
-
'command' => proc{visibility.value = 'direct' })
|
|
104
|
-
direct_button.pack('side' => 'left', 'fill' => 'both')
|
|
105
|
-
|
|
106
|
-
nsfw_button = TkButton.new(tootFrame, 'text' => 'nsfw',
|
|
107
|
-
'command' => proc{sensitive.value == 'true' ? sensitive.value = 'false' : sensitive.value = 'true' })
|
|
108
|
-
nsfw_button.pack('side' => 'left', 'fill' => 'both')
|
|
109
|
-
|
|
110
|
-
cw_button = TkButton.new(tootFrame, 'text' => 'cw',
|
|
111
|
-
'command' => proc{spoiler_text.value == "" ? spoiler_text.value = "Contents Warning!" : spoiler_text.value = "";
|
|
112
|
-
sensitive.value == 'true' ? sensitive.value = 'false' : sensitive.value = 'true' })
|
|
113
|
-
cw_button.pack('side' => 'left', 'fill' => 'both')
|
|
114
|
-
|
|
115
|
-
quitbutton = TkButton.new(tootFrame, 'text' => 'quit',
|
|
116
|
-
'command' => proc{exit})
|
|
117
|
-
quitbutton.pack('side' => 'right', 'fill' => 'both')
|
|
118
|
-
|
|
119
|
-
loop do
|
|
120
|
-
Parallel.each([[1, home_timeline, htl_list], [2, local_timeline, ltl_list], [3, public_timeline, ftl_list]], in_threads: 3) do |call|
|
|
121
|
-
streaming.Timeline(call)
|
|
122
|
-
end
|
|
123
|
-
end
|
|
1
|
+
require 'mastodon'
|
|
2
|
+
require 'highline/import'
|
|
3
|
+
require 'dotenv'
|
|
4
|
+
require 'tk'
|
|
5
|
+
require_relative 'mastodon'
|
|
6
|
+
require_relative 'ui'
|
|
7
|
+
|
|
8
|
+
def LegionLoop
|
|
9
|
+
|
|
10
|
+
window = TkRoot.new do #タイトルバーの表示
|
|
11
|
+
title( "Legion" )
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
Dotenv.load
|
|
15
|
+
|
|
16
|
+
client = Mastodon::REST::Client.new(base_url: ENV["MASTODON_URL"], bearer_token: ENV["MASTODON_TOKEN"])
|
|
17
|
+
mastodon = MastodonAPI.new(client)
|
|
18
|
+
|
|
19
|
+
stream = Mastodon::Streaming::Client.new(base_url: ENV["MASTODON_URL"], bearer_token: ENV["MASTODON_TOKEN"])
|
|
20
|
+
streaming = MastodonStreaming.new(stream)
|
|
21
|
+
|
|
22
|
+
tootFrame = TootFrame.new(window, mastodon)
|
|
23
|
+
tootFrame.set
|
|
24
|
+
|
|
25
|
+
home_timeline = Timeline.new(window, "ホームタイムライン")
|
|
26
|
+
home_timeline.set
|
|
27
|
+
|
|
28
|
+
home_timeline_yscrollbar = TkScrollbar.new(home_timeline.list) {orient "vertical"; command proc{|*args| home_timeline.list.yview(*args);} }
|
|
29
|
+
home_timeline.list['yscrollcommand'] = proc{|*args| home_timeline_yscrollbar.set(*args);}
|
|
30
|
+
home_timeline_yscrollbar.pack('side' => 'right', 'fill' => 'both', 'ipadx' => '5', 'ipady' => '170')
|
|
31
|
+
|
|
32
|
+
home_timeline_xscrollbar = TkScrollbar.new(home_timeline.list) {orient "horizontal"; command proc{|*args| home_timeline.list.xview(*args);} }
|
|
33
|
+
home_timeline.list['xscrollcommand'] = proc{|*args| home_timeline_xscrollbar.set(*args);}
|
|
34
|
+
home_timeline_xscrollbar.pack('side' => 'bottom', 'fill' => 'both')
|
|
35
|
+
|
|
36
|
+
local_timeline = Timeline.new(window, "ローカルタイムライン")
|
|
37
|
+
local_timeline.set
|
|
38
|
+
|
|
39
|
+
local_timeline_yscrollbar = TkScrollbar.new(local_timeline.list) {orient "vertical"; command proc{|*args| local_timeline.list.yview(*args);} }
|
|
40
|
+
local_timeline.list['yscrollcommand'] = proc{|*args| local_timeline_yscrollbar.set(*args);}
|
|
41
|
+
local_timeline_yscrollbar.pack('side' => 'right', 'fill' => 'both', 'ipadx' => '5', 'ipady' => '170')
|
|
42
|
+
|
|
43
|
+
local_timeline_xscrollbar = TkScrollbar.new(local_timeline.list) {orient "horizontal"; command proc{|*args| local_timeline.list.xview(*args);} }
|
|
44
|
+
local_timeline.list['xscrollcommand'] = proc{|*args| local_timeline_xscrollbar.set(*args);}
|
|
45
|
+
local_timeline_xscrollbar.pack('side' => 'bottom', 'fill' => 'both')
|
|
46
|
+
|
|
47
|
+
public_timeline = Timeline.new(window, "連合タイムライン")
|
|
48
|
+
public_timeline.set
|
|
49
|
+
|
|
50
|
+
public_timeline_yscrollbar = TkScrollbar.new(public_timeline.list) {orient "vertical"; command proc{|*args| public_timeline.list.yview(*args);} }
|
|
51
|
+
public_timeline.list['yscrollcommand'] = proc{|*args| public_timeline_yscrollbar.set(*args);}
|
|
52
|
+
public_timeline_yscrollbar.pack('side' => 'right', 'fill' => 'both', 'ipadx' => '5', 'ipady' => '170')
|
|
53
|
+
|
|
54
|
+
public_timeline_xscrollbar = TkScrollbar.new(public_timeline.list) {orient "horizontal"; command proc{|*args| public_timeline.list.xview(*args);} }
|
|
55
|
+
public_timeline.list['xscrollcommand'] = proc{|*args| public_timeline_xscrollbar.set(*args);}
|
|
56
|
+
public_timeline_xscrollbar.pack('side' => 'bottom', 'fill' => 'both')
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
t1 = Thread.start {
|
|
60
|
+
loop do
|
|
61
|
+
Parallel.each([[1, home_timeline, home_timeline.list], [2, local_timeline, local_timeline.list], [3, public_timeline, public_timeline.list]], in_threads: 3) do |call|
|
|
62
|
+
streaming.Timeline(call)
|
|
63
|
+
end
|
|
64
|
+
end
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
Tk.mainloop
|
|
68
|
+
|
|
124
69
|
end
|
data/lib/legion/mastodon.rb
CHANGED
|
@@ -1,72 +1,72 @@
|
|
|
1
|
-
require 'nokogiri'
|
|
2
|
-
require 'open-uri'
|
|
3
|
-
require 'rmagick'
|
|
4
|
-
|
|
5
|
-
class MastodonAPI
|
|
6
|
-
|
|
7
|
-
def initialize(client)
|
|
8
|
-
@client = client
|
|
9
|
-
@timeline = Hash.new
|
|
10
|
-
@avatar = Array.new
|
|
11
|
-
@media_id = nil
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
def MediaUpload(file_path)
|
|
15
|
-
|
|
16
|
-
if file_path != nil then
|
|
17
|
-
@media_id = @client.upload_media(file_path).id
|
|
18
|
-
else
|
|
19
|
-
@media_id = nil
|
|
20
|
-
end
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
def Toot(message, visibility, sensitive, spoiler_text)
|
|
24
|
-
message += "\n #Legion"
|
|
25
|
-
response = @client.create_status(message.encode("UTF-8"), :media_ids => @media_id, :visibility => visibility, :sensitive => sensitive, :spoiler_text => spoiler_text)
|
|
26
|
-
end
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
class MastodonStreaming
|
|
30
|
-
|
|
31
|
-
def initialize(stream)
|
|
32
|
-
@stream = stream
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
def HomeTimeline(window, list)
|
|
36
|
-
@stream.user() do |toot|
|
|
37
|
-
message = Nokogiri::HTML.parse(toot.content, nil, nil).search('p')
|
|
38
|
-
list.insert('0', message.text)
|
|
39
|
-
end
|
|
40
|
-
end
|
|
41
|
-
|
|
42
|
-
def PublicTimeline(window, list)
|
|
43
|
-
@stream.firehose() do |toot|
|
|
44
|
-
message = Nokogiri::HTML.parse(toot.content, nil, nil).search('p')
|
|
45
|
-
list.insert('0', message.text)
|
|
46
|
-
end
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
def LocalTimeline(window, list)
|
|
50
|
-
@stream.firehose() do |toot|
|
|
51
|
-
if toot.uri.to_s =~ /#{ENV['MASTODON_URL'].to_s}/ then
|
|
52
|
-
message = Nokogiri::HTML.parse(toot.content, nil, nil).search('p')
|
|
53
|
-
list.insert('0', message.text)
|
|
54
|
-
end
|
|
55
|
-
end
|
|
56
|
-
end
|
|
57
|
-
|
|
58
|
-
def Timeline(timeline)
|
|
59
|
-
|
|
60
|
-
case timeline[0]
|
|
61
|
-
|
|
62
|
-
when 1
|
|
63
|
-
self.HomeTimeline(timeline[1], timeline[2])
|
|
64
|
-
|
|
65
|
-
when 2
|
|
66
|
-
self.LocalTimeline(timeline[1], timeline[2])
|
|
67
|
-
|
|
68
|
-
when 3
|
|
69
|
-
self.PublicTimeline(timeline[1], timeline[2])
|
|
70
|
-
end
|
|
71
|
-
end
|
|
1
|
+
require 'nokogiri'
|
|
2
|
+
require 'open-uri'
|
|
3
|
+
require 'rmagick'
|
|
4
|
+
|
|
5
|
+
class MastodonAPI
|
|
6
|
+
|
|
7
|
+
def initialize(client)
|
|
8
|
+
@client = client
|
|
9
|
+
@timeline = Hash.new
|
|
10
|
+
@avatar = Array.new
|
|
11
|
+
@media_id = nil
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
def MediaUpload(file_path)
|
|
15
|
+
|
|
16
|
+
if file_path != nil then
|
|
17
|
+
@media_id = @client.upload_media(file_path).id
|
|
18
|
+
else
|
|
19
|
+
@media_id = nil
|
|
20
|
+
end
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def Toot(message, visibility, sensitive, spoiler_text)
|
|
24
|
+
message += "\n #Legion"
|
|
25
|
+
response = @client.create_status(message.encode("UTF-8"), :media_ids => @media_id, :visibility => visibility, :sensitive => sensitive, :spoiler_text => spoiler_text)
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
class MastodonStreaming
|
|
30
|
+
|
|
31
|
+
def initialize(stream)
|
|
32
|
+
@stream = stream
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def HomeTimeline(window, list)
|
|
36
|
+
@stream.user() do |toot|
|
|
37
|
+
message = Nokogiri::HTML.parse(toot.content, nil, nil).search('p')
|
|
38
|
+
list.insert('0', message.text)
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
def PublicTimeline(window, list)
|
|
43
|
+
@stream.firehose() do |toot|
|
|
44
|
+
message = Nokogiri::HTML.parse(toot.content, nil, nil).search('p')
|
|
45
|
+
list.insert('0', message.text)
|
|
46
|
+
end
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def LocalTimeline(window, list)
|
|
50
|
+
@stream.firehose() do |toot|
|
|
51
|
+
if toot.uri.to_s =~ /#{ENV['MASTODON_URL'].to_s}/ then
|
|
52
|
+
message = Nokogiri::HTML.parse(toot.content, nil, nil).search('p')
|
|
53
|
+
list.insert('0', message.text)
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def Timeline(timeline)
|
|
59
|
+
|
|
60
|
+
case timeline[0]
|
|
61
|
+
|
|
62
|
+
when 1
|
|
63
|
+
self.HomeTimeline(timeline[1], timeline[2])
|
|
64
|
+
|
|
65
|
+
when 2
|
|
66
|
+
self.LocalTimeline(timeline[1], timeline[2])
|
|
67
|
+
|
|
68
|
+
when 3
|
|
69
|
+
self.PublicTimeline(timeline[1], timeline[2])
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
72
|
end
|
data/lib/legion/ui.rb
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
|
|
2
|
+
class Timeline
|
|
3
|
+
attr_accessor :list
|
|
4
|
+
|
|
5
|
+
def initialize(window, timeline_name)
|
|
6
|
+
@timeline = TkFrame.new(window)
|
|
7
|
+
@label = TkLabel.new(@timeline, 'text' => timeline_name, 'width' => 50)
|
|
8
|
+
@list = TkListbox.new(@timeline, 'height' => 25, 'selectmode' => 'multiple')
|
|
9
|
+
end
|
|
10
|
+
|
|
11
|
+
def timeline_pack
|
|
12
|
+
@timeline.pack('side' => 'left', 'fill' => 'both')
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def label_pack
|
|
16
|
+
@label.pack('side' => 'top', 'fill' => 'both')
|
|
17
|
+
end
|
|
18
|
+
|
|
19
|
+
def list_pack
|
|
20
|
+
@list.pack('fill' => 'both')
|
|
21
|
+
end
|
|
22
|
+
|
|
23
|
+
def set
|
|
24
|
+
self.timeline_pack
|
|
25
|
+
self.label_pack
|
|
26
|
+
self.list_pack
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
class TootFrame
|
|
31
|
+
|
|
32
|
+
def initialize(window, mastodon)
|
|
33
|
+
@tootFrame = TkFrame.new(window)
|
|
34
|
+
@visibility = TkVariable.new('public')
|
|
35
|
+
@sensitive = TkVariable.new('false')
|
|
36
|
+
@spoiler_text = TkVariable.new("")
|
|
37
|
+
@text = text = TkText.new(@tootFrame, 'width' => '50', 'height'=> '30')
|
|
38
|
+
@button = TkButton.new(@tootFrame, 'text' => 'toot', 'command' => proc{mastodon.Toot(@text.value, @visibility.value, @sensitive.value, @spoiler_text.value);@text.value=""})
|
|
39
|
+
@mediabutton = TkButton.new(@tootFrame, 'text' => 'media', 'command' => proc{mastodon.MediaUpload(Tk.getOpenFile)})
|
|
40
|
+
@public_button = TkButton.new(@tootFrame, 'text' => 'public', 'command' => proc{@visibility.value = 'public' })
|
|
41
|
+
@unlisted_button = TkButton.new(@tootFrame, 'text' => 'unlisted', 'command' => proc{@visibility.value = 'unlisted' })
|
|
42
|
+
@private_button = TkButton.new(@tootFrame, 'text' => 'private', 'command' => proc{@visibility.value = 'private' })
|
|
43
|
+
@direct_button = TkButton.new(@tootFrame, 'text' => 'direct', 'command' => proc{@visibility.value = 'direct' })
|
|
44
|
+
@nsfw_button = TkButton.new(@tootFrame, 'text' => 'nsfw', 'command' => proc{@sensitive.value == 'true' ? @sensitive.value = 'false' : @sensitive.value = 'true' })
|
|
45
|
+
@cw_button = TkButton.new(@tootFrame, 'text' => 'cw', 'command' => proc{@spoiler_text.value == "" ? @spoiler_text.value = "Contents Warning!" : @spoiler_text.value = ""; @sensitive.value == 'true' ? @sensitive.value = 'false' : @sensitive.value = 'true' })
|
|
46
|
+
@quitbutton = TkButton.new(@tootFrame, 'text' => 'quit', 'command' => proc{exit})
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def TootFrame_pack
|
|
50
|
+
@tootFrame.pack('side' => 'left', 'fill' => 'both')
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def Text_pack
|
|
54
|
+
@text.pack('side' => 'top', 'fill' => 'both')
|
|
55
|
+
end
|
|
56
|
+
|
|
57
|
+
def Button_pack
|
|
58
|
+
@button.pack('side' => 'left', 'fill' => 'both')
|
|
59
|
+
end
|
|
60
|
+
|
|
61
|
+
def MediaButton_pack
|
|
62
|
+
@mediabutton.pack('side' => 'left', 'fill' => 'both')
|
|
63
|
+
end
|
|
64
|
+
|
|
65
|
+
def PubilcButton_pack
|
|
66
|
+
@public_button.pack('side' => 'left', 'fill' => 'both')
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def UnlistedButton_pack
|
|
70
|
+
@unlisted_button.pack('side' => 'left', 'fill' => 'both')
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def PrivateButton_pack
|
|
74
|
+
@private_button.pack('side' => 'left', 'fill' => 'both')
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def DirectButton_pack
|
|
78
|
+
@direct_button.pack('side' => 'left', 'fill' => 'both')
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
def NsfwButton_pack
|
|
82
|
+
@nsfw_button.pack('side' => 'left', 'fill' => 'both')
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
def CwButton_pack
|
|
86
|
+
@cw_button.pack('side' => 'left', 'fill' => 'both')
|
|
87
|
+
end
|
|
88
|
+
|
|
89
|
+
def Quitbutton_pack
|
|
90
|
+
@quitbutton.pack('side' => 'right', 'fill' => 'both')
|
|
91
|
+
end
|
|
92
|
+
|
|
93
|
+
def set
|
|
94
|
+
self.TootFrame_pack
|
|
95
|
+
self.Text_pack
|
|
96
|
+
self.Button_pack
|
|
97
|
+
self.PubilcButton_pack
|
|
98
|
+
self.MediaButton_pack
|
|
99
|
+
self.UnlistedButton_pack
|
|
100
|
+
self.PrivateButton_pack
|
|
101
|
+
self.DirectButton_pack
|
|
102
|
+
self.NsfwButton_pack
|
|
103
|
+
self.CwButton_pack
|
|
104
|
+
self.Quitbutton_pack
|
|
105
|
+
end
|
|
106
|
+
end
|
data/lib/legion/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: legion_mastodon_client
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.1.
|
|
4
|
+
version: 0.1.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- S-H-GAMELINKS
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: exe
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2018-06-
|
|
11
|
+
date: 2018-06-24 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: bundler
|
|
@@ -76,6 +76,7 @@ files:
|
|
|
76
76
|
- lib/legion.rb
|
|
77
77
|
- lib/legion/legion.rb
|
|
78
78
|
- lib/legion/mastodon.rb
|
|
79
|
+
- lib/legion/ui.rb
|
|
79
80
|
- lib/legion/version.rb
|
|
80
81
|
homepage: https://github.com/S-H-GAMELINKS/Legion
|
|
81
82
|
licenses:
|
|
@@ -97,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
97
98
|
version: '0'
|
|
98
99
|
requirements: []
|
|
99
100
|
rubyforge_project:
|
|
100
|
-
rubygems_version: 2.7.
|
|
101
|
+
rubygems_version: 2.7.7
|
|
101
102
|
signing_key:
|
|
102
103
|
specification_version: 4
|
|
103
104
|
summary: Mastodon Client(Ruby/Tk)
|