Merge branch 'release/0.0.13.1'
This commit is contained in:
commit
7c3e985db9
12 changed files with 104 additions and 31 deletions
|
@ -307,9 +307,13 @@ class MicropubClientController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
$query = 'geo:' . $latitude . ',' . $longitude;
|
||||||
|
if ($request->input('uncertainty') !== null) {
|
||||||
|
$query .= ';u=' . $request->input('uncertainty');
|
||||||
|
}
|
||||||
$response = $this->guzzleClient->get($micropubEndpoint, [
|
$response = $this->guzzleClient->get($micropubEndpoint, [
|
||||||
'headers' => ['Authorization' => 'Bearer ' . $token],
|
'headers' => ['Authorization' => 'Bearer ' . $token],
|
||||||
'query' => ['q' => 'geo:' . $latitude . ',' . $longitude],
|
'query' => ['q' => $query],
|
||||||
]);
|
]);
|
||||||
} catch (\GuzzleHttp\Exception\BadResponseException $e) {
|
} catch (\GuzzleHttp\Exception\BadResponseException $e) {
|
||||||
return response()->json([
|
return response()->json([
|
||||||
|
|
|
@ -147,11 +147,13 @@ EOD;
|
||||||
}
|
}
|
||||||
//nope, how about a geo URL?
|
//nope, how about a geo URL?
|
||||||
if (substr($request->input('q'), 0, 4) === 'geo:') {
|
if (substr($request->input('q'), 0, 4) === 'geo:') {
|
||||||
$geo = explode(':', $request->input('q'));
|
preg_match_all(
|
||||||
$latlng = explode(',', $geo[1]);
|
'/([0-9\.\-]+)/',
|
||||||
$latitude = $latlng[0];
|
$request->input('q'),
|
||||||
$longitude = $latlng[1];
|
$matches
|
||||||
$places = Place::near($latitude, $longitude, 1000);
|
);
|
||||||
|
$distance = (count($matches[0]) == 3) ? 100 * $matches[0][2] : 1000;
|
||||||
|
$places = Place::near($matches[0][0], $matches[0][1], $distance);
|
||||||
|
|
||||||
return response()->json([
|
return response()->json([
|
||||||
'response' => 'places',
|
'response' => 'places',
|
||||||
|
|
|
@ -25,10 +25,15 @@ class PlaceService
|
||||||
$description = $request->input('description');
|
$description = $request->input('description');
|
||||||
$geo = $request->input('geo');
|
$geo = $request->input('geo');
|
||||||
}
|
}
|
||||||
$parts = explode(':', $geo);
|
if ($geo) {
|
||||||
$latlng = explode(',', $parts[1]);
|
preg_match_all(
|
||||||
$latitude = $latlng[0];
|
'/([0-9\.\-]+)/',
|
||||||
$longitude = $latlng[1];
|
$geo,
|
||||||
|
$matches
|
||||||
|
);
|
||||||
|
$latitude = $matches[0][0];
|
||||||
|
$longitude = $matches[0][1];
|
||||||
|
}
|
||||||
if ($request->input('latitude') !== null) {
|
if ($request->input('latitude') !== null) {
|
||||||
$latitude = $request->input('latitude');
|
$latitude = $request->input('latitude');
|
||||||
$longitude = $request->input('longitude');
|
$longitude = $request->input('longitude');
|
||||||
|
|
30
changelog.md
30
changelog.md
|
@ -1,9 +1,13 @@
|
||||||
# Changelog
|
# Changelog
|
||||||
|
|
||||||
|
## Version 0.0.13.1 (2016-10-01)
|
||||||
|
- Add support for accuracy/uncertainty in geo URIs (issue#20,issue#9)
|
||||||
|
- Add some places tests
|
||||||
|
|
||||||
## Version 0.0.13 (2016-09-26)
|
## Version 0.0.13 (2016-09-26)
|
||||||
- Better places support, particularly with micropub (issue#9)
|
- Better places support, particularly with micropub (issue#9)
|
||||||
- Uglify js for better performance (issue#19)
|
- Uglify javascript for better performance (issue#19)
|
||||||
- Autolink spotify links (issue#18)
|
- Auto-link Spotify links (issue#18)
|
||||||
|
|
||||||
## Version 0.0.12 (2016-09-21)
|
## Version 0.0.12 (2016-09-21)
|
||||||
- Better indication of number of replies to a note (issue#17)
|
- Better indication of number of replies to a note (issue#17)
|
||||||
|
@ -32,7 +36,7 @@
|
||||||
- Better handling of webmention reply HTML cache
|
- Better handling of webmention reply HTML cache
|
||||||
|
|
||||||
## Version 0.0.11.2 (2016-09-19)
|
## Version 0.0.11.2 (2016-09-19)
|
||||||
- Update Typekit’s js sri hash
|
- Update Typekit’s javascript sri hash
|
||||||
|
|
||||||
## Version 0.0.11.1 (2016-09-17)
|
## Version 0.0.11.1 (2016-09-17)
|
||||||
- Fix a syntax issue in the download webmention job
|
- Fix a syntax issue in the download webmention job
|
||||||
|
@ -40,13 +44,13 @@
|
||||||
## Version 0.0.11 (2016-09-17)
|
## Version 0.0.11 (2016-09-17)
|
||||||
- update linked GPG key (issue#7)
|
- update linked GPG key (issue#7)
|
||||||
- Added `integrity` values to external assets (issue#10)
|
- Added `integrity` values to external assets (issue#10)
|
||||||
- Move mapbox links into own sub-view (issue#11)
|
- Move Mapbox links into own sub-view (issue#11)
|
||||||
- Updated mapbox version (issue#12)
|
- Updated Mapbox version (issue#12)
|
||||||
- Massive refactor of webmention code, allowing for re-parse command (issue#8)
|
- Massive refactor of webmention code, allowing for re-parse command (issue#8)
|
||||||
- Add license file (issue#13)
|
- Add license file (issue#13)
|
||||||
|
|
||||||
## Version 0.0.10 (2016-09-10)
|
## Version 0.0.10 (2016-09-10)
|
||||||
- Add an artisan command for sensiolab’s security check
|
- Add an artisan command for Sensiolab’s security check
|
||||||
- Remove `filp/whoops`, just use Laravel’s error reporting
|
- Remove `filp/whoops`, just use Laravel’s error reporting
|
||||||
- Better TokenMismatchException handling (issue#5)
|
- Better TokenMismatchException handling (issue#5)
|
||||||
|
|
||||||
|
@ -59,27 +63,27 @@
|
||||||
- Fix an issue with syndicating notes.
|
- Fix an issue with syndicating notes.
|
||||||
|
|
||||||
## Version 0.0.9 (2016-09-06)
|
## Version 0.0.9 (2016-09-06)
|
||||||
- Adding jsonb column to store webmentions’ mf2.
|
- Adding `jsonb` column to store webmentions’ microformats.
|
||||||
* As of L5.2 this needs a custom command to drop NOT NULL from content, L5.3 should allow a fix for this
|
* As of L5.2 this needs a custom command to drop NOT NULL from content, L5.3 should allow a fix for this
|
||||||
- Refactor receiving webmention code
|
- Refactor receiving webmention code
|
||||||
- Refactor sending webmention code to pass webmention.rocks
|
- Refactor sending webmention code to pass `webmention.rocks`
|
||||||
- Update to use Laravel 5.3
|
- Update to use Laravel 5.3
|
||||||
|
|
||||||
## Version 0.0.8.5 (2016-07-18)
|
## Version 0.0.8.5 (2016-07-18)
|
||||||
- Set the size of the textarea in a form better
|
- Set the size of the `textarea` in a form better
|
||||||
- Update to latest Guzzle to fix CVE-2016-5385
|
- Update to latest Guzzle to fix CVE-2016-5385
|
||||||
|
|
||||||
## Version 0.0.8.4 (2016-07-18)
|
## Version 0.0.8.4 (2016-07-18)
|
||||||
- Make the revised non-elixir asset links absolute
|
- Make the revised non-elixir asset links absolute
|
||||||
|
|
||||||
## Version 0.0.8.3 (2016-07-18)
|
## Version 0.0.8.3 (2016-07-18)
|
||||||
- Dump laravel-elixir, use gulp natively. Also this means using nginx and etags for cache-busting
|
- Dump `laravel-elixir`, use gulp natively. Also this means using nginx and etags for cache-busting
|
||||||
|
|
||||||
## Version 0.0.8.2 (2016-07-15)
|
## Version 0.0.8.2 (2016-07-15)
|
||||||
- Improve syndication parsing to allow better name display on new note form
|
- Improve syndication parsing to allow better name display on new note form
|
||||||
|
|
||||||
## Version 0.0.8.1 (2016-07-13)
|
## Version 0.0.8.1 (2016-07-13)
|
||||||
- Fix anh issue in the syndication target parsing method
|
- Fix an issue in the syndication target parsing method
|
||||||
|
|
||||||
## Version 0.0.8 (2016-07-13)
|
## Version 0.0.8 (2016-07-13)
|
||||||
- Allow new notes to be made by a JSON request from a micropub client
|
- Allow new notes to be made by a JSON request from a micropub client
|
||||||
|
@ -116,11 +120,11 @@
|
||||||
- Add a stylelint lint-staged hook
|
- Add a stylelint lint-staged hook
|
||||||
|
|
||||||
## Version 0.0.3 (2013-06-09)
|
## Version 0.0.3 (2013-06-09)
|
||||||
- Better tag normalization code organisation
|
- Better tag normalisation code organisation
|
||||||
- Remove `jonnybarnes/unicode-tools` dependency and clean up relevant code
|
- Remove `jonnybarnes/unicode-tools` dependency and clean up relevant code
|
||||||
|
|
||||||
## Version 0.0.2 (2016-05-25)
|
## Version 0.0.2 (2016-05-25)
|
||||||
- Fix issue#1: tagged notes page needs the tag from the URL normalizing.
|
- Fix issue#1: tagged notes page needs the tag from the URL normalising.
|
||||||
|
|
||||||
## Version 0.0.1 (2016-05-25)
|
## Version 0.0.1 (2016-05-25)
|
||||||
- Initial release
|
- Initial release
|
||||||
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
|
||||||
|
class CascadeDeleteNoteTags extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function up()
|
||||||
|
{
|
||||||
|
Schema::table('note_tag', function ($table) {
|
||||||
|
$table->dropForeign('note_tag_note_id_foreign');
|
||||||
|
$table->foreign('note_id')->references('id')->on('notes')->onDelete('cascade');
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migrations.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
public function down()
|
||||||
|
{
|
||||||
|
//
|
||||||
|
}
|
||||||
|
}
|
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.
|
@ -12,13 +12,13 @@ if ('geolocation' in navigator) {
|
||||||
function getLocation() {
|
function getLocation() {
|
||||||
navigator.geolocation.getCurrentPosition(function (position) {
|
navigator.geolocation.getCurrentPosition(function (position) {
|
||||||
//the locate button has been clicked so add the places/map
|
//the locate button has been clicked so add the places/map
|
||||||
addPlacesMap(position.coords.latitude, position.coords.longitude);
|
addPlacesMap(position.coords.latitude, position.coords.longitude, position.coords.accuracy);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function addPlacesMap(latitude, longitude) {
|
function addPlacesMap(latitude, longitude, uncertainty) {
|
||||||
//get the nearby places
|
//get the nearby places
|
||||||
fetch('/places/near/' + latitude + '/' + longitude, {
|
fetch('/places/near/' + latitude + '/' + longitude + '?' + uncertainty, {
|
||||||
credentials: 'same-origin',
|
credentials: 'same-origin',
|
||||||
method: 'get'
|
method: 'get'
|
||||||
}).then(function (response) {
|
}).then(function (response) {
|
||||||
|
|
|
@ -46,9 +46,6 @@ class MicropubClientTest extends TestCase
|
||||||
->see('https://twitter.com/jonnybarnes');
|
->see('https://twitter.com/jonnybarnes');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* This currently creates a new note that stays in the database.
|
|
||||||
*/
|
|
||||||
public function testClientCreatesNewNoteWithTag()
|
public function testClientCreatesNewNoteWithTag()
|
||||||
{
|
{
|
||||||
$faker = \Faker\Factory::create();
|
$faker = \Faker\Factory::create();
|
||||||
|
@ -62,6 +59,11 @@ class MicropubClientTest extends TestCase
|
||||||
$this->seeInDatabase('notes', ['note' => $note]);
|
$this->seeInDatabase('notes', ['note' => $note]);
|
||||||
$this->visit($this->appurl . '/notes/tagged/PHPUnit')
|
$this->visit($this->appurl . '/notes/tagged/PHPUnit')
|
||||||
->see('PHPUnit');
|
->see('PHPUnit');
|
||||||
|
//my client has made a request to my endpoint, which then adds
|
||||||
|
//to the db, so database transaction don’t work
|
||||||
|
//so lets manually delete the new entry
|
||||||
|
$newNote = \App\Note::where('note', $note);
|
||||||
|
$newNote->forceDelete();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -53,6 +53,12 @@ class MicropubTest extends TestCase
|
||||||
$this->see('the-bridgewater-pub');
|
$this->see('the-bridgewater-pub');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testMicropubRequestForNearbyPlacesThatExistWithUncertaintyParameter()
|
||||||
|
{
|
||||||
|
$this->call('GET', $this->appurl . '/api/post', ['q' => 'geo:53.5,-2.38;u=35'], [], [], ['HTTP_Authorization' => 'Bearer ' . $this->getToken()]);
|
||||||
|
$this->see('the-bridgewater-pub');
|
||||||
|
}
|
||||||
|
|
||||||
public function testMicropubRequestForNearbyPlacesThatDoNotExist()
|
public function testMicropubRequestForNearbyPlacesThatDoNotExist()
|
||||||
{
|
{
|
||||||
$this->call('GET', $this->appurl . '/api/post', ['q' => 'geo:1.23,4.56'], [], [], ['HTTP_Authorization' => 'Bearer ' . $this->getToken()]);
|
$this->call('GET', $this->appurl . '/api/post', ['q' => 'geo:1.23,4.56'], [], [], ['HTTP_Authorization' => 'Bearer ' . $this->getToken()]);
|
||||||
|
@ -216,6 +222,25 @@ class MicropubTest extends TestCase
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testMicropubJSONRequestCreateNewPlaceWithUncertaintyParam()
|
||||||
|
{
|
||||||
|
$faker = \Faker\Factory::create();
|
||||||
|
$this->json(
|
||||||
|
'POST',
|
||||||
|
$this->appurl . '/api/post',
|
||||||
|
[
|
||||||
|
'type' => ['h-card'],
|
||||||
|
'properties' => [
|
||||||
|
'name' => $faker->name,
|
||||||
|
'geo' => 'geo:' . $faker->latitude . ',' . $faker->longitude . ';u=35'
|
||||||
|
],
|
||||||
|
],
|
||||||
|
['HTTP_Authorization' => 'Bearer ' . $this->getToken()]
|
||||||
|
)->seeJson([
|
||||||
|
'response' => 'created'
|
||||||
|
])->assertResponseStatus(201);
|
||||||
|
}
|
||||||
|
|
||||||
private function getToken()
|
private function getToken()
|
||||||
{
|
{
|
||||||
$signer = new Sha256();
|
$signer = new Sha256();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue