jekyll-activity-pub 0.2.5 → 0.2.7

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: e5dbbab91a509e4edbb918ef90128a03415c702d3ff517c4d6466a3f38f183d1
4
+ data.tar.gz: 0c99c1dd59dfdf75144ba48a8a1b820aa5ad2adec542edb3aebca4a05b1cebea
5
5
  SHA512:
6
- metadata.gz: 26952a76b93dd2483926672ee6360a81562d7af097d5516949d3229f4c869e283f4a1939bf4fb1f6ec28a213b946a6f93f07ad7bd8c8d8f4451cd465e31dcd35
7
- data.tar.gz: e33538ae2ef792e5d1405658ac2a936e869e6d1adca347b53dd0d00b2da6fab0ac38257353628c75c3482cb1405b7910f5071c3af0c732d1c043d59f65c1e025
6
+ metadata.gz: ed1203e6aac6abd5aaa2130c6bf6ed7d47130a18a4c3866ee078cee1d7c963e5d71e9285a6dbadfe8a096ca32ebadf215747edc33fde40a2f694457a829ed991
7
+ data.tar.gz: 4d5e3a40dcd8d3fc8e64110c88d26319188d2ea43899c455b110c1cf154841114182033da31fd6fe0f02b67bfaaaf4c12567a896d7e5f28a4ab693f027dc0faa
@@ -55,6 +55,11 @@ module Jekyll
55
55
  @@site
56
56
  end
57
57
 
58
+ # Announce the website?
59
+ def announce?
60
+ !!config['announce']
61
+ end
62
+
58
63
  def url
59
64
  config['url'].tap do |u|
60
65
  abort_if_missing('activity_pub.url', u, '_config.yml')
@@ -127,7 +132,7 @@ module Jekyll
127
132
  # @todo Updating/Key rotation seems broken for now
128
133
  # @see {https://github.com/hyphacoop/social.distributed.press/issues/51}
129
134
  unless inbox.get.ok?
130
- unless (response = inbox.create(actor_url)).ok?
135
+ unless (response = inbox.create(actor_url, announce?)).ok?
131
136
  raise NotificationError, "Couldn't create/update inbox (#{response.code}: #{response.message})"
132
137
  end
133
138
  end
@@ -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,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.2.5
4
+ version: 0.2.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sutty
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-03-20 00:00:00.000000000 Z
11
+ date: 2024-04-05 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.4.0
19
+ version: 0.4.2
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.4.0
26
+ version: 0.4.2
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: jekyll
29
29
  requirement: !ruby/object:Gem::Requirement