jekyll-bluesky 0.22.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: 5c0c904bf22d022fa8c1534aa89a813fb50e2fa15bce61583e015d1aecc4d797
4
- data.tar.gz: 2e80fa2c3f94cd06419708deb4b13506c9a2e3990a0a793552ad3b062909bc75
3
+ metadata.gz: 36127678aab70a5994f67edf276638fa425b28f1d8ca42638b6cd5a446a42383
4
+ data.tar.gz: b2c6833719a852784bcd214d45f3f876b5bb173f8714bb86e78022d7ab3ded4b
5
5
  SHA512:
6
- metadata.gz: '00978981068ff8b1ded3b8c0dd4246ba6280a0da28326d1a1ea93ea703eb024eee389e9c9c127d1e56f146292db79e690215b972de477169d7cbf132f09eb5aa'
7
- data.tar.gz: ca6d073174eb9e8fc26acc2ba46e9bc6a6be95e2e16ba830d85ba99a5b7212059c57c2e4463c8e5f880875a5fe48dabccd69b6221be702dff0b492c462564075
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.22.0'
4
+ VERSION = '0.24.0'
5
5
  end
6
6
  end
@@ -1,202 +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
- }
99
- .author-name {
100
- font-weight: bold;
101
- font-size: 14px;
102
- color: #000;
103
- }
104
- .author-handle {
105
- font-size: 12px;
106
- color: #657786;
107
- }
108
- .bluesky-content {
109
- font-size: 14px;
110
- line-height: 1.5;
111
- color: #14171A;
112
- }
113
- .bluesky-footer {
114
- display: flex;
115
- justify-content: space-between;
116
- font-size: 12px;
117
- color: #657786;
118
- margin-top: 10px;
119
- }
120
- .icon {
121
- cursor: pointer;
122
- }
123
- </style>
124
- HTML
125
-
126
- formatted_posts = posts.map do |post|
127
- post_data = post['post']
128
- author = post_data['author']
129
- record = post_data['record']
130
- embed = post_data['embed']
131
-
132
- text = record['text'].gsub("\n", "<br>")
133
- author_name = author['displayName']
134
- author_handle = author['handle']
135
- post_time = "3h"
136
-
137
- image_html = ''
138
- if embed && embed['$type'] == 'app.bsky.embed.images#view'
139
- image_html = embed['images'].map do |image|
140
- <<~HTML
141
- <img src="#{image['thumb']}" alt="#{image['alt']}" class="bluesky-image" />
142
- HTML
143
- end.join
144
- end
145
-
146
- <<~HTML
147
- <div class="bluesky-post">
148
- <div class="bluesky-header">
149
- <img src="#{author['avatar']}" alt="#{author_name}" class="bluesky-avatar" />
150
- <div class="bluesky-author-info">
151
- <span class="author-name">#{author_name}</span>
152
- <span class="author-handle">@#{author_handle} · #{post_time}</span>
153
- </div>
154
- </div>
155
- <div class="bluesky-content">
156
- <p>#{text}</p>
157
- #{image_html}
158
- </div>
159
- <div class="bluesky-footer">
160
- <span class="icon">💬 #{post_data['replyCount']}</span>
161
- <span class="icon">🔁 #{post_data['repostCount']}</span>
162
- <span class="icon">❤️ #{post_data['likeCount']}</span>
163
- <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>
164
155
  </div>
165
156
  </div>
166
- HTML
167
- end.join("\n")
168
-
169
- styles + formatted_posts
170
- end
171
-
172
-
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
173
172
  end
173
+ end
174
174
 
175
- class FileCache
176
- def initialize(path)
177
- @cache_folder = File.expand_path path
178
- FileUtils.mkdir_p @cache_folder
179
- end
175
+ class FileCache
176
+ def initialize(path)
177
+ @cache_folder = File.expand_path path
178
+ FileUtils.mkdir_p @cache_folder
179
+ end
180
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
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
185
 
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)
190
- 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)
191
190
  end
191
+ end
192
192
 
193
- private
193
+ private
194
194
 
195
- def cache_file(key)
196
- File.join(@cache_folder, "#{key}.cache")
197
- end
195
+ def cache_file(key)
196
+ File.join(@cache_folder, "#{key}.cache")
198
197
  end
199
198
  end
199
+ end
200
200
 
201
- # Register the Liquid tag
202
- 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.22.0
4
+ version: 0.24.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Felipe Dias