summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAaron Parecki <aaron@parecki.com>2017-03-13 18:06:20 -0700
committerAaron Parecki <aaron@parecki.com>2017-03-13 18:06:20 -0700
commitdef648bba6307a2259bd41e1509731bdec1daf97 (patch)
treecf668cf85256159d89e1212e40b1f5bed974b7c9
parentfa782167af747ded42dd1278441035e0be0c36ea (diff)
editor sends JSON when sending HTML content
-rw-r--r--controllers/editor.php29
1 files changed, 22 insertions, 7 deletions
diff --git a/controllers/editor.php b/controllers/editor.php
index 9016d1d..ddffccb 100644
--- a/controllers/editor.php
+++ b/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(
- 'h' => 'entry',
- 'name' => $params['name'],
- 'content' => $content
- );
+ $micropub_request = array(
+ 'name' => [$params['name']],
+ 'content' => [$content]
+ );
+ $json = true;
+ } else {
+ $json = false;
+
+ $micropub_request = array(
+ 'h' => 'entry',
+ '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([