|
|
@ -58,46 +58,6 @@ $app->get('/new', function() use($app) { |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
$app->get('/pebble/settings', function() use($app) { |
|
|
|
$html = render('pebble-settings-login', array( |
|
|
|
'title' => 'Log In' |
|
|
|
)); |
|
|
|
$app->response()->body($html); |
|
|
|
}); |
|
|
|
|
|
|
|
$app->get('/pebble/settings/finished', function() use($app) { |
|
|
|
if($user=require_login($app)) { |
|
|
|
$token = JWT::encode(array( |
|
|
|
'user_id' => $_SESSION['user_id'], |
|
|
|
'me' => $_SESSION['me'], |
|
|
|
'created_at' => time() |
|
|
|
), Config::$jwtSecret); |
|
|
|
|
|
|
|
$html = render('pebble-settings', array( |
|
|
|
'title' => 'Pebble Settings', |
|
|
|
'token' => $token |
|
|
|
)); |
|
|
|
$app->response()->body($html); |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
|
$app->get('/pebble/options.json', function() use($app) { |
|
|
|
$app->response()['Content-Type'] = 'application/json'; |
|
|
|
$app->response()->body(json_encode(array( |
|
|
|
'sections' => array( |
|
|
|
array( |
|
|
|
'title' => 'Caffeine', |
|
|
|
'items' => array_map(function($e){ return array('title'=>$e); }, caffeine_options()) |
|
|
|
), |
|
|
|
array( |
|
|
|
'title' => 'Alcohol', |
|
|
|
'items' => array_map(function($e){ return array('title'=>$e); }, alcohol_options()) |
|
|
|
) |
|
|
|
) |
|
|
|
))); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
$app->post('/prefs', function() use($app) { |
|
|
|
if($user=require_login($app)) { |
|
|
|
$params = $app->request()->params(); |
|
|
@ -193,6 +153,9 @@ $app->post('/post', function() use($app) { |
|
|
|
if(k($params, 'drank')) { |
|
|
|
$entry->content = $params['drank']; |
|
|
|
$type = 'drink'; |
|
|
|
} elseif(k($params, 'drink')) { |
|
|
|
$entry->content = $params['drink']; |
|
|
|
$type = 'drink'; |
|
|
|
} elseif(k($params, 'custom_drank')) { |
|
|
|
$entry->content = $params['custom_drank']; |
|
|
|
$type = 'drink'; |
|
|
|