jekyll-bluesky 0.18.0 → 0.19.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: 6219088df98f489f5c7e8b8132c917e132d253db30a3444cef295559612c7328
4
- data.tar.gz: 8b5bd0081a8aa13960460bad495236ba24dcf71bd8950a4cc1d00702f9a3dca6
3
+ metadata.gz: 3c5b3f484918d660520da321ca09b220497ced696841a9e0cafe216f22725047
4
+ data.tar.gz: faf7bb2fbd96b20fbba64ee28addccc2f0cc35683098e44931901ed2ff85ee65
5
5
  SHA512:
6
- metadata.gz: 8c614a1a78d19919256521dd7c016bd114d25565ffb3fac3b7c0c139df48fd8b574b1e2b05b7f856cb69b224356a9cae91797715b2c780dfe6042d638992814a
7
- data.tar.gz: d193bfab19c7b2e8640a6a051742b912dac74495d6cbc16c61acd3a7b9a2b27157bac056f3c3f9b108cddccad0afc473f6f732506744e4139fbb93abbf2695eb
6
+ metadata.gz: 83310e7a345a7b0204048ce5a368822bc3b2f682215e8307af46207b018f7883a8ae8d5b1ce2207aebdba4527ca9acb26e63e07d0855923a6fa9d8600477a57d
7
+ data.tar.gz: a3e76e9f49623d7d452637e0d356095b4568313a532b48eb028c21cf317820196605ee02ff2a198ad3964ee4e10c5a8794a4979a954e933e0a8390996992f3af
@@ -1,6 +1,6 @@
1
1
  # lib/jekyll-bluesky/version.rb
2
2
  module Jekyll
3
3
  module Bluesky
4
- VERSION = '0.18.0'
4
+ VERSION = '0.19.0'
5
5
  end
6
6
  end
@@ -1,137 +1,140 @@
1
- # lib/jekyll_bluesky.rb
2
- require 'jekyll'
3
- require 'http'
4
- require 'json'
5
- require 'digest'
6
- require 'fileutils' # Needed for FileCache
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' # Needed for FileCache
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
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
37
38
  end
38
- end
39
39
 
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}"
40
+ def cache
41
+ @cache ||= FileCache.new('./.bluesky-cache')
62
42
  end
63
43
  end
64
44
 
65
- def self.format_post(data)
66
- posts = data['feed']
67
- posts.map do |post|
68
- post_data = post['post']
69
- author = post_data['author']
70
- record = post_data['record']
71
- embed = post_data['embed']
72
-
73
- text = record['text']
74
- author_name = author['displayName']
75
- author_handle = author['handle']
76
-
77
- image_html = ''
78
- if embed && embed['$type'] == 'app.bsky.embed.images#view'
79
- image_html = embed['images'].map do |image|
80
- <<~HTML
81
- <img src="#{image['thumb']}" alt="#{image['alt']}" class="bluesky-image" />
82
- HTML
83
- end.join
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}"
84
62
  end
63
+ end
85
64
 
86
- <<~HTML
87
- <div class="bluesky-post">
88
- <div class="bluesky-author">
89
- <img src="#{author['avatar']}" alt="#{author_name}" class="bluesky-avatar" />
90
- <div class="bluesky-author-info">
91
- <strong>#{author_name}</strong>
92
- <small>@#{author_handle}</small>
65
+ def self.format_post(data)
66
+ posts = data['feed']
67
+ posts.map do |post|
68
+ post_data = post['post']
69
+ author = post_data['author']
70
+ record = post_data['record']
71
+ embed = post_data['embed']
72
+
73
+ text = record['text'].gsub("\n", "<br>")
74
+ author_name = author['displayName']
75
+ author_handle = author['handle']
76
+ post_time = "3h" # Estático por enquanto
77
+
78
+ image_html = ''
79
+ if embed && embed['$type'] == 'app.bsky.embed.images#view'
80
+ image_html = embed['images'].map do |image|
81
+ <<~HTML
82
+ <img src="#{image['thumb']}" alt="#{image['alt']}" class="bluesky-image" />
83
+ HTML
84
+ end.join
85
+ end
86
+
87
+ <<~HTML
88
+ <div class="bluesky-post">
89
+ <div class="bluesky-header">
90
+ <img src="#{author['avatar']}" alt="#{author_name}" class="bluesky-avatar" />
91
+ <div class="bluesky-author-info">
92
+ <span class="author-name">#{author_name}</span>
93
+ <span class="author-handle">@#{author_handle} · #{post_time}</span>
94
+ </div>
95
+ </div>
96
+ <div class="bluesky-content">
97
+ <p>#{text}</p>
98
+ #{image_html}
99
+ </div>
100
+ <div class="bluesky-footer">
101
+ <span class="icon">💬 #{post_data['replyCount']}</span>
102
+ <span class="icon">🔁 #{post_data['repostCount']}</span>
103
+ <span class="icon">❤️ #{post_data['likeCount']}</span>
104
+ <span class="icon">···</span>
93
105
  </div>
94
106
  </div>
95
- <div class="bluesky-content">
96
- <p>#{text}</p>
97
- #{image_html}
98
- </div>
99
- <div class="bluesky-stats">
100
- <span>❤️ #{post_data['likeCount']}</span>
101
- <span>🔁 #{post_data['repostCount']}</span>
102
- <span>💬 #{post_data['replyCount']}</span>
103
- </div>
104
- </div>
105
- HTML
106
- end.join("\n")
107
+ HTML
108
+ end.join("\n")
109
+ end
110
+
107
111
  end
108
- end
109
112
 
110
- class FileCache
111
- def initialize(path)
112
- @cache_folder = File.expand_path path
113
- FileUtils.mkdir_p @cache_folder
114
- end
113
+ class FileCache
114
+ def initialize(path)
115
+ @cache_folder = File.expand_path path
116
+ FileUtils.mkdir_p @cache_folder
117
+ end
115
118
 
116
- def read(key)
117
- file_to_read = cache_file(key)
118
- File.read(file_to_read) if File.exist?(file_to_read)
119
- end
119
+ def read(key)
120
+ file_to_read = cache_file(key)
121
+ File.read(file_to_read) if File.exist?(file_to_read)
122
+ end
120
123
 
121
- def write(key, data)
122
- file_to_write = cache_file(key)
123
- File.open(file_to_write, 'w') do |f|
124
- f.write(data)
124
+ def write(key, data)
125
+ file_to_write = cache_file(key)
126
+ File.open(file_to_write, 'w') do |f|
127
+ f.write(data)
128
+ end
125
129
  end
126
- end
127
130
 
128
- private
131
+ private
129
132
 
130
- def cache_file(key)
131
- File.join(@cache_folder, "#{key}.cache")
133
+ def cache_file(key)
134
+ File.join(@cache_folder, "#{key}.cache")
135
+ end
132
136
  end
133
137
  end
134
- end
135
138
 
136
- # Register the Liquid tag
137
- Liquid::Template.register_tag 'bluesky', Jekyll::BlueskyPlugin
139
+ # Register the Liquid tag
140
+ 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.18.0
4
+ version: 0.19.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Felipe Dias