jekyll-bluesky 0.11.0 → 0.13.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 +54 -54
- 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: 766122e4d9df5ca668fa193a04e54355e6d0aae721d6696bf4975bbec1666ef1
|
4
|
+
data.tar.gz: 29013b1a83a67e1597381dc59551ff6c2707fba428658875db7c1c3431903e05
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 394df28c94e6af6c58c19a77d99f3c6921f037686a8121611ff84fdffda7a6ea176e93c8cb2854091b7db90ad0169599df2c29dd369476f7f765681987610223
|
7
|
+
data.tar.gz: 84d4f4ca1f2e5dcbf982b7ad54eb08da1210f2b9b7d8e84222254a35ea5dcdea557ab9e5cc7c6dda5142783151a9bad4112045042062aae90c3ca0af4bf8b459
|
data/lib/jekyll-bluesky.rb
CHANGED
@@ -5,7 +5,7 @@ require "json"
|
|
5
5
|
require "digest"
|
6
6
|
require "fileutils" # Needed for FileCache
|
7
7
|
|
8
|
-
puts "Plugin jekyll-bluesky load
|
8
|
+
puts "Plugin jekyll-bluesky load successfully!"
|
9
9
|
|
10
10
|
module Jekyll
|
11
11
|
class BlueskyPlugin < Liquid::Tag
|
@@ -32,7 +32,7 @@ module Jekyll
|
|
32
32
|
if cached_response
|
33
33
|
cached_response
|
34
34
|
else
|
35
|
-
response =
|
35
|
+
response = Jekyll::Client.fetch_post(@actor, @limit) # Fix: Use Jekyll::Client
|
36
36
|
cache.write(cache_key, response)
|
37
37
|
response
|
38
38
|
end
|
@@ -43,62 +43,61 @@ module Jekyll
|
|
43
43
|
end
|
44
44
|
end
|
45
45
|
|
46
|
-
|
47
|
-
|
46
|
+
class Client
|
47
|
+
API_URL = "https://public.api.bsky.app"
|
48
48
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
end
|
49
|
+
def self.fetch_post(actor, limit)
|
50
|
+
response = HTTP.get("#{API_URL}/xrpc/app.bsky.feed.getAuthorFeed?actor=#{actor}&limit=#{limit}&filter=posts_and_author_threads")
|
51
|
+
if response.status.success?
|
52
|
+
data = JSON.parse(response.body)
|
53
|
+
format_post(data)
|
54
|
+
else
|
55
|
+
"Error fetching post from Bluesky."
|
57
56
|
end
|
57
|
+
end
|
58
58
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
</div>
|
88
|
-
</div>
|
89
|
-
<div class="bluesky-content">
|
90
|
-
<p>#{text}</p>
|
91
|
-
#{image_html}
|
92
|
-
</div>
|
93
|
-
<div class="bluesky-stats">
|
94
|
-
<span>❤️ #{post_data["likeCount"]}</span>
|
95
|
-
<span>🔁 #{post_data["repostCount"]}</span>
|
96
|
-
<span>💬 #{post_data["replyCount"]}</span>
|
59
|
+
def self.format_post(data)
|
60
|
+
posts = data["feed"]
|
61
|
+
posts.map do |post|
|
62
|
+
post_data = post["post"]
|
63
|
+
author = post_data["author"]
|
64
|
+
record = post_data["record"]
|
65
|
+
embed = post_data["embed"]
|
66
|
+
|
67
|
+
text = record["text"]
|
68
|
+
author_name = author["displayName"]
|
69
|
+
author_handle = author["handle"]
|
70
|
+
|
71
|
+
image_html = ""
|
72
|
+
if embed && embed["$type"] == "app.bsky.embed.images#view"
|
73
|
+
image_html = embed["images"].map do |image|
|
74
|
+
<<~HTML
|
75
|
+
<img src="#{image['thumb']}" alt="#{image['alt']}" class="bluesky-image" />
|
76
|
+
HTML
|
77
|
+
end.join
|
78
|
+
end
|
79
|
+
|
80
|
+
<<~HTML
|
81
|
+
<div class="bluesky-post">
|
82
|
+
<div class="bluesky-author">
|
83
|
+
<img src="#{author['avatar']}" alt="#{author_name}" class="bluesky-avatar" />
|
84
|
+
<div class="bluesky-author-info">
|
85
|
+
<strong>#{author_name}</strong>
|
86
|
+
<small>@#{author_handle}</small>
|
97
87
|
</div>
|
98
88
|
</div>
|
99
|
-
|
100
|
-
|
101
|
-
|
89
|
+
<div class="bluesky-content">
|
90
|
+
<p>#{text}</p>
|
91
|
+
#{image_html}
|
92
|
+
</div>
|
93
|
+
<div class="bluesky-stats">
|
94
|
+
<span>❤️ #{post_data["likeCount"]}</span>
|
95
|
+
<span>🔁 #{post_data["repostCount"]}</span>
|
96
|
+
<span>💬 #{post_data["replyCount"]}</span>
|
97
|
+
</div>
|
98
|
+
</div>
|
99
|
+
HTML
|
100
|
+
end.join("\n")
|
102
101
|
end
|
103
102
|
end
|
104
103
|
|
@@ -128,4 +127,5 @@ module Jekyll
|
|
128
127
|
end
|
129
128
|
end
|
130
129
|
|
131
|
-
Liquid
|
130
|
+
# Register the Liquid tag
|
131
|
+
Liquid::Template.register_tag "bluesky", Jekyll::BlueskyPlugin
|