parent
915953b1bd
commit
ac5e21d8ac
|
@ -1,5 +1,11 @@
|
||||||
|
$(window).on("backstretch.before", function () {
|
||||||
|
window.NProgress.start();
|
||||||
|
});
|
||||||
|
|
||||||
|
$(window).on("backstretch.after", function () {
|
||||||
|
window.NProgress.done();
|
||||||
|
});
|
||||||
jQuery(document).ready(function () {
|
jQuery(document).ready(function () {
|
||||||
var pageImage = "/static/error/404.jpg";
|
var pageImage = "/static/error/404.jpg";
|
||||||
jQuery.backstretch(pageImage);
|
jQuery.backstretch(pageImage, {speed: 400});
|
||||||
});
|
});
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
{% block body %}
|
{% block body %}
|
||||||
<header>
|
<header>
|
||||||
<nav role="navigation" class="cyan lighten-2">
|
<nav role="navigation" class="cyan lighten-2">
|
||||||
<div class="nav-wrapper container"><a href="/w/" class="brand-logo title center">mnemonics</a>
|
<div class="nav-wrapper container"><a href="/w/" class="brand-logo title">mnemonics</a>
|
||||||
<ul id="nav-mobile" class="left">
|
<ul id="nav-mobile" class="right">
|
||||||
<li><a href="/auth/logout">Sign out</a></li>
|
<li><a href="/auth/logout">Sign out</a></li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -27,38 +27,39 @@
|
||||||
|
|
||||||
|
|
||||||
<!--Import Google Icon Font-->
|
<!--Import Google Icon Font-->
|
||||||
<link type="text/css" rel="stylesheet" href="static/normalize.css-3.0.3/normalize.css" rel="stylesheet">
|
<link type="text/css" rel="stylesheet" href="/static/normalize.css-3.0.3/normalize.css" rel="stylesheet">
|
||||||
|
|
||||||
<link type="text/css" rel="stylesheet" href="static/material-design-icons-2.2.0/material-icons.css" rel="stylesheet">
|
<link type="text/css" rel="stylesheet" href="/static/material-design-icons-2.2.0/material-icons.css" rel="stylesheet">
|
||||||
<link type="text/css" rel="stylesheet" href="static/animate.css-3.5.1/animate.min.css" rel="stylesheet">
|
<link type="text/css" rel="stylesheet" href="/static/animate.css-3.5.1/animate.min.css" rel="stylesheet">
|
||||||
<link type="text/css" rel="stylesheet" href="static/nprogress-0.2.0/nprogress.css" rel="stylesheet">
|
<link type="text/css" rel="stylesheet" href="/static/nprogress-0.2.0/nprogress.css" rel="stylesheet">
|
||||||
|
|
||||||
<!--Import materialize.css-->
|
<!--Import materialize.css-->
|
||||||
<link type="text/css" rel="stylesheet" href="static/materialize-0.97.5/css/materialize.min.css" media="screen,projection"/>
|
<link type="text/css" rel="stylesheet" href="/static/materialize-0.97.5/css/materialize.min.css" media="screen,projection"/>
|
||||||
|
|
||||||
<script type="text/javascript" src="static/nprogress-0.2.0/nprogress.js"></script>
|
<script type="text/javascript" src="/static/nprogress-0.2.0/nprogress.js"></script>
|
||||||
<script>
|
<script>
|
||||||
|
NProgress.configure({ showSpinner: false });
|
||||||
NProgress.start();
|
NProgress.start();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<script type="text/javascript" src="static/es5-shim-4.5.7/es5-shim.min.js"></script>
|
<script type="text/javascript" src="/static/es5-shim-4.5.7/es5-shim.min.js"></script>
|
||||||
<script type="text/javascript" src="static/es5-shim-4.5.7/es5-sham.min.js"></script>
|
<script type="text/javascript" src="/static/es5-shim-4.5.7/es5-sham.min.js"></script>
|
||||||
<script type="text/javascript" src="static/json3-3.3.2/json3.min.js"></script>
|
<script type="text/javascript" src="/static/json3-3.3.2/json3.min.js"></script>
|
||||||
<script type="text/javascript" src="static/es6-shim-0.35.0/es6-shim.min.js"></script>
|
<script type="text/javascript" src="/static/es6-shim-0.35.0/es6-shim.min.js"></script>
|
||||||
<script type="text/javascript" src="static/es6-shim-0.35.0/es6-sham.min.js"></script>
|
<script type="text/javascript" src="/static/es6-shim-0.35.0/es6-sham.min.js"></script>
|
||||||
|
|
||||||
<!--[if lt IE 9]>
|
<!--[if lt IE 9]>
|
||||||
<script type="text/javascript" src="static/html5shiv-3.7.3/html5shiv.min.js"></script>
|
<script type="text/javascript" src="/static/html5shiv-3.7.3/html5shiv.min.js"></script>
|
||||||
<script type="text/javascript" src="static/respond-1.4.2/respond.min.js"></script>
|
<script type="text/javascript" src="/static/respond-1.4.2/respond.min.js"></script>
|
||||||
<script type="text/javascript" src="static/jquery-1.12.1/jquery.min.js"></script>
|
<script type="text/javascript" src="/static/jquery-1.12.1/jquery.min.js"></script>
|
||||||
<![endif]-->
|
<![endif]-->
|
||||||
<!--[if (gt IE 8)|!(IE)]><!-->
|
<!--[if (gt IE 8)|!(IE)]><!-->
|
||||||
<script type="text/javascript" src="static/jquery-2.2.1/jquery.min.js"></script>
|
<script type="text/javascript" src="/static/jquery-2.2.1/jquery.min.js"></script>
|
||||||
<!--<![endif]-->
|
<!--<![endif]-->
|
||||||
|
|
||||||
<script type="text/javascript" src="static/lodash-4.6.1/lodash.min.js"></script>
|
<script type="text/javascript" src="/static/lodash-4.6.1/lodash.min.js"></script>
|
||||||
|
|
||||||
<script type="text/javascript" src="static/materialize-0.97.5/js/materialize.min.js"></script>
|
<script type="text/javascript" src="/static/materialize-0.97.5/js/materialize.min.js"></script>
|
|
@ -1,8 +1,8 @@
|
||||||
{% extends "layout/base.html" %}
|
{% extends "layout/base.html" %}
|
||||||
{% block head_add_header %}
|
{% block head_add_header %}
|
||||||
<link type="text/css" rel="stylesheet" href="static/error/404.css" rel="stylesheet">
|
<link type="text/css" rel="stylesheet" href="/static/error/404.css" rel="stylesheet">
|
||||||
<script type="text/javascript" src="static/jquery-backstretch-2.0.4/jquery.backstretch.min.js"></script>
|
<script type="text/javascript" src="/static/jquery-backstretch-2.0.4/jquery.backstretch.min.js"></script>
|
||||||
<script type="text/javascript" src="static/error/404.js"></script>
|
<script type="text/javascript" src="/static/error/404.js"></script>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
{% block body %}
|
{% block body %}
|
||||||
|
@ -10,10 +10,12 @@
|
||||||
<section class="section active">
|
<section class="section active">
|
||||||
<header class="headline">
|
<header class="headline">
|
||||||
<div class="title">
|
<div class="title">
|
||||||
<h1></h1>
|
<h1>ERR {{statusCode }} : {{ statusMessage }}</h1>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
<p class="inner"></p>
|
<p class="inner">
|
||||||
|
request url {{ path }} is {{ statusMessage }}
|
||||||
|
</p>
|
||||||
|
|
||||||
<div class="backtomain">
|
<div class="backtomain">
|
||||||
<p><a href="/">Go back to the homepage</a></p>
|
<p><a href="/">Go back to the homepage</a></p>
|
||||||
|
|
18
main.go
18
main.go
|
@ -23,6 +23,7 @@ import (
|
||||||
"amuz.es/go/mnemonics/route"
|
"amuz.es/go/mnemonics/route"
|
||||||
"amuz.es/go/mnemonics/util"
|
"amuz.es/go/mnemonics/util"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
|
"gopkg.in/tylerb/graceful.v1"
|
||||||
)
|
)
|
||||||
|
|
||||||
var argIp = flag.String("listen_ip", "", "IP to listen on, defaults to all IPs")
|
var argIp = flag.String("listen_ip", "", "IP to listen on, defaults to all IPs")
|
||||||
|
@ -34,7 +35,7 @@ func main() {
|
||||||
setMaxProcs()
|
setMaxProcs()
|
||||||
util.InitLogger()
|
util.InitLogger()
|
||||||
|
|
||||||
// gin.SetMode(gin.ReleaseMode)
|
gin.SetMode(gin.ReleaseMode)
|
||||||
r := gin.New()
|
r := gin.New()
|
||||||
// middleware settings
|
// middleware settings
|
||||||
r.Use(util.Ginrus(time.RFC3339, true))
|
r.Use(util.Ginrus(time.RFC3339, true))
|
||||||
|
@ -42,13 +43,17 @@ func main() {
|
||||||
|
|
||||||
// not found handler
|
// not found handler
|
||||||
r.NoRoute(func(c *gin.Context) {
|
r.NoRoute(func(c *gin.Context) {
|
||||||
c.HTML(http.StatusOK, "page_404.html", util.Context{})
|
code := http.StatusNotFound
|
||||||
|
c.HTML(code, "page_404.html", util.Context{
|
||||||
|
"statusCode": code,
|
||||||
|
"statusMessage": http.StatusText(code),
|
||||||
|
"path": c.Request.URL.Path,
|
||||||
|
"method": c.Request.Method})
|
||||||
})
|
})
|
||||||
|
|
||||||
// suburl process
|
// suburl process
|
||||||
path := r.Group("/")
|
path := r.Group("/")
|
||||||
|
|
||||||
|
|
||||||
// handlers
|
// handlers
|
||||||
path.GET("/api", route.Api)
|
path.GET("/api", route.Api)
|
||||||
path.GET("/self", route.Self)
|
path.GET("/self", route.Self)
|
||||||
|
@ -69,7 +74,6 @@ func main() {
|
||||||
c.Redirect(http.StatusMovedPermanently, "/static/favicon/browserconfig.xml")
|
c.Redirect(http.StatusMovedPermanently, "/static/favicon/browserconfig.xml")
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
path.GET("/login", route.Login)
|
path.GET("/login", route.Login)
|
||||||
path.GET("/", route.Index)
|
path.GET("/", route.Index)
|
||||||
|
|
||||||
|
@ -85,7 +89,11 @@ func main() {
|
||||||
|
|
||||||
util.Log().Error("bootstrapped application")
|
util.Log().Error("bootstrapped application")
|
||||||
|
|
||||||
r.Run() // listen and server on 0.0.0.0:8080
|
// r.Run() // listen and server on 0.0.0.0:8080
|
||||||
|
|
||||||
|
graceful.Run(":8080", 10*time.Second, r)
|
||||||
|
|
||||||
|
util.Log().Error("byez")
|
||||||
}
|
}
|
||||||
|
|
||||||
func setMaxProcs() {
|
func setMaxProcs() {
|
||||||
|
|
|
@ -16,7 +16,7 @@ var logger = logrus.New()
|
||||||
|
|
||||||
func InitLogger() {
|
func InitLogger() {
|
||||||
// logging framework
|
// logging framework
|
||||||
logger.Level = logrus.ErrorLevel
|
logger.Level = logrus.DebugLevel
|
||||||
logger.Out = os.Stderr
|
logger.Out = os.Stderr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ func Ginrus(timeFormat string, utc bool) gin.HandlerFunc {
|
||||||
end = end.UTC()
|
end = end.UTC()
|
||||||
}
|
}
|
||||||
|
|
||||||
entry := logger.WithFields(logrus.Fields{
|
entry := Log().WithFields(logrus.Fields{
|
||||||
"status": c.Writer.Status(),
|
"status": c.Writer.Status(),
|
||||||
"method": c.Request.Method,
|
"method": c.Request.Method,
|
||||||
"path": path,
|
"path": path,
|
||||||
|
|
|
@ -84,9 +84,6 @@ func (m memoryTemplateLoader) Abs(base, name string) string {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (m memoryTemplateLoader) Get(path string) (io.Reader, error) {
|
func (m memoryTemplateLoader) Get(path string) (io.Reader, error) {
|
||||||
|
|
||||||
Log().Errorf("hello template %s", filepath.Clean(path))
|
|
||||||
// t := pongo2.Must(p.templateSet.FromFile(path.Join(p.Path, name)))
|
|
||||||
data, err := m.loaderFunc(filepath.Clean(path))
|
data, err := m.loaderFunc(filepath.Clean(path))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
if m.fallbackLoader != nil {
|
if m.fallbackLoader != nil {
|
||||||
|
|
Loading…
Reference in New Issue