From 0000c4297d6b8518212318b277a26975d1aabc55 Mon Sep 17 00:00:00 2001 From: nelsonlaquet Date: Sun, 1 Sep 2013 16:54:33 -0500 Subject: [PATCH] Added cute error pages --- app/controllers/Api/Web/ArtistsController.php | 1 + app/filters.php | 9 +++++++++ app/models/Entities/Image.php | 2 +- app/models/Entities/Track.php | 2 +- app/views/errors/400.blade.php | 12 ++++++++++++ app/views/errors/403.blade.php | 12 ++++++++++++ app/views/errors/404.blade.php | 12 ++++++++++++ app/views/errors/500.blade.php | 12 ++++++++++++ app/views/shared/_app_layout.blade.php | 4 ++-- public/scripts/app/app.coffee | 17 +++++++++++++++++ .../scripts/app/controllers/application.coffee | 10 ++++++++-- .../app/controllers/artist-content.coffee | 5 +++-- public/scripts/app/controllers/artist.coffee | 5 +++-- public/scripts/app/services/artists.coffee | 14 ++++++++++---- public/templates/errors/400.html | 3 +++ public/templates/errors/403.html | 3 +++ public/templates/errors/404.html | 3 +++ public/templates/errors/500.html | 3 +++ 18 files changed, 115 insertions(+), 14 deletions(-) create mode 100644 app/views/errors/400.blade.php create mode 100644 app/views/errors/403.blade.php create mode 100644 app/views/errors/404.blade.php create mode 100644 app/views/errors/500.blade.php create mode 100644 public/templates/errors/400.html create mode 100644 public/templates/errors/403.html create mode 100644 public/templates/errors/404.html create mode 100644 public/templates/errors/500.html diff --git a/app/controllers/Api/Web/ArtistsController.php b/app/controllers/Api/Web/ArtistsController.php index dd3e0017..3dfaee41 100644 --- a/app/controllers/Api/Web/ArtistsController.php +++ b/app/controllers/Api/Web/ArtistsController.php @@ -14,6 +14,7 @@ use Entities\Image; use Entities\Track; use Entities\User; + use Illuminate\Support\Facades\App; use Illuminate\Support\Facades\Auth; use Illuminate\Support\Facades\Input; use Illuminate\Support\Facades\Response; diff --git a/app/filters.php b/app/filters.php index 622380bb..0456d3a0 100644 --- a/app/filters.php +++ b/app/filters.php @@ -40,6 +40,15 @@ }); } + App::error(function($exception) { + return Response::view('errors.404', array(), 404); + }); + + App::missing(function($exception) { + return Response::view('errors.404', array(), 404); + }); + + /* |-------------------------------------------------------------------------- | Authentication Filters diff --git a/app/models/Entities/Image.php b/app/models/Entities/Image.php index 7c765612..2ffb3adc 100644 --- a/app/models/Entities/Image.php +++ b/app/models/Entities/Image.php @@ -94,6 +94,6 @@ $destination = $this->getDirectory(); if (!is_dir($destination)) - mkdir($destination, 755, true); + mkdir($destination, 777, true); } } \ No newline at end of file diff --git a/app/models/Entities/Track.php b/app/models/Entities/Track.php index 32490d1d..13a9ae3e 100644 --- a/app/models/Entities/Track.php +++ b/app/models/Entities/Track.php @@ -328,7 +328,7 @@ $destination = $this->getDirectory(); if (!is_dir($destination)) - mkdir($destination, 755); + mkdir($destination, 777); } public function hasCover() { diff --git a/app/views/errors/400.blade.php b/app/views/errors/400.blade.php new file mode 100644 index 00000000..bfc98077 --- /dev/null +++ b/app/views/errors/400.blade.php @@ -0,0 +1,12 @@ +@extends('shared._app_layout') + +@section('app_content') +

400 - Invalid Request

+

Your request was invalid.

+@endsection + +@section('app_scripts') + +@endsection \ No newline at end of file diff --git a/app/views/errors/403.blade.php b/app/views/errors/403.blade.php new file mode 100644 index 00000000..3c1d4e61 --- /dev/null +++ b/app/views/errors/403.blade.php @@ -0,0 +1,12 @@ +@extends('shared._app_layout') + +@section('app_content') +

403 - Not Authorized

+

You cannot do this.

+@endsection + +@section('app_scripts') + +@endsection \ No newline at end of file diff --git a/app/views/errors/404.blade.php b/app/views/errors/404.blade.php new file mode 100644 index 00000000..05b9d0ed --- /dev/null +++ b/app/views/errors/404.blade.php @@ -0,0 +1,12 @@ +@extends('shared._app_layout') + +@section('app_content') +

404 - Not Found

+

We could not find what you were looking for.

+@endsection + +@section('app_scripts') + +@endsection \ No newline at end of file diff --git a/app/views/errors/500.blade.php b/app/views/errors/500.blade.php new file mode 100644 index 00000000..809aac05 --- /dev/null +++ b/app/views/errors/500.blade.php @@ -0,0 +1,12 @@ +@extends('shared._app_layout') + +@section('app_content') +

400 - Server Error

+

There was an error in the server.

+@endsection + +@section('app_scripts') + +@endsection \ No newline at end of file diff --git a/app/views/shared/_app_layout.blade.php b/app/views/shared/_app_layout.blade.php index 2e2cf9c9..1cab25e0 100644 --- a/app/views/shared/_app_layout.blade.php +++ b/app/views/shared/_app_layout.blade.php @@ -92,7 +92,6 @@ @endsection @section('scripts') -