1
0
mirror of https://github.com/danbee/micropub.git synced 2025-03-04 08:59:13 +00:00

Well that makes things simpler!

This commit is contained in:
Daniel Barber 2019-11-16 22:27:21 -05:00
parent 15be2d2668
commit c5532e23d4
Signed by: danbarber
GPG Key ID: 931D8112E0103DD8
3 changed files with 8 additions and 17 deletions

View File

@ -20,16 +20,7 @@ class PostJSONParser
end end
def content def content
data.dig("properties", "content", 0) || nested_content data.dig("properties", "content", 0)
end
def nested_content
text = data.dig("properties", "content", "text", 0)
html = data.dig("properties", "content", "html", 0)
return nil if text.nil? && html.nil?
{ "text" => text, "html" => html }.compact
end end
def category def category

View File

@ -26,9 +26,9 @@ describe PostJSONParser do
{ {
"type": ["h-entry"], "type": ["h-entry"],
"properties": { "properties": {
"content": { "content": [{
"text": ["Hello, World!"] "text": "Hello, World!"
} }]
} }
} }
JS JS
@ -45,9 +45,9 @@ describe PostJSONParser do
{ {
"type": ["h-entry"], "type": ["h-entry"],
"properties": { "properties": {
"content": { "content": [{
"html": ["<p>Hello, World!</p>"] "html": "<p>Hello, World!</p>"
} }]
} }
} }
JS JS

View File

@ -81,7 +81,7 @@ describe "create post" do
post_json = { post_json = {
type: ["h-entry"], type: ["h-entry"],
properties: { properties: {
content: { html: ["<p>Hello, World!</p>"] }, content: [{ html: "<p>Hello, World!</p>" }],
category: ["one", "two", "three"], category: ["one", "two", "three"],
}, },
}.to_json }.to_json