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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 36127678aab70a5994f67edf276638fa425b28f1d8ca42638b6cd5a446a42383
4
- data.tar.gz: b2c6833719a852784bcd214d45f3f876b5bb173f8714bb86e78022d7ab3ded4b
3
+ metadata.gz: 691243e229e2c2e2656db46ed566ea514d337017f3fc00849adf34d75c0cb315
4
+ data.tar.gz: f4bf2934f95900d071c714172d14eb5a409af1d9a3310992c1b0c2df2d034699
5
5
  SHA512:
6
- metadata.gz: 20a814e28bd3ddbcaf4558613a70017295602cccbc7b8b2d4a40ec84cba5d1ded1640f1b5d0334d78c24c3e0daffd97069c8312c4dac160e84dee5e9f71e0d68
7
- data.tar.gz: 10d1e301d8b0d8d1398d99dc9c403e5b6ed5f7ff4d846f0eb1dbf93727bb8bea6388f2d8d1e83877e1e5192494c1c5d97b74e307e8a8d97820b41f774813e4e1
6
+ metadata.gz: ca1be8d51f26fd13937e5532a3f0cdba7cb436866411f9e1bbc75418af6f3352ccb0990cab74550fcc3aea1ec502874093949744fb3ad3b17c7346135d66358c
7
+ data.tar.gz: f8e0eb5e24c11b05204eed30ea2d602e8283cfacf752c2ff833b680bb20e27d2c88aaadf15a0b1366f7b365c8e33a10cade7c2e41f57707cc2e446e8e05a5d71
@@ -1,6 +1,6 @@
1
1
  # lib/jekyll-bluesky/version.rb
2
2
  module Jekyll
3
3
  module Bluesky
4
- VERSION = '0.24.0'
4
+ VERSION = '0.27.0'
5
5
  end
6
6
  end
@@ -2,8 +2,7 @@
2
2
  require 'jekyll'
3
3
  require 'http'
4
4
  require 'json'
5
- require 'digest'
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
- fetch_posts
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; /* Alinha tudo à esquerda */
88
- gap: 8px; /* Espaço entre a foto e o nome */
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; /* Alinha o texto à esquerda */
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; /* Espaço entre o cabeçalho e o conteúdo */
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 = "3h"
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 write(key, data)
187
- file_to_write = cache_file(key)
188
- File.open(file_to_write, 'w') do |f|
189
- f.write(data)
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
- # Register the Liquid tag
202
- Liquid::Template.register_tag 'bluesky', Jekyll::BlueskyPlugin
172
+ Liquid::Template.register_tag 'bluesky', Jekyll::BlueskyPlugin
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-bluesky
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.24.0
4
+ version: 0.27.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Felipe Dias