Merge branch 'develop' of github.com:jonnybarnes/jonnybarnes.uk into develop

This commit is contained in:
Jonny Barnes 2017-06-04 15:10:41 +01:00
commit e29e685148
40 changed files with 394 additions and 53 deletions

View file

@ -67,15 +67,13 @@ class PlacesController extends Controller
{
$place = Place::findOrFail($placeId);
$latitude = $place->getLatitude();
$longitude = $place->getLongitude();
return view('admin.places.edit', [
'id' => $placeId,
'name' => $place->name,
'description' => $place->description,
'latitude' => $latitude,
'longitude' => $longitude,
'latitude' => $place->latitude,
'longitude' => $place->longitude,
'icon' => $place->icon ?? 'marker',
]);
}
@ -92,8 +90,60 @@ class PlacesController extends Controller
$place->name = $request->name;
$place->description = $request->description;
$place->location = new Point((float) $request->latitude, (float) $request->longitude);
$place->icon = $request->icon;
$place->save();
return redirect('/admin/places');
}
/**
* List the places we can merge with the current place.
*
* @param string Place id
* @return Illuminate\View\Factory view
*/
public function mergeIndex($placeId)
{
$first = Place::find($placeId);
$results = Place::near(new Point($first->latitude, $first->longitude))->get();
$places = [];
foreach ($results as $place) {
if ($place->slug !== $first->slug) {
$places[] = $place;
}
}
return view('admin.places.merge.index', compact('first', 'places'));
}
public function mergeEdit($place1_id, $place2_id)
{
$place1 = Place::find($place1_id);
$place2 = Place::find($place2_id);
return view('admin.places.merge.edit', compact('place1', 'place2'));
}
public function mergeStore(Request $request)
{
$place1 = Place::find($request->input('place1'));
$place2 = Place::find($request->input('place2'));
if ($request->input('delete') === '1') {
foreach ($place1->notes as $note) {
$note->place()->dissociate();
$note->place()->associate($place2->id);
}
$place1->delete();
}
if ($request->input('delete') === '2') {
foreach ($place2->notes as $note) {
$note->place()->dissociate();
$note->place()->associate($place1->id);
}
$place2->delete();
}
return redirect('/admin/places');
}
}

View file

@ -6,6 +6,7 @@ use Ramsey\Uuid\Uuid;
use App\{Media, Note, Place};
use Illuminate\Http\{Request, Response};
use App\Exceptions\InvalidTokenException;
use Phaza\LaravelPostgis\Geometries\Point;
use Ramsey\Uuid\Exception\UnsatisfiedDependencyException;
use App\Services\{NoteService, PlaceService, TokenService};
@ -313,7 +314,7 @@ class MicropubController extends Controller
$matches
);
$distance = (count($matches[0]) == 3) ? 100 * $matches[0][2] : 1000;
$places = Place::near($matches[0][0], $matches[0][1], $distance);
$places = Place::near(new Point($matches[0][0], $matches[0][1]))->get();
foreach ($places as $place) {
$place->uri = config('app.url') . '/places/' . $place->slug;
}

View file

