Struct Types
Squashed commit of the following:
commit 74ed84617fcbecf661695763323e50d049a88db7
Author: Jonny Barnes <jonny@jonnybarnes.uk>
Date: Mon Jan 15 12:46:29 2018 +0000
Test passes so remove the dump statement
commit a7d3323be02da64f76e8ec88713e3de84a13ded7
Author: Jonny Barnes <jonny@jonnybarnes.uk>
Date: Mon Jan 15 12:40:35 2018 +0000
Values with spaces need to be quoted
commit 58a120bb238f14346793c388b948b7351d3b51fd
Author: Jonny Barnes <jonny@jonnybarnes.uk>
Date: Mon Jan 15 12:37:23 2018 +0000
We need a diplay name for the tests to work now we are using strict type checking
commit b46f177053bd697db9a4835d073f2f37e088b26f
Author: Jonny Barnes <jonny@jonnybarnes.uk>
Date: Mon Jan 15 12:31:29 2018 +0000
Get travis to show more info about failing test
commit 60323f3ce5a0561329a1721ee94821571cdcc86a
Author: Jonny Barnes <jonny@jonnybarnes.uk>
Date: Mon Jan 15 12:23:27 2018 +0000
Remove un-used namnepsace imports
commit 096d3505920bc94ff8677c77430eca0aae0be58a
Author: Jonny Barnes <jonny@jonnybarnes.uk>
Date: Mon Jan 15 12:21:55 2018 +0000
we need php7.2 for object type-hint
commit bb818bc19c73d02d510af9f002199f5718a54608
Author: Jonny Barnes <jonny@jonnybarnes.uk>
Date: Mon Jan 15 12:15:48 2018 +0000
Added lots of strict_types
This commit is contained in:
parent
053e19a457
commit
e4fe2ecde3
64 changed files with 911 additions and 406 deletions
|
|
@ -12,3 +12,6 @@ SESSION_DRIVER=array
|
||||||
QUEUE_DRIVER=sync
|
QUEUE_DRIVER=sync
|
||||||
|
|
||||||
SCOUT_DRIVER=pgsql
|
SCOUT_DRIVER=pgsql
|
||||||
|
|
||||||
|
DISPLAY_NAME='Travis Test'
|
||||||
|
USER_NAME=travis
|
||||||
|
|
|
||||||
|
|
@ -34,7 +34,6 @@ env:
|
||||||
- setup=basic
|
- setup=basic
|
||||||
|
|
||||||
php:
|
php:
|
||||||
- 7.1
|
|
||||||
- 7.2
|
- 7.2
|
||||||
|
|
||||||
before_install:
|
before_install:
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Console\Commands;
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
use App\Models\WebMention;
|
use App\Models\WebMention;
|
||||||
|
|
@ -61,7 +63,7 @@ class ParseCachedWebMentions extends Command
|
||||||
* @param string
|
* @param string
|
||||||
* @return string
|
* @return string
|
||||||
*/
|
*/
|
||||||
private function URLFromFilename($filepath)
|
private function URLFromFilename(string $filepath): string
|
||||||
{
|
{
|
||||||
$dir = mb_substr($filepath, mb_strlen(storage_path() . '/HTML/'));
|
$dir = mb_substr($filepath, mb_strlen(storage_path() . '/HTML/'));
|
||||||
$url = str_replace(['http/', 'https/'], ['http://', 'https://'], $dir);
|
$url = str_replace(['http/', 'https/'], ['http://', 'https://'], $dir);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Console\Commands;
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
use App\Models\WebMention;
|
use App\Models\WebMention;
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Console\Commands;
|
namespace App\Console\Commands;
|
||||||
|
|
||||||
use Illuminate\Console\Command;
|
use Illuminate\Console\Command;
|
||||||
|
|
@ -49,7 +51,7 @@ class SecurityCheck extends Command
|
||||||
*
|
*
|
||||||
* @return mixed
|
* @return mixed
|
||||||
*/
|
*/
|
||||||
public function handle()
|
public function handle(): int
|
||||||
{
|
{
|
||||||
$alerts = $this->securityChecker->check(base_path() . '/composer.lock');
|
$alerts = $this->securityChecker->check(base_path() . '/composer.lock');
|
||||||
if (count($alerts) === 0) {
|
if (count($alerts) === 0) {
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,23 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Http\Controllers\Admin;
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
use App\Models\Article;
|
use App\Models\Article;
|
||||||
|
use Illuminate\View\View;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
|
||||||
class ArticlesController extends Controller
|
class ArticlesController extends Controller
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* List the articles that can be edited.
|
* List the articles that can be edited.
|
||||||
*
|
*
|
||||||
* @return \Illuminate\View\Factory view
|
* @return \Illuminate\View\View
|
||||||
*/
|
*/
|
||||||
public function index()
|
public function index(): View
|
||||||
{
|
{
|
||||||
$posts = Article::select('id', 'title', 'published')->orderBy('id', 'desc')->get();
|
$posts = Article::select('id', 'title', 'published')->orderBy('id', 'desc')->get();
|
||||||
|
|
||||||
|
|
@ -23,9 +27,9 @@ class ArticlesController extends Controller
|
||||||
/**
|
/**
|
||||||
* Show the new article form.
|
* Show the new article form.
|
||||||
*
|
*
|
||||||
* @return \Illuminate\View\Factory view
|
* @return \Illuminate\View\View
|
||||||
*/
|
*/
|
||||||
public function create()
|
public function create(): View
|
||||||
{
|
{
|
||||||
$message = session('message');
|
$message = session('message');
|
||||||
|
|
||||||
|
|
@ -35,23 +39,22 @@ class ArticlesController extends Controller
|
||||||
/**
|
/**
|
||||||
* Process an incoming request for a new article and save it.
|
* Process an incoming request for a new article and save it.
|
||||||
*
|
*
|
||||||
* @param \Illuminate\Http\Request $request
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
* @return \Illuminate\View\Factory view
|
|
||||||
*/
|
*/
|
||||||
public function store(Request $request)
|
public function store(): RedirectResponse
|
||||||
{
|
{
|
||||||
//if a `.md` is attached use that for the main content.
|
//if a `.md` is attached use that for the main content.
|
||||||
if ($request->hasFile('article')) {
|
if (request()->hasFile('article')) {
|
||||||
$file = $request->file('article')->openFile();
|
$file = request()->file('article')->openFile();
|
||||||
$content = $file->fread($file->getSize());
|
$content = $file->fread($file->getSize());
|
||||||
}
|
}
|
||||||
$main = $content ?? $request->input('main');
|
$main = $content ?? request()->input('main');
|
||||||
$article = Article::create(
|
$article = Article::create(
|
||||||
[
|
[
|
||||||
'url' => $request->input('url'),
|
'url' => request()->input('url'),
|
||||||
'title' => $request->input('title'),
|
'title' => request()->input('title'),
|
||||||
'main' => $main,
|
'main' => $main,
|
||||||
'published' => $request->input('published') ?? 0,
|
'published' => request()->input('published') ?? 0,
|
||||||
]
|
]
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -61,10 +64,10 @@ class ArticlesController extends Controller
|
||||||
/**
|
/**
|
||||||
* Show the edit form for an existing article.
|
* Show the edit form for an existing article.
|
||||||
*
|
*
|
||||||
* @param string The article id
|
* @param int $articleId
|
||||||
* @return \Illuminate\View\Factory view
|
* @return \Illuminate\View\View
|
||||||
*/
|
*/
|
||||||
public function edit($articleId)
|
public function edit(int $articleId): View
|
||||||
{
|
{
|
||||||
$post = Article::select(
|
$post = Article::select(
|
||||||
'title',
|
'title',
|
||||||
|
|
@ -79,17 +82,16 @@ class ArticlesController extends Controller
|
||||||
/**
|
/**
|
||||||
* Process an incoming request to edit an article.
|
* Process an incoming request to edit an article.
|
||||||
*
|
*
|
||||||
* @param \Illuminate\Http\Request $request
|
* @param int $articleId
|
||||||
* @param string
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
* @return \Illuminate|View\Factory view
|
|
||||||
*/
|
*/
|
||||||
public function update(Request $request, $articleId)
|
public function update(int $articleId): RedirectResponse
|
||||||
{
|
{
|
||||||
$article = Article::find($articleId);
|
$article = Article::find($articleId);
|
||||||
$article->title = $request->input('title');
|
$article->title = request()->input('title');
|
||||||
$article->url = $request->input('url');
|
$article->url = request()->input('url');
|
||||||
$article->main = $request->input('main');
|
$article->main = request()->input('main');
|
||||||
$article->published = $request->input('published') ?? 0;
|
$article->published = request()->input('published') ?? 0;
|
||||||
$article->save();
|
$article->save();
|
||||||
|
|
||||||
return redirect('/admin/blog');
|
return redirect('/admin/blog');
|
||||||
|
|
@ -98,10 +100,10 @@ class ArticlesController extends Controller
|
||||||
/**
|
/**
|
||||||
* Process a request to delete an aricle.
|
* Process a request to delete an aricle.
|
||||||
*
|
*
|
||||||
* @param string The article id
|
* @param int $articleId
|
||||||
* @return \Illuminate\View\Factory view
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
*/
|
*/
|
||||||
public function destroy($articleId)
|
public function destroy(int $articleId): RedirectResponse
|
||||||
{
|
{
|
||||||
Article::where('id', $articleId)->delete();
|
Article::where('id', $articleId)->delete();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,23 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Http\Controllers\Admin;
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
|
use Illuminate\View\View;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use App\Models\MicropubClient;
|
use App\Models\MicropubClient;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
|
||||||
class ClientsController extends Controller
|
class ClientsController extends Controller
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Show a list of known clients.
|
* Show a list of known clients.
|
||||||
*
|
*
|
||||||
* @return \Illuminate\View\Factory view
|
* @return \Illuminate\View\View
|
||||||
*/
|
*/
|
||||||
public function index()
|
public function index(): View
|
||||||
{
|
{
|
||||||
$clients = MicropubClient::all();
|
$clients = MicropubClient::all();
|
||||||
|
|
||||||
|
|
@ -23,9 +27,9 @@ class ClientsController extends Controller
|
||||||
/**
|
/**
|
||||||
* Show form to add a client name.
|
* Show form to add a client name.
|
||||||
*
|
*
|
||||||
* @return \Illuminate\View\Factory view
|
* @return \Illuminate\View\View
|
||||||
*/
|
*/
|
||||||
public function create()
|
public function create(): View
|
||||||
{
|
{
|
||||||
return view('admin.clients.create');
|
return view('admin.clients.create');
|
||||||
}
|
}
|
||||||
|
|
@ -33,14 +37,13 @@ class ClientsController extends Controller
|
||||||
/**
|
/**
|
||||||
* Process the request to adda new client name.
|
* Process the request to adda new client name.
|
||||||
*
|
*
|
||||||
* @param \Illuminate\Http\Request $request
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
* @return \Illuminate\View\Factory view
|
|
||||||
*/
|
*/
|
||||||
public function store(Request $request)
|
public function store(): RedirectResponse
|
||||||
{
|
{
|
||||||
MicropubClient::create([
|
MicropubClient::create([
|
||||||
'client_url' => $request->input('client_url'),
|
'client_url' => request()->input('client_url'),
|
||||||
'client_name' => $request->input('client_name'),
|
'client_name' => request()->input('client_name'),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return redirect('/admin/clients');
|
return redirect('/admin/clients');
|
||||||
|
|
@ -49,10 +52,10 @@ class ClientsController extends Controller
|
||||||
/**
|
/**
|
||||||
* Show a form to edit a client name.
|
* Show a form to edit a client name.
|
||||||
*
|
*
|
||||||
* @param string The client id
|
* @param int $clientId
|
||||||
* @return \Illuminate\View\Factory view
|
* @return \Illuminate\View\View
|
||||||
*/
|
*/
|
||||||
public function edit($clientId)
|
public function edit(int $clientId): View
|
||||||
{
|
{
|
||||||
$client = MicropubClient::findOrFail($clientId);
|
$client = MicropubClient::findOrFail($clientId);
|
||||||
|
|
||||||
|
|
@ -66,15 +69,14 @@ class ClientsController extends Controller
|
||||||
/**
|
/**
|
||||||
* Process the request to edit a client name.
|
* Process the request to edit a client name.
|
||||||
*
|
*
|
||||||
* @param string The client id
|
* @param int $clientId
|
||||||
* @param \Illuminate\Http\Request $request
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
* @return \Illuminate\View\Factory view
|
|
||||||
*/
|
*/
|
||||||
public function update($clientId, Request $request)
|
public function update(int $clientId): RedirectResponse
|
||||||
{
|
{
|
||||||
$client = MicropubClient::findOrFail($clientId);
|
$client = MicropubClient::findOrFail($clientId);
|
||||||
$client->client_url = $request->input('client_url');
|
$client->client_url = request()->input('client_url');
|
||||||
$client->client_name = $request->input('client_name');
|
$client->client_name = request()->input('client_name');
|
||||||
$client->save();
|
$client->save();
|
||||||
|
|
||||||
return redirect('/admin/clients');
|
return redirect('/admin/clients');
|
||||||
|
|
@ -83,10 +85,10 @@ class ClientsController extends Controller
|
||||||
/**
|
/**
|
||||||
* Process a request to delete a client.
|
* Process a request to delete a client.
|
||||||
*
|
*
|
||||||
* @param string The client id
|
* @param int $clientId
|
||||||
* @return redirect
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
*/
|
*/
|
||||||
public function destroy($clientId)
|
public function destroy(int $clientId): RedirectResponse
|
||||||
{
|
{
|
||||||
MicropubClient::where('id', $clientId)->delete();
|
MicropubClient::where('id', $clientId)->delete();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,25 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Http\Controllers\Admin;
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
use GuzzleHttp\Client;
|
use GuzzleHttp\Client;
|
||||||
use App\Models\Contact;
|
use App\Models\Contact;
|
||||||
|
use Illuminate\View\View;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
use Illuminate\Filesystem\Filesystem;
|
use Illuminate\Filesystem\Filesystem;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
|
||||||
class ContactsController extends Controller
|
class ContactsController extends Controller
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* List the currect contacts that can be edited.
|
* List the currect contacts that can be edited.
|
||||||
*
|
*
|
||||||
* @return \Illuminate\View\Factory view
|
* @return \Illuminate\View\View
|
||||||
*/
|
*/
|
||||||
public function index()
|
public function index(): View
|
||||||
{
|
{
|
||||||
$contacts = Contact::all();
|
$contacts = Contact::all();
|
||||||
|
|
||||||
|
|
@ -25,9 +29,9 @@ class ContactsController extends Controller
|
||||||
/**
|
/**
|
||||||
* Display the form to add a new contact.
|
* Display the form to add a new contact.
|
||||||
*
|
*
|
||||||
* @return \Illuminate\View\Factory view
|
* @return \Illuminate\View\View
|
||||||
*/
|
*/
|
||||||
public function create()
|
public function create(): View
|
||||||
{
|
{
|
||||||
return view('admin.contacts.create');
|
return view('admin.contacts.create');
|
||||||
}
|
}
|
||||||
|
|
@ -35,17 +39,16 @@ class ContactsController extends Controller
|
||||||
/**
|
/**
|
||||||
* Process the request to add a new contact.
|
* Process the request to add a new contact.
|
||||||
*
|
*
|
||||||
* @param \Illuminate\Http|request $request
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
* @return \Illuminate\View\Factory view
|
|
||||||
*/
|
*/
|
||||||
public function store(Request $request)
|
public function store(): RedirectResponse
|
||||||
{
|
{
|
||||||
$contact = new Contact();
|
$contact = new Contact();
|
||||||
$contact->name = $request->input('name');
|
$contact->name = request()->input('name');
|
||||||
$contact->nick = $request->input('nick');
|
$contact->nick = request()->input('nick');
|
||||||
$contact->homepage = $request->input('homepage');
|
$contact->homepage = request()->input('homepage');
|
||||||
$contact->twitter = $request->input('twitter');
|
$contact->twitter = request()->input('twitter');
|
||||||
$contact->facebook = $request->input('facebook');
|
$contact->facebook = request()->input('facebook');
|
||||||
$contact->save();
|
$contact->save();
|
||||||
|
|
||||||
return redirect('/admin/contacts');
|
return redirect('/admin/contacts');
|
||||||
|
|
@ -54,10 +57,10 @@ class ContactsController extends Controller
|
||||||
/**
|
/**
|
||||||
* Show the form to edit an existing contact.
|
* Show the form to edit an existing contact.
|
||||||
*
|
*
|
||||||
* @param string The contact id
|
* @param int $contactId
|
||||||
* @return \Illuminate\View\Factory view
|
* @return \Illuminate\View\View
|
||||||
*/
|
*/
|
||||||
public function edit($contactId)
|
public function edit(int $contactId): View
|
||||||
{
|
{
|
||||||
$contact = Contact::findOrFail($contactId);
|
$contact = Contact::findOrFail($contactId);
|
||||||
|
|
||||||
|
|
@ -69,28 +72,27 @@ class ContactsController extends Controller
|
||||||
*
|
*
|
||||||
* @todo Allow saving profile pictures for people without homepages
|
* @todo Allow saving profile pictures for people without homepages
|
||||||
*
|
*
|
||||||
* @param string The contact id
|
* @param int $contactId
|
||||||
* @param \Illuminate\Http\Request $request
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
* @return \Illuminate\View\Factory view
|
|
||||||
*/
|
*/
|
||||||
public function update($contactId, Request $request)
|
public function update(int $contactId): RedirectResponse
|
||||||
{
|
{
|
||||||
$contact = Contact::findOrFail($contactId);
|
$contact = Contact::findOrFail($contactId);
|
||||||
$contact->name = $request->input('name');
|
$contact->name = request()->input('name');
|
||||||
$contact->nick = $request->input('nick');
|
$contact->nick = request()->input('nick');
|
||||||
$contact->homepage = $request->input('homepage');
|
$contact->homepage = request()->input('homepage');
|
||||||
$contact->twitter = $request->input('twitter');
|
$contact->twitter = request()->input('twitter');
|
||||||
$contact->facebook = $request->input('facebook');
|
$contact->facebook = request()->input('facebook');
|
||||||
$contact->save();
|
$contact->save();
|
||||||
|
|
||||||
if ($request->hasFile('avatar') && ($request->input('homepage') != '')) {
|
if (request()->hasFile('avatar') && (request()->input('homepage') != '')) {
|
||||||
$dir = parse_url($request->input('homepage'), PHP_URL_HOST);
|
$dir = parse_url(request()->input('homepage'), PHP_URL_HOST);
|
||||||
$destination = public_path() . '/assets/profile-images/' . $dir;
|
$destination = public_path() . '/assets/profile-images/' . $dir;
|
||||||
$filesystem = new Filesystem();
|
$filesystem = new Filesystem();
|
||||||
if ($filesystem->isDirectory($destination) === false) {
|
if ($filesystem->isDirectory($destination) === false) {
|
||||||
$filesystem->makeDirectory($destination);
|
$filesystem->makeDirectory($destination);
|
||||||
}
|
}
|
||||||
$request->file('avatar')->move($destination, 'image');
|
request()->file('avatar')->move($destination, 'image');
|
||||||
}
|
}
|
||||||
|
|
||||||
return redirect('/admin/contacts');
|
return redirect('/admin/contacts');
|
||||||
|
|
@ -99,10 +101,10 @@ class ContactsController extends Controller
|
||||||
/**
|
/**
|
||||||
* Process the request to delete a contact.
|
* Process the request to delete a contact.
|
||||||
*
|
*
|
||||||
* @param string The contact id
|
* @param int $contactId
|
||||||
* @return \Illuminate\View\Factory view
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
*/
|
*/
|
||||||
public function destroy($contactId)
|
public function destroy(int $contactId): RedirectResponse
|
||||||
{
|
{
|
||||||
$contact = Contact::findOrFail($contactId);
|
$contact = Contact::findOrFail($contactId);
|
||||||
$contact->delete();
|
$contact->delete();
|
||||||
|
|
@ -116,16 +118,16 @@ class ContactsController extends Controller
|
||||||
* This method attempts to find the microformat marked-up profile image
|
* This method attempts to find the microformat marked-up profile image
|
||||||
* from a given homepage and save it accordingly
|
* from a given homepage and save it accordingly
|
||||||
*
|
*
|
||||||
* @param string The contact id
|
* @param int $contactId
|
||||||
* @return \Illuminate\View\Factory view
|
* @return \Illuminate\Http\RedirectResponse|\Illuminate\View\View
|
||||||
*/
|
*/
|
||||||
public function getAvatar($contactId)
|
public function getAvatar(int $contactId)
|
||||||
{
|
{
|
||||||
// Initialising
|
// Initialising
|
||||||
$avatarURL = null;
|
$avatarURL = null;
|
||||||
$avatar = null;
|
$avatar = null;
|
||||||
$contact = Contact::findOrFail($contactId);
|
$contact = Contact::findOrFail($contactId);
|
||||||
if (mb_strlen($contact->homepage !== null) !== 0) {
|
if ($contact->homepage !== null && mb_strlen($contact->homepage) !== 0) {
|
||||||
$client = resolve(Client::class);
|
$client = resolve(Client::class);
|
||||||
try {
|
try {
|
||||||
$response = $client->get($contact->homepage);
|
$response = $client->get($contact->homepage);
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,20 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
class HomeController extends Controller
|
class HomeController extends Controller
|
||||||
{
|
{
|
||||||
public function welcome()
|
/**
|
||||||
|
* Show the homepage of the admin CP.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\View\View
|
||||||
|
*/
|
||||||
|
public function welcome(): View
|
||||||
{
|
{
|
||||||
return view('admin.welcome', ['name' => config('admin.user')]);
|
return view('admin.welcome', ['name' => config('admin.user')]);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -12,6 +12,11 @@ use Illuminate\Http\RedirectResponse;
|
||||||
|
|
||||||
class LikesController extends Controller
|
class LikesController extends Controller
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* List the likes that can be edited.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\View\View
|
||||||
|
*/
|
||||||
public function index(): View
|
public function index(): View
|
||||||
{
|
{
|
||||||
$likes = Like::all();
|
$likes = Like::all();
|
||||||
|
|
@ -19,11 +24,21 @@ class LikesController extends Controller
|
||||||
return view('admin.likes.index', compact('likes'));
|
return view('admin.likes.index', compact('likes'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Show the form to make a new like.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\View\View
|
||||||
|
*/
|
||||||
public function create(): View
|
public function create(): View
|
||||||
{
|
{
|
||||||
return view('admin.likes.create');
|
return view('admin.likes.create');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process a request to make a new like.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
public function store(): RedirectResponse
|
public function store(): RedirectResponse
|
||||||
{
|
{
|
||||||
$like = Like::create([
|
$like = Like::create([
|
||||||
|
|
@ -34,6 +49,12 @@ class LikesController extends Controller
|
||||||
return redirect('/admin/likes');
|
return redirect('/admin/likes');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Display the form to edit a specific like.
|
||||||
|
*
|
||||||
|
* @param int $likeId
|
||||||
|
* @return \Illuminate\View\View
|
||||||
|
*/
|
||||||
public function edit(int $likeId): View
|
public function edit(int $likeId): View
|
||||||
{
|
{
|
||||||
$like = Like::findOrFail($likeId);
|
$like = Like::findOrFail($likeId);
|
||||||
|
|
@ -44,6 +65,12 @@ class LikesController extends Controller
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process a request to edit a like.
|
||||||
|
*
|
||||||
|
* @param int $likeId
|
||||||
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
public function update(int $likeId): RedirectResponse
|
public function update(int $likeId): RedirectResponse
|
||||||
{
|
{
|
||||||
$like = Like::findOrFail($likeId);
|
$like = Like::findOrFail($likeId);
|
||||||
|
|
@ -54,6 +81,12 @@ class LikesController extends Controller
|
||||||
return redirect('/admin/likes');
|
return redirect('/admin/likes');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process the request to delete a like.
|
||||||
|
*
|
||||||
|
* @param int $likeId
|
||||||
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
public function destroy(int $likeId): RedirectResponse
|
public function destroy(int $likeId): RedirectResponse
|
||||||
{
|
{
|
||||||
Like::where('id', $likeId)->delete();
|
Like::where('id', $likeId)->delete();
|
||||||
|
|
|
||||||
|
|
@ -1,20 +1,24 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Http\Controllers\Admin;
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
use App\Models\Note;
|
use App\Models\Note;
|
||||||
|
use Illuminate\View\View;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use App\Jobs\SendWebMentions;
|
use App\Jobs\SendWebMentions;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
|
||||||
class NotesController extends Controller
|
class NotesController extends Controller
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* List the notes that can be edited.
|
* List the notes that can be edited.
|
||||||
*
|
*
|
||||||
* @return \Illuminate\View\Factory view
|
* @return \Illuminate\View\View
|
||||||
*/
|
*/
|
||||||
public function index()
|
public function index(): View
|
||||||
{
|
{
|
||||||
$notes = Note::select('id', 'note')->orderBy('id', 'desc')->get();
|
$notes = Note::select('id', 'note')->orderBy('id', 'desc')->get();
|
||||||
foreach ($notes as $note) {
|
foreach ($notes as $note) {
|
||||||
|
|
@ -27,9 +31,9 @@ class NotesController extends Controller
|
||||||
/**
|
/**
|
||||||
* Show the form to make a new note.
|
* Show the form to make a new note.
|
||||||
*
|
*
|
||||||
* @return \Illuminate\View\Factory view
|
* @return \Illuminate\View\View
|
||||||
*/
|
*/
|
||||||
public function create()
|
public function create(): View
|
||||||
{
|
{
|
||||||
return view('admin.notes.create');
|
return view('admin.notes.create');
|
||||||
}
|
}
|
||||||
|
|
@ -37,14 +41,13 @@ class NotesController extends Controller
|
||||||
/**
|
/**
|
||||||
* Process a request to make a new note.
|
* Process a request to make a new note.
|
||||||
*
|
*
|
||||||
* @param Illuminate\Http\Request $request
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
* @todo Sort this mess out
|
|
||||||
*/
|
*/
|
||||||
public function store(Request $request)
|
public function store(): RedirectResponse
|
||||||
{
|
{
|
||||||
Note::create([
|
Note::create([
|
||||||
'in-reply-to' => $request->input('in-reply-to'),
|
'in-reply-to' => request()->input('in-reply-to'),
|
||||||
'note' => $request->input('content'),
|
'note' => request()->input('content'),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
return redirect('/admin/notes');
|
return redirect('/admin/notes');
|
||||||
|
|
@ -53,10 +56,10 @@ class NotesController extends Controller
|
||||||
/**
|
/**
|
||||||
* Display the form to edit a specific note.
|
* Display the form to edit a specific note.
|
||||||
*
|
*
|
||||||
* @param string The note id
|
* @param int $noteId
|
||||||
* @return \Illuminate\View\Factory view
|
* @return \Illuminate\View\View
|
||||||
*/
|
*/
|
||||||
public function edit($noteId)
|
public function edit(int $noteId): View
|
||||||
{
|
{
|
||||||
$note = Note::find($noteId);
|
$note = Note::find($noteId);
|
||||||
$note->originalNote = $note->getOriginal('note');
|
$note->originalNote = $note->getOriginal('note');
|
||||||
|
|
@ -68,18 +71,18 @@ class NotesController extends Controller
|
||||||
* Process a request to edit a note. Easy since this can only be done
|
* Process a request to edit a note. Easy since this can only be done
|
||||||
* from the admin CP.
|
* from the admin CP.
|
||||||
*
|
*
|
||||||
* @param \Illuminate\Http\Request $request
|
* @param int $noteId
|
||||||
* @return \Illuminate\View\Factory view
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
*/
|
*/
|
||||||
public function update($noteId, Request $request)
|
public function update(int $noteId): RedirectResponse
|
||||||
{
|
{
|
||||||
//update note data
|
//update note data
|
||||||
$note = Note::findOrFail($noteId);
|
$note = Note::findOrFail($noteId);
|
||||||
$note->note = $request->input('content');
|
$note->note = request()->input('content');
|
||||||
$note->in_reply_to = $request->input('in-reply-to');
|
$note->in_reply_to = request()->input('in-reply-to');
|
||||||
$note->save();
|
$note->save();
|
||||||
|
|
||||||
if ($request->input('webmentions')) {
|
if (request()->input('webmentions')) {
|
||||||
dispatch(new SendWebMentions($note));
|
dispatch(new SendWebMentions($note));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -89,12 +92,12 @@ class NotesController extends Controller
|
||||||
/**
|
/**
|
||||||
* Delete the note.
|
* Delete the note.
|
||||||
*
|
*
|
||||||
* @param int id
|
* @param int $noteId
|
||||||
* @return view
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
*/
|
*/
|
||||||
public function destroy($id)
|
public function destroy(int $noteId): RedirectResponse
|
||||||
{
|
{
|
||||||
$note = Note::findOrFail($id);
|
$note = Note::findOrFail($noteId);
|
||||||
$note->delete();
|
$note->delete();
|
||||||
|
|
||||||
return redirect('/admin/notes');
|
return redirect('/admin/notes');
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,15 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Http\Controllers\Admin;
|
namespace App\Http\Controllers\Admin;
|
||||||
|
|
||||||
use App\Models\Place;
|
use App\Models\Place;
|
||||||
|
use Illuminate\View\View;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
use App\Services\PlaceService;
|
use App\Services\PlaceService;
|
||||||
use App\Http\Controllers\Controller;
|
use App\Http\Controllers\Controller;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
use Phaza\LaravelPostgis\Geometries\Point;
|
use Phaza\LaravelPostgis\Geometries\Point;
|
||||||
|
|
||||||
class PlacesController extends Controller
|
class PlacesController extends Controller
|
||||||
|
|
@ -20,9 +24,9 @@ class PlacesController extends Controller
|
||||||
/**
|
/**
|
||||||
* List the places that can be edited.
|
* List the places that can be edited.
|
||||||
*
|
*
|
||||||
* @return \Illuminate\View\Factory view
|
* @return \Illuminate\View\View
|
||||||
*/
|
*/
|
||||||
public function index()
|
public function index(): View
|
||||||
{
|
{
|
||||||
$places = Place::all();
|
$places = Place::all();
|
||||||
|
|
||||||
|
|
@ -32,9 +36,9 @@ class PlacesController extends Controller
|
||||||
/**
|
/**
|
||||||
* Show the form to make a new place.
|
* Show the form to make a new place.
|
||||||
*
|
*
|
||||||
* @return \Illuminate\View\Factory view
|
* @return \Illuminate\View\View
|
||||||
*/
|
*/
|
||||||
public function create()
|
public function create(): View
|
||||||
{
|
{
|
||||||
return view('admin.places.create');
|
return view('admin.places.create');
|
||||||
}
|
}
|
||||||
|
|
@ -42,12 +46,11 @@ class PlacesController extends Controller
|
||||||
/**
|
/**
|
||||||
* Process a request to make a new place.
|
* Process a request to make a new place.
|
||||||
*
|
*
|
||||||
* @param Illuminate\Http\Request $request
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
* @return Illuminate\View\Factory view
|
|
||||||
*/
|
*/
|
||||||
public function store(Request $request)
|
public function store(): RedirectResponse
|
||||||
{
|
{
|
||||||
$data = $request->only(['name', 'description', 'latitude', 'longitude']);
|
$data = request()->only(['name', 'description', 'latitude', 'longitude']);
|
||||||
$place = $this->placeService->createPlace($data);
|
$place = $this->placeService->createPlace($data);
|
||||||
|
|
||||||
return redirect('/admin/places');
|
return redirect('/admin/places');
|
||||||
|
|
@ -56,10 +59,10 @@ class PlacesController extends Controller
|
||||||
/**
|
/**
|
||||||
* Display the form to edit a specific place.
|
* Display the form to edit a specific place.
|
||||||
*
|
*
|
||||||
* @param string The place id
|
* @param int $placeId
|
||||||
* @return \Illuminate\View\Factory view
|
* @return \Illuminate\View\View
|
||||||
*/
|
*/
|
||||||
public function edit($placeId)
|
public function edit(int $placeId): View
|
||||||
{
|
{
|
||||||
$place = Place::findOrFail($placeId);
|
$place = Place::findOrFail($placeId);
|
||||||
|
|
||||||
|
|
@ -69,17 +72,19 @@ class PlacesController extends Controller
|
||||||
/**
|
/**
|
||||||
* Process a request to edit a place.
|
* Process a request to edit a place.
|
||||||
*
|
*
|
||||||
* @param string The place id
|
* @param int $placeId
|
||||||
* @param Illuminate\Http\Request $request
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
* @return Illuminate\View\Factory view
|
|
||||||
*/
|
*/
|
||||||
public function update($placeId, Request $request)
|
public function update(int $placeId): RedirectResponse
|
||||||
{
|
{
|
||||||
$place = Place::findOrFail($placeId);
|
$place = Place::findOrFail($placeId);
|
||||||
$place->name = $request->name;
|
$place->name = request()->input('name');
|
||||||
$place->description = $request->description;
|
$place->description = request()->input('description');
|
||||||
$place->location = new Point((float) $request->latitude, (float) $request->longitude);
|
$place->location = new Point(
|
||||||
$place->icon = $request->icon;
|
(float) request()->input('latitude'),
|
||||||
|
(float) request()->input('longitude')
|
||||||
|
);
|
||||||
|
$place->icon = request()->input('icon');
|
||||||
$place->save();
|
$place->save();
|
||||||
|
|
||||||
return redirect('/admin/places');
|
return redirect('/admin/places');
|
||||||
|
|
@ -88,10 +93,10 @@ class PlacesController extends Controller
|
||||||
/**
|
/**
|
||||||
* List the places we can merge with the current place.
|
* List the places we can merge with the current place.
|
||||||
*
|
*
|
||||||
* @param string Place id
|
* @param int $placeId
|
||||||
* @return Illuminate\View\Factory view
|
* @return \Illuminate\View\View
|
||||||
*/
|
*/
|
||||||
public function mergeIndex($placeId)
|
public function mergeIndex(int $placeId): View
|
||||||
{
|
{
|
||||||
$first = Place::find($placeId);
|
$first = Place::find($placeId);
|
||||||
$results = Place::near(new Point($first->latitude, $first->longitude))->get();
|
$results = Place::near(new Point($first->latitude, $first->longitude))->get();
|
||||||
|
|
@ -105,27 +110,39 @@ class PlacesController extends Controller
|
||||||
return view('admin.places.merge.index', compact('first', 'places'));
|
return view('admin.places.merge.index', compact('first', 'places'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function mergeEdit($place1_id, $place2_id)
|
/**
|
||||||
|
* Show a form for merging two specific places.
|
||||||
|
*
|
||||||
|
* @param int $placeId1
|
||||||
|
* @param int $placeId2
|
||||||
|
* @return \Illuminate\View\View
|
||||||
|
*/
|
||||||
|
public function mergeEdit(int $placeId1, int $placeId2): View
|
||||||
{
|
{
|
||||||
$place1 = Place::find($place1_id);
|
$place1 = Place::find($placeId1);
|
||||||
$place2 = Place::find($place2_id);
|
$place2 = Place::find($placeId2);
|
||||||
|
|
||||||
return view('admin.places.merge.edit', compact('place1', 'place2'));
|
return view('admin.places.merge.edit', compact('place1', 'place2'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function mergeStore(Request $request)
|
/**
|
||||||
|
* Process the request to merge two places.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
|
*/
|
||||||
|
public function mergeStore(): RedirectResponse
|
||||||
{
|
{
|
||||||
$place1 = Place::find($request->input('place1'));
|
$place1 = Place::find(request()->input('place1'));
|
||||||
$place2 = Place::find($request->input('place2'));
|
$place2 = Place::find(request()->input('place2'));
|
||||||
|
|
||||||
if ($request->input('delete') === '1') {
|
if (request()->input('delete') === '1') {
|
||||||
foreach ($place1->notes as $note) {
|
foreach ($place1->notes as $note) {
|
||||||
$note->place()->dissociate();
|
$note->place()->dissociate();
|
||||||
$note->place()->associate($place2->id);
|
$note->place()->associate($place2->id);
|
||||||
}
|
}
|
||||||
$place1->delete();
|
$place1->delete();
|
||||||
}
|
}
|
||||||
if ($request->input('delete') === '2') {
|
if (request()->input('delete') === '2') {
|
||||||
foreach ($place2->notes as $note) {
|
foreach ($place2->notes as $note) {
|
||||||
$note->place()->dissociate();
|
$note->place()->dissociate();
|
||||||
$note->place()->associate($place1->id);
|
$note->place()->associate($place1->id);
|
||||||
|
|
|
||||||
|
|
@ -1,21 +1,27 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Models\Article;
|
use App\Models\Article;
|
||||||
|
use Illuminate\View\View;
|
||||||
use Jonnybarnes\IndieWeb\Numbers;
|
use Jonnybarnes\IndieWeb\Numbers;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
|
||||||
class ArticlesController extends Controller
|
class ArticlesController extends Controller
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Show all articles (with pagination).
|
* Show all articles (with pagination).
|
||||||
*
|
*
|
||||||
* @return \Illuminate\View\Factory view
|
* @param int $year
|
||||||
|
* @param int $month
|
||||||
|
* @return \Illuminate\View\View
|
||||||
*/
|
*/
|
||||||
public function index($year = null, $month = null)
|
public function index(int $year = null, int $month = null): View
|
||||||
{
|
{
|
||||||
$articles = Article::where('published', '1')
|
$articles = Article::where('published', '1')
|
||||||
->date((int) $year, (int) $month)
|
->date($year, $month)
|
||||||
->orderBy('updated_at', 'desc')
|
->orderBy('updated_at', 'desc')
|
||||||
->simplePaginate(5);
|
->simplePaginate(5);
|
||||||
|
|
||||||
|
|
@ -25,9 +31,12 @@ class ArticlesController extends Controller
|
||||||
/**
|
/**
|
||||||
* Show a single article.
|
* Show a single article.
|
||||||
*
|
*
|
||||||
* @return \Illuminate\View\Factory view
|
* @param int $year
|
||||||
|
* @param int $month
|
||||||
|
* @param string $slug
|
||||||
|
* @return \Illuminate\Http\RedirectResponse|\Illuminate\View\View
|
||||||
*/
|
*/
|
||||||
public function show($year, $month, $slug)
|
public function show(int $year, int $month, string $slug)
|
||||||
{
|
{
|
||||||
$article = Article::where('titleurl', $slug)->firstOrFail();
|
$article = Article::where('titleurl', $slug)->firstOrFail();
|
||||||
if ($article->updated_at->year != $year || $article->updated_at->month != $month) {
|
if ($article->updated_at->year != $year || $article->updated_at->month != $month) {
|
||||||
|
|
@ -44,12 +53,12 @@ class ArticlesController extends Controller
|
||||||
* We only have the ID, work out post title, year and month
|
* We only have the ID, work out post title, year and month
|
||||||
* and redirect to it.
|
* and redirect to it.
|
||||||
*
|
*
|
||||||
* @return \Illuminte\Routing\RedirectResponse redirect
|
* @param int $idFromUrl
|
||||||
|
* @return \Illuminte\Http\RedirectResponse
|
||||||
*/
|
*/
|
||||||
public function onlyIdInUrl($inURLId)
|
public function onlyIdInUrl(int $idFromUrl): RedirectResponse
|
||||||
{
|
{
|
||||||
$numbers = new Numbers();
|
$realId = resolve(Numbers::class)->b60tonum($idFromUrl);
|
||||||
$realId = $numbers->b60tonum($inURLId);
|
|
||||||
$article = Article::findOrFail($realId);
|
$article = Article::findOrFail($realId);
|
||||||
|
|
||||||
return redirect($article->link);
|
return redirect($article->link);
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,21 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
|
use Illuminate\View\View;
|
||||||
use Illuminate\Http\Request;
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
|
|
||||||
class AuthController extends Controller
|
class AuthController extends Controller
|
||||||
{
|
{
|
||||||
public function showLogin()
|
/**
|
||||||
|
* Show the login form.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\View\View
|
||||||
|
*/
|
||||||
|
public function showLogin(): View
|
||||||
{
|
{
|
||||||
return view('login');
|
return view('login');
|
||||||
}
|
}
|
||||||
|
|
@ -15,14 +24,13 @@ class AuthController extends Controller
|
||||||
* Log in a user, set a sesion variable, check credentials against
|
* Log in a user, set a sesion variable, check credentials against
|
||||||
* the .env file.
|
* the .env file.
|
||||||
*
|
*
|
||||||
* @param \Illuminate\Http\Request $request
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
* @return \Illuminate\Routing\RedirectResponse redirect
|
|
||||||
*/
|
*/
|
||||||
public function login(Request $request)
|
public function login(): RedirectResponse
|
||||||
{
|
{
|
||||||
if ($request->input('username') === config('admin.user')
|
if (request()->input('username') === config('admin.user')
|
||||||
&&
|
&&
|
||||||
$request->input('password') === config('admin.pass')
|
request()->input('password') === config('admin.pass')
|
||||||
) {
|
) {
|
||||||
session(['loggedin' => true]);
|
session(['loggedin' => true]);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,33 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Models\Bookmark;
|
use App\Models\Bookmark;
|
||||||
|
use Illuminate\View\View;
|
||||||
|
|
||||||
class BookmarksController extends Controller
|
class BookmarksController extends Controller
|
||||||
{
|
{
|
||||||
public function index()
|
/**
|
||||||
|
* Show the most recent bookmarks.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\View\View
|
||||||
|
*/
|
||||||
|
public function index(): View
|
||||||
{
|
{
|
||||||
$bookmarks = Bookmark::latest()->with('tags')->withCount('tags')->paginate(10);
|
$bookmarks = Bookmark::latest()->with('tags')->withCount('tags')->paginate(10);
|
||||||
|
|
||||||
return view('bookmarks.index', compact('bookmarks'));
|
return view('bookmarks.index', compact('bookmarks'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function show(Bookmark $bookmark)
|
/**
|
||||||
|
* Show a single bookmark.
|
||||||
|
*
|
||||||
|
* @param \App\Models\Bookmark $bookmark
|
||||||
|
* @return \Illuminate\View\View
|
||||||
|
*/
|
||||||
|
public function show(Bookmark $bookmark): View
|
||||||
{
|
{
|
||||||
$bookmark->loadMissing('tags');
|
$bookmark->loadMissing('tags');
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,8 +1,11 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
class ContactsController extends Controller
|
class ContactsController extends Controller
|
||||||
|
|
@ -10,9 +13,9 @@ class ContactsController extends Controller
|
||||||
/**
|
/**
|
||||||
* Show all the contacts.
|
* Show all the contacts.
|
||||||
*
|
*
|
||||||
* @return \Illuminate\View\Factory view
|
* @return \Illuminate\View\View
|
||||||
*/
|
*/
|
||||||
public function index()
|
public function index(): View
|
||||||
{
|
{
|
||||||
$filesystem = new Filesystem();
|
$filesystem = new Filesystem();
|
||||||
$contacts = Contact::all();
|
$contacts = Contact::all();
|
||||||
|
|
@ -31,9 +34,12 @@ class ContactsController extends Controller
|
||||||
/**
|
/**
|
||||||
* Show a single contact.
|
* Show a single contact.
|
||||||
*
|
*
|
||||||
* @return \Illuminate\View\Factory view
|
* @todo Use implicit model binding.
|
||||||
|
*
|
||||||
|
* @param string $nick The nickname associated with contact
|
||||||
|
* @return \Illuminate\View\View
|
||||||
*/
|
*/
|
||||||
public function show($nick)
|
public function show(string $nick): View
|
||||||
{
|
{
|
||||||
$filesystem = new Filesystem();
|
$filesystem = new Filesystem();
|
||||||
$contact = Contact::where('nick', '=', $nick)->firstOrFail();
|
$contact = Contact::where('nick', '=', $nick)->firstOrFail();
|
||||||
|
|
|
||||||
|
|
@ -1,7 +1,10 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
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};
|
||||||
|
|
||||||
class FeedsController extends Controller
|
class FeedsController extends Controller
|
||||||
|
|
@ -11,7 +14,7 @@ class FeedsController extends Controller
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Http\Response
|
* @return \Illuminate\Http\Response
|
||||||
*/
|
*/
|
||||||
public function blogRss()
|
public function blogRss(): Response
|
||||||
{
|
{
|
||||||
$articles = Article::where('published', '1')->latest('updated_at')->take(20)->get();
|
$articles = Article::where('published', '1')->latest('updated_at')->take(20)->get();
|
||||||
$buildDate = $articles->first()->updated_at->toRssString();
|
$buildDate = $articles->first()->updated_at->toRssString();
|
||||||
|
|
@ -26,7 +29,7 @@ class FeedsController extends Controller
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Http\Response
|
* @return \Illuminate\Http\Response
|
||||||
*/
|
*/
|
||||||
public function blogAtom()
|
public function blogAtom(): Response
|
||||||
{
|
{
|
||||||
$articles = Article::where('published', '1')->latest('updated_at')->take(20)->get();
|
$articles = Article::where('published', '1')->latest('updated_at')->take(20)->get();
|
||||||
|
|
||||||
|
|
@ -40,7 +43,7 @@ class FeedsController extends Controller
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Http\Response
|
* @return \Illuminate\Http\Response
|
||||||
*/
|
*/
|
||||||
public function notesRss()
|
public function notesRss(): Response
|
||||||
{
|
{
|
||||||
$notes = Note::latest()->take(20)->get();
|
$notes = Note::latest()->take(20)->get();
|
||||||
$buildDate = $notes->first()->updated_at->toRssString();
|
$buildDate = $notes->first()->updated_at->toRssString();
|
||||||
|
|
@ -55,7 +58,7 @@ class FeedsController extends Controller
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Http\Response
|
* @return \Illuminate\Http\Response
|
||||||
*/
|
*/
|
||||||
public function notesAtom()
|
public function notesAtom(): Response
|
||||||
{
|
{
|
||||||
$notes = Note::latest()->take(20)->get();
|
$notes = Note::latest()->take(20)->get();
|
||||||
|
|
||||||
|
|
@ -64,10 +67,12 @@ class FeedsController extends Controller
|
||||||
->header('Content-Type', 'application/atom+xml; charset=utf-8');
|
->header('Content-Type', 'application/atom+xml; charset=utf-8');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @todo sort out return type for json responses */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the blog JSON feed.
|
* Returns the blog JSON feed.
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Http\response
|
* @return \Illuminate\Http\JsonResponse
|
||||||
*/
|
*/
|
||||||
public function blogJson()
|
public function blogJson()
|
||||||
{
|
{
|
||||||
|
|
@ -100,7 +105,7 @@ class FeedsController extends Controller
|
||||||
/**
|
/**
|
||||||
* Returns the notes JSON feed.
|
* Returns the notes JSON feed.
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Http\response
|
* @return \Illuminate\Http\JsonResponse
|
||||||
*/
|
*/
|
||||||
public function notesJson()
|
public function notesJson()
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -1,19 +1,33 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use App\Models\Like;
|
use App\Models\Like;
|
||||||
|
use Illuminate\View\View;
|
||||||
|
|
||||||
class LikesController extends Controller
|
class LikesController extends Controller
|
||||||
{
|
{
|
||||||
public function index()
|
/**
|
||||||
|
* Show the latest likes.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\View\View
|
||||||
|
*/
|
||||||
|
public function index(): View
|
||||||
{
|
{
|
||||||
$likes = Like::latest()->paginate(20);
|
$likes = Like::latest()->paginate(20);
|
||||||
|
|
||||||
return view('likes.index', compact('likes'));
|
return view('likes.index', compact('likes'));
|
||||||
}
|
}
|
||||||
|
|
||||||
public function show(Like $like)
|
/**
|
||||||
|
* Show a single like.
|
||||||
|
*
|
||||||
|
* @param \App\Models\Like $like
|
||||||
|
* @return \Illuminate\View\View
|
||||||
|
*/
|
||||||
|
public function show(Like $like): View
|
||||||
{
|
{
|
||||||
return view('likes.show', compact('like'));
|
return view('likes.show', compact('like'));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,11 +1,14 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
namespace App\Http\Controllers;
|
namespace App\Http\Controllers;
|
||||||
|
|
||||||
use Monolog\Logger;
|
use Monolog\Logger;
|
||||||
use Ramsey\Uuid\Uuid;
|
use Ramsey\Uuid\Uuid;
|
||||||
use App\Jobs\ProcessMedia;
|
use App\Jobs\ProcessMedia;
|
||||||
use App\Services\TokenService;
|
use App\Services\TokenService;
|
||||||
|
use Illuminate\Http\JsonResponse;
|
||||||
use Illuminate\Http\UploadedFile;
|
use Illuminate\Http\UploadedFile;
|
||||||
use Monolog\Handler\StreamHandler;
|
use Monolog\Handler\StreamHandler;
|
||||||
use Intervention\Image\ImageManager;
|
use Intervention\Image\ImageManager;
|
||||||
|
|
@ -40,12 +43,11 @@ class MicropubController extends Controller
|
||||||
* This function receives an API request, verifies the authenticity
|
* This function receives an API request, verifies the authenticity
|
||||||
* then passes over the info to the relavent Service class.
|
* then passes over the info to the relavent Service class.
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Http\Response
|
* @return \Illuminate\Http\JsonResponse
|
||||||
*/
|
*/
|
||||||
public function post()
|
public function post(): JsonResponse
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
info(request()->input('access_token'));
|
|
||||||
$tokenData = $this->tokenService->validateToken(request()->input('access_token'));
|
$tokenData = $this->tokenService->validateToken(request()->input('access_token'));
|
||||||
} catch (InvalidTokenException $e) {
|
} catch (InvalidTokenException $e) {
|
||||||
return $this->invalidTokenResponse();
|
return $this->invalidTokenResponse();
|
||||||
|
|
@ -96,14 +98,16 @@ class MicropubController extends Controller
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Respond to a GET request to the micropub endpoint.
|
||||||
|
*
|
||||||
* A GET request has been made to `api/post` with an accompanying
|
* A GET request has been made to `api/post` with an accompanying
|
||||||
* token, here we check wether the token is valid and respond
|
* token, here we check wether the token is valid and respond
|
||||||
* appropriately. Further if the request has the query parameter
|
* appropriately. Further if the request has the query parameter
|
||||||
* synidicate-to we respond with the known syndication endpoints.
|
* synidicate-to we respond with the known syndication endpoints.
|
||||||
*
|
*
|
||||||
* @return \Illuminate\Http\Response
|
* @return \Illuminate\Http\JsonResponse
|
||||||
*/
|
*/
|
||||||
public function get()
|
public function get(): JsonResponse
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$tokenData = $this->tokenService->validateToken(request()->bearerToken());
|
$tokenData = $this->tokenService->validateToken(request()->bearerToken());
|
||||||
|
|
@ -124,7 +128,7 @@ class MicropubController extends Controller
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (substr(request()->input('q'), 0, 4) === 'geo:') {
|
if (request()->has('q') && substr(request()->input('q'), 0, 4) === 'geo:') {
|
||||||
preg_match_all(
|
preg_match_all(
|
||||||
'/([0-9\.\-]+)/',
|
'/([0-9\.\-]+)/',
|
||||||
request()->input('q'),
|
request()->input('q'),
|
||||||
|
|
@ -153,9 +157,9 @@ class MicropubController extends Controller
|
||||||
/**
|
/**
|
||||||
* Process a media item posted to the media endpoint.
|
* Process a media item posted to the media endpoint.
|
||||||
*
|
*
|
||||||
* @return Illuminate\Http\Response
|
* @return Illuminate\Http\JsonResponse
|
||||||
*/
|
*/
|
||||||
public function media()
|
public function media(): JsonResponse
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
$tokenData = $this->tokenService->validateToken(request()->bearerToken());
|
$tokenData = $this->tokenService->validateToken(request()->bearerToken());
|
||||||
|
|
@ -210,10 +214,10 @@ class MicropubController extends Controller
|
||||||
/**
|
/**
|
||||||
* Get the file type from the mimetype of the uploaded file.
|
* Get the file type from the mimetype of the uploaded file.
|
||||||
*
|
*
|
||||||
* @param string The mimetype
|
* @param string $mimetype
|
||||||
* @return string The type
|
* @return string
|
||||||
*/
|
*/
|
||||||
private function getFileTypeFromMimeType($mimetype)
|
private function getFileTypeFromMimeType(string $mimetype): string
|
||||||
{
|
{
|
||||||
//try known images
|
//try known images
|
||||||
$imageMimeTypes = [
|
$imageMimeTypes = [
|
||||||
|
|
@ -252,6 +256,11 @@ class MicropubController extends Controller
|
||||||
return 'download';
|
return 'download';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Determine the client id from the access token sent with the request.
|
||||||
|
*
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
private function getClientId(): string
|
private function getClientId(): string
|
||||||
{
|
{
|
||||||
return resolve(TokenService::class)
|
return resolve(TokenService::class)
|
||||||
|
|
@ -259,6 +268,11 @@ class MicropubController extends Controller
|
||||||
->getClaim('client_id');
|
->getClaim('client_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Save the details of the micropub request to a log file.
|
||||||
|
*
|
||||||
|
* @param array $request This is the info from request()->all()
|
||||||
|
*/
|
||||||
private function logMicropubRequest(array $request)
|
private function logMicropubRequest(array $request)
|
||||||
{
|
{
|
||||||
$logger = new Logger('micropub');
|
$logger = new Logger('micropub');
|
||||||
|
|
@ -266,7 +280,13 @@ class MicropubController extends Controller
|
||||||
$logger->debug('MicropubLog', $request);
|
$logger->debug('MicropubLog', $request);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function saveFile(UploadedFile $file)
|
/**
|
||||||
|
* Save an uploaded file to the local disk.
|
||||||
|
*
|
||||||
|
* @param \Illuminate\Http\UploadedFele $file
|
||||||
|
* @return string $filename
|
||||||
|
*/
|
||||||
|
private function saveFile(UploadedFile $file): string
|
||||||
{
|
{
|
||||||
$filename = Uuid::uuid4() . '.' . $file->extension();
|
$filename = Uuid::uuid4() . '.' . $file->extension();
|
||||||
Storage::disk('local')->put($filename, $file);
|
Storage::disk('local')->put($filename, $file);
|
||||||
|
|
@ -274,6 +294,11 @@ class MicropubController extends Controller
|
||||||
return $filename;
|
return $filename;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate a response to be returned when the token has insufficient scope.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\JsonRepsonse
|
||||||
|
*/
|
||||||
private function insufficientScopeResponse()
|
private function insufficientScopeResponse()
|
||||||
{
|
{
|
||||||
return response()->json([
|
return response()->json([
|
||||||
|
|
@ -283,6 +308,11 @@ class MicropubController extends Controller
|
||||||
], 401);
|
], 401);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate a response to be returned when the token is invalid.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\JsonRepsonse
|
||||||
|
*/
|
||||||
private function invalidTokenResponse()
|
private function invalidTokenResponse()
|
||||||
{
|
{
|
||||||
return response()->json([
|
return response()->json([
|
||||||
|
|
@ -292,6 +322,11 @@ class MicropubController extends Controller
|
||||||
], 400);
|
], 400);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Generate a response to be returned when the token has no scope.
|
||||||
|
*
|
||||||
|
* @return \Illuminate\Http\JsonRepsonse
|
||||||
|
*/
|
||||||
private function tokenHasNoScopeResponse()
|
private function tokenHasNoScopeResponse()
|
||||||
{
|
{
|
||||||
return response()->json([
|
return response()->json([
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,14 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
|
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 Illuminate\Http\Request;
|
||||||
use Jonnybarnes\IndieWeb\Numbers;
|
use Jonnybarnes\IndieWeb\Numbers;
|
||||||
|
use Illuminate\Http\RedirectResponse;
|
||||||
use App\Services\ActivityStreamsService;
|
use App\Services\ActivityStreamsService;
|
||||||
|
|
||||||
// Need to sort out Twitter and webmentions!
|
// Need to sort out Twitter and webmentions!
|
||||||
|
|
@ -14,7 +18,7 @@ class NotesController extends Controller
|
||||||
/**
|
/**
|
||||||
* Show all the notes. This is also the homepage.
|
* Show all the notes. This is also the homepage.
|
||||||
*
|
*
|
||||||
* @return \Illuminte\View\Factory view
|
* @return \Illuminate\View\View|\Illuminate\Http\JsonResponse
|
||||||
*/
|
*/
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
|
|
@ -34,10 +38,10 @@ class NotesController extends Controller
|
||||||
/**
|
/**
|
||||||
* Show a single note.
|
* Show a single note.
|
||||||
*
|
*
|
||||||
* @param string The id of the note
|
* @param string $urlId The id of the note
|
||||||
* @return \Illuminate\View\Factory view
|
* @return \Illuminate\View\View|\Illuminate\Http\JsonResponse
|
||||||
*/
|
*/
|
||||||
public function show($urlId)
|
public function show(string $urlId)
|
||||||
{
|
{
|
||||||
$note = Note::nb60($urlId)->with('webmentions')->firstOrFail();
|
$note = Note::nb60($urlId)->with('webmentions')->firstOrFail();
|
||||||
|
|
||||||
|
|
@ -51,10 +55,10 @@ class NotesController extends Controller
|
||||||
/**
|
/**
|
||||||
* Redirect /note/{decID} to /notes/{nb60id}.
|
* Redirect /note/{decID} to /notes/{nb60id}.
|
||||||
*
|
*
|
||||||
* @param string The decimal id of he note
|
* @param int $decId The decimal id of the note
|
||||||
* @return \Illuminate\Routing\RedirectResponse redirect
|
* @return \Illuminate\Http\RedirectResponse
|
||||||
*/
|
*/
|
||||||
public function redirect($decId)
|
public function redirect(int $decId): RedirectResponse
|
||||||
{
|
{
|
||||||
return redirect(config('app.url') . '/notes/' . (new Numbers())->numto60($decId));
|
return redirect(config('app.url') . '/notes/' . (new Numbers())->numto60($decId));
|
||||||
}
|
}
|
||||||
|
|
@ -62,10 +66,10 @@ class NotesController extends Controller
|
||||||
/**
|
/**
|
||||||
* Show all notes tagged with {tag}.
|
* Show all notes tagged with {tag}.
|
||||||
*
|
*
|
||||||
* @param string The tag
|
* @param string $tag
|
||||||
* @return \Illuminate\View\Factory view
|
* @return \Illuminate\View\View
|
||||||
*/
|
*/
|
||||||
public function tagged($tag)
|
public function tagged(string $tag): View
|
||||||
{
|
{
|
||||||
$notes = Note::whereHas('tags', function ($query) use ($tag) {
|
$notes = Note::whereHas('tags', function ($query) use ($tag) {
|
||||||
$query->where('tag', $tag);
|
$query->where('tag', $tag);
|
||||||
|
|
|
||||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue