Browse Source

better error messages

pull/108/head
Aaron Parecki 6 years ago
parent
commit
136c1826dd
No known key found for this signature in database GPG Key ID: 276C2817346D6056
  1. 24
      controllers/controllers.php
  2. 7
      views/email.php
  3. 4
      views/event.php
  4. 4
      views/new-bookmark.php
  5. 4
      views/new-code.php
  6. 4
      views/new-favorite.php
  7. 4
      views/new-flight.php
  8. 4
      views/new-itinerary.php
  9. 20
      views/new-post.php
  10. 4
      views/new-repost.php
  11. 4
      views/review.php

24
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
));
}

7
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>

4
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">

4
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">

4
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">

4
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">

4
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">

4
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">

20
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');
}

4
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">

4
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">

Loading…
Cancel
Save