Merge branch 'release/0.0.13.5'

This commit is contained in:
Jonny Barnes 2016-10-05 16:17:28 +01:00
commit 04e6744806
11 changed files with 38 additions and 34 deletions

View file

@ -166,17 +166,11 @@ class MicropubClientController extends Controller
];
}
}
if ($request->input('confirmlocation')) {
$latLng = $request->input('location');
$geoURL = 'geo:' . str_replace(' ', '', $latLng);
$multipart[] = [
'name' => 'location',
'contents' => $geoURL,
];
if ($request->input('address') != '') {
if ($request->input('location')) {
if ($request->input('location') !== 'no-location') {
$multipart[] = [
'name' => 'place_name',
'contents' => $request->input('address'),
'name' => 'location',
'contents' => $request->input('location'),
];
}
}
@ -319,7 +313,6 @@ class MicropubClientController extends Controller
return response()->json([
'error' => true,
'error_description' => 'The endpoint returned a non-good response',
'error_stack' => $e->getMessage()
], 400);
}

View file

@ -118,7 +118,7 @@ class MicropubController extends Controller
return response()->json([
'response' => 'error',
'error' => 'invalid_token',
'error_description' => 'The provided token did not pass validation'
'error_description' => 'The provided token did not pass validation',
], 400);
}
//we have a valid token, is `syndicate-to` set?
@ -149,6 +149,9 @@ class MicropubController extends Controller
);
$distance = (count($matches[0]) == 3) ? 100 * $matches[0][2] : 1000;
$places = Place::near($matches[0][0], $matches[0][1], $distance);
foreach ($places as $place) {
$place->uri = config('app.url') . '/place/' . $place->slug;
}
return response()->json([
'response' => 'places',

View file

@ -48,14 +48,8 @@ class AppServiceProvider extends ServiceProvider
//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']);
session(['token' => 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJtZSI6Imh0dHBzOlwvXC9qb25ueWJhcm5lcy5sb2NhbGhvc3QiLCJjbGllbnRfaWQiOiJodHRwczpcL1wvam9ubnliYXJuZXMubG9jYWxob3N0XC9ub3Rlc1wvbmV3Iiwic2NvcGUiOiJwb3N0IiwiZGF0ZV9pc3N1ZWQiOjE0NzU1MTI0NDgsIm5vbmNlIjoiYzE0MzNmNzg5ZTY4Y2M1OSJ9.7Bj9yLnWJOyVre8BPihAom2G0MEsmS3tIUraDI-GRNg']);
}
}

View file

@ -22,14 +22,14 @@ class NoteService
if ($request->header('Content-Type') == 'application/json') {
$content = $request->input('properties.content')[0];
$inReplyTo = $request->input('properties.in-reply-to')[0];
$placeSlug = $request->input('properties.location');
if (is_array($placeSlug)) {
$placeSlug = $placeSlug[0];
$place = $request->input('properties.location');
if (is_array($place)) {
$place = $place[0];
}
} else {
$content = $request->input('content');
$inReplyTo = $request->input('in-reply-to');
$placeSlug = $request->input('location');
$place = $request->input('location');
}
$note = Note::create(
@ -40,10 +40,24 @@ class NoteService
]
);
if ($placeSlug !== null && $placeSlug !== 'no-location') {
$place = Place::where('slug', '=', $placeSlug)->first();
$note->place()->associate($place);
$note->save();
if ($place !== null && $place !== 'no-location') {
if (substr($place, 0, strlen(config('app.url'))) == config('app.url')) {
//uri of form http://host/place/slug, we want slug so chop off start
//thats the apps url plus `/place/`
$slug = mb_substr($place, mb_strlen(config('app.url')) + 7);
$placeModel = Place::where('slug', '=', $slug)->first();
$note->place()->associate($placeModel);
$note->save();
}
if (substr($place, 0, 4) == 'geo:') {
preg_match_all(
'/([0-9\.\-]+)/',
$place,
$matches
);
$note->location = $matches[0][0] . ', ' . $matches[0][1];
$note->save();
}
}
//add images to media library

View file

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

View file

@ -1,5 +1,8 @@
# Changelog
## Version 0.0.13.5 (2016-10-05)
- Places can now be added to a new note created via micropub
## 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

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

@ -34,8 +34,8 @@ function addPlacesMap(latitude, longitude, uncertainty) {
for (i = 0; i < j.places.length; ++i) {
var latlng = parseLocation(j.places[i].location);
var name = j.places[i].name;
var slug = j.places[i].slug;
places.push([name, slug, latlng[0], latlng[1]]);
var uri = j.places[i].uri;
places.push([name, uri, latlng[0], latlng[1]]);
}
//add a map with the nearby places
addMap(latitude, longitude, places);