jekyll-activity-pub 0.3.0rc3 → 0.3.0rc5
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/activity_pub/activity.rb +6 -2
- data/lib/jekyll/activity_pub/helper.rb +12 -0
- data/lib/jekyll/activity_pub/notifier.rb +25 -0
- data/lib/jekyll/drops/activity_drop.rb +121 -0
- metadata +19 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d82abfcc625ec48dc8647caa1284c7919f38dd8c4df24268370aa993038d84ff
|
4
|
+
data.tar.gz: 784c93b7f2e39a906e205283348011c4f68f76df61cc11b89c993e91db14e70a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bb0a379148fbf8d2ba1362500401704de600f8188096ffbcab3dde1f2f3ea90dcef8a9461fa9de1a4d06aa041d984c871ee9f048833bbb4cec5ef403fe31aecd
|
7
|
+
data.tar.gz: df7641018f1972a00ed5c2b9105f17cb22ec95bca9d2cb804352c58c0b7d5b97144a0cbcce895345af4f7ee5e5b271b997d6aba05e4a95b3728ed7d30d28904c
|
@@ -42,6 +42,8 @@ module Jekyll
|
|
42
42
|
def read_yaml(*)
|
43
43
|
doc_content = doc.content.tr("\n", '').gsub(WHITE_SPACE, '><')
|
44
44
|
|
45
|
+
id = absolute_url(url)
|
46
|
+
|
45
47
|
self.data = {
|
46
48
|
'@context' => [
|
47
49
|
'https://www.w3.org/ns/activitystreams',
|
@@ -51,7 +53,7 @@ module Jekyll
|
|
51
53
|
}
|
52
54
|
],
|
53
55
|
'type' => 'Note',
|
54
|
-
'id' =>
|
56
|
+
'id' => id,
|
55
57
|
'url' => absolute_url(doc.url),
|
56
58
|
'summary' => summary,
|
57
59
|
'published' => (doc.data['created_at'] || doc.date).xmlschema,
|
@@ -70,7 +72,9 @@ module Jekyll
|
|
70
72
|
},
|
71
73
|
'attachment' => attachments,
|
72
74
|
'tag' => [],
|
73
|
-
'replies' => Notifier.client.absolute_url(Notifier.replies(
|
75
|
+
'replies' => Notifier.client.absolute_url(Notifier.replies(id).endpoint),
|
76
|
+
'shares' => Notifier.client.absolute_url(Notifier.shares(id).endpoint),
|
77
|
+
'likes' => Notifier.client.absolute_url(Notifier.likes(id).endpoint)
|
74
78
|
}
|
75
79
|
|
76
80
|
nil
|
@@ -16,6 +16,18 @@ module Jekyll
|
|
16
16
|
# Some filters needs a Liquid-like context
|
17
17
|
StubContext = Struct.new(:registers, keyword_init: true)
|
18
18
|
|
19
|
+
# Convert into a dereferentiable object
|
20
|
+
#
|
21
|
+
# @return [Jekyll::Drops::ActivityDrop]
|
22
|
+
def to_liquid
|
23
|
+
@to_liquid ||=
|
24
|
+
begin
|
25
|
+
require 'jekyll/drops/activity_drop'
|
26
|
+
|
27
|
+
Jekyll::Drops::ActivityDrop.new(self)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
19
31
|
# Removes empty values from data
|
20
32
|
#
|
21
33
|
# @return [Hash]
|
@@ -7,6 +7,9 @@ require 'distributed_press/v1/social/client'
|
|
7
7
|
require 'distributed_press/v1/social/inbox'
|
8
8
|
require 'distributed_press/v1/social/outbox'
|
9
9
|
require 'distributed_press/v1/social/replies'
|
10
|
+
require 'distributed_press/v1/social/shares'
|
11
|
+
require 'distributed_press/v1/social/likes'
|
12
|
+
require 'distributed_press/v1/social/dereferencer'
|
10
13
|
require_relative 'errors'
|
11
14
|
require_relative 'create'
|
12
15
|
require_relative 'update'
|
@@ -56,6 +59,10 @@ module Jekyll
|
|
56
59
|
@@site
|
57
60
|
end
|
58
61
|
|
62
|
+
def dereferencer
|
63
|
+
@@dereferencer ||= DistributedPress::V1::Social::Dereferencer.new(client: client)
|
64
|
+
end
|
65
|
+
|
59
66
|
# Announce the website?
|
60
67
|
def announce?
|
61
68
|
!!config['announce']
|
@@ -304,6 +311,24 @@ module Jekyll
|
|
304
311
|
@@replies[activity] ||= DistributedPress::V1::Social::Replies.new(client: client, actor: actor, activity: activity)
|
305
312
|
end
|
306
313
|
|
314
|
+
# Generates a Likes client per activity
|
315
|
+
#
|
316
|
+
# @param activity [String] Activity ID
|
317
|
+
# @return [DistributedPress::V1::Social::Likes]
|
318
|
+
def likes(activity)
|
319
|
+
@@likes ||= {}
|
320
|
+
@@likes[activity] ||= DistributedPress::V1::Social::Likes.new(client: client, actor: actor, activity: activity)
|
321
|
+
end
|
322
|
+
|
323
|
+
# Generates a Shares client per activity
|
324
|
+
#
|
325
|
+
# @param activity [String] Activity ID
|
326
|
+
# @return [DistributedPress::V1::Social::Shares]
|
327
|
+
def shares(activity)
|
328
|
+
@@shares ||= {}
|
329
|
+
@@shares[activity] ||= DistributedPress::V1::Social::Shares.new(client: client, actor: actor, activity: activity)
|
330
|
+
end
|
331
|
+
|
307
332
|
private
|
308
333
|
|
309
334
|
# Finds the private key path on config
|
@@ -0,0 +1,121 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'distributed_press/v1/social/referenced_object'
|
4
|
+
require 'jekyll/activity_pub/notifier'
|
5
|
+
|
6
|
+
class DistributedPress
|
7
|
+
module V1
|
8
|
+
module Social
|
9
|
+
module Liquid
|
10
|
+
def to_liquid
|
11
|
+
@to_liquid ||=
|
12
|
+
begin
|
13
|
+
if object.success?
|
14
|
+
Jekyll::Drops::ActivityDrop.new(object: object.parsed_response)
|
15
|
+
else
|
16
|
+
Jekyll.logger.warn 'ActivityPub:', "Couldn't download #{object.request.uri} (Status: #{object.code})"
|
17
|
+
{}
|
18
|
+
end
|
19
|
+
rescue Exception => e
|
20
|
+
Jekyll.logger.warn 'ActivityPub:', "Couldn't download (Error: #{e.message})"
|
21
|
+
{}
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def to_h
|
26
|
+
if object.success?
|
27
|
+
object.parsed_response.to_json
|
28
|
+
else
|
29
|
+
Jekyll.logger.warn 'ActivityPub:', "Couldn't download #{object.request.uri} (Status: #{object.code})"
|
30
|
+
|
31
|
+
{}
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def to_s
|
36
|
+
to_json
|
37
|
+
end
|
38
|
+
|
39
|
+
def to_json
|
40
|
+
if object.success?
|
41
|
+
object.parsed_response.to_json
|
42
|
+
else
|
43
|
+
Jekyll.logger.warn 'ActivityPub:', "Couldn't download #{object.request.uri} (Status: #{object.code})"
|
44
|
+
|
45
|
+
object.request.uri
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
DistributedPress::V1::Social::Reference.include DistributedPress::V1::Social::Liquid
|
54
|
+
|
55
|
+
module Jekyll
|
56
|
+
module Drops
|
57
|
+
# Converts an activity into a liquid drop that can be dereferenced on
|
58
|
+
# demand.
|
59
|
+
class ActivityDrop < Drop
|
60
|
+
extend Forwardable
|
61
|
+
|
62
|
+
mutable false
|
63
|
+
|
64
|
+
# Iterate over all items of a collection
|
65
|
+
#
|
66
|
+
# @return [Array]
|
67
|
+
def all_items
|
68
|
+
return nil unless @obj.respond_to?(:each)
|
69
|
+
|
70
|
+
@all_items ||= @obj.each.to_a
|
71
|
+
end
|
72
|
+
|
73
|
+
# This means we could dereference the object, Liquid can use it to
|
74
|
+
# check if it's possible to use it.
|
75
|
+
def available
|
76
|
+
true
|
77
|
+
end
|
78
|
+
|
79
|
+
# @todo Still no idea why Liquid/Jekyll initialize this with
|
80
|
+
# different objects
|
81
|
+
def initialize(obj)
|
82
|
+
id =
|
83
|
+
case obj
|
84
|
+
when Jekyll::Page
|
85
|
+
obj['id'] || obj.url
|
86
|
+
when DistributedPress::V1::Social::ReferencedObject
|
87
|
+
obj['id']
|
88
|
+
when Hash
|
89
|
+
obj[:object]['id']
|
90
|
+
end
|
91
|
+
|
92
|
+
raise StandardError unless id
|
93
|
+
|
94
|
+
Jekyll.logger.info 'ActivityPub:', "Referencing #{id}"
|
95
|
+
|
96
|
+
@original_obj = obj
|
97
|
+
@@objects ||= {}
|
98
|
+
@obj = @@objects[id] ||=
|
99
|
+
case obj
|
100
|
+
when Jekyll::Page
|
101
|
+
DistributedPress::V1::Social::ReferencedObject.new(object: JSON.parse(obj.to_json), dereferencer: Jekyll::ActivityPub::Notifier.dereferencer)
|
102
|
+
when DistributedPress::V1::Social::ReferencedObject
|
103
|
+
obj
|
104
|
+
when Hash
|
105
|
+
obj[:object]
|
106
|
+
else raise StandardError
|
107
|
+
end
|
108
|
+
rescue StandardError => e
|
109
|
+
Jekyll.logger.warn 'ActivityPub:', "Error"
|
110
|
+
end
|
111
|
+
|
112
|
+
def to_s
|
113
|
+
@obj.object.to_json
|
114
|
+
end
|
115
|
+
|
116
|
+
def fallback_data
|
117
|
+
@obj
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jekyll-activity-pub
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.0rc5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sutty
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-07-
|
11
|
+
date: 2024-07-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: distributed-press-api-client
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 0.5.
|
19
|
+
version: 0.5.0rc10
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 0.5.
|
26
|
+
version: 0.5.0rc10
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: jekyll
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -128,6 +128,20 @@ dependencies:
|
|
128
128
|
- - ">="
|
129
129
|
- !ruby/object:Gem::Version
|
130
130
|
version: '0'
|
131
|
+
- !ruby/object:Gem::Dependency
|
132
|
+
name: sutty-liquid
|
133
|
+
requirement: !ruby/object:Gem::Requirement
|
134
|
+
requirements:
|
135
|
+
- - ">="
|
136
|
+
- !ruby/object:Gem::Version
|
137
|
+
version: '0'
|
138
|
+
type: :development
|
139
|
+
prerelease: false
|
140
|
+
version_requirements: !ruby/object:Gem::Requirement
|
141
|
+
requirements:
|
142
|
+
- - ">="
|
143
|
+
- !ruby/object:Gem::Version
|
144
|
+
version: '0'
|
131
145
|
description:
|
132
146
|
email:
|
133
147
|
- sutty@riseup.net
|
@@ -178,6 +192,7 @@ files:
|
|
178
192
|
- lib/jekyll/command_extension.rb
|
179
193
|
- lib/jekyll/commands/generate_keys.rb
|
180
194
|
- lib/jekyll/commands/notify.rb
|
195
|
+
- lib/jekyll/drops/activity_drop.rb
|
181
196
|
homepage: https://jekyll-activity-pub.sutty.nl/
|
182
197
|
licenses:
|
183
198
|
- Apache-2.0
|