jekyll-activitypub-static 0.7.1 → 0.7.4

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: be774c7c697b0956a7a038e106e7f814d367c57eae4549fe5ba95d6103310c3f
4
- data.tar.gz: f21b6ae140379d76aa89392c366b98948e3167f896e82722c71ad623ba9978da
3
+ metadata.gz: 1e271d4690d0511a1cfd0104d9878d0b25a3062f280d5c3c1988fbd2deaf6c12
4
+ data.tar.gz: b84575f9980843f30ee6d255cc9358191604c3e2bfead5080418fddb2271b4b7
5
5
  SHA512:
6
- metadata.gz: 2fc3c85e7ae70b2fd9b700e95141412cd09883c15661f47662e237af65322c42450a64c8629015d86b1d79c41de4685365e75a313dd93e14f23f1dbbbeef628e
7
- data.tar.gz: 4bd2f60d33815a5c3e0e0c89917e74825eb2b32c57a98e2d073acf74ef83291e7285ff36460a7f5fee335ca9837fcd878cb0cf928e8a4f67c058ac57d516d305
6
+ metadata.gz: 17bbcf31128ff96050537af76eb2e99d11f20aae0196281101173197f8ccb57717f5b3bf946d8ec3e88ea0bdee29b972b934821e0bdef6434b26a46986efe83f
7
+ data.tar.gz: ccd8ac1c3ae79e58e1d417227a9910b0b91223a4c5bbc5ad1ed974428e7b749b4ec0d796c665ee344716c1cc96434f000f744afd6a16c5f5f96aefbfe2d61aef
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # jekyll-activitypub-static
2
2
 
3
- This is a plugin for Jekyll to generate a static ActivityPoll feed, the read-only polling subset of ActivityPub defined by FEP-b06c.
3
+ A Jekyll plugin that generates a static ActivityPoll feed, the read-only polling subset of ActivityPub defined by FEP-b06c.
4
4
 
5
5
  ## Install
6
6
 
@@ -8,7 +8,7 @@ To build from source:
8
8
 
9
9
  ```bash
10
10
  gem build jekyll-activitypub-static.gemspec
11
- gem install ./jekyll-activitypub-static-0.7.1.gem
11
+ gem install ./jekyll-activitypub-static-0.7.4.gem
12
12
  ```
13
13
 
14
14
  ## Usage
@@ -4,6 +4,24 @@ require "uri"
4
4
 
5
5
  module Jekyll
6
6
  module ActivityPubStatic
7
+ class JsonStaticFile < Jekyll::StaticFile
8
+ def initialize(site, dir, name, content)
9
+ super(site, site.source, dir, name)
10
+ @content = content
11
+ end
12
+
13
+ def modified?
14
+ true
15
+ end
16
+
17
+ def write(dest)
18
+ dest_path = destination(dest)
19
+ FileUtils.mkdir_p(File.dirname(dest_path))
20
+ File.write(dest_path, JSON.pretty_generate(@content))
21
+ true
22
+ end
23
+ end
24
+
7
25
  class Generator < Jekyll::Generator
8
26
  safe true
9
27
  priority :low
@@ -12,7 +30,6 @@ module Jekyll
12
30
  generate_webfinger(site)
13
31
  generate_actor(site)
14
32
  generate_inbox(site)
15
- generate_articles(site)
16
33
  generate_activities(site)
17
34
  generate_outbox_pages(site)
18
35
  generate_outbox(site)
@@ -37,17 +54,16 @@ module Jekyll
37
54
  ]
38
55
  }
39
56
 
40
- path = File.join(site.dest, ".well-known", "webfinger")
41
- FileUtils.mkdir_p(File.dirname(path))
42
- File.write(path, JSON.pretty_generate(webfinger))
57
+ sf = JsonStaticFile.new(site, ".well-known", "webfinger", webfinger)
58
+ site.static_files << sf
59
+
60
+ Jekyll.logger.info LOG_TAG, "Added webfinger as #{sf.path}"
43
61
  end
44
62
 
45
63
  def generate_actor(site)
46
64
  Jekyll.logger.info LOG_TAG, "Generating actor.jsonld"
47
65
  actor = build_actor(site)
48
- path = File.join(site.dest, "actor.jsonld")
49
- FileUtils.mkdir_p(File.dirname(path))
50
- File.write(path, JSON.pretty_generate(actor))
66
+ site.static_files << JsonStaticFile.new(site, "", "actor.jsonld", actor)
51
67
  end
52
68
 
53
69
  def generate_inbox(site)
@@ -69,21 +85,18 @@ module Jekyll
69
85
  "totalItems": 0,
70
86
  "orderedItems": []
71
87
  }
72
- path = File.join(site.dest, output_path, "inbox.jsonld")
73
- FileUtils.mkdir_p(File.dirname(path))
74
- File.write(path, JSON.pretty_generate(inbox))
88
+
89
+ site.static_files << JsonStaticFile.new(site, output_path, "inbox.jsonld", inbox)
75
90
  end
76
91
 
77
92
  def generate_articles(site)
78
93
  url = site.config["url"]
79
94
  output_path = site.config.dig("activitypub", "output_path") || "activitypub"
80
- output_dir = File.join(site.dest, output_path, "posts")
81
- FileUtils.mkdir_p(output_dir)
95
+ output_dir = File.join(output_path, "posts")
82
96
 
83
97
  site.posts.docs.each do |post|
84
98
  slug = post.basename_without_ext.sub(/^\d{4}-\d{2}-\d{2}-/, "")
