From d62b497b401a767c9a8db153726e0c7e1f2c474e Mon Sep 17 00:00:00 2001 From: Aaron Parecki Date: Wed, 10 Feb 2016 18:36:55 -0800 Subject: add interface for posting travel itinerary --- controllers/controllers.php | 45 +++++++++++++++++++++++++++++++++++---------- 1 file changed, 35 insertions(+), 10 deletions(-) (limited to 'controllers') diff --git a/controllers/controllers.php b/controllers/controllers.php index 70e84cf..0b63699 100644 --- a/controllers/controllers.php +++ b/controllers/controllers.php @@ -130,6 +130,18 @@ $app->get('/favorite', function() use($app) { } }); +$app->get('/itinerary', function() use($app) { + if($user=require_login($app)) { + $params = $app->request()->params(); + + $html = render('new-itinerary', array( + 'title' => 'Itinerary', + 'authorizing' => false + )); + $app->response()->body($html); + } +}); + $app->get('/photo', function() use($app) { if($user=require_login($app)) { $params = $app->request()->params(); @@ -217,7 +229,7 @@ $app->get('/add-to-home', function() use($app) { 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'], @@ -260,7 +272,7 @@ $app->get('/email', function() use($app) { 'test_response' => $test_response, 'user' => $user )); - $app->response()->body($html); + $app->response()->body($html); } }); @@ -294,7 +306,7 @@ $app->get('/favorite-popup', function() use($app) { $params = $app->request()->params(); $html = $app->render('favorite-popup.php', array( - 'url' => $params['url'], + 'url' => $params['url'], 'token' => $params['token'] )); $app->response()->body($html); @@ -339,7 +351,7 @@ function create_favorite(&$user, $url) { if($user->twitter_access_token && preg_match('/https?:\/\/(?:www\.)?twitter\.com\/[^\/]+\/status(?:es)?\/(\d+)/', $url, $match)) { $tweet_id = $match[1]; - $twitter = new \TwitterOAuth\Api(Config::$twitterClientID, Config::$twitterClientSecret, + $twitter = new \TwitterOAuth\Api(Config::$twitterClientID, Config::$twitterClientSecret, $user->twitter_access_token, $user->twitter_token_secret); $result = $twitter->post('favorites/create', array( 'id' => $tweet_id @@ -373,7 +385,7 @@ function create_repost(&$user, $url) { if($user->twitter_access_token && preg_match('/https?:\/\/(?:www\.)?twitter\.com\/[^\/]+\/status(?:es)?\/(\d+)/', $url, $match)) { $tweet_id = $match[1]; - $twitter = new \TwitterOAuth\Api(Config::$twitterClientID, Config::$twitterClientSecret, + $twitter = new \TwitterOAuth\Api(Config::$twitterClientID, Config::$twitterClientSecret, $user->twitter_access_token, $user->twitter_token_secret); $result = $twitter->post('statuses/retweet/'.$tweet_id); } @@ -390,8 +402,8 @@ $app->get('/favorite.js', function() use($app) { $r = create_favorite($user, $params['url']); $app->response()->body($app->render('favorite-js.php', array( - 'url' => $params['url'], - 'like_url' => $r['location'], + 'url' => $params['url'], + 'like_url' => $r['location'], 'error' => $r['error'], // 'facebook_id' => $facebook_id ))); @@ -464,6 +476,20 @@ $app->post('/repost', function() use($app) { } }); +$app->post('/itinerary', function() use($app) { + if($user=require_login($app)) { + $params = $app->request()->params(); + + $r = micropub_post_for_user($user, json_decode($params['data'], true), null, true); + + $app->response()->body(json_encode(array( + 'location' => $r['location'], + 'error' => $r['error'], + 'response' => $r['response'] + ))); + } +}); + $app->get('/micropub/syndications', function() use($app) { if($user=require_login($app)) { $data = get_syndication_targets($user); @@ -545,7 +571,7 @@ $app->get('/auth/twitter', function() use($app) { // If there is an existing Twitter token, check if it is valid // Otherwise, generate a Twitter login link $twitter_login_url = false; - $twitter = new \TwitterOAuth\Api(Config::$twitterClientID, Config::$twitterClientSecret, + $twitter = new \TwitterOAuth\Api(Config::$twitterClientID, Config::$twitterClientSecret, $user->twitter_access_token, $user->twitter_token_secret); if(array_key_exists('login', $params)) { @@ -582,7 +608,7 @@ $app->get('/auth/twitter/callback', function() use($app) { if($user=require_login($app)) { $params = $app->request()->params(); - $twitter = new \TwitterOAuth\Api(Config::$twitterClientID, Config::$twitterClientSecret, + $twitter = new \TwitterOAuth\Api(Config::$twitterClientID, Config::$twitterClientSecret, $_SESSION['twitter_auth']['oauth_token'], $_SESSION['twitter_auth']['oauth_token_secret']); $credentials = $twitter->getAccessToken($params['oauth_verifier']); @@ -634,4 +660,3 @@ $app->get('/auth/instagram/callback', function() use($app) { $app->redirect('/settings'); } }); - -- cgit v1.2.3 From 704241a3a4f3480eb87260aef9fca8f1ce00e638 Mon Sep 17 00:00:00 2001 From: Aaron Parecki Date: Wed, 10 Feb 2016 18:41:28 -0800 Subject: add dashboard with links to all post types --- controllers/controllers.php | 10 ++++++++++ views/dashboard.php | 15 +++++++++++++++ views/partials/header.php | 6 +++--- 3 files changed, 28 insertions(+), 3 deletions(-) create mode 100644 views/dashboard.php (limited to 'controllers') diff --git a/controllers/controllers.php b/controllers/controllers.php index 0b63699..ef619a6 100644 --- a/controllers/controllers.php +++ b/controllers/controllers.php @@ -41,6 +41,16 @@ function generate_login_token() { ), Config::$jwtSecret); } +$app->get('/dashboard', function() use($app) { + if($user=require_login($app)) { + $html = render('dashboard', array( + 'title' => 'Dashboard', + 'authorizing' => false + )); + $app->response()->body($html); + } +}); + $app->get('/new', function() use($app) { if($user=require_login($app)) { $params = $app->request()->params(); diff --git a/views/dashboard.php b/views/dashboard.php new file mode 100644 index 0000000..3c29f92 --- /dev/null +++ b/views/dashboard.php @@ -0,0 +1,15 @@ +
+ + + + +
diff --git a/views/partials/header.php b/views/partials/header.php index ef9f15a..4243557 100644 --- a/views/partials/header.php +++ b/views/partials/header.php @@ -1,4 +1,4 @@
- - Quill -
\ No newline at end of file + + Quill + -- cgit v1.2.3