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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 55b6801d86becb5ee13ad13e9f46f50e54670d8c4fb77483b6f387efdec5657a
4
- data.tar.gz: 8e7461bfc3508ebf9cde56f67c2b5b4967da5f15dd0586308a2b4b8b37fa326d
3
+ metadata.gz: 9b0dd7df568e8344f4d9c0c3e41cfe2cf3a2384737800d0c3b3b5120f447ed63
4
+ data.tar.gz: 8974b30de62eda46a8aa375a04f4a037ce81741f8a99181003823726c1076f10
5
5
  SHA512:
6
- metadata.gz: 26952a76b93dd2483926672ee6360a81562d7af097d5516949d3229f4c869e283f4a1939bf4fb1f6ec28a213b946a6f93f07ad7bd8c8d8f4451cd465e31dcd35
7
- data.tar.gz: e33538ae2ef792e5d1405658ac2a936e869e6d1adca347b53dd0d00b2da6fab0ac38257353628c75c3482cb1405b7910f5071c3af0c732d1c043d59f65c1e025
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).tap do |uri|
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.scheme = protocol
60
- url <<
61
- Jekyll::ActivityPub::Link.new(site, uri.to_s, 'alternate', 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"')
62
- url <<
63
- Jekyll::ActivityPub::Link.new(site, uri.to_s, 'alternate', 'application/activity+json')
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
- json = convert_uris(page.pruned_data, site.config['url'], protocol)
68
- json['url'] = url
81
+ uri = Addressable::URI.parse(page.data['id'])
82
+ add_protocol_to_uri(uri, protocol)
69
83
 
70
- uri = Addressable::URI.parse(json['id'])
71
- uri.path = uri.path.sub('.jsonld', ".#{protocol}.jsonld")
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
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-activity-pub
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.5
4
+ version: 0.2.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sutty