Merge pull request #293 from jonnybarnes/develop
MTM Mentions Improvements
This commit is contained in:
commit
9c059f822f
129 changed files with 2091 additions and 2056 deletions
12
.github/dependabot.yml
vendored
Normal file
12
.github/dependabot.yml
vendored
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
version: 2
|
||||
|
||||
updates:
|
||||
- package-ecosystem: "composer"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "daily"
|
||||
|
||||
- package-ecosystem: "npm"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "daily"
|
||||
68
.github/workflows/phpunit.yml
vendored
Normal file
68
.github/workflows/phpunit.yml
vendored
Normal file
|
|
@ -0,0 +1,68 @@
|
|||
name: PHP Unit
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
phpunit:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
name: PHPUnit test suite
|
||||
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:latest
|
||||
env:
|
||||
POSTGRES_USER: postgres
|
||||
POSTGRES_PASSWORD: postgres
|
||||
POSTGRES_DB: jbukdev_testing
|
||||
ports:
|
||||
- 5432:5432
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Install Node and dependencies
|
||||
uses: actions/setup-node@v3
|
||||
with:
|
||||
node-version: 18
|
||||
cache: 'npm'
|
||||
- run: npm ci
|
||||
|
||||
- name: Setup PHP with pecl extensions
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: '8.1'
|
||||
extensions: phpredis,imagick
|
||||
|
||||
- name: Copy .env
|
||||
run: php -r "file_exists('.env') || copy('.env.github', '.env');"
|
||||
|
||||
- name: Get Composer Cache Directory
|
||||
id: composer-cache
|
||||
run: |
|
||||
echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||
|
||||
- name: Cache composer dependencies
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ${{ steps.composer-cache.outputs.dir }}
|
||||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-composer-
|
||||
|
||||
- name: Install Composer Dependencies
|
||||
run: composer install --quiet --no-ansi --no-interaction --no-progress
|
||||
|
||||
- name: Generate Key
|
||||
run: php artisan key:generate
|
||||
|
||||
- name: Setup Directory Permissions
|
||||
run: chmod -R 777 storage bootstrap/cache
|
||||
|
||||
- name: Setup Database
|
||||
run: php artisan migrate
|
||||
|
||||
- name: Execute PHPUnit Tests
|
||||
run: vendor/bin/phpunit
|
||||
38
.github/workflows/pint.yml
vendored
Normal file
38
.github/workflows/pint.yml
vendored
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
name: Laravel Pint
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
pint:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
name: Laravel Pint
|
||||
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
|
||||
- name: Setup PHP with pecl extensions
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: '8.1'
|
||||
|
||||
- name: Get Composer Cache Directory
|
||||
id: composer-cache
|
||||
run: |
|
||||
echo "::set-output name=dir::$(composer config cache-files-dir)"
|
||||
|
||||
- name: Cache composer dependencies
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ${{ steps.composer-cache.outputs.dir }}
|
||||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-composer-
|
||||
|
||||
- name: Install Composer Dependencies
|
||||
run: composer install --quiet --no-ansi --no-interaction --no-progress
|
||||
|
||||
- name: Check Files with Laravel Pint
|
||||
run: vendor/bin/pint --test
|
||||
49
.github/workflows/run-tests.yml
vendored
49
.github/workflows/run-tests.yml
vendored
|
|
@ -1,49 +0,0 @@
|
|||
name: Run Tests
|
||||
|
||||
on:
|
||||
pull_request:
|
||||
|
||||
jobs:
|
||||
phpunit:
|
||||
runs-on: ubuntu-20.04
|
||||
|
||||
name: PHPUnit test suite
|
||||
|
||||
services:
|
||||
postgres:
|
||||
image: postgres:13.4
|
||||
env:
|
||||
POSTGRES_USER: postgres
|
||||
POSTGRES_PASSWORD: postgres
|
||||
POSTGRES_DB: jbukdev_testing
|
||||
ports:
|
||||
- 5432:5432
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Cache node modules
|
||||
uses: actions/cache@v2
|
||||
with:
|
||||
path: ~/.npm
|
||||
key: ${{ runner.os }}-${{ hashFiles('**/package.json') }}
|
||||
- name: Install npm dependencies
|
||||
run: npm install
|
||||
- name: Setup PHP with pecl extension
|
||||
uses: shivammathur/setup-php@v2
|
||||
with:
|
||||
php-version: '8.1'
|
||||
tools: phpcs
|
||||
- name: Copy .env
|
||||
run: php -r "file_exists('.env') || copy('.env.github', '.env');"
|
||||
- name: Install dependencies
|
||||
run: composer install --quiet --no-ansi --no-interaction --no-progress
|
||||
- name: Generate key
|
||||
run: php artisan key:generate
|
||||
- name: Setup directory permissions
|
||||
run: chmod -R 777 storage bootstrap/cache
|
||||
- name: Setup test database
|
||||
run: php artisan migrate
|
||||
- name: Execute tests (Unit and Feature tests) via PHPUnit
|
||||
run: vendor/bin/phpunit
|
||||
- name: Run phpcs
|
||||
run: phpcs
|
||||
17
app/CommonMark/Generators/ContactMentionGenerator.php
Normal file
17
app/CommonMark/Generators/ContactMentionGenerator.php
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\CommonMark\Generators;
|
||||
|
||||
use League\CommonMark\Extension\Mention\Generator\MentionGeneratorInterface;
|
||||
use League\CommonMark\Extension\Mention\Mention;
|
||||
use League\CommonMark\Node\Inline\AbstractInline;
|
||||
|
||||
class ContactMentionGenerator implements MentionGeneratorInterface
|
||||
{
|
||||
public function generateMention(Mention $mention): ?AbstractInline
|
||||
{
|
||||
return $mention;
|
||||
}
|
||||
}
|
||||
24
app/CommonMark/Renderers/ContactMentionRenderer.php
Normal file
24
app/CommonMark/Renderers/ContactMentionRenderer.php
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\CommonMark\Renderers;
|
||||
|
||||
use App\Models\Contact;
|
||||
use League\CommonMark\Node\Node;
|
||||
use League\CommonMark\Renderer\ChildNodeRendererInterface;
|
||||
use League\CommonMark\Renderer\NodeRendererInterface;
|
||||
|
||||
class ContactMentionRenderer implements NodeRendererInterface
|
||||
{
|
||||
public function render(Node $node, ChildNodeRendererInterface $childRenderer): string
|
||||
{
|
||||
$contact = Contact::where('nick', $node->getIdentifier())->first();
|
||||
|
||||
if ($contact === null) {
|
||||
return '<a href="https://twitter.com/' . $node->getIdentifier() . '">@' . $node->getIdentifier() . '</a>';
|
||||
}
|
||||
|
||||
return trim(view('templates.mini-hcard', ['contact' => $contact])->render());
|
||||
}
|
||||
}
|
||||
|
|
@ -43,8 +43,9 @@ class Handler extends ExceptionHandler
|
|||
*
|
||||
* This is a great spot to send exceptions to Sentry, Bugsnag, etc.
|
||||
*
|
||||
* @param Throwable $throwable
|
||||
* @param Throwable $throwable
|
||||
* @return void
|
||||
*
|
||||
* @throws Exception
|
||||
* @throws Throwable
|
||||
*/
|
||||
|
|
@ -87,9 +88,10 @@ class Handler extends ExceptionHandler
|
|||
/**
|
||||
* Render an exception into an HTTP response.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Throwable $throwable
|
||||
* @param Request $request
|
||||
* @param Throwable $throwable
|
||||
* @return Response
|
||||
*
|
||||
* @throws Throwable
|
||||
*/
|
||||
public function render($request, Throwable $throwable)
|
||||
|
|
|
|||
|
|
@ -15,8 +15,8 @@ class ArticlesController extends Controller
|
|||
/**
|
||||
* Show all articles (with pagination).
|
||||
*
|
||||
* @param int|null $year
|
||||
* @param int|null $month
|
||||
* @param int|null $year
|
||||
* @param int|null $month
|
||||
* @return View
|
||||
*/
|
||||
public function index(int $year = null, int $month = null): View
|
||||
|
|
@ -32,9 +32,9 @@ class ArticlesController extends Controller
|
|||
/**
|
||||
* Show a single article.
|
||||
*
|
||||
* @param int $year
|
||||
* @param int $month
|
||||
* @param string $slug
|
||||
* @param int $year
|
||||
* @param int $month
|
||||
* @param string $slug
|
||||
* @return RedirectResponse|View
|
||||
*/
|
||||
public function show(int $year, int $month, string $slug)
|
||||
|
|
@ -59,7 +59,7 @@ class ArticlesController extends Controller
|
|||
* We only have the ID, work out post title, year and month
|
||||
* and redirect to it.
|
||||
*
|
||||
* @param string $idFromUrl
|
||||
* @param string $idFromUrl
|
||||
* @return RedirectResponse
|
||||
*/
|
||||
public function onlyIdInUrl(string $idFromUrl): RedirectResponse
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ class BookmarksController extends Controller
|
|||
/**
|
||||
* Show a single bookmark.
|
||||
*
|
||||
* @param Bookmark $bookmark
|
||||
* @param Bookmark $bookmark
|
||||
* @return View
|
||||
*/
|
||||
public function show(Bookmark $bookmark): View
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ class ContactsController extends Controller
|
|||
/**
|
||||
* Show a single contact.
|
||||
*
|
||||
* @param Contact $contact
|
||||
* @param Contact $contact
|
||||
* @return View
|
||||
*/
|
||||
public function show(Contact $contact): View
|
||||
|
|
|
|||
|
|
@ -4,7 +4,8 @@ declare(strict_types=1);
|
|||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\{Article, Note};
|
||||
use App\Models\Article;
|
||||
use App\Models\Note;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Illuminate\Http\Response;
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ class LikesController extends Controller
|
|||
/**
|
||||
* Show a single like.
|
||||
*
|
||||
* @param Like $like
|
||||
* @param Like $like
|
||||
* @return View
|
||||
*/
|
||||
public function show(Like $like): View
|
||||
|
|
|
|||
|
|
@ -6,7 +6,9 @@ namespace App\Http\Controllers;
|
|||
|
||||
use App\Http\Responses\MicropubResponses;
|
||||
use App\Models\Place;
|
||||
use App\Services\Micropub\{HCardService, HEntryService, UpdateService};
|
||||
use App\Services\Micropub\HCardService;
|
||||
use App\Services\Micropub\HEntryService;
|
||||
use App\Services\Micropub\UpdateService;
|
||||
use App\Services\TokenService;
|
||||
use Illuminate\Http\JsonResponse;
|
||||
use Lcobucci\JWT\Encoding\CannotDecodeContent;
|
||||
|
|
@ -18,8 +20,11 @@ use Monolog\Logger;
|
|||
class MicropubController extends Controller
|
||||
{
|
||||
protected TokenService $tokenService;
|
||||
|
||||
protected HEntryService $hentryService;
|
||||
|
||||
protected HCardService $hcardService;
|
||||
|
||||
protected UpdateService $updateService;
|
||||
|
||||
public function __construct(
|
||||
|
|
@ -168,6 +173,7 @@ class MicropubController extends Controller
|
|||
* Determine the client id from the access token sent with the request.
|
||||
*
|
||||
* @return string
|
||||
*
|
||||
* @throws RequiredConstraintsViolated
|
||||
*/
|
||||
private function getClientId(): string
|
||||
|
|
@ -180,7 +186,7 @@ class MicropubController extends Controller
|
|||
/**
|
||||
* Save the details of the micropub request to a log file.
|
||||
*
|
||||
* @param array $request This is the info from request()->all()
|
||||
* @param array $request This is the info from request()->all()
|
||||
*/
|
||||
private function logMicropubRequest(array $request)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -97,6 +97,7 @@ class MicropubMediaController extends Controller
|
|||
* Process a media item posted to the media endpoint.
|
||||
*
|
||||
* @return JsonResponse
|
||||
*
|
||||
* @throws BindingResolutionException
|
||||
* @throws Exception
|
||||
*/
|
||||
|
|
@ -184,7 +185,7 @@ class MicropubMediaController extends Controller
|
|||
/**
|
||||
* Get the file type from the mime-type of the uploaded file.
|
||||
*
|
||||
* @param string $mimeType
|
||||
* @param string $mimeType
|
||||
* @return string
|
||||
*/
|
||||
private function getFileTypeFromMimeType(string $mimeType): string
|
||||
|
|
@ -229,8 +230,9 @@ class MicropubMediaController extends Controller
|
|||
/**
|
||||
* Save an uploaded file to the local disk.
|
||||
*
|
||||
* @param UploadedFile $file
|
||||
* @param UploadedFile $file
|
||||
* @return string
|
||||
*
|
||||
* @throws Exception
|
||||
*/
|
||||
private function saveFile(UploadedFile $file): string
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ class NotesController extends Controller
|
|||
/**
|
||||
* Show a single note.
|
||||
*
|
||||
* @param string $urlId The id of the note
|
||||
* @param string $urlId The id of the note
|
||||
* @return View|JsonResponse|Response
|
||||
*/
|
||||
public function show(string $urlId)
|
||||
|
|
@ -61,7 +61,7 @@ class NotesController extends Controller
|
|||
/**
|
||||
* 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 RedirectResponse
|
||||
*/
|
||||
public function redirect(int $decId): RedirectResponse
|
||||
|
|
@ -72,7 +72,7 @@ class NotesController extends Controller
|
|||
/**
|
||||
* Show all notes tagged with {tag}.
|
||||
*
|
||||
* @param string $tag
|
||||
* @param string $tag
|
||||
* @return View
|
||||
*/
|
||||
public function tagged(string $tag): View
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ class PlacesController extends Controller
|
|||
/**
|
||||
* Show a specific place.
|
||||
*
|
||||
* @param Place $place
|
||||
* @param Place $place
|
||||
* @return View
|
||||
*/
|
||||
public function show(Place $place): View
|
||||
|
|
|
|||
|
|
@ -23,8 +23,8 @@ class TokenEndpointController extends Controller
|
|||
/**
|
||||
* Inject the dependencies.
|
||||
*
|
||||
* @param Client $client
|
||||
* @param TokenService $tokenService
|
||||
* @param Client $client
|
||||
* @param TokenService $tokenService
|
||||
*/
|
||||
public function __construct(
|
||||
Client $client,
|
||||
|
|
|
|||
|
|
@ -10,8 +10,8 @@ class CSPHeader
|
|||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param Request $request
|
||||
* @param Closure $next
|
||||
* @param Request $request
|
||||
* @param Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
|
|
|
|||
|
|
@ -23,7 +23,7 @@ class AddClientToDatabase implements ShouldQueue
|
|||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @param string $client_id
|
||||
* @param string $client_id
|
||||
*/
|
||||
public function __construct(string $client_id)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ class DownloadWebMention implements ShouldQueue
|
|||
/**
|
||||
* Create a new job instance.
|
||||
*
|
||||
* @param string $source
|
||||
* @param string $source
|
||||
*/
|
||||
public function __construct(string $source)
|
||||
{
|
||||
|
|
@ -39,7 +39,8 @@ class DownloadWebMention implements ShouldQueue
|
|||
/**
|
||||
* Execute the job.
|
||||
*
|
||||
* @param Client $guzzle
|
||||
* @param Client $guzzle
|
||||
*
|
||||
* @throws GuzzleException
|
||||
* @throws FileNotFoundException
|
||||
*/
|
||||
|
|
@ -81,7 +82,7 @@ class DownloadWebMention implements ShouldQueue
|
|||
/**
|
||||
* Create a file path from a URL. This is used when caching the HTML response.
|
||||
*
|
||||
* @param string $url
|
||||
* @param string $url
|
||||
* @return string The path name
|
||||
*/
|
||||
private function createFilenameFromURL(string $url)
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue