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
def content
data.dig("properties", "content", 0) || nested_content
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
data.dig("properties", "content", 0)
end
def category

View File

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

View File

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