Showing
11 changed files
with
55 additions
and
37 deletions
| 1 | <?php namespace BookStack\Exceptions; | 1 | <?php namespace BookStack\Exceptions; |
| 2 | 2 | ||
| 3 | 3 | ||
| 4 | -class ConfirmationEmailException extends NotifyException | ||
| 5 | -{ | ||
| 6 | - | ||
| 7 | -} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 4 | +class ConfirmationEmailException extends NotifyException {} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -5,6 +5,7 @@ namespace BookStack\Exceptions; | ... | @@ -5,6 +5,7 @@ namespace BookStack\Exceptions; |
| 5 | use Exception; | 5 | use Exception; |
| 6 | use Illuminate\Contracts\Validation\ValidationException; | 6 | use Illuminate\Contracts\Validation\ValidationException; |
| 7 | use Illuminate\Database\Eloquent\ModelNotFoundException; | 7 | use Illuminate\Database\Eloquent\ModelNotFoundException; |
| 8 | +use PhpSpec\Exception\Example\ErrorException; | ||
| 8 | use Symfony\Component\HttpKernel\Exception\HttpException; | 9 | use Symfony\Component\HttpKernel\Exception\HttpException; |
| 9 | use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; | 10 | use Illuminate\Foundation\Exceptions\Handler as ExceptionHandler; |
| 10 | use Illuminate\Auth\Access\AuthorizationException; | 11 | use Illuminate\Auth\Access\AuthorizationException; |
| ... | @@ -44,11 +45,20 @@ class Handler extends ExceptionHandler | ... | @@ -44,11 +45,20 @@ class Handler extends ExceptionHandler |
| 44 | */ | 45 | */ |
| 45 | public function render($request, Exception $e) | 46 | public function render($request, Exception $e) |
| 46 | { | 47 | { |
| 47 | - if($e instanceof NotifyException) { | 48 | + // Handle notify exceptions which will redirect to the |
| 49 | + // specified location then show a notification message. | ||
| 50 | + if ($e instanceof NotifyException) { | ||
| 48 | \Session::flash('error', $e->message); | 51 | \Session::flash('error', $e->message); |
| 49 | return response()->redirectTo($e->redirectLocation); | 52 | return response()->redirectTo($e->redirectLocation); |
| 50 | } | 53 | } |
| 51 | 54 | ||
| 55 | + // Handle pretty exceptions which will show a friendly application-fitting page | ||
| 56 | + // Which will include the basic message to point the user roughly to the cause. | ||
| 57 | + if (($e instanceof PrettyException || $e->getPrevious() instanceof PrettyException) && !config('app.debug')) { | ||
| 58 | + $message = ($e instanceof PrettyException) ? $e->getMessage() : $e->getPrevious()->getMessage(); | ||
| 59 | + return response()->view('errors/500', ['message' => $message], 500); | ||
| 60 | + } | ||
| 61 | + | ||
| 52 | return parent::render($request, $e); | 62 | return parent::render($request, $e); |
| 53 | } | 63 | } |
| 54 | } | 64 | } | ... | ... |
| 1 | <?php namespace BookStack\Exceptions; | 1 | <?php namespace BookStack\Exceptions; |
| 2 | 2 | ||
| 3 | - | ||
| 4 | -use Exception; | ||
| 5 | - | ||
| 6 | -class ImageUploadException extends Exception {} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 3 | +class ImageUploadException extends PrettyException {} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| 1 | <?php namespace BookStack\Exceptions; | 1 | <?php namespace BookStack\Exceptions; |
| 2 | 2 | ||
| 3 | - | ||
| 4 | -use Exception; | ||
| 5 | - | ||
| 6 | -class LdapException extends Exception | ||
| 7 | -{ | ||
| 8 | - | ||
| 9 | -} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 3 | +class LdapException extends PrettyException {} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
app/Exceptions/PrettyException.php
0 → 100644
| 1 | <?php namespace BookStack\Exceptions; | 1 | <?php namespace BookStack\Exceptions; |
| 2 | 2 | ||
| 3 | 3 | ||
| 4 | -class SocialDriverNotConfigured extends \Exception | ||
| 5 | -{ | ||
| 6 | -} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 4 | +class SocialDriverNotConfigured extends PrettyException {} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| 1 | <?php namespace BookStack\Exceptions; | 1 | <?php namespace BookStack\Exceptions; |
| 2 | 2 | ||
| 3 | 3 | ||
| 4 | -class SocialSignInException extends NotifyException | ||
| 5 | -{ | ||
| 6 | - | ||
| 7 | -} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 4 | +class SocialSignInException extends NotifyException {} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| 1 | <?php namespace BookStack\Exceptions; | 1 | <?php namespace BookStack\Exceptions; |
| 2 | 2 | ||
| 3 | 3 | ||
| 4 | -class UserRegistrationException extends NotifyException | ||
| 5 | -{ | ||
| 6 | - | ||
| 7 | -} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 4 | +class UserRegistrationException extends NotifyException {} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -4,6 +4,7 @@ use BookStack\Exceptions\ImageUploadException; | ... | @@ -4,6 +4,7 @@ use BookStack\Exceptions\ImageUploadException; |
| 4 | use BookStack\Image; | 4 | use BookStack\Image; |
| 5 | use BookStack\User; | 5 | use BookStack\User; |
| 6 | use Exception; | 6 | use Exception; |
| 7 | +use Intervention\Image\Exception\NotSupportedException; | ||
| 7 | use Intervention\Image\ImageManager; | 8 | use Intervention\Image\ImageManager; |
| 8 | use Illuminate\Contracts\Filesystem\Factory as FileSystem; | 9 | use Illuminate\Contracts\Filesystem\Factory as FileSystem; |
| 9 | use Illuminate\Contracts\Filesystem\Filesystem as FileSystemInstance; | 10 | use Illuminate\Contracts\Filesystem\Filesystem as FileSystemInstance; |
| ... | @@ -123,6 +124,8 @@ class ImageService | ... | @@ -123,6 +124,8 @@ class ImageService |
| 123 | * @param int $height | 124 | * @param int $height |
| 124 | * @param bool $keepRatio | 125 | * @param bool $keepRatio |
| 125 | * @return string | 126 | * @return string |
| 127 | + * @throws Exception | ||
| 128 | + * @throws ImageUploadException | ||
| 126 | */ | 129 | */ |
| 127 | public function getThumbnail(Image $image, $width = 220, $height = 220, $keepRatio = false) | 130 | public function getThumbnail(Image $image, $width = 220, $height = 220, $keepRatio = false) |
| 128 | { | 131 | { |
| ... | @@ -139,8 +142,16 @@ class ImageService | ... | @@ -139,8 +142,16 @@ class ImageService |
| 139 | return $this->getPublicUrl($thumbFilePath); | 142 | return $this->getPublicUrl($thumbFilePath); |
| 140 | } | 143 | } |
| 141 | 144 | ||
| 142 | - // Otherwise create the thumbnail | 145 | + try { |
| 143 | $thumb = $this->imageTool->make($storage->get($image->path)); | 146 | $thumb = $this->imageTool->make($storage->get($image->path)); |
| 147 | + } catch (Exception $e) { | ||
| 148 | + if ($e instanceof \ErrorException || $e instanceof NotSupportedException) { | ||
| 149 | + throw new ImageUploadException('The server cannot create thumbnails. Please check you have the GD PHP extension installed.'); | ||
| 150 | + } else { | ||
| 151 | + throw $e; | ||
| 152 | + } | ||
| 153 | + } | ||
| 154 | + | ||
| 144 | if ($keepRatio) { | 155 | if ($keepRatio) { |
| 145 | $thumb->resize($width, null, function ($constraint) { | 156 | $thumb->resize($width, null, function ($constraint) { |
| 146 | $constraint->aspectRatio(); | 157 | $constraint->aspectRatio(); | ... | ... |
| ... | @@ -17,19 +17,13 @@ A platform to create documentation/wiki content. General information about BookS | ... | @@ -17,19 +17,13 @@ A platform to create documentation/wiki content. General information about BookS |
| 17 | 17 | ||
| 18 | ## Requirements | 18 | ## Requirements |
| 19 | 19 | ||
| 20 | -BookStack has similar requirements to Laravel. On top of those are some front-end build tools which are only required when developing. | 20 | +BookStack has similar requirements to Laravel: |
| 21 | 21 | ||
| 22 | * PHP >= 5.5.9, Will need to be usable from the command line. | 22 | * PHP >= 5.5.9, Will need to be usable from the command line. |
| 23 | -* OpenSSL PHP Extension | 23 | +* PHP Extensions: `OpenSSL`, `PDO`, `MBstring`, `Tokenizer`, `GD` |
| 24 | -* PDO PHP Extension | ||
| 25 | -* MBstring PHP Extension | ||
| 26 | -* Tokenizer PHP Extension | ||
| 27 | * MySQL >= 5.6 | 24 | * MySQL >= 5.6 |
| 28 | * Git (Not strictly required but helps manage updates) | 25 | * Git (Not strictly required but helps manage updates) |
| 29 | * [Composer](https://getcomposer.org/) | 26 | * [Composer](https://getcomposer.org/) |
| 30 | -* [Node.js](https://nodejs.org/en/) **Development Only** | ||
| 31 | -* [Gulp](http://gulpjs.com/) **Development Only** | ||
| 32 | - | ||
| 33 | 27 | ||
| 34 | ## Installation | 28 | ## Installation |
| 35 | 29 | ||
| ... | @@ -144,7 +138,14 @@ A user in BookStack will be linked to a LDAP user via a 'uid'. If a LDAP user ui | ... | @@ -144,7 +138,14 @@ A user in BookStack will be linked to a LDAP user via a 'uid'. If a LDAP user ui |
| 144 | 138 | ||
| 145 | You may find that you cannot log in with your initial Admin account after changing the `AUTH_METHOD` to `ldap`. To get around this set the `AUTH_METHOD` to `standard`, login with your admin account then change it back to `ldap`. You get then edit your profile and add your LDAP uid under the 'External Authentication ID' field. You will then be able to login in with that ID. | 139 | You may find that you cannot log in with your initial Admin account after changing the `AUTH_METHOD` to `ldap`. To get around this set the `AUTH_METHOD` to `standard`, login with your admin account then change it back to `ldap`. You get then edit your profile and add your LDAP uid under the 'External Authentication ID' field. You will then be able to login in with that ID. |
| 146 | 140 | ||
| 147 | -## Testing | 141 | +## Development & Testing |
| 142 | + | ||
| 143 | +All development on BookStack is currently done on the master branch. When it's time for a release the master branch is merged into release with built & minified CSS & JS then tagged at it's version. Here are the current development requirements: | ||
| 144 | + | ||
| 145 | +* [Node.js](https://nodejs.org/en/) **Development Only** | ||
| 146 | +* [Gulp](http://gulpjs.com/) **Development Only** | ||
| 147 | + | ||
| 148 | +SASS is used to help the CSS development and the JavaScript is run through browserify/babel to allow for writing ES6 code. Both of these are done using gulp. | ||
| 148 | 149 | ||
| 149 | BookStack has many integration tests that use Laravel's built-in testing capabilities which makes use of PHPUnit. To use you will need PHPUnit installed and accessible via command line. There is a `mysql_testing` database defined within the app config which is what is used by PHPUnit. This database is set with the following database name, user name and password defined as `bookstack-test`. You will have to create that database and credentials before testing. | 150 | BookStack has many integration tests that use Laravel's built-in testing capabilities which makes use of PHPUnit. To use you will need PHPUnit installed and accessible via command line. There is a `mysql_testing` database defined within the app config which is what is used by PHPUnit. This database is set with the following database name, user name and password defined as `bookstack-test`. You will have to create that database and credentials before testing. |
| 150 | 151 | ... | ... |
-
Please register or sign in to post a comment