jekyll-activity-pub 0.3.0rc3 → 0.3.0rc4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/jekyll/activity_pub/helper.rb +12 -0
- data/lib/jekyll/activity_pub/notifier.rb +5 -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: bb938546e87448c714988213943b785dc80e45f8732f1467a5194d9062676155
|
4
|
+
data.tar.gz: b3bcd5a07570d8d631c80fd1572e129f7b74d907016be00f81befb48be04beab
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3a6ab712cf1a359bcb43a2f122b8b773899adcf63a937e4493d1e8f71d2dae11da8f0bce678f50effde0a75a363de49adc530c643605335094818fa39de04627
|
7
|
+
data.tar.gz: 1d53716211728821b983f3bcc0fb6eb2a2722a310aba0cbb52aeb76225729977ab4e22cbc5558b8e3e8b4185d4bba49a1466a4b35b8d4d8fcdf3cf70e02fc413
|
@@ -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,7 @@ 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/dereferencer'
|
10
11
|
require_relative 'errors'
|
11
12
|
require_relative 'create'
|
12
13
|
require_relative 'update'
|
@@ -56,6 +57,10 @@ module Jekyll
|
|
56
57
|
@@site
|
57
58
|
end
|
58
59
|
|
60
|
+
def dereferencer
|
61
|
+
@@dereferencer ||= DistributedPress::V1::Social::Dereferencer.new(client: client)
|
62
|
+
end
|
63
|
+
|
59
64
|
# Announce the website?
|
60
65
|
def announce?
|
61
66
|
!!config['announce']
|
@@ -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.0rc4
|
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-24 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.0rc8
|
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.0rc8
|
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
|