+ 404 page

This commit is contained in:
tmshv committed 2015-03-01 19:05:50 +03:00
1 parent 85ca132c3e
commit 6994549360
5 files changed
+53 -1

No files matched your search

+15
View File
@@ -0,0 +1,15 @@
.error-404{
text-align: center;
margin: 40px;
h1{
font-size: 16pt;
font-weight: normal;
}
img{
margin: 20px;
width: 40%;
max-width: 800px;
}
}
+1 -1
View File
@@ -45,7 +45,7 @@ app.config(function ($locationProvider, $routeProvider) {
});
$routeProvider.otherwise({
redirectTo: "/"
templateUrl: "/404.html"
});
});
+31
View File
@@ -0,0 +1,31 @@
/**
* Created by tmshv on 01/03/15.
*/
var route = require("koa-route");
var router = require("./");
module.exports = function (app) {
app.use(function *(next) {
yield next;
if (404 != this.status) return;
this.status = 404;
yield router.accepts({
"text/html": router.index(),
"text/plain": function *() {
this.type = "text/plain";
this.body = "Page not found";
},
"application/json": function *() {
this.type = "application/json";
this.body = {
message: "Not Found"
};
}
});
});
};
+2
View File
@@ -53,6 +53,8 @@ app.use(route.get("/document/:doc", routes.index(
require("./routes/schedule")(app);
require("./routes/news")(app);
require("./routes/404")(app);
if (process.env["NODE_ENV"] === "development") {
app.use(route.get("/debug", function *() {
var out = {};
+4
View File
@@ -0,0 +1,4 @@
<div class="error-404">
<h1>Страница не найдена.</h1>
<img src="http://static.shburg.org/art/graphics/skull.jpg" alt=""/>
</div>