Merge pull request #1990 from wy65701436/master

customize beego 404
This commit is contained in:
Yan 2017-04-11 16:12:02 +08:00 committed by GitHub
commit 9a624c1dfc
3 changed files with 94 additions and 0 deletions

View File

@ -0,0 +1,16 @@
package controllers
import (
"github.com/astaxie/beego"
)
// ErrorController handles beego error pages
type ErrorController struct {
beego.Controller
}
// Error404 renders the 404 page
func (ec *ErrorController) Error404() {
ec.Data["content"] = "page not found"
ec.TplName = "404.tpl"
}

View File

@ -107,4 +107,7 @@ func initRouters() {
//external service that hosted on harbor process:
beego.Router("/service/notifications", &service.NotificationHandler{})
beego.Router("/service/token", &token.Handler{})
//Error pages
beego.ErrorController(&controllers.ErrorController{})
}

75
src/ui/views/404.tpl Normal file
View File

@ -0,0 +1,75 @@
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<title>404 - Page Not Found</title>
<style>
*{
maring: 0;
padding: 0;
}
a:link{
color: #1f3759;
text-decoration: none;
}
a:active{
color: #1f3759;
text-decoration: none;
}
a:hover{
color: #9fb7d9;
text-decoration: none;
}
a:visited{
color: #1f3759;
text-decoration: none;
}
a.underline, .underline{
text-decoration: underline;
}
#content{
margin: 0 auto;
width: 800px;
}
#main-body{
text-align: center;
}
.status-code {
font-weight: bolder;
font-size: 4em;
vertical-align: middle;
}
.status-text {
font-weight: bold;
font-size: 3em;
margin-left: 10px;
vertical-align: middle;
}
.status-subtitle {
font-size: 18px;
}
</style>
</head>
<body>
<div id="content">
<div id="main-body">
<div>
<span class="status-code">404</span>
<span class="status-text">Page Not Found</span>
</div>
<div class="status-subtitle">
<p> <a href="/harbor" class="underline">Home</p>
</div>
</div>
</div>
</body>
</html>