Merge branch 'release/0.14'

This commit is contained in:
Jonny Barnes 2017-12-22 15:38:43 +00:00
commit f8cb9eb4fb
181 changed files with 5816 additions and 2240 deletions

View file

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

View file

@ -7,12 +7,13 @@ cache:
- apt
addons:
hosts:
- jmb.localhost
- jonnybarnes.localhost
postgresql: "9.6"
apt:
sources:
- sourceline: 'deb http://ppa.launchpad.net/nginx/development/ubuntu trusty main'
packages:
- nginx
- nginx-full
- realpath
- postgresql-9.6-postgis-2.3
- imagemagick
@ -36,10 +37,6 @@ php:
- 7.1
- 7.2
matrix:
allow_failures:
- php: 7.2
before_install:
- printf "\n" | pecl install imagick
- cp .env.travis .env
@ -47,6 +44,7 @@ before_install:
- psql -U travis -c 'create database travis_ci_test'
- psql -U travis -d travis_ci_test -c 'create extension postgis'
- travis_retry composer self-update --preview
- pear install pear/PHP_CodeSniffer && phpenv rehash
install:
- if [[ $setup = 'basic' ]]; then travis_retry composer install --no-interaction --prefer-dist; fi
@ -66,6 +64,10 @@ before_script:
#- sleep 5
script:
- php vendor/bin/phpunit --coverage-text
- php vendor/bin/phpunit --coverage-clover build/logs/clover.xml
- phpcs
#- php artisan dusk
- php vendor/bin/security-checker security:check ./composer.lock --end-point=http://security.sensiolabs.org/check_lock
- php vendor/bin/security-checker security:check --end-point=http://security.sensiolabs.org/check_lock
after_success:
- travis_retry php vendor/bin/coveralls

View file

@ -2,7 +2,7 @@
namespace App\Console\Commands;
use App\WebMention;
use App\Models\WebMention;
use Illuminate\Console\Command;
use Illuminate\FileSystem\FileSystem;

View file

@ -2,7 +2,7 @@
namespace App\Console\Commands;
use App\WebMention;
use App\Models\WebMention;
use Illuminate\Console\Command;
use App\Jobs\DownloadWebMention;

View file

