jekyll-activity-pub 0.1.0rc10 → 0.1.0rc11
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:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 90ded40202c7b760dd22940f62dbb6c4293f79a6237262c265e80941bea76211
|
4
|
+
data.tar.gz: 3e87a0579232734f96f03d80e7ef3724daaf93a1b522a5510abd945db1d0395c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9aad7577ce38dff2e5f918b2cb81fe66b54eed700bcd56222e3bc0711536253f42fb22320d106cc30ccd3862d9db8734c7fb4697551bfb31f98b9c9ea212d87c
|
7
|
+
data.tar.gz: 3932de011836a2bb34fb9d7994be7158faad4d4fbfe5a43b5606d2be3ef9769793ae363e6c9a68c508c15b044b746522db1cca191103dfaf022800431d2d7138
|
@@ -49,6 +49,7 @@ module Jekyll
|
|
49
49
|
'id' => absolute_url(doc.url),
|
50
50
|
'summary' => summary,
|
51
51
|
'published' => (doc.data['created_at'] || doc.date).xmlschema,
|
52
|
+
'updated' => doc.data['last_modified_at']&.xmlschema,
|
52
53
|
'attributedTo' => absolute_url(actor.url),
|
53
54
|
'to' => [
|
54
55
|
'https://www.w3.org/ns/activitystreams#Public'
|
@@ -9,6 +9,9 @@ module Jekyll
|
|
9
9
|
class Create < Jekyll::Page
|
10
10
|
include Helper
|
11
11
|
|
12
|
+
# Where is the date stored
|
13
|
+
DATE_ATTRIBUTE = 'published'
|
14
|
+
|
12
15
|
# @param :object [Jekyll::ActivityPub::Activity]
|
13
16
|
attr_reader :object
|
14
17
|
|
@@ -26,10 +29,11 @@ module Jekyll
|
|
26
29
|
@actor = actor
|
27
30
|
|
28
31
|
dest = Pathname.new(object.destination(site.dest)).relative_path_from(site.dest)
|
29
|
-
name = "#{
|
32
|
+
name = "#{date.to_i}.jsonld"
|
30
33
|
dir = File.join(
|
31
34
|
File.dirname(dest),
|
32
|
-
File.basename(dest, '.jsonld')
|
35
|
+
File.basename(dest, '.jsonld'),
|
36
|
+
type.downcase
|
33
37
|
)
|
34
38
|
|
35
39
|
super(site, '', dir, name)
|
@@ -43,7 +47,7 @@ module Jekyll
|
|
43
47
|
'type' => type,
|
44
48
|
'id' => absolute_url(url),
|
45
49
|
'actor' => absolute_url(actor.url),
|
46
|
-
'published' => object.data[
|
50
|
+
'published' => object.data[DATE_ATTRIBUTE],
|
47
51
|
'to' => object.data['to'],
|
48
52
|
'cc' => object.data['cc'],
|
49
53
|
'object' => absolute_url(object.url),
|
@@ -51,6 +55,11 @@ module Jekyll
|
|
51
55
|
}
|
52
56
|
end
|
53
57
|
|
58
|
+
# @return [Time]
|
59
|
+
def date
|
60
|
+
@date ||= Time.parse(object.data[DATE_ATTRIBUTE])
|
61
|
+
end
|
62
|
+
|
54
63
|
private
|
55
64
|
|
56
65
|
def type
|
@@ -21,6 +21,13 @@ module Jekyll
|
|
21
21
|
def destination(_)
|
22
22
|
site.in_dest_dir(relative_path)
|
23
23
|
end
|
24
|
+
|
25
|
+
# @return [Time, nil]
|
26
|
+
def updated_at
|
27
|
+
@updated_at ||= Time.parse(data['updated'])
|
28
|
+
rescue StandardError
|
29
|
+
nil
|
30
|
+
end
|
24
31
|
end
|
25
32
|
|
26
33
|
class << self
|
@@ -120,10 +127,7 @@ module Jekyll
|
|
120
127
|
data['notifications'].reject do |object_url, _|
|
121
128
|
done? object_url
|
122
129
|
end.each do |object_url, status|
|
123
|
-
|
124
|
-
data = JSON.parse(File.read(path)) if File.exist? path
|
125
|
-
object = PseudoObject.new(url: object_url, site: site, relative_path: object_url, data: data || {})
|
126
|
-
process_object(outbox_endpoint, actor_object, object, status)
|
130
|
+
process_object(outbox_endpoint, actor_object, object_for(object_url), status)
|
127
131
|
end
|
128
132
|
|
129
133
|
# Store everything for later
|
@@ -151,12 +155,13 @@ module Jekyll
|
|
151
155
|
end
|
152
156
|
|
153
157
|
# Updates an activity if it was previously created, otherwise
|
154
|
-
# create it
|
158
|
+
# create it, or update it again if it was modified later
|
155
159
|
#
|
156
160
|
# @param :path [String]
|
157
161
|
# @return [nil]
|
158
162
|
def update(path)
|
159
|
-
|
163
|
+
# Compare Unix timestamps
|
164
|
+
if created?(path) && (object_for(path)&.updated_at&.to_i || 0) > (status(path)['updated_at'] || 0)
|
160
165
|
action(path, 'update')
|
161
166
|
else
|
162
167
|
create(path)
|
@@ -329,6 +334,18 @@ module Jekyll
|
|
329
334
|
rescue NameError
|
330
335
|
Jekyll.logger.warn 'ActivityPub:', "Action \"#{action}\" for #{object.url} unrecognized, ignoring."
|
331
336
|
end
|
337
|
+
|
338
|
+
def object_for(path)
|
339
|
+
@@object_for ||= {}
|
340
|
+
@@object_for[path_relative_to_dest(path)] ||=
|
341
|
+
begin
|
342
|
+
rel = path_relative_to_dest(path)
|
343
|
+
path = site.in_dest_dir(rel)
|
344
|
+
data = JSON.parse(File.read(path)) if File.exist? path
|
345
|
+
|
346
|
+
PseudoObject.new(url: rel, site: site, relative_path: rel, data: data || {})
|
347
|
+
end
|
348
|
+
end
|
332
349
|
end
|
333
350
|
end
|
334
351
|
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.1.
|
4
|
+
version: 0.1.0rc11
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sutty
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-09-
|
11
|
+
date: 2023-09-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: distributed-press-api-client
|