Browse Source
editor sends JSON when sending HTML content
pull/82/head
Aaron Parecki
8 years ago
No known key found for this signature in database
GPG Key ID: 276C2817346D6056
1 changed files with
22 additions and
7 deletions
-
controllers/editor.php
|
|
@ -19,13 +19,21 @@ $app->post('/editor/publish', function() use($app) { |
|
|
|
|
|
|
|
if($user->micropub_optin_html_content) { |
|
|
|
$content = ['html' => $content]; |
|
|
|
} |
|
|
|
|
|
|
|
$micropub_request = array( |
|
|
|
'name' => [$params['name']], |
|
|
|
'content' => [$content] |
|
|
|
); |
|
|
|
$json = true; |
|
|
|
} else { |
|
|
|
$json = false; |
|
|
|
|
|
|
|
$micropub_request = array( |
|
|
|
'h' => 'entry', |
|
|
|
'name' => $params['name'], |
|
|
|
'content' => $content |
|
|
|
'name' => [$params['name']], |
|
|
|
'content' => [$content] |
|
|
|
); |
|
|
|
} |
|
|
|
|
|
|
|
if(array_key_exists('category', $params) && $params['category']) |
|
|
|
$micropub_request['category'] = $params['category']; |
|
|
@ -42,7 +50,14 @@ $app->post('/editor/publish', function() use($app) { |
|
|
|
$micropub_request['published'] = $params['publish']; |
|
|
|
} |
|
|
|
|
|
|
|
$r = micropub_post_for_user($user, $micropub_request); |
|
|
|
if($json) { |
|
|
|
$micropub_request = [ |
|
|
|
'type' => ['h-entry'], |
|
|
|
'properties' => $micropub_request |
|
|
|
]; |
|
|
|
} |
|
|
|
|
|
|
|
$r = micropub_post_for_user($user, $micropub_request, null, $json); |
|
|
|
|
|
|
|
$app->response()['Content-type'] = 'application/json'; |
|
|
|
$app->response()->body(json_encode([ |
|
|
|