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.

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