@ -4,6 +4,8 @@ namespace App;
use DB;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Builder;
use Phaza\LaravelPostgis\Geometries\Point;
use MartinBean\Database\Eloquent\Sluggable;
use Phaza\LaravelPostgis\Eloquent\PostgisTrait;
@ -45,33 +47,23 @@ class Place extends Model
}
/**
* Get all places within a specified distance.
* Select places near a given location.
*
* @param float latitude
* @param float longitude
* @param int maximum distance
* @todo Check this shit.
* @param \Illuminate\Database\Eloquent\Builder $query
* @param Point $point
* @param int Distance
* @return \Illuminate\Database\Eloquent\Builder
*/
public static function near(float $lat, float $lng, int $distance)
public function scopeNear(Builder $query, Point $point, $distance = 1000)
{
$point = $lng . ' ' . $lat;
$distace = $distance ?? 1000;
$places = DB::select(DB::raw("select
name,
slug,
ST_AsText(location) AS location,
ST_Distance(
ST_GeogFromText('SRID=4326;POINT($point)'),
location
) AS distance
from places
where ST_DWithin(
ST_GeogFromText('SRID=4326;POINT($point)'),
location,
$distance
) ORDER BY distance"));
$field = DB::raw(
sprintf("ST_Distance(%s.location, ST_GeogFromText('%s'))",
$this->getTable(),
$point->toWKT()
)
);
return $places;
return $query->where($field, '<=', $distance)->orderBy($field);
}
/*

View file

@ -1,5 +1,9 @@
# Changelog
## Version 0.5.9 (2017-05-31)
- Mapping improvements
- Basic place merging
## Version 0.5.8 (2017-05-21)
- Hotfix: if Carbon cant parse the supplied published date of a webmention, use the Models `updated_at` value

View file

@ -14,7 +14,7 @@ class PlacesTableSeeder extends Seeder
DB::table('places')->insert([
'name' => 'The Bridgewater Pub',
'slug' => 'the-bridgewater-pub',
'description' => 'A lovely local pub with a decent selection pf cask ales',
'description' => 'A lovely local pub with a decent selection of cask ales',
'location' => 'POINT(-2.3805 53.4983)',
'created_at' => '2016-01-12 16:19:00',
'updated_at' => '2016-01-12 16:19:00',

File diff suppressed because one or more lines are too long

Binary file not shown.

Binary file not shown.

View file

@ -1 +1 @@
{"version":3,"sources":["../../../resources/assets/sass/app.scss","../../../resources/assets/sass/layout.scss","../../../resources/assets/sass/styles.scss","../../../resources/assets/sass/pagination.scss","../../../resources/assets/sass/note-form.scss","../../../resources/assets/sass/mapbox.scss","../../../resources/assets/sass/contacts.scss","../../../resources/assets/sass/emoji.scss"],"names":[],"mappings":"AAIA,KACI,8BACA,AADA,sBACA,cAAe,CAClB,qBAKG,2BAAmB,AAAnB,kBAAmB,CACtB,KCVG,eACA,cACA,iBACA,kBACA,oBAAqB,CACxB,WAGG,iBAAkB,CACrB,SAGG,gBAAiB,CACpB,MAGG,oBACA,AADA,oBACA,AADA,aACA,4BAAsB,AAAtB,6BAAsB,AAAtB,0BAAsB,AAAtB,qBAAsB,CACzB,eAGG,oBACA,AADA,oBACA,AADA,aACA,8BACA,AADA,6BACA,AADA,uBACA,AADA,mBACA,yBACA,AADA,sBACA,AADA,8BACA,gBAAiB,CACpB,UAGG,gBACA,WACA,4BAA6B,CAChC,cAGG,oBACA,AADA,oBACA,AADA,aACA,yBAAmB,AAAnB,sBAAmB,AAAnB,kBAAmB,CACtB,kBAGG,gBAAiB,CACpB,iBAGG,qBACA,WAAY,CACf,aAGG,eACA,yBAA0B,CAC7B,OAGG,eAAgB,CACnB,cAGG,eAAgB,CACnB,WAGG,eACA,cACA,iBAAkB,CACrB,sBAGG,cAAe,CAClB,sBAGG,iBACA,cAAe,CAClB,WAGG,kBACA,WACA,SACA,qBAAsB,CACzB,SAGG,kBACA,MACA,OACA,WACA,WAAY,CACf,KCvFG,6JAWc,CACjB,EAGG,qBACA,wBACA,UAAW,CACd,gBAGG,kBAAmB,CACtB,MAGG,WACA,UAAW,CACd,OAGG,iBACA,iBAAkB,CACrB,WAGG,kBAAmB,CACtB,UAGG,YACA,WAAY,CACf,YC1CG,WACA,YACA,oBACA,AADA,oBACA,AADA,aACA,8BACA,AADA,6BACA,AADA,uBACA,AADA,mBACA,yBACA,AADA,sBACA,AADA,8BACA,yBAAmB,AAAnB,sBAAmB,AAAnB,kBAAmB,CACtB,eAGG,oBAAqB,CACxB,SCVG,oBACA,AADA,oBACA,AADA,aACA,4BAAsB,AAAtB,6BAAsB,AAAtB,0BAAsB,AAAtB,qBAAsB,CACzB,0BAGG,aACI,oBACA,AADA,oBACA,AADA,aACA,8BACA,AADA,6BACA,AADA,uBACA,AADA,mBACA,cAAe,CAClB,mBAGG,SAAU,CACb,CAGL,0BACI,mBACI,UAAW,CACd,4BAIG,UAAW,CACd,CAGL,eACI,UACA,oBACA,gBAAiB,CACpB,oDAIG,mBAAO,AAAP,WAAO,AAAP,MAAO,CACV,kBAGG,qBAAsB,CACzB,QAGG,mBAAoB,CACvB,aAGG,oBAAqB,CACxB,cAGG,WACA,SAAU,CACb,KCrDG,eACA,YAAa,CAChB,QAGG,y4HACA,wBACA,WACA,WAAY,CACf,UAGG,kBACA,MACA,OACA,iBACA,cAAe,CAClB,gBAGG,gBACA,gBAAiB,CACpB,SCtBG,oBACA,AADA,oBACA,AADA,aACA,8BACA,AADA,6BACA,AADA,uBACA,AADA,mBACA,eACA,6BAA8B,CACjC,aAGG,oBACA,YACA,YAAa,CAChB,sDCPG,iBAAkB,CACrB,gFAIG,kBACA,cACA,UACA,aACA,OACA,cACA,qBACA,yBACA,oBACA,4CACA,AADA,oCACA,yBACA,kCACA,WACA,cACA,0CAAkC,AAAlC,iCAAkC,CACrC,2BAGG,KACI,aACA,6BACA,wCACA,0BACA,8BAAkC,AAAlC,qBAAkC,CAGtC,GACI,aACA,kCACA,yBACA,WACA,4CAAgD,AAAhD,mCAAgD,CAAA,CAIxD,AApBC,mBAGG,KACI,aACA,6BACA,wCACA,0BACA,8BAAkC,AAAlC,qBAAkC,CAGtC,GACI,aACA,kCACA,yBACA,WACA,4CAAgD,AAAhD,mCAAgD,CAAA,CAIxD,aACI,kCACI,kCAAmC,CACtC,CAAA","file":"app.css"}
{"version":3,"sources":["../../../resources/assets/sass/app.scss","../../../resources/assets/sass/layout.scss","../../../resources/assets/sass/styles.scss","../../../resources/assets/sass/pagination.scss","../../../resources/assets/sass/note-form.scss","../../../resources/assets/sass/mapbox.scss","../../../resources/assets/sass/contacts.scss","../../../resources/assets/sass/emoji.scss"],"names":[],"mappings":"AAIA,KACI,8BACA,AADA,sBACA,cAAe,CAClB,qBAKG,2BAAmB,AAAnB,kBAAmB,CACtB,KCVG,eACA,cACA,iBACA,kBACA,oBAAqB,CACxB,WAGG,iBAAkB,CACrB,SAGG,gBAAiB,CACpB,MAGG,oBACA,AADA,oBACA,AADA,aACA,4BAAsB,AAAtB,6BAAsB,AAAtB,0BAAsB,AAAtB,qBAAsB,CACzB,eAGG,oBACA,AADA,oBACA,AADA,aACA,8BACA,AADA,6BACA,AADA,uBACA,AADA,mBACA,yBACA,AADA,sBACA,AADA,8BACA,gBAAiB,CACpB,UAGG,gBACA,WACA,4BAA6B,CAChC,cAGG,oBACA,AADA,oBACA,AADA,aACA,yBAAmB,AAAnB,sBAAmB,AAAnB,kBAAmB,CACtB,kBAGG,gBAAiB,CACpB,iBAGG,qBACA,WAAY,CACf,aAGG,eACA,yBAA0B,CAC7B,OAGG,eAAgB,CACnB,cAGG,eAAgB,CACnB,WAGG,eACA,cACA,iBAAkB,CACrB,sBAGG,cAAe,CAClB,sBAGG,iBACA,cAAe,CAClB,WAGG,kBACA,WACA,SACA,qBAAsB,CACzB,SAGG,kBACA,MACA,OACA,WACA,WAAY,CACf,KCvFG,6JAWc,CACjB,EAGG,qBACA,wBACA,UAAW,CACd,gBAGG,kBAAmB,CACtB,MAGG,WACA,UAAW,CACd,OAGG,iBACA,iBAAkB,CACrB,WAGG,kBAAmB,CACtB,UAGG,YACA,WAAY,CACf,YC1CG,WACA,YACA,oBACA,AADA,oBACA,AADA,aACA,8BACA,AADA,6BACA,AADA,uBACA,AADA,mBACA,yBACA,AADA,sBACA,AADA,8BACA,yBAAmB,AAAnB,sBAAmB,AAAnB,kBAAmB,CACtB,eAGG,oBAAqB,CACxB,SCVG,oBACA,AADA,oBACA,AADA,aACA,4BAAsB,AAAtB,6BAAsB,AAAtB,0BAAsB,AAAtB,qBAAsB,CACzB,0BAGG,aACI,oBACA,AADA,oBACA,AADA,aACA,8BACA,AADA,6BACA,AADA,uBACA,AADA,mBACA,cAAe,CAClB,mBAGG,SAAU,CACb,CAGL,0BACI,mBACI,UAAW,CACd,4BAIG,UAAW,CACd,CAGL,eACI,UACA,oBACA,gBAAiB,CACpB,oDAIG,mBAAO,AAAP,WAAO,AAAP,MAAO,CACV,kBAGG,qBAAsB,CACzB,QAGG,mBAAoB,CACvB,aAGG,oBAAqB,CACxB,cAGG,WACA,SAAU,CACb,KCrDG,eACA,YAAa,CAChB,oBAGG,kBAAmB,CACtB,QAGG,y4HACA,wBACA,WACA,WAAY,CACf,UAGG,kBACA,MACA,OACA,iBACA,cAAe,CAClB,gBAGG,gBACA,gBAAiB,CACpB,SC1BG,oBACA,AADA,oBACA,AADA,aACA,8BACA,AADA,6BACA,AADA,uBACA,AADA,mBACA,eACA,6BAA8B,CACjC,aAGG,oBACA,YACA,YAAa,CAChB,sDCPG,iBAAkB,CACrB,gFAIG,kBACA,cACA,UACA,aACA,OACA,cACA,qBACA,yBACA,oBACA,4CACA,AADA,oCACA,yBACA,kCACA,WACA,cACA,0CAAkC,AAAlC,iCAAkC,CACrC,2BAGG,KACI,aACA,6BACA,wCACA,0BACA,8BAAkC,AAAlC,qBAAkC,CAGtC,GACI,aACA,kCACA,yBACA,WACA,4CAAgD,AAAhD,mCAAgD,CAAA,CAIxD,AApBC,mBAGG,KACI,aACA,6BACA,wCACA,0BACA,8BAAkC,AAAlC,qBAAkC,CAGtC,GACI,aACA,kCACA,yBACA,WACA,4CA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gk1X78gxntU01wP+oYotA7tJescf34oM4CfzHoz4UdUTPK3Iif
BBMTCgAnBQJXRbTjAhsDBQkB4TOABQsJCAcDBRUKCQgLBRYDAgEAAh4BAheAAAoJ
EBssdq+xbIWb0qwBfijJLkE/QUH7iAASLDtD3pUGs13TUynrzl2n8NdOnwmJTDdB
6eFT5+XxAgmuw+o28wF+MMEqzf+ELqjEyk/DZaZ3Kg9cJQAm3ybc0wFKy/kqQ2HY
TaFwEG3dAyfFDddkuaDEuHMEV0W04xIFK4EEACIDAwR0mRtrTq604CFiA8OdQR77
AVc8lRrNxFPwo7uJWsIEPBNVTHasC4OCXAvGgm9bPggQUNoOQ4fUCNmAgsVeGpYQ
/b67m0ydqjcrHpd0fIRbK5kyWYvYPRsZ6mTgiKosrZIDAQkJiJ4EGBMKACYCGwwW
IQSEGbWh2ITK9LCvj7MbLHavsWyFmwUCWSgPZQUJA8OOAgAKCRAbLHavsWyFm1fN
AYDMf1p4GegE1FHiUZo4m4Y5iQfbxT9Nmlgaopbmq+BxJRwPMxVzJOvKXo4DiUd0
nncBgOJUJ8esy6WGw+lUfkfvRNkhPw9CVt1GifjG4axGHGaDyDQdFdRcIeFyu0Fs
7HsLmg==
=sdL6
-----END PGP PUBLIC KEY BLOCK-----

View file

@ -1,2 +1,2 @@
!function(modules){function __webpack_require__(moduleId){if(installedModules[moduleId])return installedModules[moduleId].exports;var module=installedModules[moduleId]={i:moduleId,l:!1,exports:{}};return modules[moduleId].call(module.exports,module,module.exports,__webpack_require__),module.l=!0,module.exports}var installedModules={};__webpack_require__.m=modules,__webpack_require__.c=installedModules,__webpack_require__.i=function(value){return value},__webpack_require__.d=function(exports,name,getter){__webpack_require__.o(exports,name)||Object.defineProperty(exports,name,{configurable:!1,enumerable:!0,get:getter})},__webpack_require__.n=function(module){var getter=module&&module.__esModule?function(){return module.default}:function(){return module};return __webpack_require__.d(getter,"a",getter),getter},__webpack_require__.o=function(object,property){return Object.prototype.hasOwnProperty.call(object,property)},__webpack_require__.p="",__webpack_require__(__webpack_require__.s=7)}({7:function(module,exports,__webpack_require__){"use strict";var youtubeRegex=/watch\?v=([A-Za-z0-9\-_]+)\b/,spotifyRegex=/https\:\/\/play\.spotify\.com\/(.*)\b/,notes=document.querySelectorAll(".e-content"),_iteratorNormalCompletion=!0,_didIteratorError=!1,_iteratorError=void 0;try{for(var _step,_iterator=notes[Symbol.iterator]();!(_iteratorNormalCompletion=(_step=_iterator.next()).done);_iteratorNormalCompletion=!0){var note=_step.value,ytid=note.textContent.match(youtubeRegex);if(ytid){var ytcontainer=document.createElement("div");ytcontainer.classList.add("container");var ytiframe=document.createElement("iframe");ytiframe.classList.add("youtube"),ytiframe.setAttribute("src","https://www.youtube.com/embed/"+ytid[1]),ytiframe.setAttribute("frameborder",0),ytiframe.setAttribute("allowfullscreen","true"),ytcontainer.appendChild(ytiframe),note.appendChild(ytcontainer)}var spotifyid=note.textContent.match(spotifyRegex);if(spotifyid){var sid=spotifyid[1].replace("/",":"),siframe=document.createElement("iframe");siframe.classList.add("spotify"),siframe.setAttribute("src","https://embed.spotify.com/?uri=spotify:"+sid),siframe.setAttribute("frameborder",0),siframe.setAttribute("allowtransparency","true"),note.appendChild(siframe)}}}catch(err){_didIteratorError=!0,_iteratorError=err}finally{try{!_iteratorNormalCompletion&&_iterator.return&&_iterator.return()}finally{if(_didIteratorError)throw _iteratorError}}}});
!function(modules){function __webpack_require__(moduleId){if(installedModules[moduleId])return installedModules[moduleId].exports;var module=installedModules[moduleId]={i:moduleId,l:!1,exports:{}};return modules[moduleId].call(module.exports,module,module.exports,__webpack_require__),module.l=!0,module.exports}var installedModules={};__webpack_require__.m=modules,__webpack_require__.c=installedModules,__webpack_require__.i=function(value){return value},__webpack_require__.d=function(exports,name,getter){__webpack_require__.o(exports,name)||Object.defineProperty(exports,name,{configurable:!1,enumerable:!0,get:getter})},__webpack_require__.n=function(module){var getter=module&&module.__esModule?function(){return module.default}:function(){return module};return __webpack_require__.d(getter,"a",getter),getter},__webpack_require__.o=function(object,property){return Object.prototype.hasOwnProperty.call(object,property)},__webpack_require__.p="",__webpack_require__(__webpack_require__.s=8)}({8:function(module,exports,__webpack_require__){"use strict";var youtubeRegex=/watch\?v=([A-Za-z0-9\-_]+)\b/,spotifyRegex=/https\:\/\/play\.spotify\.com\/(.*)\b/,notes=document.querySelectorAll(".e-content"),_iteratorNormalCompletion=!0,_didIteratorError=!1,_iteratorError=void 0;try{for(var _step,_iterator=notes[Symbol.iterator]();!(_iteratorNormalCompletion=(_step=_iterator.next()).done);_iteratorNormalCompletion=!0){var note=_step.value,ytid=note.textContent.match(youtubeRegex);if(ytid){var ytcontainer=document.createElement("div");ytcontainer.classList.add("container");var ytiframe=document.createElement("iframe");ytiframe.classList.add("youtube"),ytiframe.setAttribute("src","https://www.youtube.com/embed/"+ytid[1]),ytiframe.setAttribute("frameborder",0),ytiframe.setAttribute("allowfullscreen","true"),ytcontainer.appendChild(ytiframe),note.appendChild(ytcontainer)}var spotifyid=note.textContent.match(spotifyRegex);if(spotifyid){var sid=spotifyid[1].replace("/",":"),siframe=document.createElement("iframe");siframe.classList.add("spotify"),siframe.setAttribute("src","https://embed.spotify.com/?uri=spotify:"+sid),siframe.setAttribute("frameborder",0),siframe.setAttribute("allowtransparency","true"),note.appendChild(siframe)}}}catch(err){_didIteratorError=!0,_iteratorError=err}finally{try{!_iteratorNormalCompletion&&_iterator.return&&_iterator.return()}finally{if(_didIteratorError)throw _iteratorError}}}});
//# sourceMappingURL=links.js.map

Binary file not shown.

Binary file not shown.

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.

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.

File diff suppressed because one or more lines are too long

View file

@ -1,2 +1,2 @@
!function(modules){function __webpack_require__(moduleId){if(installedModules[moduleId])return installedModules[moduleId].exports;var module=installedModules[moduleId]={i:moduleId,l:!1,exports:{}};return modules[moduleId].call(module.exports,module,module.exports,__webpack_require__),module.l=!0,module.exports}var installedModules={};__webpack_require__.m=modules,__webpack_require__.c=installedModules,__webpack_require__.i=function(value){return value},__webpack_require__.d=function(exports,name,getter){__webpack_require__.o(exports,name)||Object.defineProperty(exports,name,{configurable:!1,enumerable:!0,get:getter})},__webpack_require__.n=function(module){var getter=module&&module.__esModule?function(){return module.default}:function(){return module};return __webpack_require__.d(getter,"a",getter),getter},__webpack_require__.o=function(object,property){return Object.prototype.hasOwnProperty.call(object,property)},__webpack_require__.p="",__webpack_require__(__webpack_require__.s=13)}({13:function(module,exports,__webpack_require__){"use strict";var _paq=_paq||[];_paq.push(["trackPageView"]),_paq.push(["enableLinkTracking"]),_paq.push(["setTrackerUrl","https://analytics.jmb.lv/piwik.php"]),_paq.push(["setSiteId","1"])}});
!function(modules){function __webpack_require__(moduleId){if(installedModules[moduleId])return installedModules[moduleId].exports;var module=installedModules[moduleId]={i:moduleId,l:!1,exports:{}};return modules[moduleId].call(module.exports,module,module.exports,__webpack_require__),module.l=!0,module.exports}var installedModules={};__webpack_require__.m=modules,__webpack_require__.c=installedModules,__webpack_require__.i=function(value){return value},__webpack_require__.d=function(exports,name,getter){__webpack_require__.o(exports,name)||Object.defineProperty(exports,name,{configurable:!1,enumerable:!0,get:getter})},__webpack_require__.n=function(module){var getter=module&&module.__esModule?function(){return module.default}:function(){return module};return __webpack_require__.d(getter,"a",getter),getter},__webpack_require__.o=function(object,property){return Object.prototype.hasOwnProperty.call(object,property)},__webpack_require__.p="",__webpack_require__(__webpack_require__.s=14)}({14:function(module,exports,__webpack_require__){"use strict";var _paq=_paq||[];_paq.push(["trackPageView"]),_paq.push(["enableLinkTracking"]),_paq.push(["setTrackerUrl","https://analytics.jmb.lv/piwik.php"]),_paq.push(["setSiteId","1"])}});
//# sourceMappingURL=piwik.js.map

Binary file not shown.

Binary file not shown.

View file

@ -1 +1 @@
{"version":3,"sources":["webpack:/webpack/bootstrap 0f22eae8481def736e3e?3dbc*","webpack:///piwik.js"],"names":["__webpack_require__","moduleId","installedModules","exports","module","i","l","modules","call","m","c","value","d","name","getter","o","Object","defineProperty","configurable","enumerable","get","n","__esModule","object","property","prototype","hasOwnProperty","p","s","_paq","push"],"mappings":"mBAIA,QAAAA,qBAAAC,UAGA,GAAAC,iBAAAD,UACA,MAAAC,kBAAAD,UAAAE,OAGA,IAAAC,QAAAF,iBAAAD,WACAI,EAAAJ,SACAK,GAAA,EACAH,WAUA,OANAI,SAAAN,UAAAO,KAAAJ,OAAAD,QAAAC,OAAAA,OAAAD,QAAAH,qBAGAI,OAAAE,GAAA,EAGAF,OAAAD,QAvBA,GAAAD,oBA4BAF,qBAAAS,EAAAF,QAGAP,oBAAAU,EAAAR,iBAGAF,oBAAAK,EAAA,SAAAM,OAA2C,MAAAA,QAG3CX,oBAAAY,EAAA,SAAAT,QAAAU,KAAAC,QACAd,oBAAAe,EAAAZ,QAAAU,OACAG,OAAAC,eAAAd,QAAAU,MACAK,cAAA,EACAC,YAAA,EACAC,IAAAN,UAMAd,oBAAAqB,EAAA,SAAAjB,QACA,GAAAU,QAAAV,QAAAA,OAAAkB,WACA,WAA2B,MAAAlB,QAAA,SAC3B,WAAiC,MAAAA,QAEjC,OADAJ,qBAAAY,EAAAE,OAAA,IAAAA,QACAA,QAIAd,oBAAAe,EAAA,SAAAQ,OAAAC,UAAsD,MAAAR,QAAAS,UAAAC,eAAAlB,KAAAe,OAAAC,WAGtDxB,oBAAA2B,EAAA,GAGA3B,oBAAAA,oBAAA4B,EAAA,kEC9DA,IAAIC,MAAOA,QAEXA,MAAKC,MAAM,kBACXD,KAAKC,MAAM,uBACXD,KAAKC,MAAM,gBAAiB,uCAC5BD,KAAKC,MAAM,YAAa","file":"public/assets/js/piwik.js.map","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// identity function for calling harmony imports with the correct context\n \t__webpack_require__.i = function(value) { return value; };\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 13);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 0f22eae8481def736e3e","// Piwik in its own js file to allow usage with a CSP policy\n\nvar _paq = _paq || [];\n// tracker methods like \"setCustomDimension\" should be called before \"trackPageView\"\n_paq.push(['trackPageView']);\n_paq.push(['enableLinkTracking']);\n_paq.push(['setTrackerUrl', 'https://analytics.jmb.lv/piwik.php']);\n_paq.push(['setSiteId', '1']);\n\n\n\n// WEBPACK FOOTER //\n// ./piwik.js"]}
{"version":3,"sources":["webpack:/webpack/bootstrap 43ebdd943e2791855d4e?c4b5**","webpack:///piwik.js"],"names":["__webpack_require__","moduleId","installedModules","exports","module","i","l","modules","call","m","c","value","d","name","getter","o","Object","defineProperty","configurable","enumerable","get","n","__esModule","object","property","prototype","hasOwnProperty","p","s","_paq","push"],"mappings":"mBAIA,QAAAA,qBAAAC,UAGA,GAAAC,iBAAAD,UACA,MAAAC,kBAAAD,UAAAE,OAGA,IAAAC,QAAAF,iBAAAD,WACAI,EAAAJ,SACAK,GAAA,EACAH,WAUA,OANAI,SAAAN,UAAAO,KAAAJ,OAAAD,QAAAC,OAAAA,OAAAD,QAAAH,qBAGAI,OAAAE,GAAA,EAGAF,OAAAD,QAvBA,GAAAD,oBA4BAF,qBAAAS,EAAAF,QAGAP,oBAAAU,EAAAR,iBAGAF,oBAAAK,EAAA,SAAAM,OAA2C,MAAAA,QAG3CX,oBAAAY,EAAA,SAAAT,QAAAU,KAAAC,QACAd,oBAAAe,EAAAZ,QAAAU,OACAG,OAAAC,eAAAd,QAAAU,MACAK,cAAA,EACAC,YAAA,EACAC,IAAAN,UAMAd,oBAAAqB,EAAA,SAAAjB,QACA,GAAAU,QAAAV,QAAAA,OAAAkB,WACA,WAA2B,MAAAlB,QAAA,SAC3B,WAAiC,MAAAA,QAEjC,OADAJ,qBAAAY,EAAAE,OAAA,IAAAA,QACAA,QAIAd,oBAAAe,EAAA,SAAAQ,OAAAC,UAAsD,MAAAR,QAAAS,UAAAC,eAAAlB,KAAAe,OAAAC,WAGtDxB,oBAAA2B,EAAA,GAGA3B,oBAAAA,oBAAA4B,EAAA,kEC9DA,IAAIC,MAAOA,QAEXA,MAAKC,MAAM,kBACXD,KAAKC,MAAM,uBACXD,KAAKC,MAAM,gBAAiB,uCAC5BD,KAAKC,MAAM,YAAa","file":"public/assets/js/piwik.js.map","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// identity function for calling harmony imports with the correct context\n \t__webpack_require__.i = function(value) { return value; };\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 14);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 43ebdd943e2791855d4e","// Piwik in its own js file to allow usage with a CSP policy\n\nvar _paq = _paq || [];\n// tracker methods like \"setCustomDimension\" should be called before \"trackPageView\"\n_paq.push(['trackPageView']);\n_paq.push(['enableLinkTracking']);\n_paq.push(['setTrackerUrl', 'https://analytics.jmb.lv/piwik.php']);\n_paq.push(['setSiteId', '1']);\n\n\n\n// WEBPACK FOOTER //\n// ./piwik.js"]}

2
public/assets/js/places.js vendored Normal file

File diff suppressed because one or more lines are too long

Binary file not shown.

Binary file not shown.

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,7 @@
//edit-place-icon.js
export default function getIcon() {
let iconOption = document.querySelector('#icon');
return iconOption.value;
}

View file

@ -20,7 +20,23 @@ const addMapTypeOption = (map, menu, option, checked = false) => {
input.setAttribute('checked', 'checked');
}
input.addEventListener('click', function () {
let source = map.getSource('points');
map.setStyle('mapbox://styles/mapbox/' + option + '-v9');
map.on('style.load', function () {
map.addLayer({
'id': 'points',
'type': 'symbol',
'source': {
'type': 'geojson',
'data': source._data
},
'layout': {
'icon-image': '{icon}-15',
'text-field': '{title}',
'text-offset': [0, 1]
}
});
});
});
let label = document.createElement('label');
label.setAttribute('for', option);

83
resources/assets/es6/places.js vendored Normal file
View file

@ -0,0 +1,83 @@
//places.js
import addMap from './mapbox-utils';
import getIcon from './edit-place-icon';
let div = document.querySelector('.map');
let map = addMap(div);
let isDragging;
let isCursorOverPoint;
let canvas = map.getCanvasContainer();
let selectElem = document.querySelector('select[name="icon"]');
selectElem.addEventListener('click', function () {
let newIcon = getIcon();
let source = map.getSource('points');
if (source._data.features[0].properties.icon != newIcon) {
source._data.features[0].properties.icon = newIcon;
map.getSource('points').setData(source._data);
}
});
function updateFormCoords(coords) {
let latInput = document.querySelector('#latitude');
let lonInput = document.querySelector('#longitude');
latInput.value = coords.lat.toPrecision(6);
lonInput.value = coords.lng.toPrecision(6);
}
function mouseDown() {
if (!isCursorOverPoint) return;
isDragging = true;
// Set a cursor indicator
canvas.style.cursor = 'grab';
// Mouse events
map.on('mousemove', onMove);
map.once('mouseup', onUp);
}
function onMove(e) {
if (!isDragging) return;
let coords = e.lngLat;
let source = map.getSource('points');
// Set a UI indicator for dragging.
canvas.style.cursor = 'grabbing';
// Update the Point feature in `geojson` coordinates
// and call setData to the source layer `point` on it.
source._data.features[0].geometry.coordinates = [coords.lng, coords.lat];
map.getSource('points').setData(source._data);
}
function onUp(e) {
if (!isDragging) return;
let coords = e.lngLat;
// Print the coordinates of where the point had
// finished being dragged to on the map.
updateFormCoords(coords);
canvas.style.cursor = '';
isDragging = false;
// Unbind mouse events
map.off('mousemove', onMove);
}
// When the cursor enters a feature in the point layer, prepare for dragging.
map.on('mouseenter', 'points', function() {
canvas.style.cursor = 'move';
isCursorOverPoint = true;
map.dragPan.disable();
});
map.on('mouseleave', 'points', function() {
canvas.style.cursor = '';
isCursorOverPoint = false;
map.dragPan.enable();
});
map.on('mousedown', mouseDown);

View file

@ -5,6 +5,10 @@
height: 200px;
}
.mapboxgl-ctrl-logo {
border-bottom: none;
}
.marker {
background-image: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAMgAAADICAMAAACahl6sAAAAA3NCSVQICAjb4U/gAAAACXBIWXMAAAsTAAALEwEAmpwYAAACxFBMVEUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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fsBnhtZH/Fv00wqs4wo/VIsyW81/a+iHMel3iPz2NcHuS/3AuF+GWfZZ/9xjC7rv8mxMZCLsuR/lX0xF+U0geTEH4GfvIMvw3KOV2aPcXaWsyKghlwmgAAAAASUVORK5CYII=);
background-size: contain;

View file

@ -9,11 +9,121 @@ Edit Place « Admin CP
<form action="/admin/places/{{ $id }}" method="post" accept-charset="utf-8">
{{ csrf_field() }}
{{ method_field('PUT') }}
<p>Name</p>
<input type="text" name="name" id="name" value="{{ $name }}"><br>
<input type="text" name="description" id="description" value="{{ $description }}"><br>
<p>Description</p>
<textarea name="description" id="description">{{ $description }}</textarea><br>
<p>Location</p>
<div class="map" data-latitude="{{ $latitude }}" data-longitude="{{ $longitude }}" data-id="{{ $id }}"></div>
<script>
var geojson{{ $id }} = {
"type": "FeatureCollection",
"features": [{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [{{ $longitude }}, {{ $latitude }}]
},
"properties": {
"title": "{{ $name }}",
"icon": "{{ $icon }}"
}
}]
}
</script>
<input type="text" name="latitude" id="latitude" value="{{ $latitude }}"><br>
<input type="text" name="longitude" id="longitude" value="{{ $longitude }}"><br>
<p>Map Icon</p>
<select name="icon" id="icon">
<option value="airfield"@if($icon == 'airfield')selected @endif>airfield</option>
<option value="airport"@if($icon == 'airport')selected @endif>airport</option>
<option value="alcohol-shop"@if($icon == 'alcohol-shop')selected @endif>alcohol-shop</option>
<option value="amusement-park"@if($icon == 'amusement-park')selected @endif>amusement-park</option>
<option value="aquarium"@if($icon == 'aquarium')selected @endif>aquarium</option>
<option value="art-gallery"@if($icon == 'art-gallery')selected @endif>art-gallery</option>
<option value="attraction"@if($icon == 'attraction')selected @endif>attraction</option>
<option value="bakery"@if($icon == 'bakery')selected @endif>bakery</option>
<option value="bank"@if($icon == 'bank')selected @endif>bank</option>
<option value="bar"@if($icon == 'bar')selected @endif>bar</option>
<option value="beer"@if($icon == 'beer')selected @endif>beer</option>
<option value="bicycle"@if($icon == 'bicycle')selected @endif>bicycle</option>
<option value="bicycle-share"@if($icon == 'bicycle-share')selected @endif>bicycle-share</option>
<option value="bus"@if($icon == 'bus')selected @endif>bus</option>
<option value="cafe"@if($icon == 'cafe')selected @endif>cafe</option>
<option value="campsite"@if($icon == 'campsite')selected @endif>campsite</option>
<option value="car"@if($icon == 'car')selected @endif>car</option>
<option value="castle"@if($icon == 'castle')selected @endif>castle</option>
<option value="cemetery"@if($icon == 'cemetery')selected @endif>cemetery</option>
<option value="cinema"@if($icon == 'cinema')selected @endif>cinema</option>
<option value="circle"@if($icon == 'circle')selected @endif>circle</option>
<option value="circle-stroked"@if($icon == 'circle-stroked')selected @endif>circle-stroked</option>
<option value="clothing-store"@if($icon == 'clothing-store')selected @endif>clothing-store</option>
<option value="college"@if($icon == 'college')selected @endif>college</option>
<option value="dentist"@if($icon == 'dentist')selected @endif>dentist</option>
<option value="doctor"@if($icon == 'doctor')selected @endif>doctor</option>
<option value="dog-park"@if($icon == 'dog-park')selected @endif>dog-park</option>
<option value="drinking-water"@if($icon == 'drinking-water')selected @endif>drinking-water</option>
<option value="embassy"@if($icon == 'embassy')selected @endif>embassy</option>
<option value="entrance"@if($icon == 'entrance')selected @endif>entrance</option>
<option value="fast-food"@if($icon == 'fast-food')selected @endif>fast-food</option>
<option value="ferry"@if($icon == 'ferry')selected @endif>ferry</option>
<option value="fire-station"@if($icon == 'fire-station')selected @endif>fire-station</option>
<option value="fuel"@if($icon == 'fuel')selected @endif>fuel</option>
<option value="garden"@if($icon == 'garden')selected @endif>garden</option>
<option value="golf"@if($icon == 'golf')selected @endif>golf</option>
<option value="grocery"@if($icon == 'grocery')selected @endif>grocery</option>
<option value="harbor"@if($icon == 'harbor')selected @endif>harbor</option>
<option value="heliport"@if($icon == 'heliport')selected @endif>heliport</option>
<option value="hospital"@if($icon == 'hospital')selected @endif>hospital</option>
<option value="ice-cream"@if($icon == 'ice-cream')selected @endif>ice-cream</option>
<option value="information"@if($icon == 'information')selected @endif>information</option>
<option value="laundry"@if($icon == 'laundry')selected @endif>laundry</option>
<option value="library"@if($icon == 'library')selected @endif>library</option>
<option value="lodging"@if($icon == 'lodging')selected @endif>lodging</option>
<option value="marker"@if($icon == 'marker')selected @endif>marker</option>
<option value="monument"@if($icon == 'monument')selected @endif>monument</option>
<option value="mountain"@if($icon == 'mountain')selected @endif>mountain</option>
<option value="museum"@if($icon == 'museum')selected @endif>museum</option>
<option value="music"@if($icon == 'music')selected @endif>music</option>
<option value="park"@if($icon == 'park')selected @endif>park</option>
<option value="pharmacy"@if($icon == 'pharmacy')selected @endif>pharmacy</option>
<option value="picnic-site"@if($icon == 'picnic-site')selected @endif>picnic-site</option>
<option value="place-of-worship"@if($icon == 'place-of-worship')selected @endif>place-of-worship</option>
<option value="playground"@if($icon == 'playground')selected @endif>playground</option>
<option value="police"@if($icon == 'police')selected @endif>police</option>
<option value="post"@if($icon == 'post')selected @endif>post</option>
<option value="prison"@if($icon == 'prison')selected @endif>prison</option>
<option value="rail"@if($icon == 'rail')selected @endif>rail</option>
<option value="rail-light"@if($icon == 'rail-light')selected @endif>rail-light</option>
<option value="rail-metro"@if($icon == 'rail-metro')selected @endif>rail-metro</option>
<option value="religious-christian"@if($icon == 'religious-christian')selected @endif>religious-christian</option>
<option value="religious-jewish"@if($icon == 'religious-jewish')selected @endif>religious-jewish</option>
<option value="religious-muslim"@if($icon == 'religious-muslim')selected @endif>religious-muslim</option>
<option value="restaurant"@if($icon == 'restaurant')selected @endif>restaurant</option>
<option value="rocket"@if($icon == 'rocket')selected @endif>rocket</option>
<option value="school"@if($icon == 'school')selected @endif>school</option>
<option value="shop"@if($icon == 'shop')selected @endif>shop</option>
<option value="stadium"@if($icon == 'stadium')selected @endif>stadium</option>
<option value="star"@if($icon == 'star')selected @endif>star</option>
<option value="suitcase"@if($icon == 'suitcase')selected @endif>suitcase</option>
<option value="swimming"@if($icon == 'swimming')selected @endif>swimming</option>
<option value="theatre"@if($icon == 'theatre')selected @endif>theatre</option>
<option value="toilet"@if($icon == 'toilet')selected @endif>toilet</option>
<option value="town-hall"@if($icon == 'town-hall')selected @endif>town-hall</option>
<option value="triangle"@if($icon == 'triangle')selected @endif>triangle</option>
<option value="triangle-stroked"@if($icon == 'triangle-stroked')selected @endif>triangle-stroked</option>
<option value="veterinary"@if($icon == 'veterinary')selected @endif>veterinary</option>
<option value="volcano"@if($icon == 'volcano')selected @endif>volcano</option>
<option value="zoo"@if($icon == 'zoo')selected @endif>zoo</option>
</select><br>
<input type="submit" name="edit" value="Edit"><br><br>
<input type="submit" name="delete" value="Delete">
</form>
<p><a href="/admin/places/{{ $id }}/merge">Merge with another place?</a></p>
@stop
@section('scripts')
<script src="/assets/js/places.js"></script>
<link rel="stylesheet" href="/assets/frontend/mapbox-gl.css">
@stop

View file

@ -0,0 +1,47 @@
@extends('master')
@section('title')
Merge Places « Admin CP
@stop
@section('content')
<h1>Merge places</h1>
<p>When a place is deleted, it is removed from the database, and all the notes associated with it, will be re-associated with the other place.</p>
<table>
<tr>
<th></th>
<th>Place 1</th>
<th>Place 2</th>
</tr>
<tr>
<th>Name</th>
<td>{{ $place1->name }}</td>
<td>{{ $place2->name }}</td>
</tr>
<tr>
<th>Description</th>
<td>{{ $place1->description }}</td>
<td>{{ $place2->description }}</td>
</tr>
<tr>
<th>location</th>
<td>{{ $place1->latitude }}, {{ $place1->longitude }}</td>
<td>{{ $place2->latitude }}, {{ $place2->longitude }}</td>
</tr>
<tr>
<th>Foursquare</th>
<td>{{ $place1->foursquare }}</td>
<td>{{ $place2->foursquare }}</td>
</tr>
<tr>
<td></td>
<form action="/admin/places/merge" method="post">
{{ csrf_field() }}
<input type="hidden" name="place1" value="{{ $place1->id }}">
<input type="hidden" name="place2" value="{{ $place2->id }}">
<td><button type="submit" name="delete" value="1">Delete Place 1</button></td>
<td><button type="submit" name="delete" value="2">Delete Place 2</button></td>
</form>
</tr>
</table>
@stop

View file

@ -0,0 +1,14 @@
@extends('master')
@section('title')
Merge Places « Admin CP
@stop
@section('content')
<p>We shall be merging {{ $first->name }}. Its location is <code>Point({{ $first->location }})</code>.</p>
<ul>
@foreach($places as $place)
<li><a href="/admin/places/{{ $first->id }}/merge/{{ $place->id }}">{{ $place->name }}</a></li>
@endforeach
</ul>
@stop

View file

@ -80,6 +80,9 @@ Route::group(['domain' => config('url.longurl')], function () {
Route::post('/', 'PlacesController@store');
Route::get('/{id}/edit', 'PlacesController@edit');
Route::put('/{id}', 'PlacesController@update');
Route::get('/{id}/merge', 'PlacesController@mergeIndex');
Route::get('/{place1_id}/merge/{place2_id}', 'PlacesController@mergeEdit');
Route::post('/merge', 'PlacesController@mergeStore');
Route::delete('/{id}', 'PlacesController@destroy');
});
});

View file

@ -4,6 +4,7 @@ namespace Tests\Unit;
use App\Place;
use Tests\TestCase;
use Phaza\LaravelPostgis\Geometries\Point;
use Illuminate\Foundation\Testing\DatabaseMigrations;
use Illuminate\Foundation\Testing\DatabaseTransactions;
@ -16,7 +17,7 @@ class PlacesTest extends TestCase
*/
public function test_near_method()
{
$nearby = Place::near(53.5, -2.38, 1000);
$nearby = Place::near(new Point(53.5, -2.38), 1000)->get();
$this->assertEquals('the-bridgewater-pub', $nearby[0]->slug);
}
}

3
webpack.config.js vendored
View file

@ -7,7 +7,8 @@ const config = {
links: './links.js',
maps: './maps.js',
newnote: './newnote.js',
piwik: './piwik.js'
piwik: './piwik.js',
places: './places.js'
},
output: {
path: __dirname + '/public/assets/js',