jekyll-activity-pub 0.2.5 → 0.2.6
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-fep-1042.rb +30 -13
- 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: 9b0dd7df568e8344f4d9c0c3e41cfe2cf3a2384737800d0c3b3b5120f447ed63
|
4
|
+
data.tar.gz: 8974b30de62eda46a8aa375a04f4a037ce81741f8a99181003823726c1076f10
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dd1358be16b0324bd309e13c8c98d69166a3991025139f0929e2103ab63d2a914287a3bccec89c85ff3eb556932c63dd4150b68ee259114095f3a4f01477f949
|
7
|
+
data.tar.gz: 79a769c926dbf3dc4f6371da235e9d2b06dde561f80ececcb8ce54789e343603f04d7d9e3f852c8a219e9694af1b730eab3a5d22c8b66e6a02f5112b799394db
|
@@ -16,6 +16,19 @@ Jekyll::Hooks.register %i[actor activity], :post_init, priority: 8 do |page|
|
|
16
16
|
|
17
17
|
site = page.site
|
18
18
|
|
19
|
+
# @param uri [URI,Addressable::URI]
|
20
|
+
# @param protocol [String]
|
21
|
+
# @return [URI,Addressable::URI]
|
22
|
+
def add_protocol_to_uri(uri, protocol)
|
23
|
+
uri.scheme = protocol
|
24
|
+
|
25
|
+
if protocol != 'https' && uri.path.end_with?('.jsonld')
|
26
|
+
uri.path = uri.path.sub('.jsonld', ".#{protocol}.jsonld")
|
27
|
+
end
|
28
|
+
|
29
|
+
uri
|
30
|
+
end
|
31
|
+
|
19
32
|
# Changes the URLs from a base URL to have a different scheme
|
20
33
|
#
|
21
34
|
# @param object [Any]
|
@@ -33,9 +46,7 @@ Jekyll::Hooks.register %i[actor activity], :post_init, priority: 8 do |page|
|
|
33
46
|
end
|
34
47
|
when String
|
35
48
|
if object.start_with? base_url
|
36
|
-
Addressable::URI.parse(object).
|
37
|
-
uri.scheme = scheme
|
38
|
-
end.to_s
|
49
|
+
add_protocol_to_uri(Addressable::URI.parse(object), scheme).to_s
|
39
50
|
else
|
40
51
|
object
|
41
52
|
end
|
@@ -52,24 +63,30 @@ Jekyll::Hooks.register %i[actor activity], :post_init, priority: 8 do |page|
|
|
52
63
|
end
|
53
64
|
end
|
54
65
|
|
55
|
-
uri = Addressable::URI.parse page.data['id']
|
56
66
|
url = page.data['url']
|
67
|
+
formats = ['application/ld+json; profile="https://www.w3.org/ns/activitystreams"', 'application/activity+json']
|
68
|
+
data = page.pruned_data
|
57
69
|
|
70
|
+
# TODO: Fetch enabled protocols from DP API
|
58
71
|
%w[https ipns hyper bittorrent].each do |protocol|
|
59
|
-
uri
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
Jekyll::ActivityPub::Link.new(site, uri.to_s, 'alternate',
|
72
|
+
uri = Addressable::URI.parse(page.data['id'])
|
73
|
+
add_protocol_to_uri(uri, protocol)
|
74
|
+
|
75
|
+
formats.each do |format|
|
76
|
+
url << Jekyll::ActivityPub::Link.new(site, uri.to_s, 'alternate', format)
|
77
|
+
end
|
64
78
|
end
|
65
79
|
|
66
80
|
%w[ipns hyper bittorrent].each do |protocol|
|
67
|
-
|
68
|
-
|
81
|
+
uri = Addressable::URI.parse(page.data['id'])
|
82
|
+
add_protocol_to_uri(uri, protocol)
|
69
83
|
|
70
|
-
|
71
|
-
|
84
|
+
Jekyll.logger.debug 'FEP 1042:', "Generating #{uri.path} (#{protocol})"
|
85
|
+
|
86
|
+
json = convert_uris(data, site.config['url'], protocol)
|
87
|
+
json['url'] = url
|
72
88
|
json['id'] = uri.to_s
|
89
|
+
|
73
90
|
# XXX: Only works on forward slash OSes
|
74
91
|
path = uri.path.sub(%r{\A/}, '')
|
75
92
|
|