jekyll-activity-pub 0.1.0rc15 → 0.1.0rc16

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: 85320eb7b8fa252e8e66bb733d4ab51478b379f4ebd6211c0fbc6387f425cffc
4
- data.tar.gz: 122b5349c06408910f743f255112df2acc3318cc0ede289ea5811a030fda3b65
3
+ metadata.gz: bab8dd66e0a0cb65da8e304c0863aea81e9474d614d6e402ad1c467095104f13
4
+ data.tar.gz: 3197b0125944c2d0ecc5da5f81b7add9e3cfcfc7aec7a3ecc62902097ef0ea94
5
5
  SHA512:
6
- metadata.gz: a2111ddfe7cf26d72088b000014c6ac690a731235c392e9d2cb86a7831913a53d1e27a6a6920c599a52218f275eaf29f473dc37b03b561bbc8abe64d0ddafb6c
7
- data.tar.gz: 5ec690882fbc64d533a1f02741252215e71b9a156d7697228afa5b71bbd927d4bda149d3724f88ca598bd9e58530c21f350ae5c59694e1e1a9cb0256c505be32
6
+ metadata.gz: c9e2ca9f2b982b86a04ad682bd1ef431543db98ac38314a7188570ea1562b194f254b0cceb64aa141b96a4cc644bdefbc78ab4a2b99370901b0898d03a2cc787
7
+ data.tar.gz: d5305462910540cefd06f1cabba97d15beb731924995ab7f93ada8df1e327811de4f66545a77ff5a82caa7cc75d6adc3fdabe532a7a2432811729e9f4dfab61c
@@ -72,16 +72,26 @@ module Jekyll
72
72
 
73
73
  private
74
74
 
75
+ # @return [String]
76
+ def content_warning
77
+ @content_warning ||= doc.data['content_warning'].to_s.strip
78
+ end
79
+
75
80
  # Find summary
76
81
  #
77
82
  # @return [String,nil]
78
83
  def summary
79
- @summary ||= doc.data.slice('title', 'summary').values.join(separator)
84
+ @summary ||=
85
+ if content_warning.empty?
86
+ doc.data.slice('title', 'summary').values.join(separator)
87
+ else
88
+ [content_warning, doc.data['title']].join(separator)
89
+ end
80
90
  end
81
91
 
82
92
  # Should it have a content warning?
83
93
  def sensitive?
84
- !!doc.data.fetch('sensitive', false)
94
+ !content_warning.empty? || !!doc.data.fetch('sensitive', false)
85
95
  end
86
96
 
87
97
  # Separator to join title and summary by
@@ -57,7 +57,7 @@ module Jekyll
57
57
  'icon' => icons.first,
58
58
  'image' => images.first,
59
59
  'publicKey' => nil,
60
- 'published' => date.xmlschema,
60
+ 'published' => published.xmlschema,
61
61
  'updated' => updated.xmlschema,
