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
|
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
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
@ -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
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user