jekyll-bluesky 0.24.0 → 0.27.0
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/lib/jekyll-bluesky/version.rb +1 -1
- data/lib/jekyll-bluesky.rb +22 -52
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 691243e229e2c2e2656db46ed566ea514d337017f3fc00849adf34d75c0cb315
|
4
|
+
data.tar.gz: f4bf2934f95900d071c714172d14eb5a409af1d9a3310992c1b0c2df2d034699
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ca1be8d51f26fd13937e5532a3f0cdba7cb436866411f9e1bbc75418af6f3352ccb0990cab74550fcc3aea1ec502874093949744fb3ad3b17c7346135d66358c
|
7
|
+
data.tar.gz: f8e0eb5e24c11b05204eed30ea2d602e8283cfacf752c2ff833b680bb20e27d2c88aaadf15a0b1366f7b365c8e33a10cade7c2e41f57707cc2e446e8e05a5d71
|
data/lib/jekyll-bluesky.rb
CHANGED
@@ -2,8 +2,7 @@
|
|
2
2
|
require 'jekyll'
|
3
3
|
require 'http'
|
4
4
|
require 'json'
|
5
|
-
require '
|
6
|
-
require 'fileutils'
|
5
|
+
require 'time' # Necessário para manipulação de datas
|
7
6
|
|
8
7
|
puts 'Plugin jekyll-bluesky load successfully!'
|
9
8
|
|
@@ -19,26 +18,7 @@ module Jekyll
|
|
19
18
|
|
20
19
|
def render(context)
|
21
20
|
Jekyll.logger.debug 'Rendering bluesky tag...'
|
22
|
-
|
23
|
-
end
|
24
|
-
|
25
|
-
private
|
26
|
-
|
27
|
-
def fetch_posts
|
28
|
-
cache_key = Digest::MD5.hexdigest("#{@actor}-#{@limit}")
|
29
|
-
cached_response = cache.read(cache_key)
|
30
|
-
|
31
|
-
if cached_response
|
32
|
-
cached_response
|
33
|
-
else
|
34
|
-
response = Jekyll::Client.fetch_post(@actor, @limit)
|
35
|
-
cache.write(cache_key, response)
|
36
|
-
response
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
def cache
|
41
|
-
@cache ||= FileCache.new('./.bluesky-cache')
|
21
|
+
Jekyll::Client.fetch_post(@actor, @limit)
|
42
22
|
end
|
43
23
|
end
|
44
24
|
|
@@ -82,10 +62,10 @@ module Jekyll
|
|
82
62
|
margin-bottom: 10px;
|
83
63
|
}
|
84
64
|
.bluesky-header {
|
85
|
-
display: flex;
|
65
|
+
display: inline-flex;
|
86
66
|
align-items: center;
|
87
|
-
justify-content: flex-start;
|
88
|
-
gap: 8px;
|
67
|
+
justify-content: flex-start;
|
68
|
+
gap: 8px;
|
89
69
|
}
|
90
70
|
.bluesky-avatar {
|
91
71
|
width: 40px;
|
@@ -95,7 +75,7 @@ module Jekyll
|
|
95
75
|
.bluesky-author-info {
|
96
76
|
display: flex;
|
97
77
|
flex-direction: column;
|
98
|
-
align-items: flex-start;
|
78
|
+
align-items: flex-start;
|
99
79
|
}
|
100
80
|
.author-name {
|
101
81
|
font-weight: bold;
|
@@ -110,7 +90,7 @@ module Jekyll
|
|
110
90
|
font-size: 14px;
|
111
91
|
line-height: 1.5;
|
112
92
|
color: #14171A;
|
113
|
-
margin-top: 8px;
|
93
|
+
margin-top: 8px;
|
114
94
|
}
|
115
95
|
.bluesky-footer {
|
116
96
|
display: flex;
|
@@ -134,7 +114,7 @@ module Jekyll
|
|
134
114
|
text = record['text'].gsub("\n", "<br>")
|
135
115
|
author_name = author['displayName']
|
136
116
|
author_handle = author['handle']
|
137
|
-
post_time =
|
117
|
+
post_time = calculate_post_time(record['createdAt'])
|
138
118
|
|
139
119
|
image_html = ''
|
140
120
|
if embed && embed['$type'] == 'app.bsky.embed.images#view'
|
@@ -170,33 +150,23 @@ module Jekyll
|
|
170
150
|
|
171
151
|
styles + formatted_posts
|
172
152
|
end
|
173
|
-
end
|
174
|
-
|
175
|
-
class FileCache
|
176
|
-
def initialize(path)
|
177
|
-
@cache_folder = File.expand_path path
|
178
|
-
FileUtils.mkdir_p @cache_folder
|
179
|
-
end
|
180
|
-
|
181
|
-
def read(key)
|
182
|
-
file_to_read = cache_file(key)
|
183
|
-
File.read(file_to_read) if File.exist?(file_to_read)
|
184
|
-
end
|
185
153
|
|
186
|
-
def
|
187
|
-
|
188
|
-
|
189
|
-
|
154
|
+
def self.calculate_post_time(created_at)
|
155
|
+
post_time = Time.parse(created_at)
|
156
|
+
current_time = Time.now
|
157
|
+
difference_in_seconds = (current_time - post_time).round
|
158
|
+
|
159
|
+
if difference_in_seconds < 60
|
160
|
+
"#{difference_in_seconds}s"
|
161
|
+
elsif difference_in_seconds < 3600
|
162
|
+
"#{(difference_in_seconds / 60).round}m"
|
163
|
+
elsif difference_in_seconds < 86400
|
164
|
+
"#{(difference_in_seconds / 3600).round}h"
|
165
|
+
else
|
166
|
+
"#{(difference_in_seconds / 86400).round}d"
|
190
167
|
end
|
191
168
|
end
|
192
|
-
|
193
|
-
private
|
194
|
-
|
195
|
-
def cache_file(key)
|
196
|
-
File.join(@cache_folder, "#{key}.cache")
|
197
|
-
end
|
198
169
|
end
|
199
170
|
end
|
200
171
|
|
201
|
-
|
202
|
-
Liquid::Template.register_tag 'bluesky', Jekyll::BlueskyPlugin
|
172
|
+
Liquid::Template.register_tag 'bluesky', Jekyll::BlueskyPlugin
|