jekyll-bluesky 0.23.0 → 0.24.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: 665ba6d592f80381f1c4a5e1f2b36f0d8fb7801b0f8bc96eef76c4e6bdc653f4
4
- data.tar.gz: 1eaad7c384d8f4d9f6cec0cb8170611cb1265dc3ea72ef09415c94091c9bcdb7
3
+ metadata.gz: 36127678aab70a5994f67edf276638fa425b28f1d8ca42638b6cd5a446a42383
4
+ data.tar.gz: b2c6833719a852784bcd214d45f3f876b5bb173f8714bb86e78022d7ab3ded4b
5
5
  SHA512:
6
- metadata.gz: 1a533202e93c383e0571c1181c5e235d35420d9eaf43b6ec14b88e9014b95941da2edee8b9c1b105cf4d4f3888a0fd5a8ef5e9c274e4a9a1e9ec3b802a698226
7
- data.tar.gz: c4cd0b1bd986dd3ca476410362958f36580e1fc9a1f2de20e12aa5863c699907cfcda1535135c757916b4e806dc36aa889495e92590aeb7ae8db449990e6a9dc
6
+ metadata.gz: 20a814e28bd3ddbcaf4558613a70017295602cccbc7b8b2d4a40ec84cba5d1ded1640f1b5d0334d78c24c3e0daffd97069c8312c4dac160e84dee5e9f71e0d68
7
+ data.tar.gz: 10d1e301d8b0d8d1398d99dc9c403e5b6ed5f7ff4d846f0eb1dbf93727bb8bea6388f2d8d1e83877e1e5192494c1c5d97b74e307e8a8d97820b41f774813e4e1
@@ -1,6 +1,6 @@
1
1
  # lib/jekyll-bluesky/version.rb
2
2
  module Jekyll
3
3
  module Bluesky
4
- VERSION = '0.23.0'
4
+ VERSION = '0.24.0'
5
5
  end
6
6
  end
@@ -1,203 +1,202 @@
1
- # lib/jekyll_bluesky.rb
2
- require 'jekyll'
3
- require 'http'
4
- require 'json'
5
- require 'digest'
6
- require 'fileutils'
7
-
8
- puts 'Plugin jekyll-bluesky load successfully!'
9
-
10
- module Jekyll
11
- class BlueskyPlugin < Liquid::Tag
12
- def initialize(tag_name, text, tokens)
13
- super
14
- args = text.strip.split
15
- @actor = args[0]
16
- @limit = args[1] || '10'
17
- Jekyll.logger.debug "Initializing tag bluesky with actor: #{@actor}, limit: #{@limit}"
18
- end
1
+ # lib/jekyll_bluesky.rb
2
+ require 'jekyll'
3
+ require 'http'
4
+ require 'json'
5
+ require 'digest'
6
+ require 'fileutils'
7
+
8
+ puts 'Plugin jekyll-bluesky load successfully!'
9
+
10
+ module Jekyll
11
+ class BlueskyPlugin < Liquid::Tag
12
+ def initialize(tag_name, text, tokens)
13
+ super
14
+ args = text.strip.split
15
+ @actor = args[0]
16
+ @limit = args[1] || '10'
17
+ Jekyll.logger.debug "Initializing tag bluesky with actor: #{@actor}, limit: #{@limit}"
18
+ end
19
19
 
20
- def render(context)
21
- Jekyll.logger.debug 'Rendering bluesky tag...'
22
- fetch_posts
23
- end
20
+ def render(context)
21
+ Jekyll.logger.debug 'Rendering bluesky tag...'
22
+ fetch_posts
23
+ end
24
24
 
25
- private
25
+ private
26
26
 
27
- def fetch_posts
28
- cache_key = Digest::MD5.hexdigest("#{@actor}-#{@limit}")
29
- cached_response = cache.read(cache_key)
27
+ def fetch_posts
28
+ cache_key = Digest::MD5.hexdigest("#{@actor}-#{@limit}")
29
+ cached_response = cache.read(cache_key)
30
30
 
31
- if cached_response
32
- cached_response
33
- else
34
- response = Jekyll::Client.fetch_post(@actor, @limit) # Updated to use Jekyll::Client
35
- cache.write(cache_key, response)
36
- response
37
- end
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
38
37
  end
38
+ end
39
39
 
40
- def cache
41
- @cache ||= FileCache.new('./.bluesky-cache')
40
+ def cache
41
+ @cache ||= FileCache.new('./.bluesky-cache')
42
+ end
43
+ end
44
+
45
+ class Client
46
+ API_URL = 'https://public.api.bsky.app'
47
+
48
+ def self.fetch_post(actor, limit)
49
+ response = HTTP.get("#{API_URL}/xrpc/app.bsky.feed.getAuthorFeed?actor=#{actor}&limit=#{limit}&filter=posts_and_author_threads")
50
+ if response.status.success?
51
+ data = JSON.parse(response.body)
52
+ format_post(data)
53
+ else
54
+ error_details =
55
+ begin
56
+ JSON.parse(response.body)
57
+ rescue JSON::ParserError
58
+ response.body.to_s
59
+ end
60
+
61
+ "Error fetching post from Bluesky (status: #{response.status}). Details: #{error_details}"
42
62
  end