85
99
  filename = "#{slug}.jsonld"
86
- path = File.join(output_dir, filename)
87
100
 
88
101
  article_id = "#{url}/#{output_path}/posts/#{slug}.jsonld"
89
102
 
@@ -98,16 +111,14 @@ module Jekyll
98
111
  "to" => "as:Public"
99
112
  }
100
113
 
101
- File.write(path, JSON.pretty_generate(article))
102
- Jekyll.logger.info LOG_TAG, "Wrote article to #{path}"
114
+ site.static_files << JsonStaticFile.new(site, output_dir, filename, article)
103
115
  end
104
116
  end
105
117
 
106
118
  def generate_activities(site)
107
119
  url = site.config["url"]
108
120
  output_path = site.config.dig("activitypub", "output_path") || "activitypub"
109
- output_dir = File.join(site.dest, output_path, "activities")
110
- FileUtils.mkdir_p(output_dir)
121
+ output_dir = File.join(output_path, "activities")
111
122
 
112
123
  site.posts.docs.each do |post|
113
124
  slug = post.basename_without_ext.sub(/^\d{4}-\d{2}-\d{2}-/, "")
@@ -132,7 +143,7 @@ module Jekyll
132
143
  "to" => "as:Public"
133
144
  }
134
145
 
135
- File.write(path, JSON.pretty_generate(activity))
146
+ site.static_files << JsonStaticFile.new(site, output_dir, filename, activity)
136
147
  Jekyll.logger.info LOG_TAG, "Wrote activity to #{path}"
137
148
  end
138
149
  end
@@ -140,7 +151,7 @@ module Jekyll
140
151
  def generate_outbox_pages(site)
141
152
  url = site.config["url"]
142
153
  output_path = site.config.dig("activitypub", "output_path") || "activitypub"
143
- output_dir = File.join(site.dest, output_path, "outbox")
154
+ output_dir = File.join(output_path, "outbox")
144
155
 
145
156
  page_number = 1
146
157
  page = build_page(site, page_number)
@@ -152,9 +163,7 @@ module Jekyll
152
163
  activity_id = "#{url}/#{output_path}/activities/create-#{slug}.jsonld"
153
164
 
154
165
  if page["orderedItems"].length >= PAGE_SIZE
155
- path = File.join(output_dir, "page-#{page_number}.jsonld")
156
- FileUtils.mkdir_p(File.dirname(path))
157
- File.write(path, JSON.pretty_generate(page))
166
+ site.static_files << JsonStaticFile.new(site, output_dir, "page-#{page_number}.jsonld", page)
158
167
  page_number += 1
159
168
  page = build_page(site, page_number)
160
169
  end
@@ -175,8 +184,9 @@ module Jekyll
175
184
 
176
185
  if page["orderedItems"].any?
177
186
  path = File.join(output_dir, "page-#{page_number}.jsonld")
178
- FileUtils.mkdir_p(File.dirname(path))
179
- File.write(path, JSON.pretty_generate(page))
187
+
188
+ site.static_files << JsonStaticFile.new(site, output_dir, "page-#{page_number}.jsonld", page)
189
+ Jekyll.logger.info LOG_TAG, "Wrote outbox page #{page_number} to #{path}"
180
190
  end
181
191
  end
182
192
 
@@ -203,9 +213,8 @@ module Jekyll
203
213
  "first": ("#{url}/#{output_path}/outbox/page-#{page_count}.jsonld" if total_items > 0)
204
214
  }
205
215
 
206
- path = File.join(site.dest, output_path, "outbox.jsonld")
207
- FileUtils.mkdir_p(File.dirname(path))
208
- File.write(path, JSON.pretty_generate(outbox))
216
+ site.static_files << JsonStaticFile.new(site, output_path, "outbox.jsonld", outbox)
217
+ Jekyll.logger.info LOG_TAG, "Wrote outbox to #{File.join(site.dest, output_path, "outbox.jsonld")}"
209
218
  end
210
219
 
211
220
  def build_actor(site)
@@ -270,3 +279,7 @@ module Jekyll
270
279
  end
271
280
  end
272
281
  end
282
+
283
+ Jekyll::Hooks.register :site, :post_render do |site|
284
+ Jekyll::ActivityPubStatic::Generator.new(site.config).generate_articles(site)
285
+ end
@@ -1,6 +1,6 @@
1
1
  # lib/jekyll/activitypub_static/version.rb
2
2
  module Jekyll
3
3
  module ActivityPubStatic
4
- VERSION = "0.7.1"
4
+ VERSION = "0.7.4"
5
5
  end
6
6
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jekyll-activitypub-static
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.1
4
+ version: 0.7.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Evan Prodromou
@@ -37,8 +37,8 @@ dependencies:
37
37
  - - "~>"
38
38
  - !ruby/object:Gem::Version
39
39
  version: '1.65'
40
- description: A Jekyll plugin that outputs JSON-LD ActivityPoll content for posts,
41
- feeds, and actors.
40
+ description: A Jekyll plugin that generates a static ActivityPub feed with ActivityPoll,
41
+ from FEP-b06c.
42
42
  email:
43
43
  - evanp@socialwebfoundation.org
44
44
  executables: []
@@ -70,5 +70,5 @@ required_rubygems_version: !ruby/object:Gem::Requirement
70
70
  requirements: []
71
71
  rubygems_version: 3.6.9
72
72
  specification_version: 4
73
- summary: Generate a static ActivityPoll feed from your Jekyll site.
73
+ summary: A Jekyll plugin that generates a static ActivityPub feed
74
74
  test_files: []