diff options
author | Aaron Parecki <aaron@parecki.com> | 2015-05-10 16:49:22 +0200 |
---|---|---|
committer | Aaron Parecki <aaron@parecki.com> | 2015-05-10 16:49:22 +0200 |
commit | 3b7d766c31314a3d42d651b8c8f643ff8d6e15bd (patch) | |
tree | dec9c9cbed6cb077ada14754f556c21eb51da2c8 /controllers/editor.php | |
parent | 3dc97d7478781550aa1a878120082a871988f02e (diff) |
do the micropub post and redirect after it's created!medium
Diffstat (limited to 'controllers/editor.php')
-rw-r--r-- | controllers/editor.php | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/controllers/editor.php b/controllers/editor.php index a66c188..caac4a3 100644 --- a/controllers/editor.php +++ b/controllers/editor.php @@ -6,6 +6,26 @@ $app->get('/editor', function() use($app) { $app->response()->body($html); }); +$app->post('/editor/publish', function() use($app) { + + if($user=require_login($app)) { + $params = $app->request()->params(); + + $micropub_request = array( + 'h' => 'entry', + 'name' => $params['name'], + 'content' => $params['body'] + ); + + $r = micropub_post_for_user($user, $micropub_request); + + $app->response()['Content-type'] = 'application/json'; + $app->response()->body(json_encode([ + 'location' => $r['location'] + ])); + } +}); + $app->post('/editor/upload', function() use($app) { // Fake a file uploader by echo'ing back the data URI $fn = $_FILES['files']['tmp_name'][0]; @@ -21,6 +41,7 @@ $app->post('/editor/upload', function() use($app) { ] ])); }); + $app->post('/editor/delete-file', function() use($app) { $app->response()['Content-type'] = 'application/json'; $app->response()->body(json_encode(['result'=>'deleted'])); @@ -33,6 +54,12 @@ $app->get('/editor/oembed', function() use($app) { $app->response()->body($json); }); +$app->post('/editor/test-login', function() use($app) { + $logged_in = array_key_exists('user_id', $_SESSION); + $app->response()['Content-type'] = 'application/json'; + $app->response()->body(json_encode(['logged_in'=>$logged_in])); +}); + // $app->get('/appcache.manifest', function() use($app) { // $content = partial('partials/appcache'); |