43
63
  end
44
64
 
45
- class Client
46
- API_URL = 'https://public.api.bsky.app'
47
-
48
- def self.fetch_post(actor, limit)
49
- response = HTTP.get("#{API_URL}/xrpc/app.bsky.feed.getAuthorFeed?actor=#{actor}&limit=#{limit}&filter=posts_and_author_threads")
50
- if response.status.success?
51
- data = JSON.parse(response.body)
52
- format_post(data)
53
- else
54
- error_details =
55
- begin
56
- JSON.parse(response.body)
57
- rescue JSON::ParserError
58
- response.body.to_s
59
- end
60
-
61
- "Error fetching post from Bluesky (status: #{response.status}). Details: #{error_details}"
65
+ def self.format_post(data)
66
+ posts = data['feed']
67
+ styles = <<~HTML
68
+ <style>
69
+ @font-face {
70
+ font-family: 'InterVariable';
71
+ src: url("https://web-cdn.bsky.app/static/media/InterVariable.c504db5c06caaf7cdfba.woff2") format('woff2');
72
+ font-weight: 300 1000;
73
+ font-style: normal;
74
+ font-display: swap;
75
+ }
76
+ .bluesky-post {
77
+ border-bottom: 1px solid #e1e8ed;
78
+ padding: 12px;
79
+ width: 500px;
80
+ font-family: 'InterVariable', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Liberation Sans', Helvetica, Arial, sans-serif;
81
+ background: #fff;
82
+ margin-bottom: 10px;
83
+ }
84
+ .bluesky-header {
85
+ display: flex;
86
+ align-items: center;
87
+ justify-content: flex-start; /* Alinha tudo à esquerda */
88
+ gap: 8px; /* Espaço entre a foto e o nome */
89
+ }
90
+ .bluesky-avatar {
91
+ width: 40px;
92
+ height: 40px;
93
+ border-radius: 50%;
94
+ }
95
+ .bluesky-author-info {
96
+ display: flex;
97
+ flex-direction: column;
98
+ align-items: flex-start; /* Alinha o texto à esquerda */
99
+ }
100
+ .author-name {
101
+ font-weight: bold;
102
+ font-size: 14px;
103
+ color: #000;
104
+ }
105
+ .author-handle {
106
+ font-size: 12px;
107
+ color: #657786;
108
+ }
109
+ .bluesky-content {
110
+ font-size: 14px;
111
+ line-height: 1.5;
112
+ color: #14171A;
113
+ margin-top: 8px; /* Espaço entre o cabeçalho e o conteúdo */
114
+ }
115
+ .bluesky-footer {
116
+ display: flex;
117
+ justify-content: space-between;
118
+ font-size: 12px;
119
+ color: #657786;
120
+ margin-top: 10px;
121
+ }
122
+ .icon {
123
+ cursor: pointer;
124
+ }
125
+ </style>
126
+ HTML
127
+
128
+ formatted_posts = posts.map do |post|
129
+ post_data = post['post']
130
+ author = post_data['author']
131
+ record = post_data['record']
132
+ embed = post_data['embed']
133
+
134
+ text = record['text'].gsub("\n", "<br>")
135
+ author_name = author['displayName']
136
+ author_handle = author['handle']
137
+ post_time = "3h"
138
+
139
+ image_html = ''
140
+ if embed && embed['$type'] == 'app.bsky.embed.images#view'
141
+ image_html = embed['images'].map do |image|
142
+ <<~HTML
143
+ <img src="#{image['thumb']}" alt="#{image['alt']}" class="bluesky-image" />
144
+ HTML
145
+ end.join
62
146
  end
63
- end
64
147
 