@ -5,6 +5,9 @@ namespace App\Console\Commands;
use Illuminate\Console\Command;
use SensioLabs\Security\SecurityChecker;
/**
* @codeCoverageIgnore
*/
class SecurityCheck extends Command
{
/**

View file

@ -7,6 +7,9 @@ use Illuminate\Support\Facades\Route;
use Illuminate\Session\TokenMismatchException;
use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler;
/**
* @codeCoverageIgnore
*/
class Handler extends ExceptionHandler
{
/**

View file

@ -1,10 +0,0 @@
<?php
namespace App\Exceptions;
use Exception;
class InternetArchiveErrorSavingException extends Exception
{
//
}

View file

@ -0,0 +1,7 @@
<?php
namespace App\Exceptions;
class InternetArchiveException extends \Exception
{
}

View file

@ -0,0 +1,10 @@
<?php
namespace App\Exceptions;
use Exception;
class RemoteContentNotFoundException extends Exception
{
//used when guzzle can’t find the remote content
}

View file

@ -2,7 +2,7 @@
namespace App\Http\Controllers\Admin;
use App\Article;
use App\Models\Article;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;

View file

@ -2,8 +2,8 @@
namespace App\Http\Controllers\Admin;
use App\MicropubClient;
use Illuminate\Http\Request;
use App\Models\MicropubClient;
use App\Http\Controllers\Controller;
class ClientsController extends Controller
@ -86,9 +86,9 @@ class ClientsController extends Controller
* @param string The client id
* @return redirect
*/
public function destroy($articleId)
public function destroy($clientId)
{
MicropubClient::where('id', $articleId)->delete();
MicropubClient::where('id', $clientId)->delete();
return redirect('/admin/clients');
}

View file

@ -2,8 +2,8 @@
namespace App\Http\Controllers\Admin;
use App\Contact;
use GuzzleHttp\Client;
use App\Models\Contact;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Filesystem\Filesystem;
@ -83,16 +83,14 @@ class ContactsController extends Controller
$contact->facebook = $request->input('facebook');
$contact->save();
if ($request->hasFile('avatar')) {
if ($request->input('homepage') != '') {
$dir = parse_url($request->input('homepage'))['host'];
$destination = public_path() . '/assets/profile-images/' . $dir;
$filesystem = new Filesystem();
if ($filesystem->isDirectory($destination) === false) {
$filesystem->makeDirectory($destination);
}
$request->file('avatar')->move($destination, 'image');
if ($request->hasFile('avatar') && ($request->input('homepage') != '')) {
$dir = parse_url($request->input('homepage'), PHP_URL_HOST);
$destination = public_path() . '/assets/profile-images/' . $dir;
$filesystem = new Filesystem();
if ($filesystem->isDirectory($destination) === false) {
$filesystem->makeDirectory($destination);
}
$request->file('avatar')->move($destination, 'image');
}
return redirect('/admin/contacts');
@ -123,37 +121,47 @@ class ContactsController extends Controller
*/
public function getAvatar($contactId)
{
// Initialising
$avatarURL = null;
$avatar = null;
$contact = Contact::findOrFail($contactId);
$homepage = $contact->homepage;
if (($homepage !== null) && ($homepage !== '')) {
$client = new Client();
if (mb_strlen($contact->homepage !== null) !== 0) {
$client = resolve(Client::class);
try {
$response = $client->get($homepage);
$html = (string) $response->getBody();
$mf2 = \Mf2\parse($html, $homepage);
$response = $client->get($contact->homepage);
} catch (\GuzzleHttp\Exception\BadResponseException $e) {
return "Bad Response from $homepage";
return redirect('/admin/contacts/' . $contactId . '/edit')
->with('error', 'Bad resposne from contact’s homepage');
}
$avatarURL = null; // Initialising
$mf2 = \Mf2\parse((string) $response->getBody(), $contact->homepage);
foreach ($mf2['items'] as $microformat) {
if ($microformat['type'][0] == 'h-card') {
$avatarURL = $microformat['properties']['photo'][0];
if (array_get($microformat, 'type.0') == 'h-card') {
$avatarURL = array_get($microformat, 'properties.photo.0');
break;
}
}
try {
$avatar = $client->get($avatarURL);
} catch (\GuzzleHttp\Exception\BadResponseException $e) {
return "Unable to get $avatarURL";
if ($avatarURL !== null) {
try {
$avatar = $client->get($avatarURL);
} catch (\GuzzleHttp\Exception\BadResponseException $e) {
return redirect('/admin/contacts/' . $contactId . '/edit')
->with('error', 'Unable to download avatar');
}
}
$directory = public_path() . '/assets/profile-images/' . parse_url($homepage)['host'];
$filesystem = new Filesystem();
if ($filesystem->isDirectory($directory) === false) {
$filesystem->makeDirectory($directory);
}
$filesystem->put($directory . '/image', $avatar->getBody());
if ($avatar !== null) {
$directory = public_path() . '/assets/profile-images/' . parse_url($contact->homepage, PHP_URL_HOST);
$filesystem = new Filesystem();
if ($filesystem->isDirectory($directory) === false) {
$filesystem->makeDirectory($directory);
}
$filesystem->put($directory . '/image', $avatar->getBody());
return view('admin.contacts.getavatarsuccess', ['homepage' => parse_url($homepage)['host']]);
return view('admin.contacts.getavatarsuccess', [
'homepage' => parse_url($contact->homepage, PHP_URL_HOST),
]);
}
}
return redirect('/admin/contacts/' . $contactId . '/edit');
}
}

View file

@ -2,22 +2,13 @@
namespace App\Http\Controllers\Admin;
use App\Note;
use Validator;
use App\Models\Note;
use Illuminate\Http\Request;
use App\Jobs\SendWebMentions;
use App\Services\NoteService;
use App\Http\Controllers\Controller;
class NotesController extends Controller
{
protected $noteService;
public function __construct(NoteService $noteService)
{
$this->noteService = $noteService;
}
/**
* List the notes that can be edited.
*
@ -51,30 +42,10 @@ class NotesController extends Controller
*/
public function store(Request $request)
{
$validator = Validator::make(
$request->all(),
['photo' => 'photosize'],
['photosize' => 'At least one uploaded file exceeds size limit of 5MB']
);
if ($validator->fails()) {
return redirect('/admin/notes/create')
->withErrors($validator)
->withInput();
}
$data = [];
$data['content'] = $request->input('content');
$data['in-reply-to'] = $request->input('in-reply-to');
$data['location'] = $request->input('location');
$data['syndicate'] = [];
if ($request->input('twitter')) {
$data['syndicate'][] = 'twitter';
}
if ($request->input('facebook')) {
$data['syndicate'][] = 'facebook';
}
$note = $this->noteService->createNote($data);
Note::create([
'in-reply-to' => $request->input('in-reply-to'),
'note' => $request->input('content'),
]);
return redirect('/admin/notes');
}

View file

@ -2,7 +2,7 @@
namespace App\Http\Controllers\Admin;
use App\Place;
use App\Models\Place;
use Illuminate\Http\Request;
use App\Services\PlaceService;
use App\Http\Controllers\Controller;
@ -47,11 +47,7 @@ class PlacesController extends Controller
*/
public function store(Request $request)
{
$data = [];
$data['name'] = $request->name;
$data['description'] = $request->description;
$data['latitude'] = $request->latitude;
$data['longitude'] = $request->longitude;
$data = $request->only(['name', 'description', 'latitude', 'longitude']);
$place = $this->placeService->createPlace($data);
return redirect('/admin/places');
@ -67,14 +63,7 @@ class PlacesController extends Controller
{
$place = Place::findOrFail($placeId);
return view('admin.places.edit', [
'id' => $placeId,
'name' => $place->name,
'description' => $place->description,
'latitude' => $place->latitude,
'longitude' => $place->longitude,
'icon' => $place->icon ?? 'marker',
]);
return view('admin.places.edit', compact('place'));
}
/**

View file

@ -2,7 +2,7 @@
namespace App\Http\Controllers;
use App\Article;
use App\Models\Article;
use Jonnybarnes\IndieWeb\Numbers;
class ArticlesController extends Controller
@ -15,7 +15,7 @@ class ArticlesController extends Controller
public function index($year = null, $month = null)
{
$articles = Article::where('published', '1')
->date($year, $month)
->date((int) $year, (int) $month)
->orderBy('updated_at', 'desc')
->simplePaginate(5);
@ -31,7 +31,7 @@ class ArticlesController extends Controller
{
$article = Article::where('titleurl', $slug)->firstOrFail();
if ($article->updated_at->year != $year || $article->updated_at->month != $month) {
throw new \Exception;
return redirect('/blog/' . $article->updated_at->year . '/' . $article->updated_at->month .'/' . $slug);
}
return view('articles.show', compact('article'));

View file

@ -1,32 +0,0 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\SendsPasswordResetEmails;
class ForgotPasswordController extends Controller
{
/*
|--------------------------------------------------------------------------
| Password Reset Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling password reset emails and
| includes a trait which assists in sending these notifications from
| your application to your users. Feel free to explore this trait.
|
*/
use SendsPasswordResetEmails;
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest');
}
}

View file

@ -1,39 +0,0 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\AuthenticatesUsers;
class LoginController extends Controller
{
/*
|--------------------------------------------------------------------------
| Login Controller
|--------------------------------------------------------------------------
|
| This controller handles authenticating users for the application and
| redirecting them to your home screen. The controller uses a trait
| to conveniently provide its functionality to your applications.
|
*/
use AuthenticatesUsers;
/**
* Where to redirect users after login.
*
* @var string
*/
protected $redirectTo = '/home';
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest')->except('logout');
}
}

View file

@ -1,71 +0,0 @@
<?php
namespace App\Http\Controllers\Auth;
use App\User;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Validator;
use Illuminate\Foundation\Auth\RegistersUsers;
class RegisterController extends Controller
{
/*
|--------------------------------------------------------------------------
| Register Controller
|--------------------------------------------------------------------------
|
| This controller handles the registration of new users as well as their
| validation and creation. By default this controller uses a trait to
| provide this functionality without requiring any additional code.
|
*/
use RegistersUsers;
/**
* Where to redirect users after registration.
*
* @var string
*/
protected $redirectTo = '/home';
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest');
}
/**
* Get a validator for an incoming registration request.
*
* @param array $data
* @return \Illuminate\Contracts\Validation\Validator
*/
protected function validator(array $data)
{
return Validator::make($data, [
'name' => 'required|string|max:255',
'email' => 'required|string|email|max:255|unique:users',
'password' => 'required|string|min:6|confirmed',
]);
}
/**
* Create a new user instance after a valid registration.
*
* @param array $data
* @return \App\User
*/
protected function create(array $data)
{
return User::create([
'name' => $data['name'],
'email' => $data['email'],
'password' => bcrypt($data['password']),
]);
}
}

View file

@ -1,39 +0,0 @@
<?php
namespace App\Http\Controllers\Auth;
use App\Http\Controllers\Controller;
use Illuminate\Foundation\Auth\ResetsPasswords;
class ResetPasswordController extends Controller
{
/*
|--------------------------------------------------------------------------
| Password Reset Controller
|--------------------------------------------------------------------------
|
| This controller is responsible for handling password reset requests
| and uses a simple trait to include this behavior. You're free to
| explore this trait and override any methods you wish to tweak.
|
*/
use ResetsPasswords;
/**
* Where to redirect users after resetting their password.
*
* @var string
*/
protected $redirectTo = '/home';
/**
* Create a new controller instance.
*
* @return void
*/
public function __construct()
{
$this->middleware('guest');
}
}

View file

@ -2,7 +2,7 @@
namespace App\Http\Controllers;
use App\Bookmark;
use App\Models\Bookmark;
class BookmarksController extends Controller
{

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