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.

44 lines
1.2 KiB

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