Mirror of Quill
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

41 lines
1.3 KiB

  1. <?php
  2. $app->get('/editor', function() use($app) {
  3. // Don't require login because appcache caches the whole page
  4. $html = $app->render('editor.php');
  5. $app->response()->body($html);
  6. });
  7. $app->post('/editor/upload', function() use($app) {
  8. // Fake a file uploader by echo'ing back the data URI
  9. $fn = $_FILES['files']['tmp_name'][0];
  10. $imageData = base64_encode(file_get_contents($fn));
  11. $src = 'data: '.mime_content_type($fn).';base64,'.$imageData;
  12. $app->response()['Content-type'] = 'application/json';
  13. $app->response()->body(json_encode([
  14. 'files' => [
  15. [
  16. 'url'=>$src
  17. ]
  18. ]
  19. ]));
  20. });
  21. $app->post('/editor/delete-file', function() use($app) {
  22. $app->response()['Content-type'] = 'application/json';
  23. $app->response()->body(json_encode(['result'=>'deleted']));
  24. });
  25. $app->get('/editor/oembed', function() use($app) {
  26. $url = 'http://medium.iframe.ly/api/oembed?iframe=1&url='.urlencode($app->request()->params()['url']);
  27. $json = file_get_contents($url);
  28. $app->response()['Content-type'] = 'application/json';
  29. $app->response()->body($json);
  30. });
  31. // $app->get('/appcache.manifest', function() use($app) {
  32. // $content = partial('partials/appcache');
  33. // $app->response()['Content-type'] = 'text/cache-manifest';
  34. // $app->response()->body($content);
  35. // });