Merge pull request #141 from jonnybarnes/refactor-frontend

Refactor
This commit is contained in:
Jonny Barnes 2020-01-26 21:35:50 +00:00 committed by GitHub
commit 1bba326711
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
448 changed files with 7279 additions and 13416 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,9 +5,9 @@ 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
{ {
@ -16,7 +16,7 @@ class ArticlesController extends Controller
* *
* @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
{ {
@ -34,7 +34,7 @@ class ArticlesController extends Controller
* @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'));
@ -54,7 +54,7 @@ class ArticlesController extends Controller
* 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()
@ -39,14 +41,14 @@ 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'));
@ -56,7 +58,7 @@ 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
{ {
@ -67,7 +69,7 @@ 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
{ {

View file

@ -4,9 +4,9 @@ declare(strict_types=1);
namespace App\Http\Controllers; namespace App\Http\Controllers;
use IndieAuth\Client;
use App\Services\TokenService; use App\Services\TokenService;
use Illuminate\Http\JsonResponse; use Illuminate\Http\JsonResponse;
use IndieAuth\Client;
class TokenEndpointController extends Controller class TokenEndpointController extends Controller
{ {

View file

@ -4,12 +4,12 @@ declare(strict_types=1);
namespace App\Http\Controllers; namespace App\Http\Controllers;
use App\Models\Note;
use Illuminate\View\View;
use Illuminate\Http\Response;
use App\Jobs\ProcessWebMention; use App\Jobs\ProcessWebMention;
use Jonnybarnes\IndieWeb\Numbers; use App\Models\Note;
use Illuminate\Database\Eloquent\ModelNotFoundException; use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Http\Response;
use Illuminate\View\View;
use Jonnybarnes\IndieWeb\Numbers;
class WebMentionsController extends Controller class WebMentionsController extends Controller
{ {

View file

@ -14,11 +14,11 @@ class Kernel extends HttpKernel
* @var array * @var array
*/ */
protected $middleware = [ protected $middleware = [
\App\Http\Middleware\TrustProxies::class,
\App\Http\Middleware\CheckForMaintenanceMode::class, \App\Http\Middleware\CheckForMaintenanceMode::class,
\Illuminate\Foundation\Http\Middleware\ValidatePostSize::class, \Illuminate\Foundation\Http\Middleware\ValidatePostSize::class,
\App\Http\Middleware\TrimStrings::class, \App\Http\Middleware\TrimStrings::class,
\Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class, \Illuminate\Foundation\Http\Middleware\ConvertEmptyStringsToNull::class,
\App\Http\Middleware\TrustProxies::class,
]; ];
/** /**

View file

@ -3,20 +3,22 @@
namespace App\Http\Middleware; namespace App\Http\Middleware;
use Closure; use Closure;
use Illuminate\Http\Request;
class CSPHeader class CSPHeader
{ {
/** /**
* Handle an incoming request. * Handle an incoming request.
* *
* @param \Illuminate\Http\Request $request * @param Request $request
* @param \Closure $next * @param Closure $next
* @return mixed * @return mixed
*/ */
public function handle($request, Closure $next) public function handle($request, Closure $next)
{ {
// headers have to be single-line strings, // headers have to be single-line strings,
// so we concat multiple lines // so we concat multiple lines
// phpcs:disable
return $next($request) return $next($request)
->header( ->header(
'Content-Security-Policy', 'Content-Security-Policy',
@ -72,5 +74,6 @@ report-uri https://jonnybarnes.report-uri.io/r/default/csp/enforce;")
"'max-age': 10886400" . "'max-age': 10886400" .
'}' '}'
); );
// phpcs:enable
} }
} }

View file

@ -2,22 +2,22 @@
namespace App\Http\Middleware; namespace App\Http\Middleware;
use Illuminate\Http\Request;
use Fideloper\Proxy\TrustProxies as Middleware; use Fideloper\Proxy\TrustProxies as Middleware;
use Illuminate\Http\Request;
class TrustProxies extends Middleware class TrustProxies extends Middleware
{ {
/** /**
* The trusted proxies for this application. * The trusted proxies for this application.
* *
* @var array * @var array|string
*/ */
protected $proxies; protected $proxies;
/** /**
* The header that should be used to detect proxies. * The header that should be used to detect proxies.
* *
* @var string * @var int
*/ */
protected $headers = Request::HEADER_X_FORWARDED_ALL; protected $headers = Request::HEADER_X_FORWARDED_ALL;
} }

View file

@ -4,16 +4,19 @@ declare(strict_types=1);
namespace App\Jobs; namespace App\Jobs;
use Illuminate\Bus\Queueable;
use App\Models\MicropubClient; use App\Models\MicropubClient;
use Illuminate\Queue\SerializesModels; use Illuminate\Bus\Queueable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
class AddClientToDatabase implements ShouldQueue class AddClientToDatabase implements ShouldQueue
{ {
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; use Dispatchable;
use InteractsWithQueue;
use Queueable;
use SerializesModels;
protected $client_id; protected $client_id;
@ -35,7 +38,7 @@ class AddClientToDatabase implements ShouldQueue
public function handle() public function handle()
{ {
if (MicropubClient::where('client_url', $this->client_id)->count() == 0) { if (MicropubClient::where('client_url', $this->client_id)->count() == 0) {
$client = MicropubClient::create([ MicropubClient::create([
'client_url' => $this->client_id, 'client_url' => $this->client_id,
'client_name' => $this->client_id, // default client name is the URL 'client_name' => $this->client_id, // default client name is the URL
]); ]);

View file

@ -5,20 +5,24 @@ declare(strict_types=1);
namespace App\Jobs; namespace App\Jobs;
use GuzzleHttp\Client; use GuzzleHttp\Client;
use GuzzleHttp\Exception\GuzzleException;
use Illuminate\Bus\Queueable; use Illuminate\Bus\Queueable;
use Illuminate\FileSystem\FileSystem; use Illuminate\Contracts\Filesystem\FileNotFoundException;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\FileSystem\FileSystem;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
class DownloadWebMention implements ShouldQueue class DownloadWebMention implements ShouldQueue
{ {
use InteractsWithQueue, Queueable, SerializesModels; use InteractsWithQueue;
use Queueable;
use SerializesModels;
/** /**
* The webmention source URL. * The webmention source URL.
* *
* @var * @var string
*/ */
protected $source; protected $source;
@ -35,7 +39,9 @@ class DownloadWebMention implements ShouldQueue
/** /**
* Execute the job. * Execute the job.
* *
* @param \GuzzleHttp\Client $guzzle * @param Client $guzzle
* @throws GuzzleException
* @throws FileNotFoundException
*/ */
public function handle(Client $guzzle) public function handle(Client $guzzle)
{ {
@ -73,13 +79,12 @@ class DownloadWebMention implements ShouldQueue
} }
/** /**
* Create a file path from a URL. This is used when caching the HTML * Create a file path from a URL. This is used when caching the HTML response.
* response.
* *
* @param string The URL * @param string $url
* @return string The path name * @return string The path name
*/ */
private function createFilenameFromURL($url) private function createFilenameFromURL(string $url)
{ {
$filepath = str_replace(['https://', 'http://'], ['https/', 'http/'], $url); $filepath = str_replace(['https://', 'http://'], ['https/', 'http/'], $url);
if (substr($filepath, -1) == '/') { if (substr($filepath, -1) == '/') {

View file

@ -4,25 +4,29 @@ declare(strict_types=1);
namespace App\Jobs; namespace App\Jobs;
use App\Exceptions\InternetArchiveException;
use App\Models\Bookmark; use App\Models\Bookmark;
use Illuminate\Bus\Queueable;
use App\Services\BookmarkService; use App\Services\BookmarkService;
use Illuminate\Queue\SerializesModels; use Illuminate\Bus\Queueable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Foundation\Bus\Dispatchable;
use App\Exceptions\InternetArchiveException; use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
class ProcessBookmark implements ShouldQueue class ProcessBookmark implements ShouldQueue
{ {
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; use Dispatchable;
use InteractsWithQueue;
use Queueable;
use SerializesModels;
/** @var Bookmark */
protected $bookmark; protected $bookmark;
/** /**
* Create a new job instance. * Create a new job instance.
* *
* @param \App\Models\Bookmark $bookmark * @param Bookmark $bookmark
*/ */
public function __construct(Bookmark $bookmark) public function __construct(Bookmark $bookmark)
{ {

View file

@ -5,28 +5,33 @@ declare(strict_types=1);
namespace App\Jobs; namespace App\Jobs;
use App\Models\Like; use App\Models\Like;
use Codebird\Codebird;
use GuzzleHttp\Client; use GuzzleHttp\Client;
use Illuminate\Support\Arr; use GuzzleHttp\Exception\GuzzleException;
use Illuminate\Bus\Queueable;
use Thujohn\Twitter\Facades\Twitter;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use GuzzleHttp\Exception\RequestException; use GuzzleHttp\Exception\RequestException;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Arr;
use Jonnybarnes\WebmentionsParser\Authorship; use Jonnybarnes\WebmentionsParser\Authorship;
use Jonnybarnes\WebmentionsParser\Exceptions\AuthorshipParserException; use Jonnybarnes\WebmentionsParser\Exceptions\AuthorshipParserException;
class ProcessLike implements ShouldQueue class ProcessLike implements ShouldQueue
{ {
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; use Dispatchable;
use InteractsWithQueue;
use Queueable;
use SerializesModels;
/** @var Like */
protected $like; protected $like;
/** /**
* Create a new job instance. * Create a new job instance.
* *
* @param \App\Models\Like $like * @param Like $like
*/ */
public function __construct(Like $like) public function __construct(Like $like)
{ {
@ -36,14 +41,18 @@ class ProcessLike implements ShouldQueue
/** /**
* Execute the job. * Execute the job.
* *
* @param \GuzzleHttp\Client $client * @param Client $client
* @param \Jonnybarnes\WebmentionsParser\Authorship $authorship * @param Authorship $authorship
* @return int * @return int
* @throws GuzzleException
*/ */
public function handle(Client $client, Authorship $authorship): int public function handle(Client $client, Authorship $authorship): int
{ {
if ($this->isTweet($this->like->url)) { if ($this->isTweet($this->like->url)) {
$tweet = Twitter::getOembed(['url' => $this->like->url]); $codebird = resolve(Codebird::class);
$tweet = $codebird->statuses_oembed(['url' => $this->like->url]);
$this->like->author_name = $tweet->author_name; $this->like->author_name = $tweet->author_name;
$this->like->author_url = $tweet->author_url; $this->like->author_url = $tweet->author_url;
$this->like->content = $tweet->html; $this->like->content = $tweet->html;

View file

@ -5,18 +5,22 @@ declare(strict_types=1);
namespace App\Jobs; namespace App\Jobs;
use Illuminate\Bus\Queueable; use Illuminate\Bus\Queueable;
use Intervention\Image\ImageManager;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Storage;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Facades\Storage;
use Intervention\Image\Exception\NotReadableException; use Intervention\Image\Exception\NotReadableException;
use Intervention\Image\ImageManager;
class ProcessMedia implements ShouldQueue class ProcessMedia implements ShouldQueue
{ {
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; use Dispatchable;
use InteractsWithQueue;
use Queueable;
use SerializesModels;
/** @var string */
protected $filename; protected $filename;
/** /**
@ -32,7 +36,7 @@ class ProcessMedia implements ShouldQueue
/** /**
* Execute the job. * Execute the job.
* *
* @param \Intervention\Image\ImageManager $manager * @param ImageManager $manager
*/ */
public function handle(ImageManager $manager) public function handle(ImageManager $manager)
{ {
@ -49,7 +53,7 @@ class ProcessMedia implements ShouldQueue
if ($image->width() > 1000) { if ($image->width() > 1000) {
$filenameParts = explode('.', $this->filename); $filenameParts = explode('.', $this->filename);
$extension = array_pop($filenameParts); $extension = array_pop($filenameParts);
// the following acheives this data flow // the following achieves this data flow
// foo.bar.png => ['foo', 'bar', 'png'] => ['foo', 'bar'] => foo.bar // foo.bar.png => ['foo', 'bar', 'png'] => ['foo', 'bar'] => foo.bar
$basename = ltrim(array_reduce($filenameParts, function ($carry, $item) { $basename = ltrim(array_reduce($filenameParts, function ($carry, $item) {
return $carry . '.' . $item; return $carry . '.' . $item;
@ -57,7 +61,7 @@ class ProcessMedia implements ShouldQueue
$medium = $image->resize(1000, null, function ($constraint) { $medium = $image->resize(1000, null, function ($constraint) {
$constraint->aspectRatio(); $constraint->aspectRatio();
}); });
Storage::disk('s3')->put('media/'. $basename . '-medium.' . $extension, (string) $medium->encode()); Storage::disk('s3')->put('media/' . $basename . '-medium.' . $extension, (string) $medium->encode());
$small = $image->resize(500, null, function ($constraint) { $small = $image->resize(500, null, function ($constraint) {
$constraint->aspectRatio(); $constraint->aspectRatio();
}); });

View file

@ -4,30 +4,37 @@ declare(strict_types=1);
namespace App\Jobs; namespace App\Jobs;
use Mf2;
use GuzzleHttp\Client;
use Illuminate\Bus\Queueable;
use App\Models\{Note, WebMention};
use Jonnybarnes\WebmentionsParser\Parser;
use GuzzleHttp\Exception\RequestException;
use Illuminate\Contracts\Queue\ShouldQueue;
use App\Exceptions\RemoteContentNotFoundException; use App\Exceptions\RemoteContentNotFoundException;
use App\Models\{Note, WebMention};
use GuzzleHttp\Client;
use GuzzleHttp\Exception\GuzzleException;
use GuzzleHttp\Exception\RequestException;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\{InteractsWithQueue, SerializesModels}; use Illuminate\Queue\{InteractsWithQueue, SerializesModels};
use Jonnybarnes\WebmentionsParser\Exceptions\InvalidMentionException;
use Jonnybarnes\WebmentionsParser\Parser;
use Mf2;
class ProcessWebMention implements ShouldQueue class ProcessWebMention implements ShouldQueue
{ {
use InteractsWithQueue, Queueable, SerializesModels; use InteractsWithQueue;
use Queueable;
use SerializesModels;
/** @var Note */
protected $note; protected $note;
/** @var string */
protected $source; protected $source;
/** /**
* Create a new job instance. * Create a new job instance.
* *
* @param \App\Note $note * @param Note $note
* @param string $source * @param string $source
*/ */
public function __construct(Note $note, $source) public function __construct(Note $note, string $source)
{ {
$this->note = $note; $this->note = $note;
$this->source = $source; $this->source = $source;
@ -36,15 +43,18 @@ class ProcessWebMention implements ShouldQueue
/** /**
* Execute the job. * Execute the job.
* *
* @param \Jonnybarnes\WebmentionsParser\Parser $parser * @param Parser $parser
* @param \GuzzleHttp\Client $guzzle * @param Client $guzzle
* @throws RemoteContentNotFoundException
* @throws GuzzleException
* @throws InvalidMentionException
*/ */
public function handle(Parser $parser, Client $guzzle) public function handle(Parser $parser, Client $guzzle)
{ {
try { try {
$response = $guzzle->request('GET', $this->source); $response = $guzzle->request('GET', $this->source);
} catch (RequestException $e) { } catch (RequestException $e) {
throw new RemoteContentNotFoundException; throw new RemoteContentNotFoundException();
} }
$this->saveRemoteContent((string) $response->getBody(), $this->source); $this->saveRemoteContent((string) $response->getBody(), $this->source);
$microformats = Mf2\parse((string) $response->getBody(), $this->source); $microformats = Mf2\parse((string) $response->getBody(), $this->source);
@ -59,7 +69,7 @@ class ProcessWebMention implements ShouldQueue
return; return;
} }
// webmenion is still a reply, so update content // webmention is still a reply, so update content
dispatch(new SaveProfileImage($microformats)); dispatch(new SaveProfileImage($microformats));
$webmention->mf2 = json_encode($microformats); $webmention->mf2 = json_encode($microformats);
$webmention->save(); $webmention->save();
@ -91,7 +101,7 @@ class ProcessWebMention implements ShouldQueue
$webmention->source = $this->source; $webmention->source = $this->source;
$webmention->target = $this->note->longurl; $webmention->target = $this->note->longurl;
$webmention->commentable_id = $this->note->id; $webmention->commentable_id = $this->note->id;
$webmention->commentable_type = 'App\Note'; $webmention->commentable_type = 'App\Model\Note';
$webmention->type = $type; $webmention->type = $type;
$webmention->mf2 = json_encode($microformats); $webmention->mf2 = json_encode($microformats);
$webmention->save(); $webmention->save();

View file

@ -5,18 +5,21 @@ declare(strict_types=1);
namespace App\Jobs; namespace App\Jobs;
use GuzzleHttp\Client; use GuzzleHttp\Client;
use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use GuzzleHttp\Exception\RequestException; use GuzzleHttp\Exception\RequestException;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Jonnybarnes\WebmentionsParser\Authorship; use Jonnybarnes\WebmentionsParser\Authorship;
use Jonnybarnes\WebmentionsParser\Exceptions\AuthorshipParserException; use Jonnybarnes\WebmentionsParser\Exceptions\AuthorshipParserException;
class SaveProfileImage implements ShouldQueue class SaveProfileImage implements ShouldQueue
{ {
use InteractsWithQueue, Queueable, SerializesModels; use InteractsWithQueue;
use Queueable;
use SerializesModels;
/** @var array */
protected $microformats; protected $microformats;
/** /**
@ -32,7 +35,7 @@ class SaveProfileImage implements ShouldQueue
/** /**
* Execute the job. * Execute the job.
* *
* @param \Jonnybarnes\WebmentionsParser\Authorship $authorship * @param Authorship $authorship
*/ */
public function handle(Authorship $authorship) public function handle(Authorship $authorship)
{ {
@ -44,14 +47,16 @@ class SaveProfileImage implements ShouldQueue
$photo = $author['properties']['photo'][0]; $photo = $author['properties']['photo'][0];
$home = $author['properties']['url'][0]; $home = $author['properties']['url'][0];
//dont save pbs.twimg.com links //dont save pbs.twimg.com links
if (parse_url($photo, PHP_URL_HOST) != 'pbs.twimg.com' if (
&& parse_url($photo, PHP_URL_HOST) != 'twitter.com') { parse_url($photo, PHP_URL_HOST) != 'pbs.twimg.com'
&& parse_url($photo, PHP_URL_HOST) != 'twitter.com'
) {
$client = resolve(Client::class); $client = resolve(Client::class);
try { try {
$response = $client->get($photo); $response = $client->get($photo);
$image = $response->getBody(true); $image = $response->getBody(true);
} catch (RequestException $e) { } catch (RequestException $e) {
// we are openning and reading the default image so that // we are opening and reading the default image so that
$default = public_path() . '/assets/profile-images/default-image'; $default = public_path() . '/assets/profile-images/default-image';
$handle = fopen($default, 'rb'); $handle = fopen($default, 'rb');
$image = fread($handle, filesize($default)); $image = fread($handle, filesize($default));

View file

@ -6,16 +6,20 @@ namespace App\Jobs;
use App\Models\Note; use App\Models\Note;
use GuzzleHttp\Client; use GuzzleHttp\Client;
use Illuminate\Support\Str; use GuzzleHttp\Psr7\Uri;
use Illuminate\Bus\Queueable; use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
use Illuminate\Support\Str;
class SendWebMentions implements ShouldQueue class SendWebMentions implements ShouldQueue
{ {
use InteractsWithQueue, Queueable, SerializesModels; use InteractsWithQueue;
use Queueable;
use SerializesModels;
/** @var Note */
protected $note; protected $note;
/** /**
@ -101,14 +105,15 @@ class SendWebMentions implements ShouldQueue
/** /**
* Get the URLs from a note. * Get the URLs from a note.
* *
* @param string $html * @param string|null $html
* @return array $urls * @return array
*/ */
public function getLinks($html) public function getLinks(?string $html): array
{ {
if ($html == '' || is_null($html)) { if ($html == '' || is_null($html)) {
return []; return [];
} }
$urls = []; $urls = [];
$dom = new \DOMDocument(); $dom = new \DOMDocument();
$dom->loadHTML($html); $dom->loadHTML($html);
@ -123,6 +128,8 @@ class SendWebMentions implements ShouldQueue
/** /**
* Resolve a URI if necessary. * Resolve a URI if necessary.
* *
* @todo Update deprecated resolve method
*
* @param string $url * @param string $url
* @param string $base The base of the URL * @param string $base The base of the URL
* @return string * @return string
@ -134,7 +141,7 @@ class SendWebMentions implements ShouldQueue
return (string) $endpoint; return (string) $endpoint;
} }
return (string) \GuzzleHttp\Psr7\Uri::resolve( return (string) Uri::resolve(
\GuzzleHttp\Psr7\uri_for($base), \GuzzleHttp\Psr7\uri_for($base),
$endpoint $endpoint
); );

View file

@ -4,24 +4,29 @@ declare(strict_types=1);
namespace App\Jobs; namespace App\Jobs;
use GuzzleHttp\Client;
use App\Models\Bookmark; use App\Models\Bookmark;
use GuzzleHttp\Client;
use GuzzleHttp\Exception\GuzzleException;
use Illuminate\Bus\Queueable; use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable; use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
class SyndicateBookmarkToTwitter implements ShouldQueue class SyndicateBookmarkToTwitter implements ShouldQueue
{ {
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels; use Dispatchable;
use InteractsWithQueue;
use Queueable;
use SerializesModels;
/** @var Bookmark */
protected $bookmark; protected $bookmark;
/** /**
* Create a new job instance. * Create a new job instance.
* *
* @param \App\Models\Bookmark $bookmark * @param Bookmark $bookmark
*/ */
public function __construct(Bookmark $bookmark) public function __construct(Bookmark $bookmark)
{ {
@ -31,7 +36,8 @@ class SyndicateBookmarkToTwitter implements ShouldQueue
/** /**
* Execute the job. * Execute the job.
* *
* @param \GuzzleHttp\Client $guzzle * @param Client $guzzle
* @throws GuzzleException
*/ */
public function handle(Client $guzzle) public function handle(Client $guzzle)
{ {

View file

@ -6,21 +6,25 @@ namespace App\Jobs;
use App\Models\Note; use App\Models\Note;
use GuzzleHttp\Client; use GuzzleHttp\Client;
use GuzzleHttp\Exception\GuzzleException;
use Illuminate\Bus\Queueable; use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
class SyndicateNoteToTwitter implements ShouldQueue class SyndicateNoteToTwitter implements ShouldQueue
{ {
use InteractsWithQueue, Queueable, SerializesModels; use InteractsWithQueue;
use Queueable;
use SerializesModels;
/** @var Note */
protected $note; protected $note;
/** /**
* Create a new job instance. * Create a new job instance.
* *
* @param \App\Models\Note $note * @param Note $note
*/ */
public function __construct(Note $note) public function __construct(Note $note)
{ {
@ -30,7 +34,8 @@ class SyndicateNoteToTwitter implements ShouldQueue
/** /**
* Execute the job. * Execute the job.
* *
* @param \GuzzleHttp\Client $guzzle * @param Client $guzzle
* @throws GuzzleException
*/ */
public function handle(Client $guzzle) public function handle(Client $guzzle)
{ {

View file

@ -4,14 +4,14 @@ declare(strict_types=1);
namespace App\Models; namespace App\Models;
use League\CommonMark\Environment;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Builder;
use Cviebrock\EloquentSluggable\Sluggable; use Cviebrock\EloquentSluggable\Sluggable;
use League\CommonMark\CommonMarkConverter; use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
use League\CommonMark\Block\Element\FencedCode; use League\CommonMark\Block\Element\FencedCode;
use League\CommonMark\Block\Element\IndentedCode; use League\CommonMark\Block\Element\IndentedCode;
use League\CommonMark\CommonMarkConverter;
use League\CommonMark\Environment;
use Spatie\CommonMarkHighlighter\FencedCodeRenderer; use Spatie\CommonMarkHighlighter\FencedCodeRenderer;
use Spatie\CommonMarkHighlighter\IndentedCodeRenderer; use Spatie\CommonMarkHighlighter\IndentedCodeRenderer;

View file

@ -4,10 +4,10 @@ declare(strict_types=1);
namespace App\Models; namespace App\Models;
use Mf2;
use App\Traits\FilterHtml; use App\Traits\FilterHtml;
use Illuminate\Support\Arr;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Arr;
use Mf2;
class Like extends Model class Like extends Model
{ {

View file

@ -4,9 +4,9 @@ declare(strict_types=1);
namespace App\Models; namespace App\Models;
use Illuminate\Support\Str;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo; use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Support\Str;
class Media extends Model class Media extends Model
{ {

View file

@ -4,24 +4,29 @@ declare(strict_types=1);
namespace App\Models; namespace App\Models;
use Cache;
use Twitter;
use Normalizer;
use GuzzleHttp\Client;
use Laravel\Scout\Searchable;
use Jonnybarnes\IndieWeb\Numbers;
use League\CommonMark\Environment;
use Illuminate\Database\Eloquent\Model;
use Jonnybarnes\EmojiA11y\EmojiModifier;
use Illuminate\Database\Eloquent\Builder;
use League\CommonMark\CommonMarkConverter;
use App\Exceptions\TwitterContentException; use App\Exceptions\TwitterContentException;
use Cache;
use Codebird\Codebird;
use Exception;
use GuzzleHttp\Client;
use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\BelongsTo;
use Illuminate\Database\Eloquent\Relations\BelongsToMany;
use Illuminate\Database\Eloquent\Relations\HasMany;
use Illuminate\Database\Eloquent\Relations\MorphMany;
use Illuminate\Database\Eloquent\SoftDeletes; use Illuminate\Database\Eloquent\SoftDeletes;
use Jonnybarnes\IndieWeb\Numbers;
use Laravel\Scout\Searchable;
use League\CommonMark\Block\Element\FencedCode; use League\CommonMark\Block\Element\FencedCode;
use League\CommonMark\Block\Element\IndentedCode; use League\CommonMark\Block\Element\IndentedCode;
use Spatie\CommonMarkHighlighter\FencedCodeRenderer; use League\CommonMark\CommonMarkConverter;
use League\CommonMark\Environment;
use League\CommonMark\Ext\Autolink\AutolinkExtension; use League\CommonMark\Ext\Autolink\AutolinkExtension;
use Normalizer;
use Spatie\CommonMarkHighlighter\FencedCodeRenderer;
use Spatie\CommonMarkHighlighter\IndentedCodeRenderer; use Spatie\CommonMarkHighlighter\IndentedCodeRenderer;
use Twitter;
class Note extends Model class Note extends Model
{ {
@ -29,7 +34,7 @@ class Note extends Model
use SoftDeletes; use SoftDeletes;
/** /**
* The reges for matching lone usernames. * The regex for matching lone usernames.
* *
* @var string * @var string
*/ */
@ -79,7 +84,7 @@ class Note extends Model
/** /**
* Define the relationship with tags. * Define the relationship with tags.
* *
* @return \Illuminate\Database\Eloquent\Relations\BelongsToMany * @return BelongsToMany
*/ */
public function tags() public function tags()
{ {
@ -89,7 +94,7 @@ class Note extends Model
/** /**
* Define the relationship with clients. * Define the relationship with clients.
* *
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo * @return BelongsTo
*/ */
public function client() public function client()
{ {
@ -99,7 +104,7 @@ class Note extends Model
/** /**
* Define the relationship with webmentions. * Define the relationship with webmentions.
* *
* @return \Illuminate\Database\Eloquent\Relations\MorphMany * @return MorphMany
*/ */
public function webmentions() public function webmentions()
{ {
@ -109,7 +114,7 @@ class Note extends Model
/** /**
* Define the relationship with places. * Define the relationship with places.
* *
* @return \Illuminate\Database\Eloquent\Relations\BelongsTo * @return BelongsTo
*/ */
public function place() public function place()
{ {
@ -119,7 +124,7 @@ class Note extends Model
/** /**
* Define the relationship with media. * Define the relationship with media.
* *
* @return \Illuminate\Database\Eloquent\Relations\HasMany * @return HasMany
*/ */
public function media() public function media()
{ {
@ -174,9 +179,8 @@ class Note extends Model
$hcards = $this->makeHCards($value); $hcards = $this->makeHCards($value);
$hashtags = $this->autoLinkHashtag($hcards); $hashtags = $this->autoLinkHashtag($hcards);
$html = $this->convertMarkdown($hashtags); $html = $this->convertMarkdown($hashtags);
$modified = resolve(EmojiModifier::class)->makeEmojiAccessible($html);
return $modified; return $html;
} }
/** /**
@ -346,13 +350,18 @@ class Note extends Model
} }
try { try {
$oEmbed = Twitter::getOembed([ $codebird = resolve(Codebird::class);
$oEmbed = $codebird->statuses_oembed([
'url' => $this->in_reply_to, 'url' => $this->in_reply_to,
'dnt' => true, 'dnt' => true,
'align' => 'center', 'align' => 'center',
'maxwidth' => 512, 'maxwidth' => 512,
]); ]);
} catch (\Exception $e) {
if ($oEmbed->httpstatus >= 400) {
throw new Exception();
}
} catch (Exception $e) {
return null; return null;
} }
Cache::put($tweetId, $oEmbed, ($oEmbed->cache_age)); Cache::put($tweetId, $oEmbed, ($oEmbed->cache_age));
@ -376,8 +385,10 @@ class Note extends Model
// here we check the matched contact from the note corresponds to a contact // here we check the matched contact from the note corresponds to a contact
// in the database // in the database
if (count(array_unique(array_values($this->contacts))) === 1 if (
&& array_unique(array_values($this->contacts))[0] === null) { count(array_unique(array_values($this->contacts))) === 1
&& array_unique(array_values($this->contacts))[0] === null
) {
throw new TwitterContentException('The matched contact is not in the database'); throw new TwitterContentException('The matched contact is not in the database');
} }

View file

@ -4,13 +4,13 @@ declare(strict_types=1);
namespace App\Models; namespace App\Models;
use Illuminate\Support\Str;
use Illuminate\Support\Facades\DB;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Builder;
use Cviebrock\EloquentSluggable\Sluggable; use Cviebrock\EloquentSluggable\Sluggable;
use Phaza\LaravelPostgis\Geometries\Point; use Illuminate\Database\Eloquent\Builder;
use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Str;
use Phaza\LaravelPostgis\Eloquent\PostgisTrait; use Phaza\LaravelPostgis\Eloquent\PostgisTrait;
use Phaza\LaravelPostgis\Geometries\Point;
class Place extends Model class Place extends Model
{ {

View file

@ -4,8 +4,8 @@ declare(strict_types=1);
namespace App\Models; namespace App\Models;
use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable; use Illuminate\Foundation\Auth\User as Authenticatable;
use Illuminate\Notifications\Notifiable;
class User extends Authenticatable class User extends Authenticatable
{ {

View file

@ -4,12 +4,14 @@ declare(strict_types=1);
namespace App\Models; namespace App\Models;
use Cache;
use Twitter;
use App\Traits\FilterHtml; use App\Traits\FilterHtml;
use Illuminate\Filesystem\Filesystem; use Codebird\Codebird;
use Illuminate\Database\Eloquent\Model; use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\Relations\MorphTo;
use Illuminate\Filesystem\Filesystem;
use Illuminate\Support\Facades\Cache;
use Jonnybarnes\WebmentionsParser\Authorship; use Jonnybarnes\WebmentionsParser\Authorship;
use Jonnybarnes\WebmentionsParser\Exceptions\AuthorshipParserException;
class WebMention extends Model class WebMention extends Model
{ {
@ -32,7 +34,7 @@ class WebMention extends Model
/** /**
* Define the relationship. * Define the relationship.
* *
* @return \Illuminate\Database\Eloquent\Relations\MorphTo * @return MorphTo
*/ */
public function commentable() public function commentable()
{ {
@ -43,12 +45,14 @@ class WebMention extends Model
* Get the author of the webmention. * Get the author of the webmention.
* *
* @return array * @return array
* @throws AuthorshipParserException
*/ */
public function getAuthorAttribute(): array public function getAuthorAttribute(): array
{ {
$authorship = new Authorship(); $authorship = new Authorship();
$hCard = $authorship->findAuthor(json_decode($this->mf2, true)); $hCard = $authorship->findAuthor(json_decode($this->mf2, true));
if (array_key_exists('properties', $hCard) && if (
array_key_exists('properties', $hCard) &&
array_key_exists('photo', $hCard['properties']) array_key_exists('photo', $hCard['properties'])
) { ) {
$hCard['properties']['photo'][0] = $this->createPhotoLink($hCard['properties']['photo'][0]); $hCard['properties']['photo'][0] = $this->createPhotoLink($hCard['properties']['photo'][0]);
@ -118,7 +122,8 @@ class WebMention extends Model
return Cache::get($url); return Cache::get($url);
} }
$username = ltrim(parse_url($url, PHP_URL_PATH), '/'); $username = ltrim(parse_url($url, PHP_URL_PATH), '/');
$info = Twitter::getUsers(['screen_name' => $username]); $codebird = resolve(Codebird::class);
$info = $codebird->users_show(['screen_name' => $username]);
$profile_image = $info->profile_image_url_https; $profile_image = $info->profile_image_url_https;
Cache::put($url, $profile_image, 10080); //1 week Cache::put($url, $profile_image, 10080); //1 week

View file

@ -12,11 +12,11 @@ class NoteObserver
/** /**
* Listen to the Note created event. * Listen to the Note created event.
* *
* @param \App\Note $note * @param Note $note
*/ */
public function created(Note $note) public function created(Note $note)
{ {
$text = array_get($note->getAttributes(), 'note'); $text = Arr::get($note->getAttributes(), 'note');
if ($text === null) { if ($text === null) {
return; return;
} }
@ -36,7 +36,7 @@ class NoteObserver
/** /**
* Listen to the Note updated event. * Listen to the Note updated event.
* *
* @param \App\Note $Note * @param Note $note
*/ */
public function updated(Note $note) public function updated(Note $note)
{ {
@ -62,7 +62,7 @@ class NoteObserver
/** /**
* Listen to the Note deleting event. * Listen to the Note deleting event.
* *
* @param \App\Note $note * @param Note $note
*/ */
public function deleting(Note $note) public function deleting(Note $note)
{ {
@ -73,7 +73,7 @@ class NoteObserver
* Retrieve the tags from a notes text, tag for form #tag. * Retrieve the tags from a notes text, tag for form #tag.
* *
* @param string $note * @param string $note
* @return \Illuminate\Support\Collection * @return Collection
*/ */
private function getTagsFromNote(string $note): Collection private function getTagsFromNote(string $note): Collection
{ {

View file

@ -3,11 +3,12 @@
namespace App\Providers; namespace App\Providers;
use App\Models\Note; use App\Models\Note;
use Illuminate\Support\Str;
use Illuminate\Http\Request;
use App\Observers\NoteObserver; use App\Observers\NoteObserver;
use Laravel\Dusk\DuskServiceProvider; use Codebird\Codebird;
use Illuminate\Http\Request;
use Illuminate\Support\ServiceProvider; use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Str;
use Laravel\Dusk\DuskServiceProvider;
class AppServiceProvider extends ServiceProvider class AppServiceProvider extends ServiceProvider
{ {
@ -29,6 +30,23 @@ class AppServiceProvider extends ServiceProvider
$this->app->bind('Intervention\Image\ImageManager', function () { $this->app->bind('Intervention\Image\ImageManager', function () {
return new \Intervention\Image\ImageManager(['driver' => config('image.driver')]); return new \Intervention\Image\ImageManager(['driver' => config('image.driver')]);
}); });
// Bind the Codebird client
$this->app->bind('Codebird\Codebird', function () {
Codebird::setConsumerKey(
env('TWITTER_CONSUMER_KEY'),
env('TWITTER_CONSUMER_SECRET')
);
$cb = Codebird::getInstance();
$cb->setToken(
env('TWITTER_ACCESS_TOKEN'),
env('TWITTER_ACCESS_TOKEN_SECRET')
);
return $cb;
});
} }
/** /**

View file

@ -2,8 +2,8 @@
namespace App\Providers; namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use Illuminate\Support\Facades\Broadcast; use Illuminate\Support\Facades\Broadcast;
use Illuminate\Support\ServiceProvider;
/** /**
* @codeCoverageIgnore * @codeCoverageIgnore

View file

@ -2,8 +2,10 @@
namespace App\Providers; namespace App\Providers;
use Illuminate\Support\Facades\Event; use Illuminate\Auth\Events\Registered;
use Illuminate\Auth\Listeners\SendEmailVerificationNotification;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider; use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Event;
class EventServiceProvider extends ServiceProvider class EventServiceProvider extends ServiceProvider
{ {
@ -13,8 +15,8 @@ class EventServiceProvider extends ServiceProvider
* @var array * @var array
*/ */
protected $listen = [ protected $listen = [
'App\Events\Event' => [ Registered::class => [
'App\Listeners\EventListener', SendEmailVerificationNotification::class,
], ],
]; ];

View file

@ -2,8 +2,8 @@
namespace App\Providers; namespace App\Providers;
use Laravel\Horizon\Horizon;
use Illuminate\Support\Facades\Gate; use Illuminate\Support\Facades\Gate;
use Laravel\Horizon\Horizon;
use Laravel\Horizon\HorizonApplicationServiceProvider; use Laravel\Horizon\HorizonApplicationServiceProvider;
class HorizonServiceProvider extends HorizonApplicationServiceProvider class HorizonServiceProvider extends HorizonApplicationServiceProvider

View file

@ -2,8 +2,8 @@
namespace App\Providers; namespace App\Providers;
use Illuminate\Support\Facades\Route;
use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider; use Illuminate\Foundation\Support\Providers\RouteServiceProvider as ServiceProvider;
use Illuminate\Support\Facades\Route;
class RouteServiceProvider extends ServiceProvider class RouteServiceProvider extends ServiceProvider
{ {

View file

@ -2,9 +2,9 @@
namespace App\Providers; namespace App\Providers;
use Laravel\Telescope\Telescope;
use Illuminate\Support\Facades\Gate; use Illuminate\Support\Facades\Gate;
use Laravel\Telescope\IncomingEntry; use Laravel\Telescope\IncomingEntry;
use Laravel\Telescope\Telescope;
use Laravel\Telescope\TelescopeApplicationServiceProvider; use Laravel\Telescope\TelescopeApplicationServiceProvider;
class TelescopeServiceProvider extends TelescopeApplicationServiceProvider class TelescopeServiceProvider extends TelescopeApplicationServiceProvider

View file

@ -4,16 +4,16 @@ declare(strict_types=1);
namespace App\Services; namespace App\Services;
use Ramsey\Uuid\Uuid;
use GuzzleHttp\Client;
use Illuminate\Http\Request;
use App\Jobs\ProcessBookmark;
use App\Models\{Bookmark, Tag};
use Illuminate\Support\{Arr, Str};
use Spatie\Browsershot\Browsershot;
use App\Jobs\SyndicateBookmarkToTwitter;
use GuzzleHttp\Exception\ClientException;
use App\Exceptions\InternetArchiveException; use App\Exceptions\InternetArchiveException;
use App\Jobs\ProcessBookmark;
use App\Jobs\SyndicateBookmarkToTwitter;
use App\Models\{Bookmark, Tag};
use GuzzleHttp\Client;
use GuzzleHttp\Exception\ClientException;
use Illuminate\Support\{Arr, Str};
use Ramsey\Uuid\Uuid;
use Spatie\Browsershot\Browsershot;
use Spatie\Browsershot\Exceptions\CouldNotTakeBrowsershot;
class BookmarkService class BookmarkService
{ {
@ -21,7 +21,7 @@ class BookmarkService
* Create a new Bookmark. * Create a new Bookmark.
* *
* @param array $request Data from request()->all() * @param array $request Data from request()->all()
* @return Bookmark $bookmark * @return Bookmark
*/ */
public function createBookmark(array $request): Bookmark public function createBookmark(array $request): Bookmark
{ {
@ -83,6 +83,7 @@ class BookmarkService
* *
* @param string $url * @param string $url
* @return string The uuid for the screenshot * @return string The uuid for the screenshot
* @throws CouldNotTakeBrowsershot
*/ */
public function saveScreenshot(string $url): string public function saveScreenshot(string $url): string
{ {
@ -104,6 +105,7 @@ class BookmarkService
* *
* @param string $url * @param string $url
* @return string * @return string
* @throws InternetArchiveException
*/ */
public function getArchiveLink(string $url): string public function getArchiveLink(string $url): string
{ {
@ -112,7 +114,7 @@ class BookmarkService
$response = $client->request('GET', 'https://web.archive.org/save/' . $url); $response = $client->request('GET', 'https://web.archive.org/save/' . $url);
} catch (ClientException $e) { } catch (ClientException $e) {
//throw an exception to be caught //throw an exception to be caught
throw new InternetArchiveException; throw new InternetArchiveException();
} }
if ($response->hasHeader('Content-Location')) { if ($response->hasHeader('Content-Location')) {
if (Str::startsWith(Arr::get($response->getHeader('Content-Location'), 0), '/web')) { if (Str::startsWith(Arr::get($response->getHeader('Content-Location'), 0), '/web')) {
@ -121,6 +123,6 @@ class BookmarkService
} }
//throw an exception to be caught //throw an exception to be caught
throw new InternetArchiveException; throw new InternetArchiveException();
} }
} }

View file

@ -4,8 +4,8 @@ declare(strict_types=1);
namespace App\Services; namespace App\Services;
use App\Models\Like;
use App\Jobs\ProcessLike; use App\Jobs\ProcessLike;
use App\Models\Like;
use Illuminate\Support\Arr; use Illuminate\Support\Arr;
class LikeService class LikeService

View file

@ -4,8 +4,8 @@ declare(strict_types=1);
namespace App\Services\Micropub; namespace App\Services\Micropub;
use Illuminate\Support\Arr;
use App\Services\PlaceService; use App\Services\PlaceService;
use Illuminate\Support\Arr;
class HCardService class HCardService
{ {

View file

@ -4,8 +4,8 @@ declare(strict_types=1);
namespace App\Services\Micropub; namespace App\Services\Micropub;
use Illuminate\Support\Arr;
use App\Services\{BookmarkService, LikeService, NoteService}; use App\Services\{BookmarkService, LikeService, NoteService};
use Illuminate\Support\Arr;
class HEntryService class HEntryService
{ {

View file

@ -5,8 +5,8 @@ declare(strict_types=1);
namespace App\Services\Micropub; namespace App\Services\Micropub;
use App\Models\{Media, Note}; use App\Models\{Media, Note};
use Illuminate\Support\{Arr, Str};
use Illuminate\Database\Eloquent\ModelNotFoundException; use Illuminate\Database\Eloquent\ModelNotFoundException;
use Illuminate\Support\{Arr, Str};
class UpdateService class UpdateService
{ {

View file

@ -4,9 +4,9 @@ declare(strict_types=1);
namespace App\Services; namespace App\Services;
use Illuminate\Support\{Arr, Str};
use App\Models\{Media, Note, Place};
use App\Jobs\{SendWebMentions, SyndicateNoteToTwitter}; use App\Jobs\{SendWebMentions, SyndicateNoteToTwitter};
use App\Models\{Media, Note, Place};
use Illuminate\Support\{Arr, Str};
class NoteService class NoteService
{ {

View file

@ -4,9 +4,9 @@ declare(strict_types=1);
namespace App\Services; namespace App\Services;
use App\Exceptions\InvalidTokenException;
use App\Jobs\AddClientToDatabase; use App\Jobs\AddClientToDatabase;
use Lcobucci\JWT\Signer\Hmac\Sha256; use Lcobucci\JWT\Signer\Hmac\Sha256;
use App\Exceptions\InvalidTokenException;
use Lcobucci\JWT\{Builder, Parser, Token}; use Lcobucci\JWT\{Builder, Parser, Token};
class TokenService class TokenService

View file

@ -1,7 +1,7 @@
{ {
"name": "jonnybarnes/jonnybarnes.uk", "name": "jonnybarnes/jonnybarnes.uk",
"type": "project", "type": "project",
"description": "The code for jonnybanres.uk, based on Laravel 5.8", "description": "The code for jonnybarnes.uk, based on Laravel 5.8",
"keywords": [ "keywords": [
"framework", "framework",
"laravel", "laravel",
@ -9,46 +9,46 @@
], ],
"license": "CC0-1.0", "license": "CC0-1.0",
"require": { "require": {
"php": ">=7.2.0", "php": "^7.3",
"cviebrock/eloquent-sluggable": "~4.3", "ext-intl": "*",
"ext-json": "*",
"ext-dom": "*",
"cviebrock/eloquent-sluggable": "~6.0",
"fideloper/proxy": "~4.0", "fideloper/proxy": "~4.0",
"guzzlehttp/guzzle": "~6.0", "guzzlehttp/guzzle": "~6.0",
"indieauth/client": "~0.1", "indieauth/client": "~0.1",
"intervention/image": "^2.4", "intervention/image": "^2.4",
"jonnybarnes/emoji-a11y": "^0.3",
"jonnybarnes/indieweb": "dev-master", "jonnybarnes/indieweb": "dev-master",
"jonnybarnes/webmentions-parser": "0.4.*", "jonnybarnes/webmentions-parser": "0.4.*",
"laravel/framework": "5.8.*", "jublonet/codebird-php": "4.0.0-beta.1",
"laravel/framework": "^6.0",
"laravel/horizon": "^3.0", "laravel/horizon": "^3.0",
"laravel/scout": "^7.0", "laravel/scout": "^7.0",
"laravel/telescope": "^2.0", "laravel/telescope": "^2.0",
"laravel/tinker": "^1.0", "laravel/tinker": "^2.0",
"lcobucci/jwt": "^3.1", "lcobucci/jwt": "^3.1",
"league/commonmark": "^1.0", "league/commonmark": "^1.0",
"league/commonmark-ext-autolink": "^1.0", "league/commonmark-ext-autolink": "^1.0",
"league/flysystem-aws-s3-v3": "^1.0", "league/flysystem-aws-s3-v3": "^1.0",
"mf2/mf2": "~0.3", "mf2/mf2": "~0.3",
"phaza/laravel-postgis": "~3.1", "phaza/laravel-postgis": "~4.0",
"pmatseykanets/laravel-scout-postgres": "~5.0", "pmatseykanets/laravel-scout-postgres": "~6.0",
"predis/predis": "~1.0", "predis/predis": "~1.0",
"ramsey/uuid": "^3.5", "ramsey/uuid": "^3.5",
"sensiolabs/security-checker": "^6.0", "sensiolabs/security-checker": "^6.0",
"spatie/browsershot": "~3.0", "spatie/browsershot": "~3.0",
"spatie/commonmark-highlighter": "^2.0", "spatie/commonmark-highlighter": "^2.0",
"tgalopin/html-sanitizer": "^1.1", "tgalopin/html-sanitizer": "^1.1"
"thujohn/twitter": "~2.0"
}, },
"require-dev": { "require-dev": {
"barryvdh/laravel-debugbar": "^3.0",
"beyondcode/laravel-dump-server": "^1.0", "beyondcode/laravel-dump-server": "^1.0",
"barryvdh/laravel-debugbar": "~3.0", "facade/ignition": "^1.4",
"codedungeon/phpunit-result-printer": "^0.26.0", "fzaninotto/faker": "^1.4",
"filp/whoops": "~2.0",
"fzaninotto/faker": "~1.4",
"laravel/dusk": "^5.0", "laravel/dusk": "^5.0",
"mockery/mockery": "~1.0", "mockery/mockery": "^1.0",
"nunomaduro/collision": "^3.0", "nunomaduro/collision": "^3.0",
"phpunit/phpunit": "~8.0", "phpunit/phpunit": "^8.0"
"symfony/thanks": "~1.0"
}, },
"config": { "config": {
"optimize-autoloader": true, "optimize-autoloader": true,

2932
composer.lock generated

File diff suppressed because it is too large Load diff

View file

@ -13,7 +13,7 @@ return [
| |
*/ */
'name' => 'jonnybarnes.uk', 'name' => env('APP_NAME', 'Laravel'),
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
@ -100,7 +100,7 @@ return [
| |
*/ */
'timezone' => env('APP_TIMEZONE', 'UTC'), 'timezone' => 'UTC',
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
@ -113,7 +113,7 @@ return [
| |
*/ */
'locale' => env('APP_LANG', 'en'), 'locale' => 'en',
/* /*
|-------------------------------------------------------------------------- |--------------------------------------------------------------------------
@ -202,14 +202,9 @@ return [
App\Providers\AuthServiceProvider::class, App\Providers\AuthServiceProvider::class,
// App\Providers\BroadcastServiceProvider::class, // App\Providers\BroadcastServiceProvider::class,
App\Providers\EventServiceProvider::class, App\Providers\EventServiceProvider::class,
App\Providers\TelescopeServiceProvider::class,
App\Providers\HorizonServiceProvider::class,
App\Providers\RouteServiceProvider::class, App\Providers\RouteServiceProvider::class,
App\Providers\HorizonServiceProvider::class,
/* App\Providers\TelescopeServiceProvider::class,
* Thujohns Twitter API client
*/
Thujohn\Twitter\TwitterServiceProvider::class,
], ],
@ -261,8 +256,6 @@ return [
'Validator' => Illuminate\Support\Facades\Validator::class, 'Validator' => Illuminate\Support\Facades\Validator::class,
'View' => Illuminate\Support\Facades\View::class, 'View' => Illuminate\Support\Facades\View::class,
'Twitter' => Thujohn\Twitter\Facades\Twitter::class,
], ],
'piwik' => env('PIWIK', false), 'piwik' => env('PIWIK', false),

View file

@ -36,7 +36,8 @@ return [
'secret' => env('PUSHER_APP_SECRET'), 'secret' => env('PUSHER_APP_SECRET'),
'app_id' => env('PUSHER_APP_ID'), 'app_id' => env('PUSHER_APP_ID'),
'options' => [ 'options' => [
// 'cluster' => env('PUSHER_APP_CLUSTER'),
'useTLS' => true,
], ],
], ],

View file

@ -13,7 +13,8 @@ return [
| using this caching library. This connection is used when another is | using this caching library. This connection is used when another is
| not explicitly specified when executing a given caching function. | not explicitly specified when executing a given caching function.
| |
| Supported: "apc", "array", "database", "file", "memcached", "redis" | Supported: "apc", "array", "database", "file",
| "memcached", "redis", "dynamodb"
| |
*/ */
@ -75,6 +76,15 @@ return [
'connection' => 'default', 'connection' => 'default',
], ],
'dynamodb' => [
'driver' => 'dynamodb',
'key' => env('AWS_ACCESS_KEY_ID'),
'secret' => env('AWS_SECRET_ACCESS_KEY'),
'region' => env('AWS_DEFAULT_REGION', 'us-east-1'),
'table' => env('DYNAMODB_CACHE_TABLE', 'cache'),
'endpoint' => env('DYNAMODB_ENDPOINT'),
],
], ],
/* /*
@ -88,6 +98,6 @@ return [
| |
*/ */
'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_').'_cache'), 'prefix' => env('CACHE_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_') . '_cache'),
]; ];

View file

@ -1,5 +1,7 @@
<?php <?php
use Illuminate\Support\Str;
return [ return [
/* /*
@ -35,6 +37,7 @@ return [
'sqlite' => [ 'sqlite' => [
'driver' => 'sqlite', 'driver' => 'sqlite',
'url' => env('DATABASE_URL'),
'database' => env('DB_DATABASE', database_path('database.sqlite')), 'database' => env('DB_DATABASE', database_path('database.sqlite')),
'prefix' => '', 'prefix' => '',
'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true), 'foreign_key_constraints' => env('DB_FOREIGN_KEYS', true),
@ -42,6 +45,7 @@ return [
'mysql' => [ 'mysql' => [
'driver' => 'mysql', 'driver' => 'mysql',
'url' => env('DATABASE_URL'),
'host' => env('DB_HOST', 'localhost'), 'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '3306'), 'port' => env('DB_PORT', '3306'),
'database' => env('DB_DATABASE', 'forge'), 'database' => env('DB_DATABASE', 'forge'),
@ -61,6 +65,7 @@ return [
'pgsql' => [ 'pgsql' => [
'driver' => 'pgsql', 'driver' => 'pgsql',
'url' => env('DATABASE_URL'),
'host' => env('DB_HOST', 'localhost'), 'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '5432'), 'port' => env('DB_PORT', '5432'),
'database' => env('DB_DATABASE', 'forge'), 'database' => env('DB_DATABASE', 'forge'),
@ -75,6 +80,7 @@ return [
'sqlsrv' => [ 'sqlsrv' => [
'driver' => 'sqlsrv', 'driver' => 'sqlsrv',
'url' => env('DATABASE_URL'),
'host' => env('DB_HOST', 'localhost'), 'host' => env('DB_HOST', 'localhost'),
'port' => env('DB_PORT', '1433'), 'port' => env('DB_PORT', '1433'),
'database' => env('DB_DATABASE', 'forge'), 'database' => env('DB_DATABASE', 'forge'),
@ -124,9 +130,15 @@ return [
'redis' => [ 'redis' => [
'client' => 'predis', 'client' => env('REDIS_CLIENT', 'phpredis'),
'options' => [
'cluster' => env('REDIS_CLUSTER', 'redis'),
'prefix' => env('REDIS_PREFIX', Str::slug(env('APP_NAME', 'laravel'), '_') . '_database_'),
],
'default' => [ 'default' => [
'url' => env('REDIS_URL'),
'host' => env('REDIS_HOST', '127.0.0.1'), 'host' => env('REDIS_HOST', '127.0.0.1'),
'password' => env('REDIS_PASSWORD', null), 'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379), 'port' => env('REDIS_PORT', 6379),
@ -134,6 +146,7 @@ return [
], ],
'cache' => [ 'cache' => [
'url' => env('REDIS_URL'),
'host' => env('REDIS_HOST', '127.0.0.1'), 'host' => env('REDIS_HOST', '127.0.0.1'),
'password' => env('REDIS_PASSWORD', null), 'password' => env('REDIS_PASSWORD', null),
'port' => env('REDIS_PORT', 6379), 'port' => env('REDIS_PORT', 6379),

View file

@ -51,7 +51,7 @@ return [
'public' => [ 'public' => [
'driver' => 'local', 'driver' => 'local',
'root' => storage_path('app/public'), 'root' => storage_path('app/public'),
'url' => env('APP_URL').'/storage', 'url' => env('APP_URL') . '/storage',
'visibility' => 'public', 'visibility' => 'public',
], ],

View file

@ -11,10 +11,39 @@ return [
| passwords for your application. By default, the bcrypt algorithm is | passwords for your application. By default, the bcrypt algorithm is
| used; however, you remain free to modify this option if you wish. | used; however, you remain free to modify this option if you wish.
| |
| Supported: "bcrypt", "argon" | Supported: "bcrypt", "argon", "argon2id"
| |
*/ */
'driver' => 'bcrypt', 'driver' => 'bcrypt',
/*
|--------------------------------------------------------------------------
| Bcrypt Options
|--------------------------------------------------------------------------
|
| Here you may specify the configuration options that should be used when
| passwords are hashed using the Bcrypt algorithm. This will allow you
| to control the amount of time it takes to hash the given password.
|
*/
'bcrypt' => [
'rounds' => env('BCRYPT_ROUNDS', 10),
],
/*
|--------------------------------------------------------------------------
| Argon Options
|--------------------------------------------------------------------------
|
| Here you may specify the configuration options that should be used when
| passwords are hashed using the Argon algorithm. These will allow you
| to control the amount of time it takes to hash the given password.
|
*/
'argon' => [
'memory' => 1024,
'threads' => 2,
'time' => 2,
],
]; ];

View file

@ -1,5 +1,6 @@
<?php <?php
use Monolog\Handler\NullHandler;
use Monolog\Handler\StreamHandler; use Monolog\Handler\StreamHandler;
use Monolog\Handler\SyslogUdpHandler; use Monolog\Handler\SyslogUdpHandler;
@ -37,6 +38,7 @@ return [
'stack' => [ 'stack' => [
'driver' => 'stack', 'driver' => 'stack',
'channels' => ['daily'], 'channels' => ['daily'],
'ignore_exceptions' => false,
], ],
'single' => [ 'single' => [
@ -88,6 +90,11 @@ return [
'driver' => 'errorlog', 'driver' => 'errorlog',
'level' => 'debug', 'level' => 'debug',
], ],
'null' => [
'driver' => 'monolog',
'handler' => NullHandler::class,
],
], ],
]; ];

View file

@ -11,8 +11,8 @@ return [
| sending of e-mail. You may specify which one you're using throughout | sending of e-mail. You may specify which one you're using throughout
| your application here. By default, Laravel is setup for SMTP mail. | your application here. By default, Laravel is setup for SMTP mail.
| |
| Supported: "smtp", "sendmail", "mailgun", "mandrill", "ses" | Supported: "smtp", "sendmail", "mailgun", "ses"
| "sparkpost", "log", "array" | "postmark", "log", "array"
| |
*/ */

View file

@ -46,6 +46,7 @@ return [
'host' => 'localhost', 'host' => 'localhost',
'queue' => 'default', 'queue' => 'default',
'retry_after' => 90, 'retry_after' => 90,
'block_for' => 0,
], ],
'sqs' => [ 'sqs' => [
@ -79,6 +80,7 @@ return [
*/ */
'failed' => [ 'failed' => [
'driver' => env('QUEUE_FAILED_DRIVER', 'database'),
'database' => env('DB_CONNECTION', 'mysql'), 'database' => env('DB_CONNECTION', 'mysql'),
'table' => 'failed_jobs', 'table' => 'failed_jobs',
], ],

View file

@ -20,24 +20,14 @@ return [
'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'), 'endpoint' => env('MAILGUN_ENDPOINT', 'api.mailgun.net'),
], ],
'postmark' => [
'token' => env('POSTMARK_TOKEN'),
],
'ses' => [ 'ses' => [
'key' => env('SES_KEY'), 'key' => env('SES_KEY'),
'secret' => env('SES_SECRET'), 'secret' => env('SES_SECRET'),
'region' => 'us-east-1', 'region' => 'us-east-1',
], ],
'sparkpost' => [
'secret' => env('SPARKPOST_SECRET'),
],
'stripe' => [
'model' => App\User::class,
'key' => env('STRIPE_KEY'),
'secret' => env('STRIPE_SECRET'),
'webhook' => [
'secret' => env('STRIPE_WEBHOOK_SECRET'),
'tolerance' => env('STRIPE_WEBHOOK_TOLERANCE', 300),
],
],
]; ];

View file

@ -14,7 +14,7 @@ return [
| you may specify any of the other wonderful drivers provided here. | you may specify any of the other wonderful drivers provided here.
| |
| Supported: "file", "cookie", "database", "apc", | Supported: "file", "cookie", "database", "apc",
| "memcached", "redis", "array" | "memcached", "redis", "dynamodb", "array"
| |
*/ */
@ -31,7 +31,7 @@ return [
| |
*/ */
'lifetime' => 60 * 24 * 7, 'lifetime' => env('SESSION_LIFETIME', 120),
'expire_on_close' => false, 'expire_on_close' => false,
@ -126,7 +126,7 @@ return [
'cookie' => env( 'cookie' => env(
'SESSION_COOKIE', 'SESSION_COOKIE',
Str::slug(env('APP_NAME', 'laravel'), '_').'_session' Str::slug(env('APP_NAME', 'laravel'), '_') . '_session'
), ),
/* /*

View file

@ -2,9 +2,13 @@
use App\Models\Note; use App\Models\Note;
use Faker\Generator as Faker; use Faker\Generator as Faker;
use Illuminate\Support\Carbon;
$factory->define(Note::class, function (Faker $faker) { $factory->define(Note::class, function (Faker $faker) {
$now = Carbon::now()->subDays(rand(5, 15));
return [ return [
'note' => $faker->paragraph, 'note' => $faker->paragraph,
'created_at' => $now,
'updated_at' => $now,
]; ];
}); });

View file

@ -1,7 +1,9 @@
<?php <?php
use App\Models\Article; use App\Models\Article;
use Illuminate\Support\Carbon;
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class ArticlesTableSeeder extends Seeder class ArticlesTableSeeder extends Seeder
{ {
@ -12,12 +14,18 @@ class ArticlesTableSeeder extends Seeder
*/ */
public function run() public function run()
{ {
Article::create([ $now = Carbon::now()->subMonth();
$articleFirst = Article::create([
'title' => 'My New Blog', 'title' => 'My New Blog',
'main' => 'This is *my* new blog. It uses `Markdown`.', 'main' => 'This is *my* new blog. It uses `Markdown`.',
'published' => 1, 'published' => 1,
'created_at' => $now,
]); ]);
DB::table('articles')
->where('id', $articleFirst->id)
->update(['updated_at' => $now->toDateTimeString()]);
$now = Carbon::now()->subHours(2)->subMinutes(25);
$articleWithCode = <<<EOF $articleWithCode = <<<EOF
I wrote some code. I wrote some code.
@ -37,10 +45,14 @@ class Foo
} }
``` ```
EOF; EOF;
Article::create([ $articleSecond = Article::create([
'title' => 'Some code I did', 'title' => 'Some code I did',
'main' => $articleWithCode, 'main' => $articleWithCode,
'published' => 1, 'published' => 1,
'created_at' => $now,
]); ]);
DB::table('articles')
->where('id', $articleSecond->id)
->update(['updated_at' => $now->toDateTimeString()]);
} }
} }

View file

@ -1,7 +1,9 @@
<?php <?php
use Illuminate\Support\Carbon;
use App\Models\{Bookmark, Tag}; use App\Models\{Bookmark, Tag};
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class BookmarksTableSeeder extends Seeder class BookmarksTableSeeder extends Seeder
{ {
@ -14,6 +16,14 @@ class BookmarksTableSeeder extends Seeder
{ {
factory(Bookmark::class, 10)->create()->each(function ($bookmark) { factory(Bookmark::class, 10)->create()->each(function ($bookmark) {
$bookmark->tags()->save(factory(Tag::class)->make()); $bookmark->tags()->save(factory(Tag::class)->make());
$now = Carbon::now()->subDays(rand(2, 12));
DB::table('bookmarks')
->where('id', $bookmark->id)
->update([
'created_at' => $now->toDateTimeString(),
'updated_at' => $now->toDateTimeString(),
]);
}); });
} }
} }

View file

@ -2,7 +2,9 @@
use App\Models\Like; use App\Models\Like;
use Faker\Generator; use Faker\Generator;
use Illuminate\Support\Carbon;
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
class LikesTableSeeder extends Seeder class LikesTableSeeder extends Seeder
{ {
@ -13,20 +15,40 @@ class LikesTableSeeder extends Seeder
*/ */
public function run() public function run()
{ {
factory(Like::class, 10)->create(); factory(Like::class, 10)->create()->each(function ($like) {
sleep(1); $now = Carbon::now()->subDays(rand(5, 15));
DB::table('likes')
->where('id', $like->id)
->update([
'created_at' => $now->toDateTimeString(),
'updated_at' => $now->toDateTimeString(),
]);
});
$now = Carbon::now()->subDays(rand(3, 6));
$faker = new Generator(); $faker = new Generator();
$faker->addProvider(new \Faker\Provider\en_US\Person($faker)); $faker->addProvider(new \Faker\Provider\en_US\Person($faker));
$faker->addProvider(new \Faker\Provider\Lorem($faker)); $faker->addProvider(new \Faker\Provider\Lorem($faker));
$faker->addProvider(new \Faker\Provider\Internet($faker)); $faker->addProvider(new \Faker\Provider\Internet($faker));
Like::create([ $likeFromAuthor = Like::create([
'url' => $faker->url, 'url' => $faker->url,
'author_url' => $faker->url, 'author_url' => $faker->url,
'author_name' => $faker->name, 'author_name' => $faker->name,
]); ]);
sleep(1); DB::table('likes')
->where('id', $likeFromAuthor->id)
->update([
'created_at' => $now->toDateTimeString(),
'updated_at' => $now->toDateTimeString(),
]);
Like::create(['url' => 'https://example.com']); $now = Carbon::now()->subHours(rand(3, 6));
$likeJustUrl = Like::create(['url' => 'https://example.com']);
DB::table('likes')
->where('id', $likeJustUrl->id)
->update([
'created_at' => $now->toDateTimeString(),
'updated_at' => $now->toDateTimeString(),
]);
} }
} }

View file

@ -1,6 +1,8 @@
<?php <?php
use Illuminate\Support\Carbon;
use Illuminate\Database\Seeder; use Illuminate\Database\Seeder;
use Illuminate\Support\Facades\DB;
use App\Models\{Media, Note, Place}; use App\Models\{Media, Note, Place};
class NotesTableSeeder extends Seeder class NotesTableSeeder extends Seeder
@ -12,103 +14,175 @@ class NotesTableSeeder extends Seeder
*/ */
public function run() public function run()
{ {
factory(Note::class, 10)->create(); //factory(Note::class, 10)->create();
sleep(1);
$now = Carbon::now()->subDays(rand(2, 5));
$noteTwitterReply = Note::create([ $noteTwitterReply = Note::create([
'note' => 'What does this even mean?', 'note' => 'What does this even mean?',
'in_reply_to' => 'https://twitter.com/realDonaldTrump/status/933662564587855877', 'in_reply_to' => 'https://twitter.com/realDonaldTrump/status/933662564587855877',
'created_at' => $now,
]); ]);
sleep(1); DB::table('notes')
->where('id', $noteTwitterReply->id)
->update(['updated_at' => $now->toDateTimeString()]);
$now = Carbon::now()->subDays(rand(2, 5));
$noteWithPlace = Note::create([ $noteWithPlace = Note::create([
'note' => 'Having a #beer at the local. 🍺', 'note' => 'Having a #beer at the local. 🍺',
'created_at' => $now,
]); ]);
$noteWithPlace->tweet_id = '123456789'; $noteWithPlace->tweet_id = '123456789';
$place = Place::find(1); $place = Place::find(1);
$noteWithPlace->place()->associate($place); $noteWithPlace->place()->associate($place);
$noteWithPlace->save(); $noteWithPlace->save();
sleep(1); DB::table('notes')
->where('id', $noteWithPlace->id)
->update(['updated_at' => $now->toDateTimeString()]);
$now = Carbon::now()->subDays(rand(3, 6));
$noteWithPlaceTwo = Note::create([ $noteWithPlaceTwo = Note::create([
'note' => 'Its really good', 'note' => 'Its really good',
'created_at' => $now,
]); ]);
$place = Place::find(1); $place = Place::find(1);
$noteWithPlaceTwo->place()->associate($place); $noteWithPlaceTwo->place()->associate($place);
$noteWithPlaceTwo->save(); $noteWithPlaceTwo->save();
sleep(1); DB::table('notes')
->where('id', $noteWithPlaceTwo->id)
->update(['updated_at' => $now->toDateTimeString()]);
$now = Carbon::now()->subDays(rand(4, 8));
$noteWithContact = Note::create([ $noteWithContact = Note::create([
'note' => 'Hi @tantek' 'note' => 'Hi @tantek',
'created_at' => $now,
]); ]);
sleep(1); DB::table('notes')
->where('id', $noteWithContact->id)
->update(['updated_at' => $now->toDateTimeString()]);
$now = Carbon::now()->subDays(rand(1, 10));
$noteWithContactPlusPic = Note::create([ $noteWithContactPlusPic = Note::create([
'note' => 'Hi @aaron', 'note' => 'Hi @aaron',
'client_id' => 'https://jbl5.dev/notes/new' 'client_id' => 'https://jbl5.dev/notes/new',
'created_at' => $now,
]); ]);
sleep(1); DB::table('notes')
->where('id', $noteWithContactPlusPic->id)
->update(['updated_at' => $now->toDateTimeString()]);
$now = Carbon::now()->subDays(rand(2, 5));
$noteWithoutContact = Note::create([ $noteWithoutContact = Note::create([
'note' => 'Hi @bob', 'note' => 'Hi @bob',
'client_id' => 'https://quill.p3k.io' 'client_id' => 'https://quill.p3k.io',
'created_at' => $now,
]); ]);
sleep(1); DB::table('notes')
->where('id', $noteWithoutContact->id)
->update(['updated_at' => $now->toDateTimeString()]);
//copy aarons profile pic in place //copy aarons profile pic in place
$spl = new SplFileInfo(public_path() . '/assets/profile-images/aaronparecki.com'); $spl = new SplFileInfo(public_path() . '/assets/profile-images/aaronparecki.com');
if ($spl->isDir() === false) { if ($spl->isDir() === false) {
mkdir(public_path() . '/assets/profile-images/aaronparecki.com', 0755); mkdir(public_path() . '/assets/profile-images/aaronparecki.com', 0755);
copy(base_path() . '/tests/aaron.png', public_path() . '/assets/profile-images/aaronparecki.com/image'); copy(base_path() . '/tests/aaron.png', public_path() . '/assets/profile-images/aaronparecki.com/image');
} }
$now = Carbon::now()->subDays(rand(3, 7));
$noteWithCoords = Note::create([ $noteWithCoords = Note::create([
'note' => 'Note from a town', 'note' => 'Note from a town',
'created_at' => $now,
]); ]);
DB::table('notes')
->where('id', $noteWithCoords->id)
->update(['updated_at' => $now->toDateTimeString()]);
$noteWithCoords->location = '53.499,-2.379'; $noteWithCoords->location = '53.499,-2.379';
$noteWithCoords->save(); $noteWithCoords->save();
sleep(1);
$noteWithCoords2 = Note::create([ $noteWithCoords2 = Note::create([
'note' => 'Note from a city', 'note' => 'Note from a city',
'created_at' => $now,
]); ]);
$noteWithCoords2->location = '53.9026894,-2.42250444118781'; $noteWithCoords2->location = '53.9026894,-2.42250444118781';
$noteWithCoords2->save(); $noteWithCoords2->save();
sleep(1); DB::table('notes')
->where('id', $noteWithCoords2->id)
->update(['updated_at' => $now->toDateTimeString()]);
$noteWithCoords3 = Note::create([ $noteWithCoords3 = Note::create([
'note' => 'Note from a county', 'note' => 'Note from a county',
'created_at' => $now,
]); ]);
$noteWithCoords3->location = '57.5066357,-5.0038367'; $noteWithCoords3->location = '57.5066357,-5.0038367';
$noteWithCoords3->save(); $noteWithCoords3->save();
sleep(1); DB::table('notes')
->where('id', $noteWithCoords3->id)
->update(['updated_at' => $now->toDateTimeString()]);
$noteWithCoords4 = Note::create([ $noteWithCoords4 = Note::create([
'note' => 'Note from a country', 'note' => 'Note from a country',
'created_at' => $now,
]); ]);
$noteWithCoords4->location = '63.000147,-136.002502'; $noteWithCoords4->location = '63.000147,-136.002502';
$noteWithCoords4->save(); $noteWithCoords4->save();
sleep(1); DB::table('notes')
->where('id', $noteWithCoords4->id)
->update(['updated_at' => $now->toDateTimeString()]);
$now = Carbon::now()->subHours(7);
$noteSyndicated = Note::create([ $noteSyndicated = Note::create([
'note' => 'This note has all the syndication targets', 'note' => 'This note has all the syndication targets',
'created_at' => $now,
]); ]);
$noteSyndicated->tweet_id = '123456'; $noteSyndicated->tweet_id = '123456';
$noteSyndicated->facebook_url = 'https://www.facebook.com/post/12345789'; $noteSyndicated->facebook_url = 'https://www.facebook.com/post/12345789';
$noteSyndicated->swarm_url = 'https://www.swarmapp.com/checking/123456789'; $noteSyndicated->swarm_url = 'https://www.swarmapp.com/checking/123456789';
$noteSyndicated->instagram_url = 'https://www.instagram.com/p/aWsEd123Jh'; $noteSyndicated->instagram_url = 'https://www.instagram.com/p/aWsEd123Jh';
$noteSyndicated->save(); $noteSyndicated->save();
sleep(1); DB::table('notes')
->where('id', $noteSyndicated->id)
->update(['updated_at' => $now->toDateTimeString()]);
$now = Carbon::now()->subHours(6);
$noteWithTextLinkandEmoji = Note::create([ $noteWithTextLinkandEmoji = Note::create([
'note' => 'I love https://duckduckgo.com 💕' // theres a two-heart emoji at the end of this 'note' => 'I love https://duckduckgo.com 💕', // theres a two-heart emoji at the end of this
'created_at' => $now,
]); ]);
sleep(1); DB::table('notes')
->where('id', $noteWithTextLinkandEmoji->id)
->update(['updated_at' => $now->toDateTimeString()]);
$now = Carbon::now()->subHours(5);
$noteJustCheckin = new Note(); $noteJustCheckin = new Note();
$noteJustCheckin->setCreatedAt($now);
$place = Place::find(1); $place = Place::find(1);
$noteJustCheckin->place()->associate($place); $noteJustCheckin->place()->associate($place);
$noteJustCheckin->save(); $noteJustCheckin->save();
sleep(1); DB::table('notes')
->where('id', $noteJustCheckin->id)
->update(['updated_at' => $now->toDateTimeString()]);
$now = Carbon::now()->subHours(4);
$media = new Media(); $media = new Media();
$media->path = 'media/f1bc8faa-1a8f-45b8-a9b1-57282fa73f87.jpg'; $media->path = 'media/f1bc8faa-1a8f-45b8-a9b1-57282fa73f87.jpg';
$media->type = 'image'; $media->type = 'image';
$media->image_widths = '3648'; $media->image_widths = '3648';
$media->save(); $media->save();
$noteWithOnlyImage = new Note(); $noteWithOnlyImage = new Note();
$noteWithOnlyImage->setCreatedAt($now);
$noteWithOnlyImage->setUpdatedAt($now);
$noteWithOnlyImage->save(); $noteWithOnlyImage->save();
$noteWithOnlyImage->media()->save($media); $noteWithOnlyImage->media()->save($media);
sleep(1); DB::table('notes')
->where('id', $noteWithOnlyImage->id)
->update(['updated_at' => $now->toDateTimeString()]);
$now = Carbon::now()->subHours(3);
$noteCapitalHashtag = Note::create([ $noteCapitalHashtag = Note::create([
'note' => 'A #TwoWord hashtag', 'note' => 'A #TwoWord hashtag',
'created_at' => $now,
]); ]);
sleep(1); DB::table('notes')
->where('id', $noteCapitalHashtag->id)
->update(['updated_at' => $now->toDateTimeString()]);
$now = Carbon::now()->subHours(2);
$noteWithCodeContent = <<<EOF $noteWithCodeContent = <<<EOF
A note with some code: A note with some code:
```php ```php
@ -118,6 +192,10 @@ echo 'Hello World';
EOF; EOF;
$noteWithCode = Note::create([ $noteWithCode = Note::create([
'note' => $noteWithCodeContent, 'note' => $noteWithCodeContent,
'created_at' => $now,
]); ]);
DB::table('notes')
->where('id', $noteWithCode->id)
->update(['updated_at' => $now->toDateTimeString()]);
} }
} }

14185
package-lock.json generated

File diff suppressed because it is too large Load diff

View file

@ -5,54 +5,32 @@
"repository": "https://github.com/jonnybarnes/jonnybarnes.uk", "repository": "https://github.com/jonnybarnes/jonnybarnes.uk",
"license": "CC0-1.0", "license": "CC0-1.0",
"dependencies": { "dependencies": {
"a11y.css": "^5.0.3",
"alertify.js": "^1.0.12",
"marked": "^0.7.0",
"normalize.css": "^8.0.1", "normalize.css": "^8.0.1",
"puppeteer": "^1.18.1" "puppeteer": "^2.0.0"
}, },
"devDependencies": { "devDependencies": {
"@babel/core": "^7.5.4", "css-loader": "^3.4.2",
"@babel/preset-env": "^7.5.4", "husky": "^4.2.1",
"ajv": "^6.10.1", "lint-staged": "^10.0.2",
"ajv-keywords": "^3.4.1", "mini-css-extract-plugin": "^0.9.0",
"autoprefixer": "^9.6.1", "node-sass": "^4.13.1",
"babel-cli": "^6.26.0",
"babel-loader": "^8.0.6",
"babel-preset-env": "^1.7.0",
"babel-runtime": "^6.26.0",
"dotenv-webpack": "^1.7.0",
"eslint": "^6.0.1",
"eslint-config-standard": "^13.0.1",
"eslint-plugin-import": "^2.18.0",
"eslint-plugin-node": "^9.1.0",
"eslint-plugin-promise": "^4.2.1",
"eslint-plugin-standard": "^4.0.0",
"husky": "^3.0.0",
"lint-staged": "^9.2.0",
"postcss-cli": "^6.1.3",
"postcss-sass": "^0.4.1",
"pre-commit": "^1.1.3", "pre-commit": "^1.1.3",
"source-list-map": "^2.0.1", "sass-loader": "^8.0.2",
"stylelint": "^10.1.0", "style-loader": "^1.1.3",
"stylelint-config-standard": "^18.3.0", "stylelint": "^13.0.0",
"uglify-js": "^3.6.0", "stylelint-config-standard": "^19.0.0",
"webpack": "^4.35.3", "webpack": "^4.41.5",
"webpack-cli": "^3.3.5", "webpack-cli": "^3.3.10"
"webpack-sources": "^1.3.0"
}, },
"scripts": { "scripts": {
"compress": "scripts/compress", "compress": "scripts/compress",
"copy-dist": "cp ./node_modules/alertify.js/dist/css/alertify.css ./public/assets/frontend/ && cp ./node_modules/normalize.css/normalize.css ./public/assets/frontend/ && cp ./node_modules/a11y.css/css/*.css ./public/assets/frontend/a11y.css/", "copy-dist": "cp ./node_modules/normalize.css/normalize.css ./public/assets/frontend/",
"lint:es6": "eslint resources/es6/*.js", "lint:es6": "eslint resources/es/*.js",
"lint:sass": "stylelint --syntax=scss resources/sass/**/*.scss", "lint:sass": "stylelint --syntax=scss resources/sass/**/*.scss",
"make": "npm run make:css && npm run make:js", "make": "npm run make:css && npm run make:js",
"make:css": "npm run lint:sass && npm run sass && npm run postcss", "make:css": "npm run lint:sass && npm run sass && npm run postcss",
"make:js": "npm run lint:es6 && npm run webpack && npm run uglifyjs", "make:js": "npm run lint:es6 && npm run webpack && npm run uglifyjs",
"postcss": "postcss public/assets/css/app.css --use autoprefixer --autoprefixer.browsers \"> 5%\" --replace --map", "webpack": "webpack"
"sass": "sassc --style compressed --sourcemap resources/sass/app.scss public/assets/css/app.css",
"uglifyjs": "scripts/uglifyjs",
"webpack": "webpack --progress --colors"
}, },
"husky": { "husky": {
"hooks": { "hooks": {
@ -61,12 +39,10 @@
}, },
"lint-staged": { "lint-staged": {
"./resources/es6/*.js": [ "./resources/es6/*.js": [
"eslint --fix", "eslint"
"git add"
], ],
"*.scss": [ "*.scss": [
"stylelint --syntax=scss --fix", "stylelint --syntax=scss"
"git add"
] ]
} }
} }

View file

@ -2,7 +2,5 @@
<ruleset name="jonnybarnes.uk"> <ruleset name="jonnybarnes.uk">
<description>Custom configuration for code running jonnybarnes.uk</description> <description>Custom configuration for code running jonnybarnes.uk</description>
<file>./app/</file> <file>./app/</file>
<rule ref="PSR2"> <rule ref="PSR12" />
<exclude name="PSR2.Namespaces.UseDeclaration" />
</rule>
</ruleset> </ruleset>

View file

@ -7,8 +7,8 @@
convertNoticesToExceptions="true" convertNoticesToExceptions="true"
convertWarningsToExceptions="true" convertWarningsToExceptions="true"
processIsolation="false" processIsolation="false"
stopOnFailure="false" stopOnFailure="true"
printerClass="Codedungeon\PHPUnitPrettyResultPrinter\Printer"> >
<testsuites> <testsuites>
<testsuite name="Unit"> <testsuite name="Unit">
<directory suffix="Test.php">./tests/Unit</directory> <directory suffix="Test.php">./tests/Unit</directory>

78
public/assets/app.css vendored Normal file
View file

@ -0,0 +1,78 @@
:root {
--font-stack-body: montserrat, sans-serif;
--font-stack-headings: bebas-neue, sans-serif; }
body {
font-family: var(--font-stack-body);
font-size: 2rem; }
h1,
h2,
h3,
h4,
h5,
h6 {
font-family: var(--font-stack-headings); }
body {
display: flex;
flex-direction: column; }
#top-header {
display: flex;
flex-direction: column;
justify-content: center; }
#top-header h1 {
display: flex;
justify-content: center; }
#top-header nav {
display: flex;
justify-content: center; }
#top-header nav a {
margin: 0 0.5rem; }
.h-feed {
display: flex;
flex-direction: column;
margin: auto; }
@media screen and (min-width: 700px) {
.h-feed {
max-width: 700px; }
.h-feed > .note,
.h-feed > .h-entry {
padding: 0 1rem; } }
.note {
display: flex;
flex-direction: column; }
.note .note-metadata {
display: flex;
flex-direction: row;
justify-content: space-between; }
.note .note-metadata .syndication-links svg {
height: 1em;
width: 1em; }
.note > .e-content > .naked-link .u-photo {
margin: 2rem 0; }
.personal-bio {
padding: 0 2rem; }
footer {
display: flex;
flex-direction: column;
align-items: center;
margin-top: 1.5rem; }
.post-info a {
text-decoration: none; }
.syndication-links .u-syndication {
text-decoration: none; }
.p-bridgy-facebook-content,
.p-bridgy-twitter-content {
display: none; }
/*# sourceMappingURL=app.css.map*/

View file

@ -0,0 +1 @@
{"version":3,"sources":["webpack:///./resources/sass/_variables.scss","webpack:///./resources/sass/_base.scss","webpack:///./resources/sass/_layout-main.scss","webpack:///./resources/sass/_link-styles.scss","webpack:///./resources/sass/_posse.scss"],"names":[],"mappings":"AAAA;EACI,yCAAkB;EAClB,6CAAsB;;ACF1B;EACI,mCAAmC;EACnC,eAAe;;AAGnB;;;;;;EAMI,uCAAuC;;ACX3C;EACI,aAAa;EACb,sBAAsB;;AAG1B;EACI,aAAa;EACb,sBAAsB;EACtB,uBAAuB;EAH3B;IAMQ,aAAa;IACb,uBAAuB;EAP/B;IAWQ,aAAa;IACb,uBAAuB;IAZ/B;MAeY,gBAAgB;;AAK5B;EACI,aAAa;EACb,sBAAsB;EACtB,YAAY;EAEZ;IALJ;MAMQ,gBAAgB;MANxB;;QAUY,eAAe,IAClB;;AAIT;EACI,aAAa;EACb,sBAAsB;EAF1B;IAKQ,aAAa;IACb,mBAAmB;IACnB,8BAA8B;IAPtC;MAWgB,WAAW;MACX,UAAU;EAZ1B;IAoBgB,cAAc;;AAM9B;EACI,eAAe;;AAGnB;EACI,aAAa;EACb,sBAAsB;EACtB,mBAAmB;EACnB,kBAAkB;;AC1EtB;EAEQ,qBAAqB;;AAI7B;EAEQ,qBAAqB;;ACR7B;;EAEI,aAAa","file":"app.css","sourcesContent":[":root {\n --font-stack-body: montserrat, sans-serif;\n --font-stack-headings: bebas-neue, sans-serif;\n}\n","body {\n font-family: var(--font-stack-body);\n font-size: 2rem;\n}\n\nh1,\nh2,\nh3,\nh4,\nh5,\nh6 {\n font-family: var(--font-stack-headings);\n}\n","body {\n display: flex;\n flex-direction: column;\n}\n\n#top-header {\n display: flex;\n flex-direction: column;\n justify-content: center;\n\n h1 {\n display: flex;\n justify-content: center;\n }\n\n nav {\n display: flex;\n justify-content: center;\n\n a {\n margin: 0 0.5rem;\n }\n }\n}\n\n.h-feed {\n display: flex;\n flex-direction: column;\n margin: auto;\n\n @media screen and (min-width: 700px) {\n max-width: 700px;\n\n > .note,\n > .h-entry {\n padding: 0 1rem;\n }\n }\n}\n\n.note {\n display: flex;\n flex-direction: column;\n\n .note-metadata {\n display: flex;\n flex-direction: row;\n justify-content: space-between;\n\n .syndication-links {\n svg {\n height: 1em;\n width: 1em;\n }\n }\n }\n\n > .e-content {\n > .naked-link {\n .u-photo {\n margin: 2rem 0;\n }\n }\n }\n}\n\n.personal-bio {\n padding: 0 2rem;\n}\n\nfooter {\n display: flex;\n flex-direction: column;\n align-items: center;\n margin-top: 1.5rem;\n}\n",".post-info {\n a {\n text-decoration: none;\n }\n}\n\n.syndication-links {\n .u-syndication {\n text-decoration: none;\n }\n}\n",".p-bridgy-facebook-content,\n.p-bridgy-twitter-content {\n display: none;\n}\n"],"sourceRoot":""}

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