Added cute error pages

This commit is contained in:
nelsonlaquet 2013-09-01 16:54:33 -05:00
parent ddd11ff79b
commit 0000c4297d
18 changed files with 115 additions and 14 deletions

View file

@ -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;

View file

@ -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

View file

@ -94,6 +94,6 @@
$destination = $this->getDirectory();
if (!is_dir($destination))
mkdir($destination, 755, true);
mkdir($destination, 777, true);
}
}

View file

@ -328,7 +328,7 @@
$destination = $this->getDirectory();
if (!is_dir($destination))
mkdir($destination, 755);
mkdir($destination, 777);
}
public function hasCover() {

View file

@ -0,0 +1,12 @@
@extends('shared._app_layout')
@section('app_content')
<h1>400 - Invalid Request</h1>
<p>Your request was invalid.</p>
@endsection
@section('app_scripts')
<script>
window.pfm.error = 400;
</script>
@endsection

View file

@ -0,0 +1,12 @@
@extends('shared._app_layout')
@section('app_content')
<h1>403 - Not Authorized</h1>
<p>You cannot do this.</p>
@endsection
@section('app_scripts')
<script>
window.pfm.error = 403;
</script>
@endsection

View file

@ -0,0 +1,12 @@
@extends('shared._app_layout')
@section('app_content')
<h1>404 - Not Found</h1>
<p>We could not find what you were looking for.</p>
@endsection
@section('app_scripts')
<script>
window.pfm.error = 404;
</script>
@endsection

View file

@ -0,0 +1,12 @@
@extends('shared._app_layout')
@section('app_content')
<h1>400 - Server Error</h1>
<p>There was an error in the server.</p>
@endsection
@section('app_scripts')
<script>
window.pfm.error = 500;
</script>
@endsection

View file

@ -92,7 +92,6 @@
@endsection
@section('scripts')
<script>
window.pfm = {
token: "{{Session::token()}}",
@ -112,7 +111,6 @@
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-29463256-1']);
_gaq.push(['_setDomainName', 'pony.fm']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
@ -123,4 +121,6 @@
{{ Assets::scriptIncludes() }}
@yield('app_scripts')
@endsection

View file

@ -22,6 +22,23 @@ module.config [
analytics.setEventHandlers ['Google']
# Errors
state.state 'errors-404',
url: '/errors/not-found'
templateUrl: '/templates/errors/404.html'
state.state 'errors-500',
url: '/errors/server'
templateUrl: '/templates/errors/500.html'
state.state 'errors-403',
url: '/errors/not-authorized'
templateUrl: '/templates/errors/403.html'
state.state 'errors-400',
url: '/errors/invalid'
templateUrl: '/templates/errors/400.html'
# Upload
state.state 'uploader',

View file

@ -8,6 +8,9 @@ angular.module('ponyfm').controller "application", [
$loadingElement = null
loadingStateName = null
if window.pfm.error
$state.transitionTo 'errors-' + window.pfm.error
$rootScope.safeApply = (fn) ->
phase = $rootScope.$$phase
if (phase == '$apply' || phase == 'digest')
@ -73,7 +76,10 @@ angular.module('ponyfm').controller "application", [
stateToInject = angular.copy newState
stateToInject.params = newParams
$injector.invoke(preloader, null, {$state: stateToInject}).then ->
statesPreloaded[newState] = true
try
$injector.invoke(preloader, null, {$state: stateToInject}).then ->
statesPreloaded[newState] = true
$state.transitionTo newState, newParams
catch error
$state.transitionTo newState, newParams
]

View file

@ -7,6 +7,7 @@ window.pfm.preloaders['artist-content'] = [
angular.module('ponyfm').controller "artist-content", [
'$scope', 'artists', '$state'
($scope, artists, $state) ->
artists.fetchContent($state.params.slug).done (artistResponse) ->
$scope.content = artistResponse
artists.fetchContent($state.params.slug)
.done (artistResponse) ->
$scope.content = artistResponse
]

View file

@ -7,8 +7,9 @@ window.pfm.preloaders['artist'] = [
angular.module('ponyfm').controller "artist", [
'$scope', 'artists', '$state', 'follow'
($scope, artists, $state, follow) ->
artists.fetch($state.params.slug).done (artistResponse) ->
$scope.artist = artistResponse.artist
artists.fetch($state.params.slug)
.done (artistResponse) ->
$scope.artist = artistResponse.artist
$scope.toggleFollow = () ->
follow.toggle('artist', $scope.artist.id).then (res) ->

View file

@ -25,8 +25,11 @@ angular.module('ponyfm').factory('artists', [
slug = 1 if !slug
return artists[slug] if !force && artists[slug]
artistsDef = new $.Deferred()
$http.get('/api/web/artists/' + slug).success (albums) ->
artistsDef.resolve albums
$http.get('/api/web/artists/' + slug)
.success (albums) ->
artistsDef.resolve albums
.catch () ->
artistsDef.reject()
artists[slug] = artistsDef.promise()
@ -35,8 +38,11 @@ angular.module('ponyfm').factory('artists', [
slug = 1 if !slug
return artistContent[slug] if !force && artistContent[slug]
artistsDef = new $.Deferred()
$http.get('/api/web/artists/' + slug + '/content').success (albums) ->
artistsDef.resolve albums
$http.get('/api/web/artists/' + slug + '/content')
.success (albums) ->
artistsDef.resolve albums
.catch () ->
artistsDef.reject()
artistContent[slug] = artistsDef.promise()

View file

@ -0,0 +1,3 @@
<h1>Twilight Sparkle burns with the rage of 400 suns.</h1>
<p>The request you sent was not properly formed. Unfortunately, this means it had to be rejected.</p>
<p>There isn&#39;t much you can do here, but perhaps you would like to go to our <a href="/">home page</a>?</p>

View file

@ -0,0 +1,3 @@
<h1>403 Royal Guards stand in your way.</h1>
<p>Looks like you tried to do something you weren&#39;t allowed to!</p>
<p>There isn&#39;t much you can do here, but perhaps you would like to go to our <a href="/">home page</a>?</p>

View file

@ -0,0 +1,3 @@
<h1>404 parasprites invaded the town!</h1>
<p>We couldn&#39;t track down the page you were looking for! Perhaps a parasprite has eaten it, or it may never have existed in the first place. It&#39;s also possible that Princess Celestia banished it to the moon for heresy.</p>
<p>In any case, we&#39;re sorry this happened. Perhaps you would like to go to our <a href="/">home page</a>?</p>

View file

@ -0,0 +1,3 @@
<h1>500 buckets of oats on the wall.</h1>
<p>Something went wrong on our servers while we were processing your request. We're really sorry about this, and will work hard to get this resolved as soon as possible.</p>
<p>In any case, we&#39;re sorry this happened. Perhaps you would like to go to our <a href="/">home page</a>?</p>