diff options
| author | Aaron Parecki <aaron@parecki.com> | 2014-05-25 22:23:51 -0700 | 
|---|---|---|
| committer | Aaron Parecki <aaron@parecki.com> | 2014-05-25 22:23:51 -0700 | 
| commit | 9ff3e59193a9e300860c58ae1e65a4c55b0d21b0 (patch) | |
| tree | 51cb4f8038b5cf7c0776f75e287dc0d0131d38b1 /controllers/controllers.php | |
| parent | a3701e1e4f248ddb2e9fda275e55febecadc32cc (diff) | |
removes top nav bar from design. new logo. adds a mechanism to add the post interface to your home screen.
Diffstat (limited to 'controllers/controllers.php')
| -rw-r--r-- | controllers/controllers.php | 41 | 
1 files changed, 41 insertions, 0 deletions
| diff --git a/controllers/controllers.php b/controllers/controllers.php index 3ff111e..5b28bb8 100644 --- a/controllers/controllers.php +++ b/controllers/controllers.php @@ -63,6 +63,47 @@ $app->get('/docs', function() use($app) {    $app->response()->body($html);  }); +$app->get('/add-to-home', function() use($app) { +  $params = $app->request()->params(); + +  if(array_key_exists('token', $params) && !session('add-to-home-started')) { + +    // Verify the token and sign the user in +    try { +      $data = JWT::decode($params['token'], Config::$jwtSecret); +      $_SESSION['user_id'] = $data->user_id; +      $_SESSION['me'] = $data->me; +      $app->redirect('/new', 301); +    } catch(DomainException $e) { +      header('X-Error: DomainException'); +      $app->redirect('/', 301); +    } catch(UnexpectedValueException $e) { +      header('X-Error: UnexpectedValueException'); +      $app->redirect('/', 301); +    } + +  } else { + +    if($user=require_login($app)) { +      if(array_key_exists('start', $params)) { +        $_SESSION['add-to-home-started'] = true; +         +        $token = JWT::encode(array( +          'user_id' => $_SESSION['user_id'], +          'me' => $_SESSION['me'], +          'created_at' => time() +        ), Config::$jwtSecret); + +        $app->redirect('/add-to-home?token='.$token, 301); +      } else { +        unset($_SESSION['add-to-home-started']); +        $html = render('add-to-home', array('title' => 'Quill')); +        $app->response()->body($html); +      } +    } +  } +}); +  $app->post('/micropub/post', function() use($app) {    if($user=require_login($app)) {      $params = $app->request()->params(); | 
