Merge pull request #145 from jonnybarnes/develop

MTM: Laravel 6
This commit is contained in:
Jonny Barnes 2020-01-26 21:44:12 +00:00 • committed by GitHub
commit b042752888
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
457 changed files with 11092 additions and 18846 deletions

View file

@ -1,7 +1,7 @@
APP_ENV=testing APP_ENV=testing
APP_DEBUG=true APP_DEBUG=true
APP_KEY=base64:6DJhvZLVjE6dD4Cqrteh+6Z5vZlG+v/soCKcDHLOAH0= APP_KEY=base64:6DJhvZLVjE6dD4Cqrteh+6Z5vZlG+v/soCKcDHLOAH0=
APP_URL=http://jonnybarnes.localhost:8000 APP_URL=http://jonnybarnes.localhost
APP_LONGURL=jonnybarnes.localhost APP_LONGURL=jonnybarnes.localhost
APP_SHORTURL=jmb.localhost APP_SHORTURL=jmb.localhost

View file

@ -1,10 +1,7 @@
language: php language: php
sudo: false sudo: false
dist: trusty dist: bionic
cache:
- apt
addons: addons:
hosts: hosts:
@ -14,8 +11,7 @@ addons:
apt: apt:
packages: packages:
- nginx-full - nginx-full
- realpath - postgresql-9.6-postgis-2.4
- postgresql-9.6-postgis-2.3
- imagemagick - imagemagick
#- google-chrome-stable #- google-chrome-stable
artifacts: artifacts:
@ -34,8 +30,8 @@ env:
- setup=basic - setup=basic
php: php:
- 7.2
- 7.3 - 7.3
- 7.4.2
before_install: before_install:
- printf "\n" | pecl install imagick - printf "\n" | pecl install imagick

View file

