Notes created via the micropub client can now have associated places
Squashed commit of the following: commit d98a19ac59d29540f9eeca473013da4e52ad99eb Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Wed Oct 5 16:09:33 2016 +0100 Get places working again, location info will add a place to a note commit 98ec16174cb4431e6e0e13f5f1d3303ceafcd7b1 Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Wed Oct 5 16:08:32 2016 +0100 gulp build assets from js commit 2e7e50a6f6f7f8b129bb472d92a38801575020a8 Author: Jonny Barnes <jonny@jonnybarnes.uk> Date: Wed Oct 5 16:07:21 2016 +0100 Use full URIs instead of slugs for places
This commit is contained in:
parent
d924f9916e
commit
ac7f002293
8 changed files with 33 additions and 22 deletions
|
@ -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
|
||||
//that’s the app’s 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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue