Merge branch 'release/0.0.14'

This commit is contained in:
Jonny Barnes 2016-10-07 15:34:39 +01:00
commit 4a6ff98690
13 changed files with 163 additions and 129 deletions

View file

@ -224,7 +224,7 @@ class MicropubClientController extends Controller
}
return response()->json([
'url' => $place,
'uri' => $place,
'name' => $request->input('place-name'),
'latitude' => $request->input('place-latitude'),
'longitude' => $request->input('place-longitude'),

View file

@ -150,7 +150,7 @@ 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;
$place->uri = config('app.url') . '/places/' . $place->slug;
}
return response()->json([

View file

@ -141,10 +141,12 @@ class NotesController extends Controller
$note->placeLink = '/places/' . $note->place->slug;
}
$note->photoURLs = [];
foreach ($note->getMedia() as $photo) {
$note->photoURLs[] = $photo->getUrl();
$photoURLs = [];
$photos = $note->getMedia();
foreach ($photos as $photo) {
$photoURLs[] = $photo->getUrl();
}
$note->photoURLs = $photoURLs;
return view('singlenote', [
'note' => $note,

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];
$place = $request->input('properties.location');
if (is_array($place)) {
$place = $place[0];
$location = $request->input('properties.location');
if (is_array($location)) {
$location = $location[0];
}
} else {
$content = $request->input('content');
$inReplyTo = $request->input('in-reply-to');
$place = $request->input('location');
$location = $request->input('location');
}
$note = Note::create(
@ -40,19 +40,19 @@ class NoteService
]
);
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);
if ($location !== null && $location !== 'no-location') {
if (substr($location, 0, strlen(config('app.url'))) == config('app.url')) {
//uri of form http://host/places/slug, we want slug so chop off start
//thats the apps url plus `/places/`
$slug = mb_substr($location, mb_strlen(config('app.url')) + 8);
$place = Place::where('slug', '=', $slug)->first();
$note->place()->associate($place);
$note->save();
}
if (substr($place, 0, 4) == 'geo:') {
if (substr($location, 0, 4) == 'geo:') {
preg_match_all(
'/([0-9\.\-]+)/',
$place,
$location,
$matches
);
$note->location = $matches[0][0] . ', ' . $matches[0][1];
@ -64,7 +64,7 @@ class NoteService
if ($request->hasFile('photo')) {
$files = $request->file('photo');
foreach ($files as $file) {
$note->addMedia($file)->toMediaLibrary('images', 's3');
$note->addMedia($file)->toCollectionOnDisk('images', 's3');
}
}

View file

@ -1,5 +1,10 @@
# Changelog
## Version 0.0.14 (2016-10-07)
- Fix image upload for notes
- Allow co-ordinates to be sent by the client as a geo: URI
- Allow endpoint to process geo: URIs for location
## Version 0.0.13.9 (2016-10-06)
- Hotfix, add missing semi-colon

174
composer.lock generated
View file

@ -58,16 +58,16 @@
},
{
"name": "aws/aws-sdk-php",
"version": "3.19.12",
"version": "3.19.13",
"source": {
"type": "git",
"url": "https://github.com/aws/aws-sdk-php.git",
"reference": "5d5697c7bc9ab22ce718afb51e5496d0c5cb8778"
"reference": "57b0efed8fcf5d8c854bc1c26cf4a685af9108d9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/5d5697c7bc9ab22ce718afb51e5496d0c5cb8778",
"reference": "5d5697c7bc9ab22ce718afb51e5496d0c5cb8778",
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/57b0efed8fcf5d8c854bc1c26cf4a685af9108d9",
"reference": "57b0efed8fcf5d8c854bc1c26cf4a685af9108d9",
"shasum": ""
},
"require": {
@ -134,7 +134,7 @@
"s3",
"sdk"
],
"time": "2016-09-29 21:07:49"
"time": "2016-10-06 21:17:44"
},
{
"name": "barnabywalters/mf-cleaner",
@ -1532,16 +1532,16 @@
},
{
"name": "laravel/framework",
"version": "v5.3.15",
"version": "v5.3.17",
"source": {
"type": "git",
"url": "https://github.com/laravel/framework.git",
"reference": "f034a02f38db77d4b0b3e89942394cae456a627f"
"reference": "67fb3e638eb4d862279f50642101910163d14e61"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/laravel/framework/zipball/f034a02f38db77d4b0b3e89942394cae456a627f",
"reference": "f034a02f38db77d4b0b3e89942394cae456a627f",
"url": "https://api.github.com/repos/laravel/framework/zipball/67fb3e638eb4d862279f50642101910163d14e61",
"reference": "67fb3e638eb4d862279f50642101910163d14e61",
"shasum": ""
},
"require": {
@ -1656,7 +1656,7 @@
"framework",
"laravel"
],
"time": "2016-09-29 22:13:17"
"time": "2016-10-06 18:06:32"
},
{
"name": "lcobucci/jwt",
@ -2891,16 +2891,16 @@
},
{
"name": "spatie/laravel-medialibrary",
"version": "4.9.1",
"version": "4.9.2",
"source": {
"type": "git",
"url": "https://github.com/spatie/laravel-medialibrary.git",
"reference": "bb8786724f87c2d187897809849b7dc79a84a4d9"
"reference": "8799c17ca99c49718d7effe49de06b55117e8662"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/spatie/laravel-medialibrary/zipball/bb8786724f87c2d187897809849b7dc79a84a4d9",
"reference": "bb8786724f87c2d187897809849b7dc79a84a4d9",
"url": "https://api.github.com/repos/spatie/laravel-medialibrary/zipball/8799c17ca99c49718d7effe49de06b55117e8662",
"reference": "8799c17ca99c49718d7effe49de06b55117e8662",
"shasum": ""
},
"require": {
@ -2953,7 +2953,7 @@
"media",
"spatie"
],
"time": "2016-09-23 11:54:31"
"time": "2016-10-06 05:42:25"
},
{
"name": "spatie/pdf-to-image",
@ -3007,24 +3007,24 @@
},
{
"name": "spatie/string",
"version": "2.1.0",
"version": "2.2.0",
"source": {
"type": "git",
"url": "https://github.com/spatie/string.git",
"reference": "1843189c711be4dcf62b655824f2f17120c2dc7d"
"reference": "42b433803942494ee96dabd8f763f5b455e8de1a"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/spatie/string/zipball/1843189c711be4dcf62b655824f2f17120c2dc7d",
"reference": "1843189c711be4dcf62b655824f2f17120c2dc7d",
"url": "https://api.github.com/repos/spatie/string/zipball/42b433803942494ee96dabd8f763f5b455e8de1a",
"reference": "42b433803942494ee96dabd8f763f5b455e8de1a",
"shasum": ""
},
"require": {
"anahkiasen/underscore-php": "^2.0",
"php": ">=5.5.0"
"php": ">=5.6.0"
},
"require-dev": {
"phpunit/phpunit": "4.*",
"phpunit/phpunit": "5.*",
"scrutinizer/ocular": "~1.1"
},
"type": "library",
@ -3056,7 +3056,7 @@
"spatie",
"string"
],
"time": "2015-11-02 13:00:37"
"time": "2016-10-04 15:31:55"
},
{
"name": "swiftmailer/swiftmailer",
@ -3113,20 +3113,21 @@
},
{
"name": "symfony/console",
"version": "v3.1.4",
"version": "v3.1.5",
"source": {
"type": "git",
"url": "https://github.com/symfony/console.git",
"reference": "8ea494c34f0f772c3954b5fbe00bffc5a435e563"
"reference": "6cb0872fb57b38b3b09ff213c21ed693956b9eb0"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/console/zipball/8ea494c34f0f772c3954b5fbe00bffc5a435e563",
"reference": "8ea494c34f0f772c3954b5fbe00bffc5a435e563",
"url": "https://api.github.com/repos/symfony/console/zipball/6cb0872fb57b38b3b09ff213c21ed693956b9eb0",
"reference": "6cb0872fb57b38b3b09ff213c21ed693956b9eb0",
"shasum": ""
},
"require": {
"php": ">=5.5.9",
"symfony/debug": "~2.8|~3.0",
"symfony/polyfill-mbstring": "~1.0"
},
"require-dev": {
@ -3169,20 +3170,20 @@
],
"description": "Symfony Console Component",
"homepage": "https://symfony.com",
"time": "2016-08-19 06:48:39"
"time": "2016-09-28 00:11:12"
},
{
"name": "symfony/debug",
"version": "v3.1.4",
"version": "v3.1.5",
"source": {
"type": "git",
"url": "https://github.com/symfony/debug.git",
"reference": "34f6ac18c2974ca5fce68adf419ee7d15def6f11"
"reference": "e2b3f74a67fc928adc3c1b9027f73e1bc01190a8"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/debug/zipball/34f6ac18c2974ca5fce68adf419ee7d15def6f11",
"reference": "34f6ac18c2974ca5fce68adf419ee7d15def6f11",
"url": "https://api.github.com/repos/symfony/debug/zipball/e2b3f74a67fc928adc3c1b9027f73e1bc01190a8",
"reference": "e2b3f74a67fc928adc3c1b9027f73e1bc01190a8",
"shasum": ""
},
"require": {
@ -3226,11 +3227,11 @@
],
"description": "Symfony Debug Component",
"homepage": "https://symfony.com",
"time": "2016-08-23 13:39:15"
"time": "2016-09-06 11:02:40"
},
{
"name": "symfony/event-dispatcher",
"version": "v3.1.4",
"version": "v3.1.5",
"source": {
"type": "git",
"url": "https://github.com/symfony/event-dispatcher.git",
@ -3290,16 +3291,16 @@
},
{
"name": "symfony/finder",
"version": "v3.1.4",
"version": "v3.1.5",
"source": {
"type": "git",
"url": "https://github.com/symfony/finder.git",
"reference": "e568ef1784f447a0e54dcb6f6de30b9747b0f577"
"reference": "205b5ffbb518a98ba2ae60a52656c4a31ab00c6f"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/finder/zipball/e568ef1784f447a0e54dcb6f6de30b9747b0f577",
"reference": "e568ef1784f447a0e54dcb6f6de30b9747b0f577",
"url": "https://api.github.com/repos/symfony/finder/zipball/205b5ffbb518a98ba2ae60a52656c4a31ab00c6f",
"reference": "205b5ffbb518a98ba2ae60a52656c4a31ab00c6f",
"shasum": ""
},
"require": {
@ -3335,20 +3336,20 @@
],
"description": "Symfony Finder Component",
"homepage": "https://symfony.com",
"time": "2016-08-26 12:04:02"
"time": "2016-09-28 00:11:12"
},
{
"name": "symfony/http-foundation",
"version": "v3.1.4",
"version": "v3.1.5",
"source": {
"type": "git",
"url": "https://github.com/symfony/http-foundation.git",
"reference": "63592e00fd90632b57ee50220a1ddb29b6bf3bb4"
"reference": "5114f1becca9f29e3af94374f1689c83c1aa3d97"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/http-foundation/zipball/63592e00fd90632b57ee50220a1ddb29b6bf3bb4",
"reference": "63592e00fd90632b57ee50220a1ddb29b6bf3bb4",
"url": "https://api.github.com/repos/symfony/http-foundation/zipball/5114f1becca9f29e3af94374f1689c83c1aa3d97",
"reference": "5114f1becca9f29e3af94374f1689c83c1aa3d97",
"shasum": ""
},
"require": {
@ -3388,20 +3389,20 @@
],
"description": "Symfony HttpFoundation Component",
"homepage": "https://symfony.com",
"time": "2016-08-22 12:11:19"
"time": "2016-09-21 20:55:10"
},
{
"name": "symfony/http-kernel",
"version": "v3.1.4",
"version": "v3.1.5",
"source": {
"type": "git",
"url": "https://github.com/symfony/http-kernel.git",
"reference": "aeda215d6b01f119508c090d2a09ebb5b0bc61f3"
"reference": "dc339d6eebadfa6e39c52868b4d4a715eff13c69"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/http-kernel/zipball/aeda215d6b01f119508c090d2a09ebb5b0bc61f3",
"reference": "aeda215d6b01f119508c090d2a09ebb5b0bc61f3",
"url": "https://api.github.com/repos/symfony/http-kernel/zipball/dc339d6eebadfa6e39c52868b4d4a715eff13c69",
"reference": "dc339d6eebadfa6e39c52868b4d4a715eff13c69",
"shasum": ""
},
"require": {
@ -3470,7 +3471,7 @@
],
"description": "Symfony HttpKernel Component",
"homepage": "https://symfony.com",
"time": "2016-09-03 15:28:24"
"time": "2016-10-03 19:01:06"
},
{
"name": "symfony/polyfill-mbstring",
@ -3641,16 +3642,16 @@
},
{
"name": "symfony/process",
"version": "v3.1.4",
"version": "v3.1.5",
"source": {
"type": "git",
"url": "https://github.com/symfony/process.git",
"reference": "e64e93041c80e77197ace5ab9385dedb5a143697"
"reference": "66de154ae86b1a07001da9fbffd620206e4faf94"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/process/zipball/e64e93041c80e77197ace5ab9385dedb5a143697",
"reference": "e64e93041c80e77197ace5ab9385dedb5a143697",
"url": "https://api.github.com/repos/symfony/process/zipball/66de154ae86b1a07001da9fbffd620206e4faf94",
"reference": "66de154ae86b1a07001da9fbffd620206e4faf94",
"shasum": ""
},
"require": {
@ -3686,11 +3687,11 @@
],
"description": "Symfony Process Component",
"homepage": "https://symfony.com",
"time": "2016-08-16 14:58:24"
"time": "2016-09-29 14:13:09"
},
{
"name": "symfony/routing",
"version": "v3.1.4",
"version": "v3.1.5",
"source": {
"type": "git",
"url": "https://github.com/symfony/routing.git",
@ -3765,16 +3766,16 @@
},
{
"name": "symfony/translation",
"version": "v3.1.4",
"version": "v3.1.5",
"source": {
"type": "git",
"url": "https://github.com/symfony/translation.git",
"reference": "a35edc277513c9bc0f063ca174c36b346f974528"
"reference": "93013a18d272e59dab8e67f583155b78c68947eb"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/translation/zipball/a35edc277513c9bc0f063ca174c36b346f974528",
"reference": "a35edc277513c9bc0f063ca174c36b346f974528",
"url": "https://api.github.com/repos/symfony/translation/zipball/93013a18d272e59dab8e67f583155b78c68947eb",
"reference": "93013a18d272e59dab8e67f583155b78c68947eb",
"shasum": ""
},
"require": {
@ -3825,20 +3826,20 @@
],
"description": "Symfony Translation Component",
"homepage": "https://symfony.com",
"time": "2016-08-05 08:37:39"
"time": "2016-09-06 11:02:40"
},
{
"name": "symfony/var-dumper",
"version": "v3.1.4",
"version": "v3.1.5",
"source": {
"type": "git",
"url": "https://github.com/symfony/var-dumper.git",
"reference": "62ee73706c421654a4c840028954510277f7dfc8"
"reference": "70bfe927b86ba9999aeebd829715b0bb2cd39a10"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/var-dumper/zipball/62ee73706c421654a4c840028954510277f7dfc8",
"reference": "62ee73706c421654a4c840028954510277f7dfc8",
"url": "https://api.github.com/repos/symfony/var-dumper/zipball/70bfe927b86ba9999aeebd829715b0bb2cd39a10",
"reference": "70bfe927b86ba9999aeebd829715b0bb2cd39a10",
"shasum": ""
},
"require": {
@ -3888,7 +3889,7 @@
"debug",
"dump"
],
"time": "2016-08-31 09:05:42"
"time": "2016-09-29 14:13:09"
},
{
"name": "themattharris/tmhoauth",
@ -4851,16 +4852,16 @@
},
{
"name": "phpunit/phpunit",
"version": "5.5.6",
"version": "5.6.0",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit.git",
"reference": "146e0fe0bb7f44d1cefade0c93e86fe0b206dd79"
"reference": "a7f2db56518e50ab92f28f739810dfad2f223b6b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/146e0fe0bb7f44d1cefade0c93e86fe0b206dd79",
"reference": "146e0fe0bb7f44d1cefade0c93e86fe0b206dd79",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/a7f2db56518e50ab92f28f739810dfad2f223b6b",
"reference": "a7f2db56518e50ab92f28f739810dfad2f223b6b",
"shasum": ""
},
"require": {
@ -4894,7 +4895,6 @@
"ext-pdo": "*"
},
"suggest": {
"ext-tidy": "*",
"ext-xdebug": "*",
"phpunit/php-invoker": "~1.1"
},
@ -4904,7 +4904,7 @@
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "5.5.x-dev"
"dev-master": "5.6.x-dev"
}
},
"autoload": {
@ -4930,20 +4930,20 @@
"testing",
"xunit"
],
"time": "2016-10-03 07:48:45"
"time": "2016-10-06 15:20:39"
},
{
"name": "phpunit/phpunit-mock-objects",
"version": "3.3.0",
"version": "3.3.1",
"source": {
"type": "git",
"url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git",
"reference": "7462c19bdb9814f6e6bdeb5cad3eb3ce72c6e0da"
"reference": "03500345483e1e17b52e2e4d34a89c9408ab2902"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/7462c19bdb9814f6e6bdeb5cad3eb3ce72c6e0da",
"reference": "7462c19bdb9814f6e6bdeb5cad3eb3ce72c6e0da",
"url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/03500345483e1e17b52e2e4d34a89c9408ab2902",
"reference": "03500345483e1e17b52e2e4d34a89c9408ab2902",
"shasum": ""
},
"require": {
@ -4989,7 +4989,7 @@
"mock",
"xunit"
],
"time": "2016-09-27 03:17:40"
"time": "2016-10-04 11:03:26"
},
{
"name": "sebastian/code-unit-reverse-lookup",
@ -5506,16 +5506,16 @@
},
{
"name": "symfony/css-selector",
"version": "v3.1.4",
"version": "v3.1.5",
"source": {
"type": "git",
"url": "https://github.com/symfony/css-selector.git",
"reference": "2851e1932d77ce727776154d659b232d061e816a"
"reference": "ca809c64072e0fe61c1c7fb3c76cdc32265042ac"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/css-selector/zipball/2851e1932d77ce727776154d659b232d061e816a",
"reference": "2851e1932d77ce727776154d659b232d061e816a",
"url": "https://api.github.com/repos/symfony/css-selector/zipball/ca809c64072e0fe61c1c7fb3c76cdc32265042ac",
"reference": "ca809c64072e0fe61c1c7fb3c76cdc32265042ac",
"shasum": ""
},
"require": {
@ -5555,11 +5555,11 @@
],
"description": "Symfony CssSelector Component",
"homepage": "https://symfony.com",
"time": "2016-06-29 05:41:56"
"time": "2016-09-06 11:02:40"
},
{
"name": "symfony/dom-crawler",
"version": "v3.1.4",
"version": "v3.1.5",
"source": {
"type": "git",
"url": "https://github.com/symfony/dom-crawler.git",
@ -5615,16 +5615,16 @@
},
{
"name": "symfony/yaml",
"version": "v3.1.4",
"version": "v3.1.5",
"source": {
"type": "git",
"url": "https://github.com/symfony/yaml.git",
"reference": "f291ed25eb1435bddbe8a96caaef16469c2a092d"
"reference": "368b9738d4033c8b93454cb0dbd45d305135a6d3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/yaml/zipball/f291ed25eb1435bddbe8a96caaef16469c2a092d",
"reference": "f291ed25eb1435bddbe8a96caaef16469c2a092d",
"url": "https://api.github.com/repos/symfony/yaml/zipball/368b9738d4033c8b93454cb0dbd45d305135a6d3",
"reference": "368b9738d4033c8b93454cb0dbd45d305135a6d3",
"shasum": ""
},
"require": {
@ -5660,7 +5660,7 @@
],
"description": "Symfony Yaml Component",
"homepage": "https://symfony.com",
"time": "2016-09-02 02:12:52"
"time": "2016-09-25 08:27:07"
},
{
"name": "webmozart/assert",

View file

@ -29,7 +29,12 @@ return [
* When urls to files get generated this class will be called. Leave empty
* if your files are stored locally above the site root or on s3.
*/
'custom_url_generator_class' => '',
'custom_url_generator_class' => null,
/*
* The class that contains the strategy for determining a media file's path.
*/
'custom_path_generator_class' => null,
's3' => [
/*
@ -37,4 +42,18 @@ return [
*/
'domain' => env('AWS_S3_URL'),
],
'remote' => [
/**
* Any extra headers that should be included when uploading media to
* a remote disk. Even though supported headers may vary between
* different drivers, a sensible default has been provided.
*
* Supported by S3: CacheControl, Expires, StorageClass,
* ServerSideEncryption, Metadata, ACL, ContentEncoding
*/
'extra_headers' => [
'CacheControl' => 'max-age=604800',
]
],
];

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

@ -71,24 +71,34 @@ function addMap(latitude, longitude, places) {
//when the location marker is dragged, if the new place form elements exist
//update the lat/lng values
marker.on('dragend', function () {
var mapMarkerLatitude = getLatitudeFromMapboxMarker(marker.getLatLng());
var mapMarkerLongitude = getLongitudeFromMapboxMarker(marker.getLatLng());
var coordsOption = document.querySelector('#option-coords');
if (coordsOption != null) {
coordsOption.value = 'geo:' + mapMarkerLatitude + ',' + mapMarkerLongitude;
}
var placeFormLatitude = document.querySelector('#place-latitude');
if (placeFormLatitude !== null) {
placeFormLatitude.value = getLatitudeFromMapboxMarker(marker.getLatLng());
placeFormLatitude.value = mapMarkerLatitude;
}
var placeFormLongitude = document.querySelector('#place-longitude');
if (placeFormLongitude !== null) {
placeFormLongitude.value = getLongitudeFromMapboxMarker(marker.getLatLng());
placeFormLongitude.value = mapMarkerLongitude;
}
});
//create the <select> element and give it a no location default
var selectEl = document.createElement('select');
selectEl.setAttribute('name', 'location');
var noLocation = document.createElement('option');
noLocation.setAttribute('selected', 'selected');
noLocation.setAttribute('value', 'no-location');
var noLocText = document.createTextNode('Select no location');
noLocation.appendChild(noLocText);
noLocation.appendChild(document.createTextNode('Dont send location'));
selectEl.appendChild(noLocation);
var geoLocation = document.createElement('option');
geoLocation.setAttribute('selected', 'selected');
geoLocation.setAttribute('id', 'option-coords');
geoLocation.setAttribute('value', 'geo:' + latitude + ',' + longitude);
geoLocation.appendChild(document.createTextNode('Send co-ordinates'));
selectEl.appendChild(geoLocation);
form.insertBefore(selectEl, div);
if (places !== null) {
//add the places both to the map and <select>
@ -206,9 +216,6 @@ function addMap(latitude, longitude, places) {
if (placeJson.error == true) {
throw new Error(placeJson.error_description);
}
//create the slug from the url
var urlParts = placeJson.split('/');
var slug = urlParts.pop();
//remove un-needed form elements
form.removeChild(document.querySelector('#place-name'));
form.removeChild(document.querySelector('#place-description'));
@ -224,28 +231,29 @@ function addMap(latitude, longitude, places) {
map.removeLayer(marker);
//add place marker
var newOption = document.createElement('option');
newOption.setAttribute('value', slug);
newOption.appendChild(document.createTextNode(placeJson['name']));
newOption.dataset.latitude = placeJson['latitude'];
newOption.dataset.longitude = placeJson['longitude'];
newOption.setAttribute('value', placeJson.uri);
newOption.appendChild(document.createTextNode(placeJson.name));
newOption.dataset.latitude = placeJson.latitude;
newOption.dataset.longitude = placeJson.longitude;
selectEl.appendChild(newOption);
var newPlaceMarker = L.marker([placeJson['latitude'], placeJson['longitude']], {
var newPlaceMarker = L.marker([placeJson.latitude, placeJson.longitude], {
icon: L.mapbox.marker.icon({
'marker-size': 'large',
'marker-symbol': 'building',
'marker-color': '#fa0'
})
}).addTo(map);
var newName = 'Name: ' + placeJson['name'];
map.panTo([placeJson.latitude, placeJson.longitude]);
var newName = 'Name: ' + placeJson.name;
newPlaceMarker.bindPopup(newName, {
closeButton: true
});
newPlaceMarker.on('click', function () {
map.panTo([placeJson['latitude'], placeJson['longitude']]);
selectPlace(slug);
map.panTo([placeJson.latitude, placeJson.longitude]);
selectPlace(placeJson.uri);
});
//make selected
selectPlace(slug);
selectPlace(placeJson.uri);
}).catch(function (placeError) {
alertify.reset();
alertify.error(placeError);
@ -263,8 +271,8 @@ function parseLocation(point) {
return [location[1], location[0]];
}
function selectPlace(slug) {
document.querySelector('select [value=' + slug + ']').selected = true;
function selectPlace(uri) {
document.querySelector('select [value="' + uri + '"]').selected = true;
}
function getLatitudeFromMapboxMarker(latlng) {

View file

@ -30,7 +30,7 @@
<main>
@yield('content')
</main>
<script src="https://use.typekit.net/kmb3cdb.js" integrity="sha384-OB5f9FHlHSvyS7naCO3mhhaMFEPYwqwcyFjiY6HdkAq3MihmBkC2KW8QmYboUwS3" crossorigin="anonymous"></script>
<script src="https://use.typekit.net/kmb3cdb.js" integrity="sha384-0dhd7OudcM5zfMelBVFKeuV+wz6Y3xYrssP9G2sYBCDnCKWmcaAl9oqYzmhiSO7k" crossorigin="anonymous"></script>
<script>try{Typekit.load({ async: true });}catch(e){}</script>
@section('scripts')
<!--scripts go here when needed-->