jekyll-activity-pub 0.2.4 → 0.2.5
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 55b6801d86becb5ee13ad13e9f46f50e54670d8c4fb77483b6f387efdec5657a
|
4
|
+
data.tar.gz: 8e7461bfc3508ebf9cde56f67c2b5b4967da5f15dd0586308a2b4b8b37fa326d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 26952a76b93dd2483926672ee6360a81562d7af097d5516949d3229f4c869e283f4a1939bf4fb1f6ec28a213b946a6f93f07ad7bd8c8d8f4451cd465e31dcd35
|
7
|
+
data.tar.gz: e33538ae2ef792e5d1405658ac2a936e869e6d1adca347b53dd0d00b2da6fab0ac38257353628c75c3482cb1405b7910f5071c3af0c732d1c043d59f65c1e025
|
@@ -0,0 +1,83 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Implement FEP-1042 Peer to Peer Fediverse Activities by creating new
|
4
|
+
# activities and actors under supported protocols/schemes.
|
5
|
+
#
|
6
|
+
# Priority is low so it's the last thing we do. If you need to modify
|
7
|
+
# the original activities after this plugins runs, use priority lower
|
8
|
+
# than 8.
|
9
|
+
#
|
10
|
+
# The hook runs on post render so we can add the extra pages after
|
11
|
+
# activity generation but before write.
|
12
|
+
require_relative 'jekyll-activity-pub-fep-fffd'
|
13
|
+
|
14
|
+
Jekyll::Hooks.register %i[actor activity], :post_init, priority: 8 do |page|
|
15
|
+
Jekyll.logger.info 'FEP 1042:', 'Generating'
|
16
|
+
|
17
|
+
site = page.site
|
18
|
+
|
19
|
+
# Changes the URLs from a base URL to have a different scheme
|
20
|
+
#
|
21
|
+
# @param object [Any]
|
22
|
+
# @param base_url [String]
|
23
|
+
# @param scheme [String]
|
24
|
+
def convert_uris(object, base_url, scheme)
|
25
|
+
case object
|
26
|
+
when Hash
|
27
|
+
object.transform_values do |value|
|
28
|
+
convert_uris(value, base_url, scheme)
|
29
|
+
end
|
30
|
+
when Array
|
31
|
+
object.map do |value|
|
32
|
+
convert_uris(value, base_url, scheme)
|
33
|
+
end
|
34
|
+
when String
|
35
|
+
if object.start_with? base_url
|
36
|
+
Addressable::URI.parse(object).tap do |uri|
|
37
|
+
uri.scheme = scheme
|
38
|
+
end.to_s
|
39
|
+
else
|
40
|
+
object
|
41
|
+
end
|
42
|
+
when Nokogiri::HTML5::DocumentFragment
|
43
|
+
object.dup.tap do |html|
|
44
|
+
html.css('[src]').each do |element|
|
45
|
+
element['src'] = convert_uris(element['src'], base_url, scheme)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
when Jekyll::ActivityPub::Helper
|
49
|
+
convert_uris(object.data, base_url, scheme)
|
50
|
+
else
|
51
|
+
object
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
uri = Addressable::URI.parse page.data['id']
|
56
|
+
url = page.data['url']
|
57
|
+
|
58
|
+
%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')
|
64
|
+
end
|
65
|
+
|
66
|
+
%w[ipns hyper bittorrent].each do |protocol|
|
67
|
+
json = convert_uris(page.pruned_data, site.config['url'], protocol)
|
68
|
+
json['url'] = url
|
69
|
+
|
70
|
+
uri = Addressable::URI.parse(json['id'])
|
71
|
+
uri.path = uri.path.sub('.jsonld', ".#{protocol}.jsonld")
|
72
|
+
json['id'] = uri.to_s
|
73
|
+
# XXX: Only works on forward slash OSes
|
74
|
+
path = uri.path.sub(%r{\A/}, '')
|
75
|
+
|
76
|
+
Jekyll::PageWithoutAFile.new(site, site.source, File.dirname(path), File.basename(path)).tap do |alternate|
|
77
|
+
site.pages << alternate
|
78
|
+
alternate.content = json.to_json
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
Jekyll.logger.info 'FEP 1042:', 'Generated'
|
83
|
+
end
|
@@ -1,86 +1,3 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
|
4
|
-
# activities and actors under supported protocols/schemes.
|
5
|
-
#
|
6
|
-
# Priority is low so it's the last thing we do. If you need to modify
|
7
|
-
# the original activities after this plugins runs, use priority 0.
|
8
|
-
#
|
9
|
-
# The hook runs on post render so we can add the extra pages after
|
10
|
-
# activity generation but before write.
|
11
|
-
Jekyll::Hooks.register :site, :post_render, priority: 1 do |site|
|
12
|
-
require 'jekyll/activity_pub/link'
|
13
|
-
|
14
|
-
# Changes the URLs from a base URL to have a different scheme
|
15
|
-
#
|
16
|
-
# @param object [Any]
|
17
|
-
# @param base_url [String]
|
18
|
-
# @param scheme [String]
|
19
|
-
def convert_uris(object, base_url, scheme)
|
20
|
-
case object
|
21
|
-
when Hash
|
22
|
-
object.transform_values do |value|
|
23
|
-
convert_uris(value, base_url, scheme)
|
24
|
-
end
|
25
|
-
when Array
|
26
|
-
object.map do |value|
|
27
|
-
convert_uris(value, base_url, scheme)
|
28
|
-
end
|
29
|
-
when String
|
30
|
-
if object.start_with? base_url
|
31
|
-
Addressable::URI.parse(object).tap do |uri|
|
32
|
-
uri.scheme = scheme
|
33
|
-
end.to_s
|
34
|
-
else
|
35
|
-
object
|
36
|
-
end
|
37
|
-
when Nokogiri::HTML5::DocumentFragment
|
38
|
-
object.dup.tap do |html|
|
39
|
-
html.css('[src]').each do |element|
|
40
|
-
element['src'] = convert_uris(element['src'], base_url, scheme)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
when Jekyll::ActivityPub::Helper
|
44
|
-
convert_uris(object.data, base_url, scheme)
|
45
|
-
else
|
46
|
-
object
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
|
-
site.pages.each do |page|
|
51
|
-
case page
|
52
|
-
when Jekyll::ActivityPub::Activity, Jekyll::ActivityPub::Actor
|
53
|
-
uri = Addressable::URI.parse page.data['id']
|
54
|
-
url = [ Jekyll::ActivityPub::Link.new(site, page.data['url'], 'canonical', 'text/html') ]
|
55
|
-
|
56
|
-
%w[https ipns hyper bittorrent].each do |protocol|
|
57
|
-
uri.scheme = protocol
|
58
|
-
url <<
|
59
|
-
Jekyll::ActivityPub::Link.new(site, uri.to_s, 'alternate', 'application/ld+json; profile="https://www.w3.org/ns/activitystreams"')
|
60
|
-
url <<
|
61
|
-
Jekyll::ActivityPub::Link.new(site, uri.to_s, 'alternate', 'application/activity+json')
|
62
|
-
end
|
63
|
-
|
64
|
-
%w[ipns hyper bittorrent].each do |protocol|
|
65
|
-
json = convert_uris(page.pruned_data, site.config['url'], protocol)
|
66
|
-
json['url'] = url
|
67
|
-
|
68
|
-
uri = Addressable::URI.parse(json['id'])
|
69
|
-
uri.path = uri.path.sub('.jsonld', ".#{protocol}.jsonld")
|
70
|
-
json['id'] = uri.to_s
|
71
|
-
path = uri.path.sub(%r{\A/}, '')
|
72
|
-
|
73
|
-
Jekyll::PageWithoutAFile.new(site, site.source, File.dirname(path), File.basename(path)).tap do |alternate|
|
74
|
-
site.pages << alternate
|
75
|
-
|
76
|
-
alternate.output = alternate.content = json.to_json
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
page.data['url'] = url
|
81
|
-
page.output = page.content
|
82
|
-
|
83
|
-
Jekyll.logger.info 'FEP fffd:', 'Generated'
|
84
|
-
end
|
85
|
-
end
|
86
|
-
end
|
3
|
+
require_relative 'jekyll-activity-pub-fep-1042'
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require_relative 'jekyll-activity-pub-fep-fffd'
|
4
|
+
|
5
|
+
# Add a license to each activity by finding a page/post with layout
|
6
|
+
# "license"
|
7
|
+
Jekyll::Hooks.register :activity, :post_init, priority: 9 do |activity|
|
8
|
+
Jekyll.logger.info 'FEP fffd:', 'Adding license'
|
9
|
+
|
10
|
+
site = activity.site
|
11
|
+
|
12
|
+
# Look for a page or a post
|
13
|
+
license = site.pages.find do |page|
|
14
|
+
page.data['layout'] == 'license'
|
15
|
+
end
|
16
|
+
|
17
|
+
# Find the first one in case there are several
|
18
|
+
license ||= activity.renderer.payload['site']['posts'].find do |post|
|
19
|
+
post.data['layout'] == 'license'
|
20
|
+
end
|
21
|
+
|
22
|
+
if license
|
23
|
+
Jekyll.logger.info 'FEP fffd:', "License \"#{license.data['title']}\" found"
|
24
|
+
else
|
25
|
+
Jekyll.logger.info 'FEP fffd:', 'License not found, skipping...'
|
26
|
+
next
|
27
|
+
end
|
28
|
+
|
29
|
+
activity.data['url'] << Jekyll::ActivityPub::Link.new(site, activity.absolute_url(license.url), 'license', 'text/html')
|
30
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# Implement FEP-fffd Proxy Objects by changing the url attribute to an
|
4
|
+
# array of Link objects.
|
5
|
+
#
|
6
|
+
# Priority is low so it's the last thing we do. If you need to modify
|
7
|
+
# the original activities after this plugins runs, use priority lower
|
8
|
+
# than 10.
|
9
|
+
Jekyll::Hooks.register %i[actor activity], :post_init, priority: :low do |page|
|
10
|
+
require 'jekyll/activity_pub/link'
|
11
|
+
|
12
|
+
site = page.site
|
13
|
+
|
14
|
+
Jekyll.logger.info 'FEP fffd:', 'Generating'
|
15
|
+
|
16
|
+
page.data['url'] = [ Jekyll::ActivityPub::Link.new(site, page.data['url'], 'canonical', 'text/html') ]
|
17
|
+
|
18
|
+
Jekyll.logger.info 'FEP fffd:', 'Generated'
|
19
|
+
end
|
20
|
+
|
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.
|
4
|
+
version: 0.2.5
|
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-
|
11
|
+
date: 2024-03-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: distributed-press-api-client
|
@@ -141,7 +141,10 @@ files:
|
|
141
141
|
- README.md
|
142
142
|
- lib/jekyll-activity-pub-absolute-assets.rb
|
143
143
|
- lib/jekyll-activity-pub-assets-as-attachments.rb
|
144
|
+
- lib/jekyll-activity-pub-fep-1042.rb
|
144
145
|
- lib/jekyll-activity-pub-fep-fffd-distributed-press.rb
|
146
|
+
- lib/jekyll-activity-pub-fep-fffd-license.rb
|
147
|
+
- lib/jekyll-activity-pub-fep-fffd.rb
|
145
148
|
- lib/jekyll-activity-pub-link-iframes.rb
|
146
149
|
- lib/jekyll-activity-pub-nokogiri.rb
|
147
150
|
- lib/jekyll-activity-pub.rb
|