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:
parent
15be2d2668
commit
c5532e23d4
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user