65
- def self.format_post(data)
66
- posts = data['feed']
67
- styles = <<~HTML
68
- <style>
69
- @font-face {
70
- font-family: 'InterVariable';
71
- src: url("https://web-cdn.bsky.app/static/media/InterVariable.c504db5c06caaf7cdfba.woff2") format('woff2');
72
- font-weight: 300 1000;
73
- font-style: normal;
74
- font-display: swap;
75
- }
76
- .bluesky-post {
77
- border-bottom: 1px solid #e1e8ed;
78
- padding: 12px;
79
- width: 500px;
80
- font-family: 'InterVariable', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Liberation Sans', Helvetica, Arial, sans-serif;
81
- background: #fff;
82
- margin-bottom: 10px;
83
- }
84
- .bluesky-header {
85
- display: flex;
86
- align-items: center;
87
- justify-content: flex-start; /* Alinha tudo à esquerda */
88
- gap: 8px; /* Espaço entre a foto e o nome */
89
- }
90
- .bluesky-avatar {
91
- width: 40px;
92
- height: 40px;
93
- border-radius: 50%;
94
- }
95
- .bluesky-author-info {
96
- display: flex;
97
- flex-direction: column;
98
- align-items: flex-start;
99
- }
100
- .author-name {
101
- font-weight: bold;
102
- font-size: 14px;
103
- color: #000;
104
- }
105
- .author-handle {
106
- font-size: 12px;
107
- color: #657786;
108
- }
109
- .bluesky-content {
110
- font-size: 14px;
111
- line-height: 1.5;
112
- color: #14171A;
113
- }
114
- .bluesky-footer {
115
- display: flex;
116
- justify-content: space-between;
117
- font-size: 12px;
118
- color: #657786;
119
- margin-top: 10px;
120
- }
121
- .icon {
122
- cursor: pointer;
123
- }
124
- </style>
125
- HTML
126
-
127
- formatted_posts = posts.map do |post|
128
- post_data = post['post']
129
- author = post_data['author']
130
- record = post_data['record']
131
- embed = post_data['embed']
132
-
133
- text = record['text'].gsub("\n", "<br>")
134
- author_name = author['displayName']
135
- author_handle = author['handle']
136
- post_time = "3h"
137
-
138
- image_html = ''
139
- if embed && embed['$type'] == 'app.bsky.embed.images#view'
140
- image_html = embed['images'].map do |image|
141
- <<~HTML
142
- <img src="#{image['thumb']}" alt="#{image['alt']}" class="bluesky-image" />
143
- HTML
144
- end.join
145
- end
146
-
147
- <<~HTML
148
- <div class="bluesky-post">
149
- <div class="bluesky-header">
150
- <img src="#{author['avatar']}" alt="#{author_name}" class="bluesky-avatar" />
151
- <div class="bluesky-author-info">
152
- <span class="author-name">#{author_name}</span>
153
- <span class="author-handle">@#{author_handle} · #{post_time}</span>
154
- </div>
155
- </div>
156
- <div class="bluesky-content">
157
- <p>#{text}</p>
158
- #{image_html}
159
- </div>
160
- <div class="bluesky-footer">
161
- <span class="icon">💬 #{post_data['replyCount']}</span>
162
- <span class="icon">🔁 #{post_data['repostCount']}</span>
163
- <span class="icon">❤️ #{post_data['likeCount']}</span>
164
- <span class="icon">···</span>
148
+ <<~HTML
149
+ <div class="bluesky-post">
150
+ <div class="bluesky-header">
151
+ <img src="#{author['avatar']}" alt="#{author_name}" class="bluesky-avatar" />
152
+ <div class="bluesky-author-info">
153
+ <span class="author-name">#{author_name}</span>
154
+ <span class="author-handle">@#{author_handle} · #{post_time}</span>
165
155
  </div>
166
156
  </div>
167
- HTML
168
- end.join("\n")
169
-
170
- styles + formatted_posts
171
- end
172
-
173
-
157
+ <div class="bluesky-content">
158
+ <p>#{text}</p>
159
+ #{image_html}
160
+ </div>
161
+ <div class="bluesky-footer">
162
+ <span class="icon">💬 #{post_data['replyCount']}</span>
163
+ <span class="icon">🔁 #{post_data['repostCount']}</span>
164
+ <span class="icon">❤️ #{post_data['likeCount']}</span>
165
+ <span class="icon">···</span>
166
+ </div>
167
+ </div>
168
+ HTML
169
+ end.join("\n")
170
+
171
+ styles + formatted_posts
174
172
  end
173
+ end
175
174
 
176
- class FileCache
177
- def initialize(path)
178
- @cache_folder = File.expand_path path
179
- FileUtils.mkdir_p @cache_folder
180
- end
175
+ class FileCache
176
+ def initialize(path)
177
+ @cache_folder = File.expand_path path
178
+ FileUtils.mkdir_p @cache_folder
179
+ end
181
180
 
182
- def read(key)
183
- file_to_read = cache_file(key)
184
- File.read(file_to_read) if File.exist?(file_to_read)
185
- end
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
186
185
 
187
- def write(key, data)
188
- file_to_write = cache_file(key)
189
- File.open(file_to_write, 'w') do |f|
190
- f.write(data)
191
- end
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)
192
190
  end
191
+ end
193
192
 
194
- private
193
+ private
195
194
 
196
- def cache_file(key)
197
- File.join(@cache_folder, "#{key}.cache")
198
- end
195
+ def cache_file(key)
196
+ File.join(@cache_folder, "#{key}.cache")
199
197
  end
200
198
  end
199
+ end
201
200
 
202
- # Register the Liquid tag
203
- Liquid::Template.register_tag 'bluesky', Jekyll::BlueskyPlugin
201
+ # Register the Liquid tag
202
+ 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.23.0
4
+ version: 0.24.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Felipe Dias