diff options
author | Aaron Parecki <aaron@parecki.com> | 2018-08-01 19:20:53 -0700 |
---|---|---|
committer | Aaron Parecki <aaron@parecki.com> | 2018-08-01 19:20:53 -0700 |
commit | 136c1826dd64d9d7ed368004312b4f5fcd7f2ed9 (patch) | |
tree | b8aba37178691f71be2f5c75030a2d5c8dece54a | |
parent | 4ed2513ded964eb99d460755ed2e312141426d84 (diff) |
better error messages
-rw-r--r-- | controllers/controllers.php | 24 | ||||
-rw-r--r-- | views/email.php | 9 | ||||
-rw-r--r-- | views/event.php | 4 | ||||
-rw-r--r-- | views/new-bookmark.php | 4 | ||||
-rw-r--r-- | views/new-code.php | 4 | ||||
-rw-r--r-- | views/new-favorite.php | 4 | ||||
-rw-r--r-- | views/new-flight.php | 4 | ||||
-rw-r--r-- | views/new-itinerary.php | 4 | ||||
-rw-r--r-- | views/new-post.php | 20 | ||||
-rw-r--r-- | views/new-repost.php | 4 | ||||
-rw-r--r-- | views/review.php | 6 |
11 files changed, 26 insertions, 61 deletions
diff --git a/controllers/controllers.php b/controllers/controllers.php index 228f6fb..2cbe56e 100644 --- a/controllers/controllers.php +++ b/controllers/controllers.php @@ -63,17 +63,6 @@ $app->get('/new', function() use($app) { if(array_key_exists('reply', $params)) $in_reply_to = $params['reply']; - $test_response = ''; - if($user->last_micropub_response) { - try { - if(@json_decode($user->last_micropub_response)) { - $d = json_decode($user->last_micropub_response); - $test_response = $d->response; - } - } catch(Exception $e) { - } - } - render('new-post', array( 'title' => 'New Post', 'in_reply_to' => $in_reply_to, @@ -83,7 +72,6 @@ $app->get('/new', function() use($app) { 'micropub_access_token' => $user->micropub_access_token, 'response_date' => $user->last_micropub_response_date, 'syndication_targets' => json_decode($user->syndication_targets, true), - 'test_response' => $test_response, 'location_enabled' => $user->location_enabled, 'user' => $user, 'authorizing' => false @@ -452,17 +440,6 @@ $app->get('/add-to-home', function() use($app) { $app->get('/email', function() use($app) { if($user=require_login($app)) { - $test_response = ''; - if($user->last_micropub_response) { - try { - if(@json_decode($user->last_micropub_response)) { - $d = json_decode($user->last_micropub_response); - $test_response = $d->response; - } - } catch(Exception $e) { - } - } - if(!$user->email_username) { $host = parse_url($user->url, PHP_URL_HOST); $user->email_username = $host . '.' . rand(100000,999999); @@ -472,7 +449,6 @@ $app->get('/email', function() use($app) { render('email', array( 'title' => 'Post-by-Email', 'micropub_endpoint' => $user->micropub_endpoint, - 'test_response' => $test_response, 'user' => $user )); } diff --git a/views/email.php b/views/email.php index 1f97905..e3464f6 100644 --- a/views/email.php +++ b/views/email.php @@ -19,11 +19,4 @@ <p>If you attach a photo to your email or MMS, it will be sent to your Micropub endpoint. (Only one photo is currently supported.)</p> </div> - <div> - <?php if($this->test_response): ?> - <h4>Last response from your Micropub endpoint</h4> - <pre id="test_response" style="width: 100%; min-height: 280px;"><?= htmlspecialchars($this->test_response) ?></pre> - <?php endif; ?> - </div> - -</div>
\ No newline at end of file +</div> diff --git a/views/event.php b/views/event.php index 3c26f73..81742d8 100644 --- a/views/event.php +++ b/views/event.php @@ -2,8 +2,8 @@ <?= partial('partials/header') ?> <div style="clear: both;"> - <div class="alert alert-success hidden" id="test_success"><strong>Success! We found a Location header in the response!</strong><br>Your post should be on your website now!<br><a href="" id="post_href">View your post</a></div> - <div class="alert alert-danger hidden" id="test_error"><strong>Your endpoint did not return a Location header.</strong><br>See <a href="/creating-a-micropub-endpoint">Creating a Micropub Endpoint</a> for more information.</div> + <div class="alert alert-success hidden" id="test_success"><strong>Success! </strong><a href="" id="post_href">View your post</a></div> + <div class="alert alert-danger hidden" id="test_error"><strong>Something went wrong!</strong><br>Your Micropub endpoint indicated that something went wrong creating the post.</div> </div> <form role="form" style="margin-top: 20px;" id="note_form"> diff --git a/views/new-bookmark.php b/views/new-bookmark.php index 0181dae..f50801a 100644 --- a/views/new-bookmark.php +++ b/views/new-bookmark.php @@ -6,8 +6,8 @@ </div> <div style="clear: both;"> - <div class="alert alert-success hidden" id="test_success"><strong>Success! We found a Location header in the response!</strong><br>Your post should be on your website now!<br><a href="" id="post_href">View your post</a></div> - <div class="alert alert-danger hidden" id="test_error"><strong>Your endpoint did not return a Location header.</strong><br>See <a href="/creating-a-micropub-endpoint">Creating a Micropub Endpoint</a> for more information.</div> + <div class="alert alert-success hidden" id="test_success"><strong>Success! </strong><a href="" id="post_href">View your post</a></div> + <div class="alert alert-danger hidden" id="test_error"><strong>Something went wrong!</strong><br>Your Micropub endpoint indicated that something went wrong creating the post.</div> </div> <form role="form" style="margin-top: 20px;" id="note_form"> diff --git a/views/new-code.php b/views/new-code.php index 96a93d3..4201816 100644 --- a/views/new-code.php +++ b/views/new-code.php @@ -2,8 +2,8 @@ <?= partial('partials/header') ?> <div style="clear: both;" class="notice-pad"> - <div class="alert alert-success hidden" id="test_success"><strong>Success!</strong><br>Your post should be on your website now!<br><a href="" id="post_href">View your post</a></div> - <div class="alert alert-danger hidden" id="test_error"><strong>Your endpoint did not return a Location header.</strong><br>See <a href="/creating-a-micropub-endpoint">Creating a Micropub Endpoint</a> for more information.</div> + <div class="alert alert-success hidden" id="test_success"><strong>Success! </strong><a href="" id="post_href">View your post</a></div> + <div class="alert alert-danger hidden" id="test_error"><strong>Something went wrong!</strong><br>Your Micropub endpoint indicated that something went wrong creating the post.</div> </div> <form role="form" style="margin-top: 20px;" id="note_form"> diff --git a/views/new-favorite.php b/views/new-favorite.php index 72de412..f457e3b 100644 --- a/views/new-favorite.php +++ b/views/new-favorite.php @@ -2,8 +2,8 @@ <?= partial('partials/header') ?> <div style="clear: both;" class="notice-pad"> - <div class="alert alert-success hidden" id="test_success"><strong>Success!</strong><br>Your post should be on your website now!<br><a href="" id="post_href">View your post</a></div> - <div class="alert alert-danger hidden" id="test_error"><strong>Your endpoint did not return a Location header.</strong><br>See <a href="/creating-a-micropub-endpoint">Creating a Micropub Endpoint</a> for more information.</div> + <div class="alert alert-success hidden" id="test_success"><strong>Success! </strong><a href="" id="post_href">View your post</a></div> + <div class="alert alert-danger hidden" id="test_error"><strong>Something went wrong!</strong><br>Your Micropub endpoint indicated that something went wrong creating the post.</div> </div> <form role="form" style="margin-top: 20px;" id="note_form"> diff --git a/views/new-flight.php b/views/new-flight.php index 031b86f..da3f6bf 100644 --- a/views/new-flight.php +++ b/views/new-flight.php @@ -2,8 +2,8 @@ <?= partial('partials/header') ?> <div style="clear: both;" class="notice-pad"> - <div class="alert alert-success hidden" id="test_success"><strong>Success!</strong><br>Your checkin should be on your website now!<br><a href="" id="post_href">View your post</a></div> - <div class="alert alert-danger hidden" id="test_error"><strong>Your endpoint did not return a Location header.</strong><br>See <a href="/creating-a-micropub-endpoint">Creating a Micropub Endpoint</a> for more information.</div> + <div class="alert alert-success hidden" id="test_success"><strong>Success! </strong><a href="" id="post_href">View your post</a></div> + <div class="alert alert-danger hidden" id="test_error"><strong>Something went wrong!</strong><br>Your Micropub endpoint indicated that something went wrong creating the post.</div> </div> <form role="form" style="margin-top: 20px;" id="note_form"> diff --git a/views/new-itinerary.php b/views/new-itinerary.php index 14deb65..e40ec2a 100644 --- a/views/new-itinerary.php +++ b/views/new-itinerary.php @@ -2,8 +2,8 @@ <?= partial('partials/header') ?> <div style="clear: both;" class="notice-pad"> - <div class="alert alert-success hidden" id="test_success"><strong>Success! We found a Location header in the response!</strong><br>Your post should be on your website now!<br><a href="" id="post_href">View your post</a></div> - <div class="alert alert-danger hidden" id="test_error"><strong>Your endpoint did not return a Location header.</strong><br>See <a href="/creating-a-micropub-endpoint">Creating a Micropub Endpoint</a> for more information.</div> + <div class="alert alert-success hidden" id="test_success"><strong>Success! </strong><a href="" id="post_href">View your post</a></div> + <div class="alert alert-danger hidden" id="test_error"><strong>Something went wrong!</strong><br>Your Micropub endpoint indicated that something went wrong creating the post.</div> </div> <form role="form" style="margin-top: 20px;" id="note_form"> diff --git a/views/new-post.php b/views/new-post.php index ec74b28..3455644 100644 --- a/views/new-post.php +++ b/views/new-post.php @@ -117,20 +117,15 @@ <button class="btn btn-success" id="btn_post">Post</button> </form> - <div class="alert alert-success hidden" id="test_success"><strong>Success! We found a Location header in the response!</strong><br>Your post should be on your website now!<br><a href="" id="post_href">View your post</a></div> - <div class="alert alert-danger hidden" id="test_error"><strong>Your endpoint did not return a Location header.</strong><br>See <a href="/creating-a-micropub-endpoint">Creating a Micropub Endpoint</a> for more information.</div> + <div class="alert alert-success hidden" id="test_success"><strong>Success! </strong><a href="" id="post_href">View your post</a></div> + <div class="alert alert-danger hidden" id="test_error"><strong>Something went wrong!</strong><br>Your Micropub endpoint indicated that something went wrong creating the post.</div> - - <div id="last_request_container" style="display: none;"> - <h4>Request made to your Micropub endpoint</h4> - <pre id="test_request" style="width: 100%; min-height: 140px;"></pre> + <div id="test_response_container" class="hidden"> + <h4>Micropub Response</h4> + <p>Below is the response from your Micropub endpoint. This may contain helpful information that can be used to troubleshoot the issue.</p> + <pre id="test_response" style="width: 100%; min-height: 240px;"></pre> </div> - <?php if($this->test_response): ?> - <h4>Last response from your Micropub endpoint <span id="last_response_date">(<?= relative_time($this->response_date) ?>)</span></h4> - <?php endif; ?> - <pre id="test_response" class="<?= $this->test_response ? '' : 'hidden' ?>" style="width: 100%; min-height: 240px;"><?= htmlspecialchars($this->test_response) ?></pre> - <hr> <div style="text-align: right;"> <a href="/add-to-home?start">Add to Home Screen</a> @@ -825,7 +820,8 @@ $(function(){ window.location = response.location; // console.log(response.location); } else { - $("#test_response").html(response.response).removeClass('hidden'); + $("#test_response").html(response.response); + $("#test_response_container").removeClass('hidden'); $("#test_success").addClass('hidden'); $("#test_error").removeClass('hidden'); } diff --git a/views/new-repost.php b/views/new-repost.php index 4ef84db..95cc770 100644 --- a/views/new-repost.php +++ b/views/new-repost.php @@ -2,8 +2,8 @@ <?= partial('partials/header') ?> <div style="clear: both;" class="notice-pad"> - <div class="alert alert-success hidden" id="test_success"><strong>Success!</strong><br>Your post should be on your website now!<br><a href="" id="post_href">View your post</a></div> - <div class="alert alert-danger hidden" id="test_error"><strong>Your endpoint did not return a Location header.</strong><br>See <a href="/creating-a-micropub-endpoint">Creating a Micropub Endpoint</a> for more information.</div> + <div class="alert alert-success hidden" id="test_success"><strong>Success! </strong><a href="" id="post_href">View your post</a></div> + <div class="alert alert-danger hidden" id="test_error"><strong>Something went wrong!</strong><br>Your Micropub endpoint indicated that something went wrong creating the post.</div> </div> <form role="form" style="margin-top: 20px;" id="note_form"> diff --git a/views/review.php b/views/review.php index d364666..f77ffb8 100644 --- a/views/review.php +++ b/views/review.php @@ -2,8 +2,8 @@ <?= partial('partials/header') ?> <div style="clear: both;"> - <div class="alert alert-success hidden" id="post_success"><strong>Success! Your post should be on your website now!</strong><br><a href="" id="post_href">View your post</a></div> - <div class="alert alert-danger hidden" id="post_error"><strong>There was a problem saving your post. Your endpoint did not return a Location header.</strong><br>See <a href="/creating-a-micropub-endpoint">Creating a Micropub Endpoint</a> for more information.</div> + <div class="alert alert-success hidden" id="test_success"><strong>Success! </strong><a href="" id="post_href">View your post</a></div> + <div class="alert alert-danger hidden" id="test_error"><strong>Something went wrong!</strong><br>Your Micropub endpoint indicated that something went wrong creating the post.</div> </div> <form role="form" style="margin-top: 20px;" id="note_form"> @@ -35,7 +35,7 @@ <div class="row review-content hidden"> <div class="col-xs-12"> <div class="form-group"> - <textarea id="review_content" value="" class="form-control" style="height: 4em;" placeholder="Write your review here"></textarea> + <textarea id="review_content" value="" class="form-control" style="height: 4em;" placeholder="Write your review here"></textarea> <div id="review-html-note"> <input type="checkbox" id="review_is_html" value="1"> Post as HTML </div> |