nineteen_ninetynine 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +23 -13
- data/lib/nineteen_ninetynine/core.rb +9 -0
- data/lib/nineteen_ninetynine/event/profile.rb +1 -5
- data/lib/nineteen_ninetynine/img2cat.rb +18 -0
- data/lib/nineteen_ninetynine/utils.rb +0 -1
- data/lib/nineteen_ninetynine/version.rb +1 -1
- data/lib/nineteen_ninetynine.rb +7 -3
- metadata +7 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: cd4cf054fe4f43f913dc3fa062f9b2c62c1c83c150665b28c78fff9e71e09d23
|
4
|
+
data.tar.gz: 8fb116cb44eae5301f1e860acddf2ffc801eab82aa2057fd9872c24291fa9917
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 416ef2cf0289d38f2795604047ade18837a8ef8000fa310bc59f133a6ba54f5baff2d3f886bf8f6db4f4a78314937157c08107640abe0dde111df8ba9e707547
|
7
|
+
data.tar.gz: ddddd0b688b6448553e3114254d471ea92368e8b8e921fa3bda14580c5d51aa77316a1550f5106afc972570a5e7468fc5859405ac18a100b1f7f2646ebaf87e2
|
data/README.md
CHANGED
@@ -1,24 +1,34 @@
|
|
1
1
|
# NineteenNinetynine
|
2
2
|
|
3
|
-
TODO: Delete this and the text below, and describe your gem
|
4
|
-
|
5
|
-
Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/nineteen_ninetynine`. To experiment with that code, run `bin/console` for an interactive prompt.
|
6
3
|
|
7
4
|
## Installation
|
8
5
|
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
$ bundle add UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
|
14
|
-
|
15
|
-
If bundler is not being used to manage dependencies, install the gem by executing:
|
16
|
-
|
17
|
-
$ gem install UPDATE_WITH_YOUR_GEM_NAME_PRIOR_TO_RELEASE_TO_RUBYGEMS_ORG
|
6
|
+
```
|
7
|
+
gem install nineteen_ninetynine
|
8
|
+
```
|
18
9
|
|
19
10
|
## Usage
|
20
11
|
|
21
|
-
|
12
|
+
```
|
13
|
+
nineteen_ninetynine
|
14
|
+
```
|
15
|
+
|
16
|
+
You can display icon images by installing `imgcat` or `wezterm imgcat`, `img2sixel`.
|
17
|
+
|
18
|
+
## TODO
|
19
|
+
|
20
|
+
- [ ] Specify relay server url from environment variable
|
21
|
+
- [ ] Test!(more test!)
|
22
|
+
- [ ] Debug mode
|
23
|
+
- [ ] Expand the image on the terminal
|
24
|
+
- [ ] Expand the URL(OGP) on the terminal
|
25
|
+
- [ ] Write event
|
26
|
+
- [ ] Implementation `:show {event,user} $aa` command
|
27
|
+
- [ ] Implementation `:replay $aa` command
|
28
|
+
- [ ] Implementation of user name suggestions
|
29
|
+
- [ ] Add alternative `nineteen_ninetynine` command (`$ 1999`)
|
30
|
+
- [ ] Implementation for reconnecting to the relay server
|
31
|
+
- [ ] Implementation for some options
|
22
32
|
|
23
33
|
## Development
|
24
34
|
|
@@ -69,6 +69,15 @@ module NineteenNinetynine
|
|
69
69
|
@last_data_received_at = time
|
70
70
|
end
|
71
71
|
|
72
|
+
def error(e)
|
73
|
+
case e
|
74
|
+
when Exception
|
75
|
+
insert "[ERROR] #{e.message}\n #{e.backtrace.join("\n ")}".c(:notice)
|
76
|
+
else
|
77
|
+
insert "[ERROR] #{e}".c(:notice)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
72
81
|
def start_stream
|
73
82
|
users = create_users
|
74
83
|
notes = create_notes
|
@@ -37,10 +37,6 @@ module NineteenNinetynine
|
|
37
37
|
"#{XDG_CONFIG_DIR}/icons"
|
38
38
|
end
|
39
39
|
|
40
|
-
def icon
|
41
|
-
`wezterm imgcat --height 1 #{@icon_path}`.strip
|
42
|
-
end
|
43
|
-
|
44
40
|
def download_icon_image
|
45
41
|
if @picture_url.start_with?("data:image/")
|
46
42
|
File.write(icon_path, Base64.decode64(@picture_url.split(",")[1]))
|
@@ -57,7 +53,7 @@ module NineteenNinetynine
|
|
57
53
|
puts "unknown"
|
58
54
|
puts @picture_url
|
59
55
|
end
|
60
|
-
rescue SocketError, Net::OpenTimeout => e
|
56
|
+
rescue SocketError, Net::OpenTimeout, OpenSSL::SSL::SSLError => e
|
61
57
|
# ignore
|
62
58
|
end
|
63
59
|
else
|
@@ -0,0 +1,18 @@
|
|
1
|
+
module NineteenNinetynine
|
2
|
+
module Img2cat
|
3
|
+
def executable_img2cat_command
|
4
|
+
@executable_img2cat_command ||= nil
|
5
|
+
end
|
6
|
+
|
7
|
+
def determine_img2cat_command
|
8
|
+
# TODO: use exit code, supressess STDOUT
|
9
|
+
if system("which", "wezterm")
|
10
|
+
@executable_img2cat_command = "wezterm imgcat"
|
11
|
+
elsif system("which", "imgcat")
|
12
|
+
@executable_img2cat_command = "imgcat"
|
13
|
+
elsif system("which", "img2sixel")
|
14
|
+
@executable_img2cat_command = "img2sixel"
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
data/lib/nineteen_ninetynine.rb
CHANGED
@@ -6,6 +6,7 @@ require_relative "nineteen_ninetynine/core"
|
|
6
6
|
require_relative "nineteen_ninetynine/ext"
|
7
7
|
require_relative "nineteen_ninetynine/renderer"
|
8
8
|
require_relative "nineteen_ninetynine/id_var"
|
9
|
+
require_relative "nineteen_ninetynine/img2cat"
|
9
10
|
require_relative "nineteen_ninetynine/initializer"
|
10
11
|
require_relative "nineteen_ninetynine/output"
|
11
12
|
require_relative "nineteen_ninetynine/subscriber"
|
@@ -31,6 +32,7 @@ module NineteenNinetynine
|
|
31
32
|
extend Renderer
|
32
33
|
extend Output
|
33
34
|
extend IdVar
|
35
|
+
extend Img2cat
|
34
36
|
|
35
37
|
User = Data.define :name, :pubkey
|
36
38
|
|
@@ -42,10 +44,11 @@ module NineteenNinetynine
|
|
42
44
|
unless Dir.exist?(XDG_CONFIG_DIR)
|
43
45
|
FileUtils.mkdir_p(XDG_CONFIG_DIR)
|
44
46
|
FileUtils.mkdir_p(XDG_CONFIG_DIR + "/icons")
|
45
|
-
FileUtils.cp(File.dirname(__FILE__) + "../assets/default.png", XDG_CONFIG_DIR + "/icons/default.png")
|
46
47
|
end
|
48
|
+
FileUtils.cp(File.dirname(__FILE__) + "/assets/default.png", XDG_CONFIG_DIR + "/icons/default.png")
|
47
49
|
|
48
50
|
init do
|
51
|
+
determine_img2cat_command
|
49
52
|
self.id_var ||= IdVar::Gen.new
|
50
53
|
outputs.clear
|
51
54
|
output_filters.clear
|
@@ -70,7 +73,7 @@ module NineteenNinetynine
|
|
70
73
|
|
71
74
|
if /\n/ =~ text
|
72
75
|
text.prepend("\n")
|
73
|
-
text.gsub!(/\n/, "\n
|
76
|
+
text.gsub!(/\n/, "\n " + "|".c(:info))
|
74
77
|
text << "\n "
|
75
78
|
else
|
76
79
|
text.gsub!(/\s+/, ' ')
|
@@ -98,11 +101,12 @@ module NineteenNinetynine
|
|
98
101
|
# end
|
99
102
|
|
100
103
|
mark = item._mark || ""
|
104
|
+
icon = `#{@executable_img2cat_command} --height 1 #{item.user.icon_path}`.strip
|
101
105
|
|
102
106
|
status = [
|
103
107
|
item.date.strftime("%H:%M").c(:info),
|
104
108
|
mark + id.c(:info),
|
105
|
-
"#{
|
109
|
+
"#{icon}#{item.user.name.c(color_of(item.user.name))}:",
|
106
110
|
text,
|
107
111
|
info.join(' - ').c(:info),
|
108
112
|
].compact.join(" ")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: nineteen_ninetynine
|
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
|
- Yuya Fujiwara
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-
|
11
|
+
date: 2023-07-15 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -77,6 +77,7 @@ files:
|
|
77
77
|
- lib/nineteen_ninetynine/event/profile.rb
|
78
78
|
- lib/nineteen_ninetynine/ext.rb
|
79
79
|
- lib/nineteen_ninetynine/id_var.rb
|
80
|
+
- lib/nineteen_ninetynine/img2cat.rb
|
80
81
|
- lib/nineteen_ninetynine/initializer.rb
|
81
82
|
- lib/nineteen_ninetynine/output.rb
|
82
83
|
- lib/nineteen_ninetynine/renderer.rb
|
@@ -92,7 +93,7 @@ metadata:
|
|
92
93
|
homepage_uri: https://ason.as
|
93
94
|
source_code_uri: https://github.com/asonas/nineteen_ninetynine
|
94
95
|
changelog_uri: https://github.com/asonas/nineteen_ninetynine
|
95
|
-
post_install_message:
|
96
|
+
post_install_message:
|
96
97
|
rdoc_options: []
|
97
98
|
require_paths:
|
98
99
|
- lib
|
@@ -107,8 +108,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
107
108
|
- !ruby/object:Gem::Version
|
108
109
|
version: '0'
|
109
110
|
requirements: []
|
110
|
-
rubygems_version: 3.4.
|
111
|
-
signing_key:
|
111
|
+
rubygems_version: 3.4.10
|
112
|
+
signing_key:
|
112
113
|
specification_version: 4
|
113
114
|
summary: nineteen_ninetynine is nostr client
|
114
115
|
test_files: []
|