adding template engine
This commit is contained in:
parent
05c529eafa
commit
97b2901e7d
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,18 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
{% include "header.html" %}
|
||||||
|
</head>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<div id="sidebar">
|
||||||
|
{% block sidebar %}
|
||||||
|
{% include "sidebar.html" %}
|
||||||
|
{% endblock %}
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="content">
|
||||||
|
{% block content %}{% endblock %}
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -3,14 +3,14 @@
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||||
|
|
||||||
<title>Gentallela Alela! | </title>
|
<title>{% block title %}Mnemonics{% endblock %}-Amuz.es</title>
|
||||||
|
|
||||||
<!-- Bootstrap core CSS -->
|
<!-- Bootstrap core CSS -->
|
||||||
|
|
||||||
<link href="css/bootstrap.min.css" rel="stylesheet">
|
<link href="static/css/bootstrap.min.css" rel="stylesheet">
|
||||||
|
|
||||||
<link href="fonts/css/font-awesome.min.css" rel="stylesheet">
|
<link href="static/fonts/css/font-awesome.min.css" rel="stylesheet">
|
||||||
<link href="css/animate.min.css" rel="stylesheet">
|
<link href="static/css/animate.min.css" rel="stylesheet">
|
||||||
|
|
||||||
<!--[if lt IE 9]>
|
<!--[if lt IE 9]>
|
||||||
<script src="../assets/js/ie8-responsive-file-warning.js"></script>
|
<script src="../assets/js/ie8-responsive-file-warning.js"></script>
|
||||||
|
|
|
@ -1,117 +1,118 @@
|
||||||
<!-- sidebar menu -->
|
<div class="col-md-3 left_col">
|
||||||
<div id="sidebar-menu" class="main_menu_side hidden-print main_menu">
|
<div class="left_col scroll-view">
|
||||||
|
|
||||||
<div class="menu_section">
|
<div class="navbar nav_title" style="border: 0;">
|
||||||
<h3>General</h3>
|
<a href="index.html" class="site_title">Gentellela Alela!</a>
|
||||||
<ul class="nav side-menu">
|
</div>
|
||||||
<li><a><i class="fa fa-home"></i> Home <span class="fa fa-chevron-down"></span></a>
|
|
||||||
<ul class="nav child_menu" style="display: none">
|
<div class="profile"><!--img_2 -->
|
||||||
<li><a href="index.html">Dashboard</a>
|
<div class="profile_pic">
|
||||||
</li>
|
<img src="images/img.jpg" alt="..." class="img-circle profile_img">
|
||||||
<li><a href="index2.html">Dashboard2</a>
|
</div>
|
||||||
</li>
|
<div class="profile_info">
|
||||||
<li><a href="index3.html">Dashboard3</a>
|
<span>Welcome,</span>
|
||||||
</li>
|
<h2>Anthony Mutisya</h2>
|
||||||
</ul>
|
</div>
|
||||||
</li>
|
</div>
|
||||||
<li><a><i class="fa fa-edit"></i> Forms <span class="fa fa-chevron-down"></span></a>
|
|
||||||
<ul class="nav child_menu" style="display: none">
|
<br>
|
||||||
<li><a href="form.html">General Form</a>
|
<div id="sidebar-menu" class="main_menu_side hidden-print main_menu">
|
||||||
</li>
|
|
||||||
<li><a href="form_advanced.html">Advanced Components</a>
|
<div class="menu_section">
|
||||||
</li>
|
<h3>General</h3>
|
||||||
<li><a href="form_validation.html">Form Validation</a>
|
<ul class="nav side-menu">
|
||||||
</li>
|
<li><a><i class="fa fa-home"></i> Home <span class="fa fa-chevron-down"></span></a>
|
||||||
<li><a href="form_wizards.html">Form Wizard</a>
|
<ul class="nav child_menu" style="display: none">
|
||||||
</li>
|
<li><a href="index.html">Dashboard</a></li>
|
||||||
<li><a href="form_upload.html">Form Upload</a>
|
<li><a href="index2.html">Dashboard2</a></li>
|
||||||
</li>
|
</ul>
|
||||||
<li><a href="form_buttons.html">Form Buttons</a>
|
</li>
|
||||||
</li>
|
<li><a><i class="fa fa-edit"></i> Forms <span class="fa fa-chevron-down"></span></a>
|
||||||
</ul>
|
<ul class="nav child_menu" style="display: none">
|
||||||
</li>
|
<li><a href="form.html">General Form</a></li>
|
||||||
<li><a><i class="fa fa-desktop"></i> UI Elements <span class="fa fa-chevron-down"></span></a>
|
<li><a href="form_advanced.html">Advanced Components</a></li>
|
||||||
<ul class="nav child_menu" style="display: none">
|
<li><a href="form_validation.html">Form Validation</a></li>
|
||||||
<li><a href="general_elements.html">General Elements</a>
|
<li><a href="form_wizards.html">Form Wizard</a></li>
|
||||||
</li>
|
<li><a href="form_upload.html">Form Upload</a></li>
|
||||||
<li><a href="media_gallery.html">Media Gallery</a>
|
<li><a href="form_buttons.html">Form Buttons</a></li>
|
||||||
</li>
|
</ul>
|
||||||
<li><a href="typography.html">Typography</a>
|
</li>
|
||||||
</li>
|
<li><a><i class="fa fa-desktop"></i> UI Elements <span class="fa fa-chevron-down"></span></a>
|
||||||
<li><a href="icons.html">Icons</a>
|
<ul class="nav child_menu" style="display: none">
|
||||||
</li>
|
<li><a href="general_elements.html">General Elements</a></li>
|
||||||
<li><a href="glyphicons.html">Glyphicons</a>
|
<li><a href="media_gallery.html">Media Gallery</a></li>
|
||||||
</li>
|
<li><a href="typography.html">Typography</a></li>
|
||||||
<li><a href="widgets.html">Widgets</a>
|
<li><a href="icons.html">Icons</a></li>
|
||||||
</li>
|
<li><a href="glyphicons.html">Glyphicons</a></li>
|
||||||
<li><a href="invoice.html">Invoice</a>
|
<li><a href="widgets.html">Widgets</a></li>
|
||||||
</li>
|
<li><a href="invoice.html">Invoice</a></li>
|
||||||
<li><a href="inbox.html">Inbox</a>
|
<li><a href="inbox.html">Inbox</a></li>
|
||||||
</li>
|
<li><a href="calender.html">Calender</a></li>
|
||||||
<li><a href="calender.html">Calender</a>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
<li><a><i class="fa fa-table"></i> Tables <span class="fa fa-chevron-down"></span></a>
|
||||||
</li>
|
<ul class="nav child_menu" style="display: none">
|
||||||
<li><a><i class="fa fa-table"></i> Tables <span class="fa fa-chevron-down"></span></a>
|
<li><a href="tables.html">Tables</a></li>
|
||||||
<ul class="nav child_menu" style="display: none">
|
<li><a href="tables_dynamic.html">Table Dynamic</a></li>
|
||||||
<li><a href="tables.html">Tables</a>
|
</ul>
|
||||||
</li>
|
</li>
|
||||||
<li><a href="tables_dynamic.html">Table Dynamic</a>
|
<li><a><i class="fa fa-bar-chart-o"></i> Data Presentation <span class="fa fa-chevron-down"></span></a>
|
||||||
</li>
|
<ul class="nav child_menu" style="display: none">
|
||||||
</ul>
|
<li><a href="chartjs.html">Chart JS</a></li>
|
||||||
</li>
|
<li><a href="chartjs2.html">Chart JS2</a></li>
|
||||||
<li><a><i class="fa fa-bar-chart-o"></i> Data Presentation <span class="fa fa-chevron-down"></span></a>
|
<li><a href="morisjs.html">Moris JS</a></li>
|
||||||
<ul class="nav child_menu" style="display: none">
|
<li><a href="echarts.html">ECharts </a></li>
|
||||||
<li><a href="chartjs.html">Chart JS</a>
|
<li><a href="other_charts.html">Other Charts </a></li>
|
||||||
</li>
|
</ul>
|
||||||
<li><a href="chartjs2.html">Chart JS2</a>
|
</li>
|
||||||
</li>
|
</ul>
|
||||||
<li><a href="morisjs.html">Moris JS</a>
|
</div>
|
||||||
</li>
|
<div class="menu_section">
|
||||||
<li><a href="echarts.html">ECharts </a>
|
<h3>Live On</h3>
|
||||||
</li>
|
<ul class="nav side-menu">
|
||||||
<li><a href="other_charts.html">Other Charts </a>
|
<li><a><i class="fa fa-bug"></i> Additional Pages <span class="fa fa-chevron-down"></span></a>
|
||||||
</li>
|
<ul class="nav child_menu" style="display: none">
|
||||||
</ul>
|
<li><a href="e_commerce.html">E-commerce</a></li>
|
||||||
</li>
|
<li><a href="e_commerce_backend.html">E-commerce Backend</a></li>
|
||||||
</ul>
|
<li><a href="projects.html">Projects</a></li>
|
||||||
</div>
|
<li><a href="project_detail.html">Project Detail</a></li>
|
||||||
<div class="menu_section">
|
<li><a href="contacts.html">Contacts</a></li>
|
||||||
<h3>Live On</h3>
|
<li><a href="profile.html">Profile</a></li>
|
||||||
<ul class="nav side-menu">
|
<li><a href="real_estate.html">Real Estate</a></li>
|
||||||
<li><a><i class="fa fa-bug"></i> Additional Pages <span class="fa fa-chevron-down"></span></a>
|
|
||||||
<ul class="nav child_menu" style="display: none">
|
</ul>
|
||||||
<li><a href="e_commerce.html">E-commerce</a>
|
</li>
|
||||||
</li>
|
<li><a><i class="fa fa-windows"></i> Extras <span class="fa fa-chevron-down"></span></a>
|
||||||
<li><a href="projects.html">Projects</a>
|
<ul class="nav child_menu" style="display: none">
|
||||||
</li>
|
<li><a href="page_404.html">404 Error</a></li>
|
||||||
<li><a href="project_detail.html">Project Detail</a>
|
<li><a href="page_500.html">500 Error</a></li>
|
||||||
</li>
|
<li><a href="coming_soon.html">Coming Soon</a></li>
|
||||||
<li><a href="contacts.html">Contacts</a>
|
<li><a href="plain_page.html">Plain Page</a></li>
|
||||||
</li>
|
<li><a href="login.html">Login Page</a></li>
|
||||||
<li><a href="profile.html">Profile</a>
|
<li><a href="sign_up.html">SignUp Page</a></li>
|
||||||
</li>
|
<li><a href="pricing_tables.html">Pricing Tables</a></li>
|
||||||
</ul>
|
|
||||||
</li>
|
</ul>
|
||||||
<li><a><i class="fa fa-windows"></i> Extras <span class="fa fa-chevron-down"></span></a>
|
</li>
|
||||||
<ul class="nav child_menu" style="display: none">
|
<li><a><i class="fa fa-laptop"></i> Landing Page <span class="label label-success pull-right">Coming Soon</span></a></li>
|
||||||
<li><a href="page_404.html">404 Error</a>
|
</ul>
|
||||||
</li>
|
</div>
|
||||||
<li><a href="page_500.html">500 Error</a>
|
|
||||||
</li>
|
</div>
|
||||||
<li><a href="plain_page.html">Plain Page</a>
|
|
||||||
</li>
|
<div class="sidebar-footer hidden-small">
|
||||||
<li><a href="login.html">Login Page</a>
|
<a data-toggle="tooltip" data-placement="top" title="Settings">
|
||||||
</li>
|
<span class="glyphicon glyphicon-cog" aria-hidden="true"></span>
|
||||||
<li><a href="pricing_tables.html">Pricing Tables</a>
|
</a>
|
||||||
</li>
|
<a data-toggle="tooltip" data-placement="top" title="FullScreen">
|
||||||
|
<span class="glyphicon glyphicon-fullscreen" aria-hidden="true"></span>
|
||||||
</ul>
|
</a>
|
||||||
</li>
|
<a data-toggle="tooltip" data-placement="top" title="Lock">
|
||||||
<li><a><i class="fa fa-laptop"></i> Landing Page <span class="label label-success pull-right">Coming Soon</span></a>
|
<span class="glyphicon glyphicon-eye-close" aria-hidden="true"></span>
|
||||||
</li>
|
</a>
|
||||||
</ul>
|
<a data-toggle="tooltip" data-placement="top" title="Logout">
|
||||||
</div>
|
<span class="glyphicon glyphicon-off" aria-hidden="true"></span>
|
||||||
|
</a>
|
||||||
</div>
|
</div>
|
||||||
<!-- /sidebar menu -->
|
</div>
|
||||||
|
</div>
|
11
main.go
11
main.go
|
@ -17,7 +17,6 @@ package main
|
||||||
import (
|
import (
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
"github.com/Sirupsen/logrus"
|
"github.com/Sirupsen/logrus"
|
||||||
"github.com/gin-gonic/contrib/ginrus"
|
|
||||||
"runtime"
|
"runtime"
|
||||||
"time"
|
"time"
|
||||||
"flag"
|
"flag"
|
||||||
|
@ -31,6 +30,7 @@ import (
|
||||||
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")
|
||||||
var argPort = flag.Int("port", 8080, "port to listen")
|
var argPort = flag.Int("port", 8080, "port to listen")
|
||||||
var maxProcs = flag.Int("max_procs", 0, "max number of CPUs that can be used simultaneously. Less than 1 for default (number of cores).")
|
var maxProcs = flag.Int("max_procs", 0, "max number of CPUs that can be used simultaneously. Less than 1 for default (number of cores).")
|
||||||
|
var logger = logrus.New()
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
@ -38,7 +38,7 @@ func main() {
|
||||||
r := gin.New()
|
r := gin.New()
|
||||||
|
|
||||||
|
|
||||||
r.Use(ginrus.Ginrus(logrus.StandardLogger(), time.RFC3339, true))
|
r.Use(util.Ginrus(logrus.StandardLogger(), time.RFC3339, true))
|
||||||
|
|
||||||
r.Use(gin.Recovery())
|
r.Use(gin.Recovery())
|
||||||
|
|
||||||
|
@ -47,10 +47,9 @@ func main() {
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
logger := logrus.New()
|
|
||||||
logger.Level = logrus.ErrorLevel
|
logger.Level = logrus.ErrorLevel
|
||||||
logger.SetOutput(os.Stderr)
|
logger.Out=os.Stderr
|
||||||
r.Use(ginrus.Ginrus(logger, time.RFC3339, false))
|
r.Use(util.Ginrus(logger, time.RFC3339, false))
|
||||||
r.StaticFS("/static", route.Static(""))
|
r.StaticFS("/static", route.Static(""))
|
||||||
|
|
||||||
r.GET("/api", route.Api)
|
r.GET("/api", route.Api)
|
||||||
|
@ -84,6 +83,6 @@ func setMaxProcs() {
|
||||||
// Check if the setting was successful.
|
// Check if the setting was successful.
|
||||||
actualNumProcs := runtime.GOMAXPROCS(0)
|
actualNumProcs := runtime.GOMAXPROCS(0)
|
||||||
if actualNumProcs != numProcs {
|
if actualNumProcs != numProcs {
|
||||||
logger.Warningf("Specified max procs of %v but using %v", numProcs, actualNumProcs)
|
logger.Warnf("Specified max procs of %v but using %v", numProcs, actualNumProcs)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,51 @@
|
||||||
|
// Package ginrus provides log handling using logrus package.
|
||||||
|
//
|
||||||
|
// Based on github.com/stephenmuss/ginerus but adds more options.
|
||||||
|
package util
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/Sirupsen/logrus"
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Ginrus returns a gin.HandlerFunc (middleware) that logs requests using logrus.
|
||||||
|
//
|
||||||
|
// Requests with errors are logged using logrus.Error().
|
||||||
|
// Requests without errors are logged using logrus.Info().
|
||||||
|
//
|
||||||
|
// It receives:
|
||||||
|
// 1. A time package format string (e.g. time.RFC3339).
|
||||||
|
// 2. A boolean stating whether to use UTC time zone or local.
|
||||||
|
func Ginrus(logger *logrus.Logger, timeFormat string, utc bool) gin.HandlerFunc {
|
||||||
|
return func(c *gin.Context) {
|
||||||
|
start := time.Now()
|
||||||
|
// some evil middlewares modify this values
|
||||||
|
path := c.Request.URL.Path
|
||||||
|
c.Next()
|
||||||
|
|
||||||
|
end := time.Now()
|
||||||
|
latency := end.Sub(start)
|
||||||
|
if utc {
|
||||||
|
end = end.UTC()
|
||||||
|
}
|
||||||
|
|
||||||
|
entry := logger.WithFields(logrus.Fields{
|
||||||
|
"status": c.Writer.Status(),
|
||||||
|
"method": c.Request.Method,
|
||||||
|
"path": path,
|
||||||
|
"ip": c.ClientIP(),
|
||||||
|
"latency": latency,
|
||||||
|
"user-agent": c.Request.UserAgent(),
|
||||||
|
"time": end.Format(timeFormat),
|
||||||
|
})
|
||||||
|
|
||||||
|
if len(c.Errors) > 0 {
|
||||||
|
// Append error field if this is an erroneous request.
|
||||||
|
entry.Error(c.Errors.String())
|
||||||
|
} else {
|
||||||
|
entry.Info()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue