open_blog 0.5.0 → 0.6.0
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 +4 -4
- data/CHANGELOG.md +7 -0
- data/lib/open_blog/api_fields.rb +1 -1
- data/lib/open_blog/errors.rb +1 -0
- data/lib/open_blog/mcp/registry.rb +3 -2
- data/lib/open_blog/mcp/schemas.rb +4 -1
- data/lib/open_blog/post_attributes.rb +23 -6
- data/lib/open_blog/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 77119d6cb031ab89f76c8aa2e8841c34da092f14f0aaaad59c9b0b7db448be13
|
|
4
|
+
data.tar.gz: 9b22fc6d46f99316c4ba885021e80a9abc6aba293d7d221a79e4be169fbdbc71
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 49ecb66b5c29bdde2c522ec67199150730c048fd03649e9aa2c070cbad9cd4b9d1e7871666819483bf0f5d4e3f1abbd187ddf30adffb4c83fd2c81ed0dde819a
|
|
7
|
+
data.tar.gz: df4a5972797d0bf7b7660edf365c1c3612db201cc509f7a33e69837efaea902a67ad46d4e8d699abfef03ad152d24329d940b4c102b3832ade9e295dc8534bc7
|
data/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.6.0] - 2026-11-30
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Post writes accept `category` as an object, through the JSON API, the MCP post tools, and Ruby operations. `{slug: "guides"}` finds the category by slug only. `{name: "Guides"}` finds the category by name, or creates it with a slug made from the name. The string form does not change.
|
|
15
|
+
- A new 422 error, `unknown_category`, refuses a `{slug:}` that no category has. `details` contains the slug, and Open Blog writes no post, category, or author. An integration that sends a stale slug now gets this refusal, not a new public category or a post in a different category.
|
|
16
|
+
|
|
10
17
|
## [0.5.0] - 2026-10-29
|
|
11
18
|
|
|
12
19
|
### Added
|
data/lib/open_blog/api_fields.rb
CHANGED
|
@@ -4,7 +4,7 @@ module OpenBlog
|
|
|
4
4
|
POST_WRITE = (PostAttributes::CONTENT_FIELDS + PostAttributes::RECORD_FIELDS).freeze
|
|
5
5
|
POST_LIST = %i[status category tag author series q page per_page].freeze
|
|
6
6
|
POST_NESTED = {
|
|
7
|
-
author: %i[name type url], approval: %i[name facts_checked revision_identifier],
|
|
7
|
+
author: %i[name type url], category: %i[name slug], approval: %i[name facts_checked revision_identifier],
|
|
8
8
|
cover_image: %i[image_id signed_id url], social_image: %i[image_id signed_id url],
|
|
9
9
|
connections: %i[connections third_party_paid declared_by declared_on], faq: %i[question answer]
|
|
10
10
|
}.freeze
|
data/lib/open_blog/errors.rb
CHANGED
|
@@ -20,6 +20,7 @@ module OpenBlog
|
|
|
20
20
|
already_changed_in_gem: [ 409, "This post has changed since its adoption." ],
|
|
21
21
|
validation_failed: [ 422, "One or more fields are invalid." ],
|
|
22
22
|
unknown_field: [ 422, "The request contains unsupported fields." ],
|
|
23
|
+
unknown_category: [ 422, "No category has this slug. Read the category list and send an existing slug." ],
|
|
23
24
|
change_type_required: [ 422, "This update changes the public revision. Send change: substantive, correction or maintenance." ],
|
|
24
25
|
correction_note_required: [ 422, "A correction needs a note describing what changed." ],
|
|
25
26
|
approval_required: [ 422, "This publication requires approval with facts checked." ],
|
|
@@ -4,9 +4,10 @@ module OpenBlog
|
|
|
4
4
|
module_function
|
|
5
5
|
|
|
6
6
|
def definitions
|
|
7
|
+
filters = Schemas.fields(ApiFields::POST_LIST).merge("category" => Schemas.text(nullable: true))
|
|
7
8
|
[
|
|
8
|
-
endpoint("list_posts", :read, "posts", :index,
|
|
9
|
-
endpoint("search_posts", :read, "posts", :index,
|
|
9
|
+
endpoint("list_posts", :read, "posts", :index, properties: filters),
|
|
10
|
+
endpoint("search_posts", :read, "posts", :index, properties: filters, required: [ :q ]),
|
|
10
11
|
endpoint("get_post", :read, "posts", :show, id: :required),
|
|
11
12
|
endpoint("get_post_records", :read, "records", :show, id: :required),
|
|
12
13
|
endpoint("check_post", :read, "findings", :show, id: :required),
|
|
@@ -36,6 +36,9 @@ module OpenBlog
|
|
|
36
36
|
when :faq then { type: "array", items: object(fields(ApiFields::POST_NESTED.fetch(:faq)), required: %w[question answer]) }
|
|
37
37
|
when :author
|
|
38
38
|
{ anyOf: [ text, object(fields(ApiFields::POST_NESTED.fetch(:author)), required: [ "name" ]) ] }
|
|
39
|
+
when :category
|
|
40
|
+
category = object(fields(ApiFields::POST_NESTED.fetch(:category)).transform_values { { type: "string", minLength: 1 } })
|
|
41
|
+
{ anyOf: [ text(nullable: true), category.merge(minProperties: 1) ] }
|
|
39
42
|
when :cover_image, :social_image, :avatar
|
|
40
43
|
{ anyOf: [ { type: "null" }, image ] }
|
|
41
44
|
when :approval
|
|
@@ -55,7 +58,7 @@ module OpenBlog
|
|
|
55
58
|
when :change then { type: "string", enum: %w[substantive correction maintenance] }
|
|
56
59
|
when :status then { type: "string", enum: %w[draft scheduled published archived] }
|
|
57
60
|
when :body, :description, :search_title, :search_description, :canonical_url, :cover_alt, :external_id,
|
|
58
|
-
:
|
|
61
|
+
:series, :provenance_evidence, :publish_at, :first_published_at, :last_modified_at,
|
|
59
62
|
:first_published_evidence, :last_modified_evidence, :declared_first_published_at, :source_body_sha256,
|
|
60
63
|
:bio, :url, :host_reference, :new_path, :redirect_to, :moved_on
|
|
61
64
|
text(nullable: true)
|
|
@@ -32,9 +32,8 @@ module OpenBlog
|
|
|
32
32
|
validate_types
|
|
33
33
|
assign_scalars
|
|
34
34
|
assign_author if @attributes.key?(:author) || @post.author.nil?
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
end
|
|
35
|
+
@post.category = category(@attributes[:category]) if @attributes.key?(:category)
|
|
36
|
+
@post.series = taxonomy(Series, @attributes[:series]) if @attributes.key?(:series)
|
|
38
37
|
assign_faq if @attributes.key?(:faq)
|
|
39
38
|
assign_tags if @attributes.key?(:tags)
|
|
40
39
|
%i[cover_image social_image].each do |field|
|
|
@@ -57,9 +56,8 @@ module OpenBlog
|
|
|
57
56
|
if @attributes.key?(:series_position) && !@attributes[:series_position].nil?
|
|
58
57
|
invalid(:series_position) unless @attributes[:series_position].is_a?(Integer) && @attributes[:series_position].positive?
|
|
59
58
|
end
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
end
|
|
59
|
+
invalid(:series) if @attributes.key?(:series) && !@attributes[:series].nil? && !@attributes[:series].is_a?(String)
|
|
60
|
+
validate_category if @attributes.key?(:category)
|
|
63
61
|
if @attributes.key?(:body_format)
|
|
64
62
|
format = @attributes[:body_format]
|
|
65
63
|
unless (format.is_a?(String) || format.is_a?(Symbol)) && OpenBlog.config.body_formats.map(&:to_s).include?(format.to_s)
|
|
@@ -123,6 +121,25 @@ module OpenBlog
|
|
|
123
121
|
@post.author_name = author.name
|
|
124
122
|
end
|
|
125
123
|
|
|
124
|
+
def validate_category
|
|
125
|
+
value = @attributes[:category]
|
|
126
|
+
return if value.nil? || value.is_a?(String)
|
|
127
|
+
invalid(:category) unless value.is_a?(Hash)
|
|
128
|
+
fields = value.symbolize_keys
|
|
129
|
+
invalid(:category) if fields.empty? || (fields.keys - %i[name slug]).any?
|
|
130
|
+
invalid(:category) unless fields.values.all? { |field| field.is_a?(String) && field.present? }
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
def category(value)
|
|
134
|
+
return taxonomy(Category, value) unless value.is_a?(Hash)
|
|
135
|
+
fields = value.symbolize_keys
|
|
136
|
+
if fields.key?(:slug)
|
|
137
|
+
Category.find_by(slug: fields[:slug]) || raise(Error::UnknownCategory.new(details: [ fields[:slug] ]))
|
|
138
|
+
else
|
|
139
|
+
Category.find_by(name: fields[:name]) || Category.create!(name: fields[:name])
|
|
140
|
+
end
|
|
141
|
+
end
|
|
142
|
+
|
|
126
143
|
def taxonomy(model, value)
|
|
127
144
|
return if value.blank?
|
|
128
145
|
model.find_by(slug: value) || model.find_by(name: value) || model.create!(name: value)
|
data/lib/open_blog/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: open_blog
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.6.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- TechWright Labs
|
|
8
8
|
bindir: bin
|
|
9
9
|
cert_chain: []
|
|
10
|
-
date: 2026-
|
|
10
|
+
date: 2026-11-30 00:00:00.000000000 Z
|
|
11
11
|
dependencies:
|
|
12
12
|
- !ruby/object:Gem::Dependency
|
|
13
13
|
name: json
|