jekyll-activitypub-static 0.7.1 → 0.7.3

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: b1c1766dd68f2800d25fc7df592437c35feea85078a1854844da1c9bcf002b64
4
+ data.tar.gz: 52d1e9fb21652a79c4a64cd443cb07d93b1134a68915aad2ec42b2c589940ccc
5
5
  SHA512:
6
- metadata.gz: 2fc3c85e7ae70b2fd9b700e95141412cd09883c15661f47662e237af65322c42450a64c8629015d86b1d79c41de4685365e75a313dd93e14f23f1dbbbeef628e
7
- data.tar.gz: 4bd2f60d33815a5c3e0e0c89917e74825eb2b32c57a98e2d073acf74ef83291e7285ff36460a7f5fee335ca9837fcd878cb0cf928e8a4f67c058ac57d516d305
6
+ metadata.gz: e38b2f34411400d648d35436f2ac8b89d9392c3b6ff46461919fde42a5748b5b0ed0a893dd950a82183ed6f74df2b7f7a36ed7e488d38ac37bc59f476509cca7
7
+ data.tar.gz: 506f812d26892654489b856ef34fa913c63f99e779a81ffa57f9d2e2061ab9409c7062e26ad123257626926999f6b710c4c7d747ad890d4e68c867071e86e268
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.3.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
@@ -37,17 +55,16 @@ module Jekyll
37
55
  ]
38
56
  }
39
57
 
40
- path = File.join(site.dest, ".well-known", "webfinger")
41
- FileUtils.mkdir_p(File.dirname(path))
42
- File.write(path, JSON.pretty_generate(webfinger))
58
+ sf = JsonStaticFile.new(site, ".well-known", "webfinger", webfinger)
59
+ site.static_files << sf
60
+
61
+ Jekyll.logger.info LOG_TAG, "Added webfinger as #{sf.path}"
43
62
  end
44
63
 
45
64
  def generate_actor(site)
46
65
  Jekyll.logger.info LOG_TAG, "Generating actor.jsonld"
47
66
  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))
67
+ site.static_files << JsonStaticFile.new(site, "", "actor.jsonld", actor)
51
68
  end
52
69
 
53
70
  def generate_inbox(site)
@@ -69,21 +86,18 @@ module Jekyll
69
86
  "totalItems": 0,
70
87
  "orderedItems": []
71
88
  }
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))
89
+
90
+ site.static_files << JsonStaticFile.new(site, output_path, "inbox.jsonld", inbox)
75
91
  end
76
92
 
77
93
  def generate_articles(site)
78
94
  url = site.config["url"]
79
95
  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)
96
+ output_dir = File.join(output_path, "posts")
82
97
 
83
98
  site.posts.docs.each do |post|
84
99
  slug = post.basename_without_ext.sub(/^\d{4}-\d{2}-\d{2}-/, "")
85
100
  filename = "#{slug}.jsonld"
86
- path = File.join(output_dir, filename)
87
101
 
88
102
  article_id = "#{url}/#{output_path}/posts/#{slug}.jsonld"
89
103
 
@@ -98,16 +112,14 @@ module Jekyll
98
112
  "to" => "as:Public"
99
113
  }
100
114
 
101
- File.write(path, JSON.pretty_generate(article))
102
- Jekyll.logger.info LOG_TAG, "Wrote article to #{path}"
115
+ site.static_files << JsonStaticFile.new(site, output_dir, filename, article)
103
116
  end
104
117
  end
105
118
 
106
119
  def generate_activities(site)
107
120
  url = site.config["url"]
108
121
  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)
122
+ output_dir = File.join(output_path, "activities")
111
123
 
112
124
  site.posts.docs.each do |post|
113
125
  slug = post.basename_without_ext.sub(/^\d{4}-\d{2}-\d{2}-/, "")
@@ -132,7 +144,7 @@ module Jekyll
132
144
  "to" => "as:Public"
133
145
  }
134
146
 
135
- File.write(path, JSON.pretty_generate(activity))
147
+ site.static_files << JsonStaticFile.new(site, output_dir, filename, activity)
136
148
  Jekyll.logger.info LOG_TAG, "Wrote activity to #{path}"
137
149
  end
138
150
  end
@@ -140,7 +152,7 @@ module Jekyll
140
152
  def generate_outbox_pages(site)
141
153
  url = site.config["url"]
142
154
  output_path = site.config.dig("activitypub", "output_path") || "activitypub"
143
- output_dir = File.join(site.dest, output_path, "outbox")
155
+ output_dir = File.join(output_path, "outbox")
144
156
 
145
157
  page_number = 1
146
158
  page = build_page(site, page_number)
@@ -152,9 +164,7 @@ module Jekyll
152
164
  activity_id = "#{url}/#{output_path}/activities/create-#{slug}.jsonld"
153
165
 
154
166
  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))
167
+ site.static_files << JsonStaticFile.new(site, output_dir, "page-#{page_number}.jsonld", page)
158
168
  page_number += 1
159
169
  page = build_page(site, page_number)
160
170
  end
@@ -175,8 +185,9 @@ module Jekyll
175
185
 
176
186
  if page["orderedItems"].any?
177
187
  path = File.join(output_dir, "page-#{page_number}.jsonld")
178
- FileUtils.mkdir_p(File.dirname(path))
179
- File.write(path, JSON.pretty_generate(page))
188
+
189
+ site.static_files << JsonStaticFile.new(site, output_dir, "page-#{page_number}.jsonld", page)
190
+ Jekyll.logger.info LOG_TAG, "Wrote outbox page #{page_number} to #{path}"
180
191
  end
181
192
  end
182
193
 
@@ -203,9 +214,8 @@ module Jekyll
203
214
  "first": ("#{url}/#{output_path}/outbox/page-#{page_count}.jsonld" if total_items > 0)
204
215
  }
205
216
 
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))
217
+ site.static_files << JsonStaticFile.new(site, output_path, "outbox.jsonld", outbox)
218
+ Jekyll.logger.info LOG_TAG, "Wrote outbox to #{File.join(site.dest, output_path, "outbox.jsonld")}"
209
219
  end
210
220
 
211
221
  def build_actor(site)
@@ -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.3"
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.3
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: []