@ -4,9 +4,9 @@ declare(strict_types=1);
namespace App\Console\Commands; namespace App\Console\Commands;
use App\Jobs\DownloadWebMention;
use App\Models\WebMention; use App\Models\WebMention;
use Illuminate\Console\Command; use Illuminate\Console\Command;
use App\Jobs\DownloadWebMention;
class ReDownloadWebMentions extends Command class ReDownloadWebMentions extends Command
{ {

View file

@ -21,7 +21,7 @@ class Kernel extends ConsoleKernel
/** /**
* Define the application's command schedule. * Define the application's command schedule.
* *
* @param \Illuminate\Console\Scheduling\Schedule $schedule * @param Schedule $schedule
* @return void * @return void
*/ */
protected function schedule(Schedule $schedule) protected function schedule(Schedule $schedule)
@ -37,7 +37,7 @@ class Kernel extends ConsoleKernel
*/ */
protected function commands() protected function commands()
{ {
$this->load(__DIR__.'/Commands'); $this->load(__DIR__ . '/Commands');
require base_path('routes/console.php'); require base_path('routes/console.php');
} }

View file

@ -4,9 +4,11 @@ namespace App\Exceptions;
use App; use App;
use Exception; use Exception;
use Illuminate\Support\Facades\Route;
use Illuminate\Session\TokenMismatchException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
use Illuminate\Http\Request;
use Illuminate\Http\Response;
use Illuminate\Session\TokenMismatchException;
use Illuminate\Support\Facades\Route;
/** /**
* @codeCoverageIgnore * @codeCoverageIgnore
@ -37,11 +39,14 @@ class Handler extends ExceptionHandler
* *
* This is a great spot to send exceptions to Sentry, Bugsnag, etc. * This is a great spot to send exceptions to Sentry, Bugsnag, etc.
* *
* @param \Exception $exception * @param Exception $exception
* @return void * @return void
* @throws Exception
*/ */
public function report(Exception $exception) public function report(Exception $exception)
{ {
parent::report($exception);
$guzzle = new \GuzzleHttp\Client([ $guzzle = new \GuzzleHttp\Client([
'headers' => [ 'headers' => [
'Content-Type' => 'application/json', 'Content-Type' => 'application/json',
@ -56,7 +61,7 @@ class Handler extends ExceptionHandler
'fallback' => 'There was an exception.', 'fallback' => 'There was an exception.',
'pretext' => 'There was an exception.', 'pretext' => 'There was an exception.',
'color' => '#d00000', 'color' => '#d00000',
'author_name' => App::environment(), 'author_name' => app()->environment(),
'author_link' => config('app.url'), 'author_link' => config('app.url'),
'fields' => [[ 'fields' => [[
'title' => get_class($exception) ?? 'Unkown Exception', 'title' => get_class($exception) ?? 'Unkown Exception',
@ -67,16 +72,15 @@ class Handler extends ExceptionHandler
]), ]),
] ]
); );
parent::report($exception);
} }
/** /**
* Render an exception into an HTTP response. * Render an exception into an HTTP response.
* *
* @param \Illuminate\Http\Request $request * @param Request $request
* @param \Exception $exception * @param Exception $exception
* @return \Illuminate\Http\Response * @return Response
* @throws Exception
*/ */
public function render($request, Exception $exception) public function render($request, Exception $exception)
{ {

View file

@ -4,11 +4,11 @@ declare(strict_types=1);
namespace App\Http\Controllers\Admin; namespace App\Http\Controllers\Admin;
use App\Models\Article;
use Illuminate\View\View;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Models\Article;
use Illuminate\Http\RedirectResponse; use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\View\View;
class ArticlesController extends Controller class ArticlesController extends Controller
{ {

View file

@ -4,11 +4,11 @@ declare(strict_types=1);
namespace App\Http\Controllers\Admin; namespace App\Http\Controllers\Admin;
use Illuminate\View\View;
use Illuminate\Http\Request;
use App\Models\MicropubClient;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Models\MicropubClient;
use Illuminate\Http\RedirectResponse; use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\View\View;
class ClientsController extends Controller class ClientsController extends Controller
{ {

View file

@ -4,14 +4,14 @@ declare(strict_types=1);
namespace App\Http\Controllers\Admin; namespace App\Http\Controllers\Admin;
use GuzzleHttp\Client;
use App\Models\Contact;
use Illuminate\View\View;
use Illuminate\Support\Arr;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Models\Contact;
use GuzzleHttp\Client;
use Illuminate\Filesystem\Filesystem; use Illuminate\Filesystem\Filesystem;
use Illuminate\Http\RedirectResponse; use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\Support\Arr;
use Illuminate\View\View;
class ContactsController extends Controller class ContactsController extends Controller
{ {

View file

@ -4,8 +4,8 @@ declare(strict_types=1);
namespace App\Http\Controllers\Admin; namespace App\Http\Controllers\Admin;
use Illuminate\View\View;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use Illuminate\View\View;
class HomeController extends Controller class HomeController extends Controller
{ {

View file

@ -4,11 +4,11 @@ declare(strict_types=1);
namespace App\Http\Controllers\Admin; namespace App\Http\Controllers\Admin;
use App\Models\Like;
use App\Jobs\ProcessLike;
use Illuminate\View\View;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Jobs\ProcessLike;
use App\Models\Like;
use Illuminate\Http\RedirectResponse; use Illuminate\Http\RedirectResponse;
use Illuminate\View\View;
class LikesController extends Controller class LikesController extends Controller
{ {

View file

@ -4,12 +4,12 @@ declare(strict_types=1);
namespace App\Http\Controllers\Admin; namespace App\Http\Controllers\Admin;
use App\Models\Note;
use Illuminate\View\View;
use Illuminate\Http\Request;
use App\Jobs\SendWebMentions;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Jobs\SendWebMentions;
use App\Models\Note;
use Illuminate\Http\RedirectResponse; use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\View\View;
class NotesController extends Controller class NotesController extends Controller
{ {

View file

@ -4,12 +4,12 @@ declare(strict_types=1);
namespace App\Http\Controllers\Admin; namespace App\Http\Controllers\Admin;
use App\Models\Place;
use Illuminate\View\View;
use Illuminate\Http\Request;
use App\Services\PlaceService;
use App\Http\Controllers\Controller; use App\Http\Controllers\Controller;
use App\Models\Place;
use App\Services\PlaceService;
use Illuminate\Http\RedirectResponse; use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Request;
use Illuminate\View\View;
use Phaza\LaravelPostgis\Geometries\Point; use Phaza\LaravelPostgis\Geometries\Point;
class PlacesController extends Controller class PlacesController extends Controller

View file

@ -5,18 +5,18 @@ declare(strict_types=1);
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Models\Article; use App\Models\Article;
use Illuminate\Http\RedirectResponse;
use Illuminate\View\View; use Illuminate\View\View;
use Jonnybarnes\IndieWeb\Numbers; use Jonnybarnes\IndieWeb\Numbers;
use Illuminate\Http\RedirectResponse;
class ArticlesController extends Controller class ArticlesController extends Controller
{ {
/** /**
* Show all articles (with pagination). * Show all articles (with pagination).
* *
* @param int $year * @param int $year
* @param int $month * @param int $month
* @return \Illuminate\View\View * @return View
*/ */
public function index(int $year = null, int $month = null): View public function index(int $year = null, int $month = null): View
{ {
@ -31,10 +31,10 @@ class ArticlesController extends Controller
/** /**
* Show a single article. * Show a single article.
* *
* @param int $year * @param int $year
* @param int $month * @param int $month
* @param string $slug * @param string $slug
* @return \Illuminate\Http\RedirectResponse|\Illuminate\View\View * @return RedirectResponse|View
*/ */
public function show(int $year, int $month, string $slug) public function show(int $year, int $month, string $slug)
{ {
@ -43,7 +43,7 @@ class ArticlesController extends Controller
return redirect('/blog/' return redirect('/blog/'
. $article->updated_at->year . $article->updated_at->year
. '/' . $article->updated_at->format('m') . '/' . $article->updated_at->format('m')
.'/' . $slug); . '/' . $slug);
} }
return view('articles.show', compact('article')); return view('articles.show', compact('article'));
@ -53,8 +53,8 @@ class ArticlesController extends Controller
* We only have the ID, work out post title, year and month * We only have the ID, work out post title, year and month
* and redirect to it. * and redirect to it.
* *
* @param int $idFromUrl * @param int $idFromUrl
* @return \Illuminte\Http\RedirectResponse * @return RedirectResponse
*/ */
public function onlyIdInUrl(int $idFromUrl): RedirectResponse public function onlyIdInUrl(int $idFromUrl): RedirectResponse
{ {

View file

@ -4,8 +4,8 @@ declare(strict_types=1);
namespace App\Http\Controllers; namespace App\Http\Controllers;
use Illuminate\Support\Facades\Auth;
use Illuminate\Http\RedirectResponse; use Illuminate\Http\RedirectResponse;
use Illuminate\Support\Facades\Auth;
class AuthController extends Controller class AuthController extends Controller
{ {

View file

@ -5,8 +5,8 @@ declare(strict_types=1);
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Models\Contact; use App\Models\Contact;
use Illuminate\View\View;
use Illuminate\Filesystem\Filesystem; use Illuminate\Filesystem\Filesystem;
use Illuminate\View\View;
class ContactsController extends Controller class ContactsController extends Controller
{ {

View file

@ -2,12 +2,14 @@
namespace App\Http\Controllers; namespace App\Http\Controllers;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Routing\Controller as BaseController;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Foundation\Auth\Access\AuthorizesRequests; use Illuminate\Foundation\Auth\Access\AuthorizesRequests;
use Illuminate\Foundation\Bus\DispatchesJobs;
use Illuminate\Foundation\Validation\ValidatesRequests;
use Illuminate\Routing\Controller as BaseController;
class Controller extends BaseController class Controller extends BaseController
{ {
use AuthorizesRequests, DispatchesJobs, ValidatesRequests; use AuthorizesRequests;
use DispatchesJobs;
use ValidatesRequests;
} }

View file

@ -4,8 +4,8 @@ declare(strict_types=1);
namespace App\Http\Controllers; namespace App\Http\Controllers;
use Illuminate\Http\Response;
use App\Models\{Article, Note}; use App\Models\{Article, Note};
use Illuminate\Http\Response;
class FeedsController extends Controller class FeedsController extends Controller
{ {

View file

@ -0,0 +1,46 @@
<?php
namespace App\Http\Controllers;
use App\Models\Article;
use App\Models\Bookmark;
use App\Models\Like;
use App\Models\Note;
use App\Services\ActivityStreamsService;
class FrontPageController extends Controller
{
/**
* Show all the recent activity.
*/
public function index()
{
if (request()->wantsActivityStream()) {
return (new ActivityStreamsService())->siteOwnerResponse();
}
$pageNumber = request()->query('page') ?? 1;
$notes = Note::latest()->get();
$articles = Article::latest()->get();
$bookmarks = Bookmark::latest()->get();
$likes = Like::latest()->get();
$allItems = collect($notes)
->merge($articles)
->merge($bookmarks)
->merge($likes)
->sortByDesc('updated_at')
->chunk(10);
$page = $allItems->get($pageNumber - 1);
if (is_null($page)) {
abort(404);
}
return view('front-page', [
'items' => $page,
]);
}
}

View file

@ -4,22 +4,22 @@ declare(strict_types=1);
namespace App\Http\Controllers; namespace App\Http\Controllers;
use Monolog\Logger; use App\Exceptions\InvalidTokenException;
use Ramsey\Uuid\Uuid;
use Illuminate\Http\File;
use App\Jobs\ProcessMedia; use App\Jobs\ProcessMedia;
use App\Models\{Like, Media, Note, Place};
use App\Services\Micropub\{HCardService, HEntryService, UpdateService};
use App\Services\TokenService; use App\Services\TokenService;
use Illuminate\Http\File;
use Illuminate\Http\JsonResponse; use Illuminate\Http\JsonResponse;
use Illuminate\Http\UploadedFile; use Illuminate\Http\UploadedFile;
use Monolog\Handler\StreamHandler;
use Intervention\Image\ImageManager;
use Illuminate\Support\Facades\Storage;
use Illuminate\Http\{Request, Response}; use Illuminate\Http\{Request, Response};
use App\Exceptions\InvalidTokenException; use Illuminate\Support\Facades\Storage;
use App\Models\{Like, Media, Note, Place};
use Phaza\LaravelPostgis\Geometries\Point;
use Intervention\Image\Exception\NotReadableException; use Intervention\Image\Exception\NotReadableException;
use App\Services\Micropub\{HCardService, HEntryService, UpdateService}; use Intervention\Image\ImageManager;
use Monolog\Handler\StreamHandler;
use Monolog\Logger;
use Phaza\LaravelPostgis\Geometries\Point;
use Ramsey\Uuid\Uuid;
class MicropubController extends Controller class MicropubController extends Controller
{ {
@ -72,7 +72,7 @@ class MicropubController extends Controller
], 201)->header('Location', $location); ], 201)->header('Location', $location);
} }
if (request()->input('h') == 'card' || request()->input('type')[0] == 'h-card') { if (request()->input('h') == 'card' || request()->input('type.0') == 'h-card') {
if (stristr($tokenData->getClaim('scope'), 'create') === false) { if (stristr($tokenData->getClaim('scope'), 'create') === false) {
return $this->insufficientScopeResponse(); return $this->insufficientScopeResponse();
} }

View file

@ -5,11 +5,13 @@ declare(strict_types=1);
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Models\Note; use App\Models\Note;
use Illuminate\View\View;
use Illuminate\Http\Request;
use Jonnybarnes\IndieWeb\Numbers;
use Illuminate\Http\RedirectResponse;
use App\Services\ActivityStreamsService; use App\Services\ActivityStreamsService;
use Illuminate\Contracts\View\Factory as ViewFactory;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\RedirectResponse;
use Illuminate\Http\Response;
use Illuminate\View\View;
use Jonnybarnes\IndieWeb\Numbers;
// Need to sort out Twitter and webmentions! // Need to sort out Twitter and webmentions!
@ -18,12 +20,12 @@ class NotesController extends Controller
/** /**
* Show all the notes. This is also the homepage. * Show all the notes. This is also the homepage.
* *
* @return \Illuminate\View\View|\Illuminate\Http\JsonResponse * @return ViewFactory|View|Response
*/ */
public function index() public function index()
{ {
if (request()->wantsActivityStream()) { if (request()->wantsActivityStream()) {
return (new ActivityStreamsService)->siteOwnerResponse(); return (new ActivityStreamsService())->siteOwnerResponse();
} }
$notes = Note::latest() $notes = Note::latest()
@ -38,15 +40,15 @@ class NotesController extends Controller
/** /**
* Show a single note. * Show a single note.
* *
* @param string $urlId The id of the note * @param string $urlId The id of the note
* @return \Illuminate\View\View|\Illuminate\Http\JsonResponse * @return View|JsonResponse|Response
*/ */
public function show(string $urlId) public function show(string $urlId)
{ {
$note = Note::nb60($urlId)->with('webmentions')->firstOrFail(); $note = Note::nb60($urlId)->with('webmentions')->firstOrFail();
if (request()->wantsActivityStream()) { if (request()->wantsActivityStream()) {
return (new ActivityStreamsService)->singleNoteResponse($note); return (new ActivityStreamsService())->singleNoteResponse($note);
} }
return view('notes.show', compact('note')); return view('notes.show', compact('note'));
@ -55,8 +57,8 @@ class NotesController extends Controller
/** /**
* Redirect /note/{decID} to /notes/{nb60id}. * Redirect /note/{decID} to /notes/{nb60id}.
* *
* @param int $decId The decimal id of the note * @param int $decId The decimal id of the note
* @return \Illuminate\Http\RedirectResponse * @return RedirectResponse
*/ */
public function redirect(int $decId): RedirectResponse public function redirect(int $decId): RedirectResponse
{ {
@ -66,8 +68,8 @@ class NotesController extends Controller
/** /**
* Show all notes tagged with {tag}. * Show all notes tagged with {tag}.
* *
* @param string $tag * @param string $tag
* @return \Illuminate\View\View * @return View
*/ */
public function tagged(string $tag): View public function tagged(string $tag): View
{ {

Some files were not shown because too many files have changed in this diff Show more