Browse Source

better error messages

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

+ 0
- 24
controllers/controllers.php View File

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

+ 1
- 8
views/email.php View File

@ -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>
</div>

+ 2
- 2
views/event.php View File

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

+ 2
- 2
views/new-bookmark.php View File

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

+ 2
- 2
views/new-code.php View File

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

+ 2
- 2
views/new-favorite.php View File

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

+ 2
- 2
views/new-flight.php View File

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

+ 2
- 2
views/new-itinerary.php View File

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

+ 8
- 12
views/new-post.php View File

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

+ 2
- 2
views/new-repost.php View File

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

+ 3
- 3
views/review.php View File

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

Loading…
Cancel
Save