Merge branch 'release/0.0.13.1'

This commit is contained in:
Jonny Barnes 2016-10-01 14:27:14 +01:00
commit 7c3e985db9
12 changed files with 104 additions and 31 deletions

View file

@ -307,9 +307,13 @@ class MicropubClientController extends Controller
}
try {
$query = 'geo:' . $latitude . ',' . $longitude;
if ($request->input('uncertainty') !== null) {
$query .= ';u=' . $request->input('uncertainty');
}
$response = $this->guzzleClient->get($micropubEndpoint, [
'headers' => ['Authorization' => 'Bearer ' . $token],
'query' => ['q' => 'geo:' . $latitude . ',' . $longitude],
'query' => ['q' => $query],
]);
} catch (\GuzzleHttp\Exception\BadResponseException $e) {
return response()->json([

View file

@ -147,11 +147,13 @@ EOD;
}
//nope, how about a geo URL?
if (substr($request->input('q'), 0, 4) === 'geo:') {
$geo = explode(':', $request->input('q'));
$latlng = explode(',', $geo[1]);
$latitude = $latlng[0];
$longitude = $latlng[1];
$places = Place::near($latitude, $longitude, 1000);
preg_match_all(
'/([0-9\.\-]+)/',
$request->input('q'),
$matches
);
$distance = (count($matches[0]) == 3) ? 100 * $matches[0][2] : 1000;
$places = Place::near($matches[0][0], $matches[0][1], $distance);
return response()->json([
'response' => 'places',

View file

@ -25,10 +25,15 @@ class PlaceService
$description = $request->input('description');
$geo = $request->input('geo');
}
$parts = explode(':', $geo);
$latlng = explode(',', $parts[1]);
$latitude = $latlng[0];
$longitude = $latlng[1];
if ($geo) {
preg_match_all(
'/([0-9\.\-]+)/',
$geo,
$matches
);
$latitude = $matches[0][0];
$longitude = $matches[0][1];
}
if ($request->input('latitude') !== null) {
$latitude = $request->input('latitude');
$longitude = $request->input('longitude');

View file

@ -1,9 +1,13 @@
# 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)
- Better places support, particularly with micropub (issue#9)
- Uglify js for better performance (issue#19)
- Autolink spotify links (issue#18)
- Uglify javascript for better performance (issue#19)
- Auto-link Spotify links (issue#18)
## Version 0.0.12 (2016-09-21)
- Better indication of number of replies to a note (issue#17)
@ -32,7 +36,7 @@
- Better handling of webmention reply HTML cache
## Version 0.0.11.2 (2016-09-19)
- Update Typekits js sri hash
- Update Typekits javascript sri hash
## Version 0.0.11.1 (2016-09-17)
- Fix a syntax issue in the download webmention job
@ -40,13 +44,13 @@
## Version 0.0.11 (2016-09-17)
- update linked GPG key (issue#7)
- Added `integrity` values to external assets (issue#10)
- Move mapbox links into own sub-view (issue#11)
- Updated mapbox version (issue#12)
- Move Mapbox links into own sub-view (issue#11)
- Updated Mapbox version (issue#12)
- Massive refactor of webmention code, allowing for re-parse command (issue#8)
- Add license file (issue#13)
## Version 0.0.10 (2016-09-10)
- Add an artisan command for sensiolabs security check
- Add an artisan command for Sensiolabs security check
- Remove `filp/whoops`, just use Laravels error reporting
- Better TokenMismatchException handling (issue#5)
@ -59,27 +63,27 @@
- Fix an issue with syndicating notes.
## 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
- 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
## 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
## Version 0.0.8.4 (2016-07-18)
- Make the revised non-elixir asset links absolute
## 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)
- Improve syndication parsing to allow better name display on new note form
## 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)
- Allow new notes to be made by a JSON request from a micropub client
@ -116,11 +120,11 @@
- Add a stylelint lint-staged hook
## 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
## 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)
- Initial release

View file

@ -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.

View file

@ -12,13 +12,13 @@ if ('geolocation' in navigator) {
function getLocation() {
navigator.geolocation.getCurrentPosition(function (position) {
//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
fetch('/places/near/' + latitude + '/' + longitude, {
fetch('/places/near/' + latitude + '/' + longitude + '?' + uncertainty, {
credentials: 'same-origin',
method: 'get'
}).then(function (response) {

View file

@ -46,9 +46,6 @@ class MicropubClientTest extends TestCase
->see('https://twitter.com/jonnybarnes');
}
/**
* This currently creates a new note that stays in the database.
*/
public function testClientCreatesNewNoteWithTag()
{
$faker = \Faker\Factory::create();
@ -62,6 +59,11 @@ class MicropubClientTest extends TestCase
$this->seeInDatabase('notes', ['note' => $note]);
$this->visit($this->appurl . '/notes/tagged/PHPUnit')
->see('PHPUnit');
//my client has made a request to my endpoint, which then adds
//to the db, so database transaction dont work
//so lets manually delete the new entry
$newNote = \App\Note::where('note', $note);
$newNote->forceDelete();
}

View file

@ -53,6 +53,12 @@ class MicropubTest extends TestCase
$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()
{
$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()
{
$signer = new Sha256();