Merge branch 'release/0.8'

This commit is contained in:
Jonny Barnes 2017-09-16 12:15:43 +01:00
commit f7d807be9c
31 changed files with 386 additions and 71 deletions

View file

@ -16,6 +16,7 @@ addons:
- nginx - nginx
- realpath - realpath
- postgresql-9.6-postgis-2.3 - postgresql-9.6-postgis-2.3
- imagemagick
artifacts: artifacts:
s3_region: "eu-west-1" s3_region: "eu-west-1"
paths: paths:
@ -33,8 +34,10 @@ env:
php: php:
- 7.1 - 7.1
- 7.2
before_install: before_install:
- printf "\n" | pecl install imagick
- cp .env.travis .env - cp .env.travis .env
- echo 'error_log = "/tmp/php.error.log"' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini - echo 'error_log = "/tmp/php.error.log"' >> ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/travis.ini
- psql -U travis -c 'create database travis_ci_test' - psql -U travis -c 'create database travis_ci_test'

View file

@ -2,10 +2,13 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use Storage;
use Monolog\Logger; use Monolog\Logger;
use Ramsey\Uuid\Uuid; use Ramsey\Uuid\Uuid;
use App\Jobs\ProcessImage;
use App\{Media, Note, Place}; use App\{Media, Note, Place};
use Monolog\Handler\StreamHandler; use Monolog\Handler\StreamHandler;
use Intervention\Image\ImageManager;
use Illuminate\Http\{Request, Response}; use Illuminate\Http\{Request, Response};
use App\Exceptions\InvalidTokenException; use App\Exceptions\InvalidTokenException;
use Phaza\LaravelPostgis\Geometries\Point; use Phaza\LaravelPostgis\Geometries\Point;
@ -90,7 +93,9 @@ class MicropubController extends Controller
if (is_array($request->input('properties.location.0'))) { if (is_array($request->input('properties.location.0'))) {
if ($request->input('properties.location.0.type.0' === 'h-card')) { if ($request->input('properties.location.0.type.0' === 'h-card')) {
try { try {
$place = $this->placeService->createPlaceFromCheckin($request->input('properties.location.0')); $place = $this->placeService->createPlaceFromCheckin(
$request->input('properties.location.0')
);
$data['checkin'] = $place->longurl; $data['checkin'] = $place->longurl;
} catch (\Exception $e) { } catch (\Exception $e) {
// //
@ -102,7 +107,9 @@ class MicropubController extends Controller
if (array_key_exists('checkin', $request->input('properties'))) { if (array_key_exists('checkin', $request->input('properties'))) {
$data['swarm-url'] = $request->input('properties.syndication.0'); $data['swarm-url'] = $request->input('properties.syndication.0');
try { try {
$place = $this->placeService->createPlaceFromCheckin($request->input('properties.checkin.0')); $place = $this->placeService->createPlaceFromCheckin(
$request->input('properties.checkin.0')
);
$data['checkin'] = $place->longurl; $data['checkin'] = $place->longurl;
} catch (\Exception $e) { } catch (\Exception $e) {
$data['checkin'] = null; $data['checkin'] = null;
@ -395,8 +402,11 @@ class MicropubController extends Controller
'error_description' => 'A problem occured handling your request', 'error_description' => 'A problem occured handling your request',
], 500); ], 500);
} }
$size = $request->file('file')->getClientSize();
Storage::disk('local')->put($filename, $request->file('file')->openFile()->fread($size));
try { try {
$path = $request->file('file')->storeAs('media', $filename, 's3'); Storage::disk('s3')->put('media/' . $filename, $request->file('file')->openFile()->fread($size));
} catch (Exception $e) { // which exception? } catch (Exception $e) { // which exception?
return response()->json([ return response()->json([
'response' => 'error', 'response' => 'error',
@ -404,12 +414,25 @@ class MicropubController extends Controller
'error_description' => 'Unable to save media to S3', 'error_description' => 'Unable to save media to S3',
], 503); ], 503);
} }
$manager = app()->make(ImageManager::class);
try {
$image = $manager->make($request->file('file'));
$width = $image->width();
} catch (\Intervention\Image\Exception\NotReadableException $exception) {
// not an image
$width = null;
}
$media = new Media(); $media = new Media();
$media->token = $request->bearerToken(); $media->token = $request->bearerToken();
$media->path = $path; $media->path = 'media/' . $filename;
$media->type = $this->getFileTypeFromMimeType($request->file('file')->getMimeType()); $media->type = $this->getFileTypeFromMimeType($request->file('file')->getMimeType());
$media->image_widths = $width;
$media->save(); $media->save();
dispatch(new ProcessImage($filename));
return response()->json([ return response()->json([
'response' => 'created', 'response' => 'created',
'location' => $media->url, 'location' => $media->url,

68
app/Jobs/ProcessImage.php Normal file
View file

@ -0,0 +1,68 @@
<?php
namespace App\Jobs;
use Storage;
use Illuminate\Bus\Queueable;
use Intervention\Image\ImageManager;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Intervention\Image\Exception\NotReadableException;
class ProcessImage implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
protected $filename;
/**
* Create a new job instance.
*
* @return void
*/
public function __construct(string $filename)
{
$this->filename = $filename;
}
/**
* Execute the job.
*
* @return void
*/
public function handle(ImageManager $manager)
{
//open file
try {
$image = $manager->make(storage_path('app') . '/' . $this->filename);
} catch (NotReadableException $exception) {
// not an image; delete file and end job
unlink(storage_path('app') . '/' . $this->filename);
return;
}
//create smaller versions if necessary
if ($image->width() >= 1000) {
$filenameParts = explode('.', $this->filename);
$extension = array_pop($filenameParts);
// the following acheives this data flow
// foo.bar.png => ['foo', 'bar', 'png'] => ['foo', 'bar'] => foo.bar
$basename = ltrim(array_reduce($filenameParts, function ($carry, $item) {
return $carry . '.' . $item;
}, ''), '.');
$medium = $image->resize(1000, null, function ($constraint) {
$constraint->aspectRatio();
});
Storage::disk('s3')->put('media/'. $basename . '-medium.' . $extension, (string) $medium->encode());
$small = $image->resize(500, null, function ($constraint) {
$constraint->aspectRatio();
});
Storage::disk('s3')->put('media/' . $basename . '-small.' . $extension, (string) $small->encode());
}
// now we can delete the locally saved image
unlink(storage_path('app') . '/' . $this->filename);
}
}

View file

@ -41,4 +41,40 @@ class Media extends Model
return config('filesystems.disks.s3.url') . '/' . $this->path; return config('filesystems.disks.s3.url') . '/' . $this->path;
} }
/**
* Get the URL for the medium size of an S3 image file.
*
* @return string
*/
public function getMediumurlAttribute()
{
$filenameParts = explode('.', $this->path);
$extension = array_pop($filenameParts);
// the following acheives this data flow
// foo.bar.png => ['foo', 'bar', 'png'] => ['foo', 'bar'] => foo.bar
$basename = ltrim(array_reduce($filenameParts, function ($carry, $item) {
return $carry . '.' . $item;
}, ''), '.');
return config('filesystems.disks.s3.url') . '/' . $basename . '-medium.' . $extension;
}
/**
* Get the URL for the small size of an S3 image file.
*
* @return string
*/
public function getSmallurlAttribute()
{
$filenameParts = explode('.', $this->path);
$extension = array_pop($filenameParts);
// the following acheives this data flow
// foo.bar.png => ['foo', 'bar', 'png'] => ['foo', 'bar'] => foo.bar
$basename = ltrim(array_reduce($filenameParts, function ($carry, $item) {
return $carry . '.' . $item;
}, ''), '.');
return config('filesystems.disks.s3.url') . '/' . $basename . '-small.' . $extension;
}
} }

View file

@ -280,8 +280,8 @@ class Note extends Model
try { try {
$oEmbed = Twitter::getOembed([ $oEmbed = Twitter::getOembed([
'id' => $tweetId, 'id' => $tweetId,
'dnt' => true,
'align' => 'center', 'align' => 'center',
'omit_script' => true,
'maxwidth' => 550, 'maxwidth' => 550,
]); ]);
} catch (\Exception $e) { } catch (\Exception $e) {
@ -368,7 +368,8 @@ class Note extends Model
return $matches[0]; return $matches[0];
} }
if ($contact->facebook) { if ($contact->facebook) {
return '<a class="u-category h-card" href="https://facebook.com/' . $contact->facebook . '">' . $contact->name . '</a>'; return '<a class="u-category h-card" href="https://facebook.com/'
. $contact->facebook . '">' . $contact->name . '</a>';
} }
return $contact->name; return $contact->name;

View file

@ -67,7 +67,8 @@ class Place extends Model
public function scopeNear(Builder $query, Point $point, $distance = 1000) public function scopeNear(Builder $query, Point $point, $distance = 1000)
{ {
$field = DB::raw( $field = DB::raw(
sprintf("ST_Distance(%s.location, ST_GeogFromText('%s'))", sprintf(
"ST_Distance(%s.location, ST_GeogFromText('%s'))",
$this->getTable(), $this->getTable(),
$point->toWKT() $point->toWKT()
) )

View file

@ -52,6 +52,11 @@ class AppServiceProvider extends ServiceProvider
Request::macro('wantsActivityStream', function () { Request::macro('wantsActivityStream', function () {
return str_contains(mb_strtolower($this->header('Accept')), 'application/activity+json'); return str_contains(mb_strtolower($this->header('Accept')), 'application/activity+json');
}); });
// configure Intervention/Image
$this->app->bind('Intervention\Image\ImageManager', function () {
return new \Intervention\Image\ImageManager(['driver' => config('image.driver')]);
});
} }
/** /**

View file

@ -1,5 +1,9 @@
# Changelog # Changelog
## Version 0.8 (2017-09-16)
- Improve embedding of tweets (issue#66)
- Allow for “responsive” images (issue#62)
## Version 0.7.3 (2017-09-13) ## Version 0.7.3 (2017-09-13)
- Fix a test - Fix a test

View file

@ -11,6 +11,7 @@
"fideloper/proxy": "~3.3", "fideloper/proxy": "~3.3",
"guzzlehttp/guzzle": "~6.0", "guzzlehttp/guzzle": "~6.0",
"indieauth/client": "~0.1", "indieauth/client": "~0.1",
"intervention/image": "^2.4",
"jonnybarnes/commonmark-linkify": "^0.2", "jonnybarnes/commonmark-linkify": "^0.2",
"jonnybarnes/emoji-a11y": "^0.3", "jonnybarnes/emoji-a11y": "^0.3",
"jonnybarnes/indieweb": "dev-master", "jonnybarnes/indieweb": "dev-master",

188
composer.lock generated
View file

@ -4,20 +4,20 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "ee80722747b7215eddfb5da75063b542", "content-hash": "560e297345d19c326c8ff08ccfd3668c",
"packages": [ "packages": [
{ {
"name": "aws/aws-sdk-php", "name": "aws/aws-sdk-php",
"version": "3.36.4", "version": "3.36.7",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/aws/aws-sdk-php.git", "url": "https://github.com/aws/aws-sdk-php.git",
"reference": "acb08da60a042e17b0cd9e5e111ba895c8a79f2d" "reference": "421088947540b1c7956cd693b032124e2c74eb76"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/acb08da60a042e17b0cd9e5e111ba895c8a79f2d", "url": "https://api.github.com/repos/aws/aws-sdk-php/zipball/421088947540b1c7956cd693b032124e2c74eb76",
"reference": "acb08da60a042e17b0cd9e5e111ba895c8a79f2d", "reference": "421088947540b1c7956cd693b032124e2c74eb76",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -84,7 +84,7 @@
"s3", "s3",
"sdk" "sdk"
], ],
"time": "2017-09-08T19:50:29+00:00" "time": "2017-09-13T18:56:17+00:00"
}, },
{ {
"name": "barnabywalters/mf-cleaner", "name": "barnabywalters/mf-cleaner",
@ -1493,6 +1493,76 @@
], ],
"time": "2017-01-11T17:14:49+00:00" "time": "2017-01-11T17:14:49+00:00"
}, },
{
"name": "intervention/image",
"version": "2.4.0",
"source": {
"type": "git",
"url": "https://github.com/Intervention/image.git",
"reference": "322a4ade249467179c50a3e50eda8760ff3af2a3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Intervention/image/zipball/322a4ade249467179c50a3e50eda8760ff3af2a3",
"reference": "322a4ade249467179c50a3e50eda8760ff3af2a3",
"shasum": ""
},
"require": {
"ext-fileinfo": "*",
"guzzlehttp/psr7": "~1.1",
"php": ">=5.4.0"
},
"require-dev": {
"mockery/mockery": "~0.9.2",
"phpunit/phpunit": "^4.8 || ^5.7"
},
"suggest": {
"ext-gd": "to use GD library based image processing.",
"ext-imagick": "to use Imagick based image processing.",
"intervention/imagecache": "Caching extension for the Intervention Image library"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.3-dev"
},
"laravel": {
"providers": [
"Intervention\\Image\\ImageServiceProvider"
],
"aliases": {
"Image": "Intervention\\Image\\Facades\\Image"
}
}
},
"autoload": {
"psr-4": {
"Intervention\\Image\\": "src/Intervention/Image"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Oliver Vogel",
"email": "oliver@olivervogel.com",
"homepage": "http://olivervogel.com/"
}
],
"description": "Image handling and manipulation library with support for Laravel integration",
"homepage": "http://image.intervention.io/",
"keywords": [
"gd",
"image",
"imagick",
"laravel",
"thumbnail",
"watermark"
],
"time": "2017-07-03T15:50:40+00:00"
},
{ {
"name": "jakub-onderka/php-console-color", "name": "jakub-onderka/php-console-color",
"version": "0.1", "version": "0.1",
@ -1815,16 +1885,16 @@
}, },
{ {
"name": "laravel/framework", "name": "laravel/framework",
"version": "v5.5.3", "version": "v5.5.4",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/laravel/framework.git", "url": "https://github.com/laravel/framework.git",
"reference": "779a98d3b2ebed2128db1a668dcc10a65c9b01be" "reference": "d3e0493bead126cf7fb9a005c64e6b58a9190e51"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/laravel/framework/zipball/779a98d3b2ebed2128db1a668dcc10a65c9b01be", "url": "https://api.github.com/repos/laravel/framework/zipball/d3e0493bead126cf7fb9a005c64e6b58a9190e51",
"reference": "779a98d3b2ebed2128db1a668dcc10a65c9b01be", "reference": "d3e0493bead126cf7fb9a005c64e6b58a9190e51",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1943,20 +2013,20 @@
"framework", "framework",
"laravel" "laravel"
], ],
"time": "2017-09-07T13:50:21+00:00" "time": "2017-09-13T13:36:29+00:00"
}, },
{ {
"name": "laravel/horizon", "name": "laravel/horizon",
"version": "v1.0.2", "version": "v1.0.3",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/laravel/horizon.git", "url": "https://github.com/laravel/horizon.git",
"reference": "ec52cd6c304eb9dfc3320e32d9e43c5ee55e7d7c" "reference": "df65f5b3f5119cc5f0a6bfbd501f83580efd0842"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/laravel/horizon/zipball/ec52cd6c304eb9dfc3320e32d9e43c5ee55e7d7c", "url": "https://api.github.com/repos/laravel/horizon/zipball/df65f5b3f5119cc5f0a6bfbd501f83580efd0842",
"reference": "ec52cd6c304eb9dfc3320e32d9e43c5ee55e7d7c", "reference": "df65f5b3f5119cc5f0a6bfbd501f83580efd0842",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -2011,20 +2081,20 @@
"laravel", "laravel",
"queue" "queue"
], ],
"time": "2017-09-08T16:30:09+00:00" "time": "2017-09-12T12:50:19+00:00"
}, },
{ {
"name": "laravel/scout", "name": "laravel/scout",
"version": "v3.0.7", "version": "v3.0.9",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/laravel/scout.git", "url": "https://github.com/laravel/scout.git",
"reference": "b899432186096dacc90700d5320d95cc3db1efe1" "reference": "84762c8ed51cb57f09b5f465e09993e48baf9d55"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/laravel/scout/zipball/b899432186096dacc90700d5320d95cc3db1efe1", "url": "https://api.github.com/repos/laravel/scout/zipball/84762c8ed51cb57f09b5f465e09993e48baf9d55",
"reference": "b899432186096dacc90700d5320d95cc3db1efe1", "reference": "84762c8ed51cb57f09b5f465e09993e48baf9d55",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -2076,7 +2146,7 @@
"laravel", "laravel",
"search" "search"
], ],
"time": "2017-07-12T18:42:43+00:00" "time": "2017-09-13T18:24:31+00:00"
}, },
{ {
"name": "laravel/tinker", "name": "laravel/tinker",
@ -3402,16 +3472,16 @@
}, },
{ {
"name": "symfony/console", "name": "symfony/console",
"version": "v3.3.8", "version": "v3.3.9",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/console.git", "url": "https://github.com/symfony/console.git",
"reference": "d6596cb5022b6a0bd940eae54a1de78646a5fda6" "reference": "a1e1b01293a090cb9ae2ddd221a3251a4a7e4abf"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/console/zipball/d6596cb5022b6a0bd940eae54a1de78646a5fda6", "url": "https://api.github.com/repos/symfony/console/zipball/a1e1b01293a090cb9ae2ddd221a3251a4a7e4abf",
"reference": "d6596cb5022b6a0bd940eae54a1de78646a5fda6", "reference": "a1e1b01293a090cb9ae2ddd221a3251a4a7e4abf",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -3466,11 +3536,11 @@
], ],
"description": "Symfony Console Component", "description": "Symfony Console Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2017-08-27T14:52:21+00:00" "time": "2017-09-06T16:40:18+00:00"
}, },
{ {
"name": "symfony/css-selector", "name": "symfony/css-selector",
"version": "v3.3.8", "version": "v3.3.9",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/css-selector.git", "url": "https://github.com/symfony/css-selector.git",
@ -3523,16 +3593,16 @@
}, },
{ {
"name": "symfony/debug", "name": "symfony/debug",
"version": "v3.3.8", "version": "v3.3.9",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/debug.git", "url": "https://github.com/symfony/debug.git",
"reference": "084d804fe35808eb2ef596ec83d85d9768aa6c9d" "reference": "8beb24eec70b345c313640962df933499373a944"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/debug/zipball/084d804fe35808eb2ef596ec83d85d9768aa6c9d", "url": "https://api.github.com/repos/symfony/debug/zipball/8beb24eec70b345c313640962df933499373a944",
"reference": "084d804fe35808eb2ef596ec83d85d9768aa6c9d", "reference": "8beb24eec70b345c313640962df933499373a944",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -3575,11 +3645,11 @@
], ],
"description": "Symfony Debug Component", "description": "Symfony Debug Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2017-08-27T14:52:21+00:00" "time": "2017-09-01T13:23:39+00:00"
}, },
{ {
"name": "symfony/event-dispatcher", "name": "symfony/event-dispatcher",
"version": "v3.3.8", "version": "v3.3.9",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/event-dispatcher.git", "url": "https://github.com/symfony/event-dispatcher.git",
@ -3642,7 +3712,7 @@
}, },
{ {
"name": "symfony/finder", "name": "symfony/finder",
"version": "v3.3.8", "version": "v3.3.9",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/finder.git", "url": "https://github.com/symfony/finder.git",
@ -3691,16 +3761,16 @@
}, },
{ {
"name": "symfony/http-foundation", "name": "symfony/http-foundation",
"version": "v3.3.8", "version": "v3.3.9",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/http-foundation.git", "url": "https://github.com/symfony/http-foundation.git",
"reference": "14bacad23a4f075bfd3fd456755236cb261320e3" "reference": "2cdc7de1921d1a1c805a13dc05e44a2cd58f5ad3"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/http-foundation/zipball/14bacad23a4f075bfd3fd456755236cb261320e3", "url": "https://api.github.com/repos/symfony/http-foundation/zipball/2cdc7de1921d1a1c805a13dc05e44a2cd58f5ad3",
"reference": "14bacad23a4f075bfd3fd456755236cb261320e3", "reference": "2cdc7de1921d1a1c805a13dc05e44a2cd58f5ad3",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -3740,20 +3810,20 @@
], ],
"description": "Symfony HttpFoundation Component", "description": "Symfony HttpFoundation Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2017-08-10T07:07:06+00:00" "time": "2017-09-06T17:07:39+00:00"
}, },
{ {
"name": "symfony/http-kernel", "name": "symfony/http-kernel",
"version": "v3.3.8", "version": "v3.3.9",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/http-kernel.git", "url": "https://github.com/symfony/http-kernel.git",
"reference": "1c1717d28904744dc9a9f6a9d97a8b9bed1680e9" "reference": "70f5bb3cdd737624249953b61023411e26be5db7"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/symfony/http-kernel/zipball/1c1717d28904744dc9a9f6a9d97a8b9bed1680e9", "url": "https://api.github.com/repos/symfony/http-kernel/zipball/70f5bb3cdd737624249953b61023411e26be5db7",
"reference": "1c1717d28904744dc9a9f6a9d97a8b9bed1680e9", "reference": "70f5bb3cdd737624249953b61023411e26be5db7",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -3826,7 +3896,7 @@
], ],
"description": "Symfony HttpKernel Component", "description": "Symfony HttpKernel Component",
"homepage": "https://symfony.com", "homepage": "https://symfony.com",
"time": "2017-08-28T22:35:03+00:00" "time": "2017-09-11T16:13:23+00:00"
}, },
{ {
"name": "symfony/polyfill-mbstring", "name": "symfony/polyfill-mbstring",
@ -3889,7 +3959,7 @@
}, },
{ {
"name": "symfony/process", "name": "symfony/process",
"version": "v3.3.8", "version": "v3.3.9",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/process.git", "url": "https://github.com/symfony/process.git",
@ -3938,7 +4008,7 @@
}, },
{ {
"name": "symfony/routing", "name": "symfony/routing",
"version": "v3.3.8", "version": "v3.3.9",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/routing.git", "url": "https://github.com/symfony/routing.git",
@ -4016,7 +4086,7 @@
}, },
{ {
"name": "symfony/translation", "name": "symfony/translation",
"version": "v3.3.8", "version": "v3.3.9",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/translation.git", "url": "https://github.com/symfony/translation.git",
@ -4081,7 +4151,7 @@
}, },
{ {
"name": "symfony/var-dumper", "name": "symfony/var-dumper",
"version": "v3.3.8", "version": "v3.3.9",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/var-dumper.git", "url": "https://github.com/symfony/var-dumper.git",
@ -4772,16 +4842,16 @@
}, },
{ {
"name": "laravel/dusk", "name": "laravel/dusk",
"version": "v2.0.1", "version": "v2.0.4",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/laravel/dusk.git", "url": "https://github.com/laravel/dusk.git",
"reference": "5e0ceaa27c9a78897f201a26f176b23bef20210f" "reference": "1c702f428b4813cdb2ea92f1026f066cb0be90a2"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/laravel/dusk/zipball/5e0ceaa27c9a78897f201a26f176b23bef20210f", "url": "https://api.github.com/repos/laravel/dusk/zipball/1c702f428b4813cdb2ea92f1026f066cb0be90a2",
"reference": "5e0ceaa27c9a78897f201a26f176b23bef20210f", "reference": "1c702f428b4813cdb2ea92f1026f066cb0be90a2",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -4829,7 +4899,7 @@
"testing", "testing",
"webdriver" "webdriver"
], ],
"time": "2017-09-06T13:19:28+00:00" "time": "2017-09-12T18:46:34+00:00"
}, },
{ {
"name": "maximebf/debugbar", "name": "maximebf/debugbar",
@ -5103,16 +5173,16 @@
}, },
{ {
"name": "phpdocumentor/reflection-common", "name": "phpdocumentor/reflection-common",
"version": "1.0", "version": "1.0.1",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/phpDocumentor/ReflectionCommon.git", "url": "https://github.com/phpDocumentor/ReflectionCommon.git",
"reference": "144c307535e82c8fdcaacbcfc1d6d8eeb896687c" "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/144c307535e82c8fdcaacbcfc1d6d8eeb896687c", "url": "https://api.github.com/repos/phpDocumentor/ReflectionCommon/zipball/21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6",
"reference": "144c307535e82c8fdcaacbcfc1d6d8eeb896687c", "reference": "21bdeb5f65d7ebf9f43b1b25d404f87deab5bfb6",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -5153,7 +5223,7 @@
"reflection", "reflection",
"static analysis" "static analysis"
], ],
"time": "2015-12-27T11:43:31+00:00" "time": "2017-09-11T18:02:19+00:00"
}, },
{ {
"name": "phpdocumentor/reflection-docblock", "name": "phpdocumentor/reflection-docblock",
@ -6353,7 +6423,7 @@
}, },
{ {
"name": "symfony/yaml", "name": "symfony/yaml",
"version": "v3.3.8", "version": "v3.3.9",
"source": { "source": {
"type": "git", "type": "git",
"url": "https://github.com/symfony/yaml.git", "url": "https://github.com/symfony/yaml.git",

20
config/image.php Normal file
View file

@ -0,0 +1,20 @@
<?php
return array(
/*
|--------------------------------------------------------------------------
| Image Driver
|--------------------------------------------------------------------------
|
| Intervention Image supports "GD Library" and "Imagick" to process images
| internally. You may choose one of them according to your PHP
| configuration. By default PHP's "GD Library" implementation is used.
|
| Supported: "gd", "imagick"
|
*/
'driver' => 'imagick'
);

View file

@ -0,0 +1,32 @@
<?php
use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class UpdateMediaEndpointTableAddNullableImageWidthColumn extends Migration
{
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::table('media_endpoint', function (Blueprint $table) {
$table->text('image_widths')->nullable();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::table('media_endpoint', function (Blueprint $table) {
$table->dropColumn('image_widths');
});
}
}

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","../../../resources/assets/sass/bridgy-links.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,eACA,4BAA6B,CAChC,cAGG,oBACA,AADA,oBACA,AADA,aACA,yBAAmB,AAAnB,sBAAmB,AAAnB,kBAAmB,CACtB,kBAGG,gBAAiB,CACpB,aAGG,iBAAkB,CACrB,qBAGG,kBACA,WAAY,CACf,wBAGG,YAAa,CAChB,8BAGG,eACA,uBACA,sBACA,kBACA,gBACA,WACA,UACA,WACA,2BAA4B,CAC/B,oBAGG,kBACA,SACA,WACA,WACA,YACA,mBAAoB,CACvB,wBAGG,aAAc,CACjB,qBAGG,aACA,eAAgB,CACnB,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,KC9HG,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,4CAAgD,AAAhD,mCAAgD,CAAA,CAIxD,aACI,kCACI,kCAAmC,CACtC,CC/CL,qDAEI,YAAa,CAChB","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","../../../resources/assets/sass/bridgy-links.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,eACA,4BAA6B,CAChC,cAGG,oBACA,AADA,oBACA,AADA,aACA,yBAAmB,AAAnB,sBAAmB,AAAnB,kBAAmB,CACtB,kBAGG,gBAAiB,CACpB,aAGG,iBAAkB,CACrB,qBAGG,kBACA,WAAY,CACf,wBAGG,YAAa,CAChB,8BAGG,eACA,uBACA,sBACA,kBACA,gBACA,WACA,UACA,WACA,2BAA4B,CAC/B,oBAGG,kBACA,SACA,WACA,WACA,YACA,mBAAoB,CACvB,wBAGG,aAAc,CACjB,qBAGG,aACA,eAAgB,CACnB,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,KC9HG,6JAWc,CACjB,EAGG,qBACA,wBACA,UAAW,CACd,aAGG,mBACA,aAAc,CACjB,gBAGG,kBAAmB,CACtB,MAGG,WACA,UAAW,CACd,OAGG,iBACA,iBAAkB,CACrB,WAGG,kBAAmB,CACtB,UAGG,YACA,WAAY,CACf,YC/CG,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,4CAAgD,AAAhD,mCAAgD,CAAA,CAIxD,aACI,kCACI,kCAAmC,CACtC,CC/CL,qDAEI,YAAa,CAChB","file":"app.css"}

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -22,6 +22,11 @@ a {
color: blue; color: blue;
} }
a.naked-link {
border-bottom: none;
color: inherit;
}
.social-links a { .social-links a {
border-bottom: none; border-bottom: none;
} }

View file

@ -9,7 +9,7 @@
<div class="e-content p-name"> <div class="e-content p-name">
{!! $note->note !!} {!! $note->note !!}
@foreach($note->media as $media) @foreach($note->media as $media)
@if($media->type == 'image')<img class="u-photo" src="{{ $media->url }}" alt="">@endif @if($media->type == 'image')<a class="naked-link" href="{{ $media->url }}"><img class="u-photo" src="{{ $media->url }}" alt="" @if($media->image_widths !== null) srcset="{{ $media->url }} {{ $media->image_widths }}w, {{ $media->mediumurl }} 1000w, {{ $media->smallurl }} 500w" sizes="80vh"@endif></a>@endif
@if($media->type == 'audio')<audio class="u-audio" src="{{ $media->url }}" controls>@endif @if($media->type == 'audio')<audio class="u-audio" src="{{ $media->url }}" controls>@endif
@if($media->type == 'video')<video class="u-video" src="{{ $media->url }}" controls>@endif @if($media->type == 'video')<video class="u-video" src="{{ $media->url }}" controls>@endif
@if($media->type == 'download')<p><a class="u-attachment" href="{{ $media->url }}">Download the attached media</a></p>@endif @if($media->type == 'download')<p><a class="u-attachment" href="{{ $media->url }}">Download the attached media</a></p>@endif

View file

@ -2,14 +2,17 @@
echo "Putting the Laravel app in maintenance mode" echo "Putting the Laravel app in maintenance mode"
php artisan down php artisan down
#php artisan horizon:terminate php artisan horizon:terminate
echo "Pulling the latest changes" echo "Pulling the latest changes"
git pull git pull
echo "Updating composer and dependencies" echo "Updating composer and dependencies"
sudo composer self-update sudo composer self-update
composer install --no-dev composer install --no-dev --optimize-autoloader
echo "running any migrations"
php artisan migrate
echo "Caching Laravel route and config files" echo "Caching Laravel route and config files"
php artisan route:cache php artisan route:cache

View file

@ -0,0 +1,43 @@
<?php
namespace Tests\Feature;
use Storage;
use Tests\TestCase;
use Intervention\Image\ImageManager;
class ProcessImageTest extends TestCase
{
public function test_job_does_nothing_to_non_image()
{
$manager = app()->make(ImageManager::class);
Storage::disk('local')->put('file.txt', 'This is not an image');
$job = new \App\Jobs\ProcessImage('file.txt');
$job->handle($manager);
$this->assertFalse(file_exists(storage_path('app') . '/file.txt'));
}
public function test_job_does_nothing_to_small_images()
{
$manager = app()->make(ImageManager::class);
Storage::disk('local')->put('aaron.png', file_get_contents(__DIR__.'/../aaron.png'));
$job = new \App\Jobs\ProcessImage('aaron.png');
$job->handle($manager);
$this->assertFalse(file_exists(storage_path('app') . '/aaron.png'));
}
public function test_large_images_have_smaller_files_created()
{
$manager = app()->make(ImageManager::class);
Storage::disk('local')->put('test-image.jpg', file_get_contents(__DIR__.'/../test-image.jpg'));
Storage::fake('s3');
$job = new \App\Jobs\ProcessImage('test-image.jpg');
$job->handle($manager);
Storage::disk('s3')->assertExists('media/test-image-small.jpg');
Storage::disk('s3')->assertExists('media/test-image-medium.jpg');
$this->assertFalse(file_exists(storage_path('app') . '/test-image.jpg'));
}
}

BIN
tests/test-image.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 MiB