nginx: error pages are now respond as json if accept header request it.
As a consequence, we can rely on them to display a correct information on user pages through angularJS.
This commit is contained in:
parent
cf290732dc
commit
63a55a8a0b
@ -35,4 +35,29 @@ server {
|
||||
location /tags/ {
|
||||
rewrite ^/.*$ /index.html;
|
||||
}
|
||||
|
||||
location = /welcome.html {
|
||||
internal;
|
||||
if ($http_accept ~ "^application/json") {
|
||||
rewrite ^/(.*).html$ /$1.json;
|
||||
}
|
||||
}
|
||||
location = /e404.html {
|
||||
internal;
|
||||
if ($http_accept ~ "^application/json") {
|
||||
rewrite ^/(.*).html$ /$1.json;
|
||||
}
|
||||
}
|
||||
location = /e413.html {
|
||||
internal;
|
||||
if ($http_accept ~ "^application/json") {
|
||||
rewrite ^/(.*).html$ /$1.json;
|
||||
}
|
||||
}
|
||||
location = /e500.html {
|
||||
internal;
|
||||
if ($http_accept ~ "^application/json") {
|
||||
rewrite ^/(.*).html$ /$1.json;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,6 +22,31 @@ server {
|
||||
#auth_basic_user_file ficpasswd;
|
||||
}
|
||||
|
||||
location = /welcome.html {
|
||||
internal;
|
||||
if ($http_accept ~ "^application/json") {
|
||||
rewrite ^/(.*).html$ /$1.json;
|
||||
}
|
||||
}
|
||||
location = /e404.html {
|
||||
internal;
|
||||
if ($http_accept ~ "^application/json") {
|
||||
rewrite ^/(.*).html$ /$1.json;
|
||||
}
|
||||
}
|
||||
location = /e413.html {
|
||||
internal;
|
||||
if ($http_accept ~ "^application/json") {
|
||||
rewrite ^/(.*).html$ /$1.json;
|
||||
}
|
||||
}
|
||||
location = /e500.html {
|
||||
internal;
|
||||
if ($http_accept ~ "^application/json") {
|
||||
rewrite ^/(.*).html$ /$1.json;
|
||||
}
|
||||
}
|
||||
|
||||
location /edit {
|
||||
rewrite ^/.*$ /index.html;
|
||||
}
|
||||
|
@ -41,15 +41,27 @@ server {
|
||||
}
|
||||
location = /welcome.html {
|
||||
internal;
|
||||
if ($http_accept ~ "^application/json") {
|
||||
rewrite ^/(.*).html$ /$1.json;
|
||||
}
|
||||
}
|
||||
location = /e404.html {
|
||||
internal;
|
||||
if ($http_accept ~ "^application/json") {
|
||||
rewrite ^/(.*).html$ /$1.json;
|
||||
}
|
||||
}
|
||||
location = /e413.html {
|
||||
internal;
|
||||
if ($http_accept ~ "^application/json") {
|
||||
rewrite ^/(.*).html$ /$1.json;
|
||||
}
|
||||
}
|
||||
location = /e500.html {
|
||||
internal;
|
||||
if ($http_accept ~ "^application/json") {
|
||||
rewrite ^/(.*).html$ /$1.json;
|
||||
}
|
||||
}
|
||||
|
||||
location ~ ^/[A-Z] {
|
||||
|
@ -10,6 +10,11 @@
|
||||
<meta name="robots" content="all">
|
||||
<link href="/css/bootstrap.min.css" type="text/css" rel="stylesheet" media="screen">
|
||||
<link href="/css/fic.css" type="text/css" rel="stylesheet" media="screen">
|
||||
<style>
|
||||
.niceborder {
|
||||
border-bottom-color: #ee5f5b;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body class="bg-light">
|
||||
|
||||
@ -30,7 +35,7 @@
|
||||
</div>
|
||||
|
||||
<div class="container" style="margin-top:20px;">
|
||||
<div class="jumbotron">
|
||||
<div class="jumbotron niceborder">
|
||||
<h1>Page introuvable <small>Erreur 404</small></h1>
|
||||
<hr>
|
||||
<p class="lead">
|
||||
|
1
frontend/static/e404.json
Normal file
1
frontend/static/e404.json
Normal file
@ -0,0 +1 @@
|
||||
{"errmsg": "La page à laquelle vous tentez d'accéder n'existe pas ou l'adresse que vous avez tapée est incorrecte."}
|
@ -10,6 +10,11 @@
|
||||
<meta name="robots" content="all">
|
||||
<link href="/css/bootstrap.min.css" type="text/css" rel="stylesheet" media="screen">
|
||||
<link href="/css/fic.css" type="text/css" rel="stylesheet" media="screen">
|
||||
<style>
|
||||
.niceborder {
|
||||
border-bottom-color: #ee5f5b;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body class="bg-light">
|
||||
|
||||
@ -30,7 +35,7 @@
|
||||
</div>
|
||||
|
||||
<div class="container" style="margin-top:20px;">
|
||||
<div class="jumbotron">
|
||||
<div class="jumbotron niceborder">
|
||||
<h1>Requête trop grosse <small>Erreur 413</small></h1>
|
||||
<hr>
|
||||
<p class="lead">
|
||||
|
1
frontend/static/e413.json
Normal file
1
frontend/static/e413.json
Normal file
@ -0,0 +1 @@
|
||||
{"errmsg": "La quantité de données que vous souhaitez envoyer au serveur est trop importante pour qu'il accepte de la traiter."}
|
@ -10,6 +10,11 @@
|
||||
<meta name="robots" content="all">
|
||||
<link href="/css/bootstrap.min.css" type="text/css" rel="stylesheet" media="screen">
|
||||
<link href="/css/fic.css" type="text/css" rel="stylesheet" media="screen">
|
||||
<style>
|
||||
.niceborder {
|
||||
border-bottom-color: #ee5f5b;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body class="bg-light">
|
||||
|
||||
@ -30,11 +35,11 @@
|
||||
</div>
|
||||
|
||||
<div class="container" style="margin-top:20px;">
|
||||
<div class="jumbotron">
|
||||
<div class="jumbotron niceborder">
|
||||
<h1>Erreur interne <small>Erreur 500</small></h1>
|
||||
<hr>
|
||||
<p class="lead">
|
||||
Notre serveur est actuellement dans l'incapacité de repondre à votre requête.<br>Veuillez recommencer dans quelques instants.
|
||||
Notre serveur est actuellement dans l'incapacité de répondre à votre requête.<br>Veuillez recommencer dans quelques instants.
|
||||
</p>
|
||||
<p>
|
||||
Si le problème persiste, <a href="mailto:root@srs.epita.fr">contactez un administrateur</a>.
|
||||
|
1
frontend/static/e500.json
Normal file
1
frontend/static/e500.json
Normal file
@ -0,0 +1 @@
|
||||
{"errmsg": "Notre serveur est actuellement dans l'incapacité de répondre à votre requête. \nVeuillez recommencer dans quelques instants."}
|
@ -293,17 +293,13 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
||||
};
|
||||
})
|
||||
.controller("SubmissionController", function($scope, $http, $rootScope, $timeout) {
|
||||
$rootScope.sberr = "";
|
||||
$scope.sberr = null;
|
||||
|
||||
var cbs;
|
||||
var cbd;
|
||||
|
||||
$scope.$watch("my", function(my) {
|
||||
if (!my || !my.exercices || !my.exercices[$rootScope.current_exercice]) {
|
||||
if (cbs)
|
||||
$timeout.cancel(cbs);
|
||||
cbs = $timeout(waitMy, 420);
|
||||
} else {
|
||||
if (my && my.exercices && my.exercices[$rootScope.current_exercice]) {
|
||||
angular.forEach(my.exercices[$rootScope.current_exercice].mcqs, function(mcq,qid) {
|
||||
angular.forEach(mcq["choices"], function(choice,cid) {
|
||||
this[cid] = {
|
||||
@ -322,6 +318,7 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
||||
$scope.ssubmit = function() {
|
||||
var resp = {}
|
||||
var check = undefined
|
||||
$scope.sberr = null;
|
||||
|
||||
if ($scope.my.exercices[$rootScope.current_exercice].flags && Object.keys($scope.my.exercices[$rootScope.current_exercice].flags).length)
|
||||
{
|
||||
@ -384,10 +381,10 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
||||
return;
|
||||
}
|
||||
|
||||
$http({ url: "/submit/" + $rootScope.current_exercice, method: "POST", data: resp }).then(function(response, status, header, config) {
|
||||
$rootScope.messageClass = {"text-success": true};
|
||||
$rootScope.message = response.data.errmsg;
|
||||
$rootScope.sberr = "";
|
||||
$http({ url: "/submit/" + $rootScope.current_exercice, method: "POST", data: resp }).then(function(response) {
|
||||
$scope.messageClass = {"text-success": true};
|
||||
$scope.message = response.data.errmsg;
|
||||
$scope.sberr = null;
|
||||
|
||||
angular.forEach($scope.flags, function(flag,kid) {
|
||||
flag.value = "";
|
||||
@ -407,15 +404,13 @@ angular.module("FICApp", ["ngRoute", "ngSanitize"])
|
||||
});
|
||||
};
|
||||
checkDiff();
|
||||
}, function(response, status, header, config) {
|
||||
if (status >= 500) {
|
||||
}, function(response) {
|
||||
if (response.status >= 500) {
|
||||
$scope.my.exercices[$rootScope.current_exercice].submitted = false;
|
||||
}
|
||||
$rootScope.messageClass = {"text-danger": true};
|
||||
$rootScope.message = response.data.errmsg;
|
||||
if (status != 402) {
|
||||
$rootScope.sberr = "Une erreur est survenue lors de l'envoi. Veuillez réessayer dans quelques instants.";
|
||||
}
|
||||
$scope.messageClass = {"text-danger": true};
|
||||
$scope.sberr = "Oups !";
|
||||
$scope.message = response.data.errmsg;
|
||||
});
|
||||
$scope.my.exercices[$rootScope.current_exercice].submitted = true;
|
||||
};
|
||||
|
@ -30,7 +30,7 @@
|
||||
</div>
|
||||
|
||||
<div class="container text-justify" style="margin-top:20px; text-indent: 1.5em">
|
||||
<div class="jumbotron">
|
||||
<div class="jumbotron niceborder">
|
||||
<h1 style="text-indent: 0">Bienvenue !</h1>
|
||||
<p style="text-indent: 0" class="alert alert-primary">
|
||||
<strong>
|
||||
@ -50,7 +50,7 @@
|
||||
</p>
|
||||
</div>
|
||||
|
||||
<div class="card" style="margin-bottom:20px;">
|
||||
<div class="card niceborder" style="margin-bottom:20px;">
|
||||
<div class="card-header bg-dark">
|
||||
<h2 style="margin: 0">Installation du certificat client</h2>
|
||||
</div>
|
||||
@ -92,7 +92,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card" style="margin-bottom:20px;">
|
||||
<div class="card niceborder" style="margin-bottom:20px;">
|
||||
<div class="card-header bg-dark">
|
||||
<h2 id="cert-client-mozilla-firefox" style="margin: 0">Mozilla Firefox</h2>
|
||||
</div>
|
||||
@ -109,7 +109,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card" style="margin-bottom:20px;">
|
||||
<div class="card niceborder" style="margin-bottom:20px;">
|
||||
<div class="card-header bg-dark">
|
||||
<h2 id="cert-client-chromium" style="margin: 0">Chromium/Google Chrome</h2>
|
||||
</div>
|
||||
@ -141,7 +141,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card" style="margin-bottom:20px;">
|
||||
<div class="card niceborder" style="margin-bottom:20px;">
|
||||
<div class="card-header bg-dark">
|
||||
<h2 id="cert-client-ie" style="margin: 0">Internet Explorer</h2>
|
||||
</div>
|
||||
@ -168,7 +168,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card" style="margin-bottom:20px;">
|
||||
<div class="card niceborder" style="margin-bottom:20px;">
|
||||
<div class="card-header bg-dark">
|
||||
<h2 id="cert-client-safari" style="margin: 0">Safari</h2>
|
||||
</div>
|
||||
|
1
frontend/static/welcome.json
Normal file
1
frontend/static/welcome.json
Normal file
@ -0,0 +1 @@
|
||||
{"errmsg": "Vous n'avez pas les droits nécessaires pour effectuer cette action."}
|
Loading…
Reference in New Issue
Block a user