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.

51 lines
1.3 KiB

  1. <?php
  2. $app->get('/pebble', function() use($app) {
  3. $html = render('pebble', array(
  4. 'title' => 'Teacup for Pebble'
  5. ));
  6. $app->response()->body($html);
  7. });
  8. $app->get('/pebble/settings', function() use($app) {
  9. $html = render('pebble-settings-login', array(
  10. 'title' => 'Log In',
  11. 'footer' => false
  12. ));
  13. $app->response()->body($html);
  14. });
  15. $app->get('/pebble/settings/finished', function() use($app) {
  16. if($user=require_login($app)) {
  17. $token = JWT::encode(array(
  18. 'user_id' => $_SESSION['user_id'],
  19. 'me' => $_SESSION['me'],
  20. 'created_at' => time()
  21. ), Config::$jwtSecret);
  22. $html = render('pebble-settings', array(
  23. 'title' => 'Pebble Settings',
  24. 'token' => $token
  25. ));
  26. $app->response()->body($html);
  27. }
  28. });
  29. $app->get('/pebble/options.json', function() use($app) {
  30. // TODO: if a token is provided, return the user's custom list
  31. $app->response()['Content-Type'] = 'application/json';
  32. $app->response()->body(json_encode(array(
  33. 'sections' => array(
  34. array(
  35. 'title' => 'Caffeine',
  36. 'items' => array_map(function($e){ return array('title'=>$e, 'type'=>'drink'); }, caffeine_options())
  37. ),
  38. array(
  39. 'title' => 'Alcohol',
  40. 'items' => array_map(function($e){ return array('title'=>$e, 'type'=>'drink'); }, alcohol_options())
  41. )
  42. )
  43. )));
  44. });