Merge branch 'release/0.0.13.4'

This commit is contained in:
Jonny Barnes 2016-10-03 16:51:58 +01:00
commit 4beb9feae4
10 changed files with 30 additions and 15 deletions

View file

@ -309,7 +309,7 @@ class MicropubClientController extends Controller
try { try {
$query = 'geo:' . $latitude . ',' . $longitude; $query = 'geo:' . $latitude . ',' . $longitude;
if ($request->input('u') !== null) { if ($request->input('u') !== null) {
$query .= ';u=' . $request->input('uncertainty'); $query .= ';u=' . $request->input('u');
} }
$response = $this->guzzleClient->get($micropubEndpoint, [ $response = $this->guzzleClient->get($micropubEndpoint, [
'headers' => ['Authorization' => 'Bearer ' . $token], 'headers' => ['Authorization' => 'Bearer ' . $token],
@ -319,6 +319,7 @@ class MicropubClientController extends Controller
return response()->json([ return response()->json([
'error' => true, 'error' => true,
'error_description' => 'The endpoint returned a non-good response', 'error_description' => 'The endpoint returned a non-good response',
'error_stack' => $e->getMessage()
], 400); ], 400);
} }

View file

@ -115,16 +115,11 @@ class MicropubController extends Controller
$valid = $this->tokenService->validateToken($token); $valid = $this->tokenService->validateToken($token);
if ($valid === null) { if ($valid === null) {
$content = <<<'EOD' return response()->json([
{ 'response' => 'error',
"respose": "error", 'error' => 'invalid_token',
"error": "invalid_token", 'error_description' => 'The provided token did not pass validation'
"error_description": "The provided token did not pass validation" ], 400);
}
EOD;
return (new Response($content, 400))
->header('Content-Type', 'application/json');
} }
//we have a valid token, is `syndicate-to` set? //we have a valid token, is `syndicate-to` set?
if ($request->input('q') === 'syndicate-to') { if ($request->input('q') === 'syndicate-to') {

View file

@ -45,6 +45,18 @@ class AppServiceProvider extends ServiceProvider
$note->tags()->attach($tagsToAdd); $note->tags()->attach($tagsToAdd);
} }
}); });
//allow micropub use in development
if (env('APP_DEBUG') == true) {
$tokenService = new \App\Services\TokenService();
$token = $tokenService->getNewToken([
'me' => 'https://jonnybarnes.localhost',
'client_id' => 'https://jonnybarnes.localhost/notes/new',
'scope' => 'post'
]);
session(['me' => 'https://jonnybarnes.localhost']);
session(['token' => 'abc123']);
}
} }
/** /**

View file

@ -38,6 +38,9 @@ class TokenService
*/ */
public function validateToken($token) public function validateToken($token)
{ {
if (env('APP_DEBUG') == true) {
return true;
}
$signer = new Sha256(); $signer = new Sha256();
try { try {
$token = (new Parser())->parse((string) $token); $token = (new Parser())->parse((string) $token);

View file

@ -1,5 +1,9 @@
# Changelog # Changelog
## Version 0.0.13.4 (2016-10-03)
- Better working code for places in newnote.js (issue#21)
* In aid of this add ability to run micropub code locally
## Version 0.0.13.3 (2016-10-03) ## Version 0.0.13.3 (2016-10-03)
- Use the actual results of places in `newnote.js` (issue#21) - Use the actual results of places in `newnote.js` (issue#21)

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

Binary file not shown.

Binary file not shown.

View file

@ -28,11 +28,11 @@ function addPlacesMap(latitude, longitude, uncertainty) {
alertify.reset(); alertify.reset();
alertify.error(j.error_description); alertify.error(j.error_description);
} }
if (j.length > 0) { if (j.places.length > 0) {
var i; var i;
var places = []; var places = [];
for (i = 0; i < j.places.length; ++i) { for (i = 0; i < j.places.length; ++i) {
var latlng = parseLocation(j[i].location); var latlng = parseLocation(j.places[i].location);
var name = j.places[i].name; var name = j.places[i].name;
var slug = j.places[i].slug; var slug = j.places[i].slug;
places.push([name, slug, latlng[0], latlng[1]]); places.push([name, slug, latlng[0], latlng[1]]);