62
62
  'attachment' => [
63
63
  PropertyValue.new(website_name, website_link)
@@ -67,7 +67,7 @@ module Jekyll
67
67
 
68
68
  # @return [Time]
69
69
  def date
70
- @date ||= site.config.dig('activity_pub', 'published') || site.time
70
+ published
71
71
  end
72
72
 
73
73
  private
@@ -77,21 +77,6 @@ module Jekyll
77
77
  @updated ||= site.config.dig('activity_pub', 'updated') || site.time
78
78
  end
79
79
 
80
- # Finds public name
81
- #
82
- # @return [String,nil]
83
- def public_name
84
- @public_name ||= find_best_value_for(site.config, %w[activity_pub public_name], 'title') || username
85
- end
86
-
87
- # Find summary between site tagline or description, reusing fields
88
- # that are used on jekyll-seo-tag
89
- #
90
- # @return [String,nil]
91
- def summary
92
- @summary ||= find_best_value_for(site.config, %w[activity_pub summary], 'tagline', 'description')
93
- end
94
-
95
80
  # Find icons
96
81
  #
97
82
  # @return [Array]
@@ -84,6 +84,26 @@ module Jekyll
84
84
  @username ||= 'site'
85
85
  end
86
86
 
87
+ # Finds public name
88
+ #
89
+ # @return [String,nil]
90
+ def public_name
91
+ @public_name ||= find_best_value_for(site.config, %w[activity_pub public_name], 'title') || username
92
+ end
93
+
94
+ # @return [Time]
95
+ def published
96
+ @published ||= site.config.dig('activity_pub', 'published') || site.time
97
+ end
98
+
99
+ # Find summary between site tagline or description, reusing fields
100
+ # that are used on jekyll-seo-tag
101
+ #
102
+ # @return [String,nil]
103
+ def summary
104
+ @summary ||= find_best_value_for(site.config, %w[activity_pub summary], 'tagline', 'description')
105
+ end
106
+
87
107
  # Return hostname
88
108
  #
89
109
  # @return [String]
@@ -0,0 +1,117 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'jekyll/page'
4
+ require_relative 'helper'
5
+ require_relative 'version'
6
+
7
+ module Jekyll
8
+ module ActivityPub
9
+ # Points to site's metadata
10
+ class Instance < Jekyll::Page
11
+ include Helper
12
+
13
+ # Initialize with default data
14
+ #
15
+ # @param :site [Jekyll::Site]
16
+ # @param :base [String]
17
+ # @param :dir [String]
18
+ # @param :name [String]
19
+ def initialize(site, base = '', dir = 'api/v2', name = 'instance')
20
+ @context = StubContext.new(registers: { site: site })
21
+
22
+ super(site, base, dir, name)
23
+
24
+ trigger_hooks :post_init
25
+ end
26
+
27
+ def permalink
28
+ 'api/v2/instance/'
29
+ end
30
+
31
+ def output_ext
32
+ '.json'
33
+ end
34
+
35
+ def read_yaml(*)
36
+ self.data = {
37
+ 'domain' => hostname,
38
+ 'version' => Jekyll::ActivityPub::VERSION,
39
+ 'source_url' => 'https://0xacab.org/sutty/jekyll/jekyll-activity-pub',
40
+ 'title' => public_name,
41
+ 'description' => summary,
42
+ 'usage' => {
43
+ 'users' => {
44
+ 'active_month' => 1
45
+ }
46
+ },
47
+ 'thumbnail' => {
48
+ 'url' => conditional_absolute_url(avatar)
49
+ },
50
+ 'languages' => languages,
51
+ 'configuration' => {
52
+ 'urls' => {},
53
+ 'accounts' => {},
54
+ 'statuses' => {},
55
+ 'media_attachments' => {},
56
+ 'polls' => {},
57
+ 'translation' => {},
58
+ },
59
+ 'registrations' => {
60
+ 'enabled' => false,
61
+ 'approval_required' => false,
62
+ 'message' => nil
63
+ },
64
+ 'contact' => {
65
+ 'email' => email,
66
+ 'account' => {
67
+ 'id' => 1,
68
+ 'username' => username,
69
+ 'acct' => username,
70
+ 'display_name' => public_name,
71
+ 'locked' => false,
72
+ 'bot' => false,
73
+ 'discoverable' => true,
74
+ 'group' => false,
75
+ 'created_at' => published.xmlschema,
76
+ 'note' => summary,
77
+ 'url' => site.config['url'],
78
+ 'avatar' => conditional_absolute_url(avatar),
79
+ 'avatar_static' => conditional_absolute_url(avatar),
80
+ 'header' => conditional_absolute_url(header),
81
+ 'header_static' => conditional_absolute_url(header),
82
+ 'followers_count' => 0,
83
+ 'following_count' => 0,
84
+ 'statuses_count' => 0,
85
+ 'last_status_at' => nil,
86
+ 'noindex' => false,
87
+ 'emojis' => [],
88
+ 'fields' => []
89
+ },
90
+ 'rules' => []
91
+ }
92
+ }
93
+ end
94
+
95
+ private
96
+
97
+ # @return [String,nil]
98
+ def header
99
+ @header ||= [find_best_value_for(site.config, %w[activity_pub images], %w[image path])].flatten.compact.first
100
+ end
101
+
102
+ # @return [Array<String>]
103
+ def languages
104
+ @languages ||= site.config['locales'] || [locale]
105
+ end
106
+
107
+ # @return [String,nil]
108
+ def email
109
+ @email ||= find_best_value_for(site.config, %w[activity_pub email], 'email')
110
+ end
111
+
112
+ def avatar
113
+ @avatar ||= [find_best_value_for(site.config, %w[activity_pub icons], 'logo')].flatten.compact.first
114
+ end
115
+ end
116
+ end
117
+ end
@@ -0,0 +1,40 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'jekyll/page'
4
+ require_relative 'helper'
5
+
6
+ module Jekyll
7
+ module ActivityPub
8
+ # Points to site's nodeinfo
9
+ class Nodeinfo < Jekyll::Page
10
+ include Helper
11
+
12
+ # Initialize with default data
13
+ #
14
+ # @param :site [Jekyll::Site]
15
+ # @param :nodeinfos [Array<Nodeinfo21>]
16
+ # @param :base [String]
17
+ # @param :dir [String]
18
+ # @param :name [String]
19
+ def initialize(site, nodeinfos, base = '', dir = '.well-known', name = 'webfinger')
20
+ @context = StubContext.new(registers: { site: site })
21
+ @nodeinfos = nodeinfos
22
+
23
+ super(site, base, dir, name)
24
+
25
+ trigger_hooks :post_init
26
+ end
27
+
28
+ def read_yaml(*)
29
+ self.data = { 'links' => @nodeinfos.map(&:to_jrd) }
30
+ end
31
+
32
+ # The nodeinfo file is expected to be at this location always
33
+ #
34
+ # @return [String]
35
+ def permalink
36
+ '.well-known/nodeinfo'
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,76 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'jekyll/page'
4
+ require_relative 'helper'
5
+ require_relative 'version'
6
+
7
+ module Jekyll
8
+ module ActivityPub
9
+ # Points to site's nodeinfo 2.0
10
+ class Nodeinfo20 < Jekyll::Page
11
+ include Helper
12
+
13
+ def version
14
+ '2.0'
15
+ end
16
+
17
+ # Initialize with default data
18
+ #
19
+ # @param :site [Jekyll::Site]
20
+ # @param :base [String]
21
+ # @param :dir [String]
22
+ # @param :name [String]
23
+ def initialize(site, base = '', dir = 'nodeinfo', name = version)
24
+ @context = StubContext.new(registers: { site: site })
25
+
26
+ super(site, base, dir, name)
27
+
28
+ trigger_hooks :post_init
29
+ end
30
+
31
+ def read_yaml(*)
32
+ self.data = {
33
+ 'version' => version,
34
+ 'software' => {
35
+ 'name' => 'sutty-distributed-press',
36
+ 'version' => Jekyll::ActivityPub::VERSION
37
+ },
38
+ 'protocols' => ['activitypub'],
39
+ 'services' => {},
40
+ 'openRegistrations' => false,
41
+ 'usage' => {
42
+ 'users' => {
43
+ 'total' => 1,
44
+ 'activeHalfyear' => 1,
45
+ 'activeMonth' => 1
46
+ },
47
+ 'localPosts' => 0,
48
+ 'localComments' => 0
49
+ },
50
+ 'metadata' => {}
51
+ }
52
+ end
53
+
54
+ # The nodeinfo file is expected to be at this location always
55
+ #
56
+ # @return [String]
57
+ def permalink
58
+ "nodeinfo/#{version}.json"
59
+ end
60
+
61
+ # @return [Hash]
62
+ def to_jrd
63
+ {
64
+ 'rel' => "http://nodeinfo.diaspora.software/ns/schema/#{version}",
65
+ 'href' => absolute_url(url)
66
+ }
67
+ end
68
+
69
+ # @return [nil]
70
+ def increase_local_posts_counter!
71
+ data['usage']['localPosts'] += 1
72
+ nil
73
+ end
74
+ end
75
+ end
76
+ end
@@ -0,0 +1,22 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'jekyll/page'
4
+ require_relative 'nodeinfo_20'
5
+
6
+ module Jekyll
7
+ module ActivityPub
8
+ # Points to site's nodeinfo 2.1
9
+ class Nodeinfo21 < Nodeinfo20
10
+ def version
11
+ '2.1'
12
+ end
13
+
14
+ def read_yaml(*)
15
+ super.tap do |data|
16
+ data['software']['repository'] = 'https://0xacab.org/sutty/jekyll/jekyll-activity-pub/'
17
+ data['software']['homepage'] = 'https://sutty.nl'
18
+ end
19
+ end
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ module Jekyll
4
+ module ActivityPub
5
+ VERSION = '0.1.0'
6
+ end
7
+ end
@@ -8,6 +8,10 @@ require_relative 'activity_pub/host_meta'
8
8
  require_relative 'activity_pub/create'
9
9
  require_relative 'activity_pub/update'
10
10
  require_relative 'activity_pub/public_key'
11
+ require_relative 'activity_pub/nodeinfo'
12
+ require_relative 'activity_pub/nodeinfo_20'
13
+ require_relative 'activity_pub/nodeinfo_21'
14
+ require_relative 'activity_pub/instance'
11
15
 
12
16
  module Jekyll
13
17
  # ActivityPub
@@ -29,6 +29,16 @@ Jekyll::Hooks.register :site, :post_read, priority: :low do |site|
29
29
  site.pages << site.config['webfinger'] = webfinger = Jekyll::ActivityPub::WebFinger.new(site, actor)
30
30
  site.pages << site.config['outbox'] = Jekyll::ActivityPub::Outbox.new(site, actor)
31
31
  site.pages << site.config['host-meta'] = Jekyll::ActivityPub::HostMeta.new(site, webfinger)
32
+ site.pages << site.config['instance'] = Jekyll::ActivityPub::Instance.new(site)
33
+
34
+ # Nodeinfo
35
+ site.config['nodeinfos'] = [Jekyll::ActivityPub::Nodeinfo20, Jekyll::ActivityPub::Nodeinfo21].map do |nodeinfo|
36
+ nodeinfo.new(site).tap do |n|
37
+ site.pages << n
38
+ end
39
+ end
40
+
41
+ site.pages << site.config['nodeinfo'] = Jekyll::ActivityPub::Nodeinfo.new(site, site.config['nodeinfos'])
32
42
 
33
43
  # Add Actor to home page
34
44
  home = site.pages.find do |page|
@@ -85,6 +95,17 @@ Jekyll::Hooks.register(:documents, :post_convert, priority: :high) do |doc|
85
95
 
86
96
  outbox.data['totalItems'] += 1
87
97
  outbox.data['orderedItems'] << action
98
+
99
+ site.config['nodeinfos'].map(&:increase_local_posts_counter!)
100
+
101
+ site.config['instance'].data['contact']['account']['statuses_count'] += 1
102
+
103
+ last_status_at = site.config['instance'].data['contact']['account']['last_status_at']
104
+
105
+ if !last_status_at || last_status_at < doc.date
106
+ site.config['instance'].data['contact']['account']['last_status_at'] = doc.date
107
+ end
108
+
88
109
  site.pages << action
89
110
  end
90
111
 
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.1.0rc15
4
+ version: 0.1.0rc16
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sutty
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-11-07 00:00:00.000000000 Z
11
+ date: 2023-11-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: distributed-press-api-client
@@ -152,6 +152,10 @@ files:
152
152
  - lib/jekyll/activity_pub/helper.rb
153
153
  - lib/jekyll/activity_pub/host_meta.rb
154
154
  - lib/jekyll/activity_pub/image.rb
155
+ - lib/jekyll/activity_pub/instance.rb
156
+ - lib/jekyll/activity_pub/nodeinfo.rb
157
+ - lib/jekyll/activity_pub/nodeinfo_20.rb
158
+ - lib/jekyll/activity_pub/nodeinfo_21.rb
155
159
  - lib/jekyll/activity_pub/notifier.rb
156
160
  - lib/jekyll/activity_pub/ordered_collection.rb
157
161
  - lib/jekyll/activity_pub/ordered_collection_page.rb
@@ -160,18 +164,19 @@ files:
160
164
  - lib/jekyll/activity_pub/public_key.rb
161
165
  - lib/jekyll/activity_pub/tomsbtone.rb~
162
166
  - lib/jekyll/activity_pub/update.rb
167
+ - lib/jekyll/activity_pub/version.rb
163
168
  - lib/jekyll/activity_pub/webfinger.rb
164
169
  - lib/jekyll/command_extension.rb
165
170
  - lib/jekyll/commands/generate_keys.rb
166
171
  - lib/jekyll/commands/notify.rb
167
- homepage: https://0xacab.org/sutty/jekyll/jekyll-activity-pub
172
+ homepage: https://jekyll-activity-pub.sutty.nl/
168
173
  licenses:
169
174
  - Apache-2.0
170
175
  metadata:
171
- bug_tracker_uri: https://0xacab.org/sutty/jekyll/jekyll-activity-pub/issues
172
- homepage_uri: https://0xacab.org/sutty/jekyll/jekyll-activity-pub
176
+ bug_tracker_uri: https://jekyll-activity-pub.sutty.nl//issues
177
+ homepage_uri: https://jekyll-activity-pub.sutty.nl/
173
178
  source_code_uri: https://0xacab.org/sutty/jekyll/jekyll-activity-pub
174
- changelog_uri: https://0xacab.org/sutty/jekyll/jekyll-activity-pub/-/blob/master/CHANGELOG.md
179
+ changelog_uri: https://jekyll-activity-pub.sutty.nl//-/blob/master/CHANGELOG.md
175
180
  documentation_uri: https://rubydoc.info/gems/jekyll-activity-pub
176
181
  post_install_message:
177
182
  rdoc_options: