1
0
Fork 0

adding template engine

This commit is contained in:
Sangbum Kim 2016-03-10 00:28:35 +09:00
parent 05c529eafa
commit 97b2901e7d
7 changed files with 1549 additions and 1474 deletions

File diff suppressed because it is too large Load Diff

1349
asset/template/index__.html Normal file

File diff suppressed because it is too large Load Diff

View File

@ -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>

View File

@ -3,14 +3,14 @@
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<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 -->
<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="css/animate.min.css" rel="stylesheet">
<link href="static/fonts/css/font-awesome.min.css" rel="stylesheet">
<link href="static/css/animate.min.css" rel="stylesheet">
<!--[if lt IE 9]>
<script src="../assets/js/ie8-responsive-file-warning.js"></script>

View File

@ -1,117 +1,118 @@
<!-- sidebar menu -->
<div id="sidebar-menu" class="main_menu_side hidden-print main_menu">
<div class="menu_section">
<h3>General</h3>
<ul class="nav side-menu">
<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">
<li><a href="index.html">Dashboard</a>
</li>
<li><a href="index2.html">Dashboard2</a>
</li>
<li><a href="index3.html">Dashboard3</a>
</li>
</ul>
</li>
<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">
<li><a href="form.html">General Form</a>
</li>
<li><a href="form_advanced.html">Advanced Components</a>
</li>
<li><a href="form_validation.html">Form Validation</a>
</li>
<li><a href="form_wizards.html">Form Wizard</a>
</li>
<li><a href="form_upload.html">Form Upload</a>
</li>
<li><a href="form_buttons.html">Form Buttons</a>
</li>
</ul>
</li>
<li><a><i class="fa fa-desktop"></i> UI Elements <span class="fa fa-chevron-down"></span></a>
<ul class="nav child_menu" style="display: none">
<li><a href="general_elements.html">General Elements</a>
</li>
<li><a href="media_gallery.html">Media Gallery</a>
</li>
<li><a href="typography.html">Typography</a>
</li>
<li><a href="icons.html">Icons</a>
</li>
<li><a href="glyphicons.html">Glyphicons</a>
</li>
<li><a href="widgets.html">Widgets</a>
</li>
<li><a href="invoice.html">Invoice</a>
</li>
<li><a href="inbox.html">Inbox</a>
</li>
<li><a href="calender.html">Calender</a>
</li>
</ul>
</li>
<li><a><i class="fa fa-table"></i> Tables <span class="fa fa-chevron-down"></span></a>
<ul class="nav child_menu" style="display: none">
<li><a href="tables.html">Tables</a>
</li>
<li><a href="tables_dynamic.html">Table Dynamic</a>
</li>
</ul>
</li>
<li><a><i class="fa fa-bar-chart-o"></i> Data Presentation <span class="fa fa-chevron-down"></span></a>
<ul class="nav child_menu" style="display: none">
<li><a href="chartjs.html">Chart JS</a>
</li>
<li><a href="chartjs2.html">Chart JS2</a>
</li>
<li><a href="morisjs.html">Moris JS</a>
</li>
<li><a href="echarts.html">ECharts </a>
</li>
<li><a href="other_charts.html">Other Charts </a>
</li>
</ul>
</li>
</ul>
<div class="col-md-3 left_col">
    <div class="left_col scroll-view">
 
        <div class="navbar nav_title" style="border: 0;">
            <a href="index.html" class="site_title">Gentellela Alela!</a>
        </div>
 
        <div class="profile"><!--img_2 -->
            <div class="profile_pic">
                <img src="images/img.jpg" alt="..." class="img-circle profile_img">
            </div>
            <div class="profile_info">
                <span>Welcome,</span>
                <h2>Anthony Mutisya</h2>
            </div>
        </div>
 
        <br>
        <div id="sidebar-menu" class="main_menu_side hidden-print main_menu">
 
            <div class="menu_section">
                <h3>General</h3>
                <ul class="nav side-menu">
                    <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">
                            <li><a href="index.html">Dashboard</a></li>
                            <li><a href="index2.html">Dashboard2</a></li>
                        </ul>
                    </li>
                    <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">
                            <li><a href="form.html">General Form</a></li>
                            <li><a href="form_advanced.html">Advanced Components</a></li>
                            <li><a href="form_validation.html">Form Validation</a></li>
                            <li><a href="form_wizards.html">Form Wizard</a></li>
                            <li><a href="form_upload.html">Form Upload</a></li>
                            <li><a href="form_buttons.html">Form Buttons</a></li>
                        </ul>
                    </li>
                    <li><a><i class="fa fa-desktop"></i> UI Elements <span class="fa fa-chevron-down"></span></a>
                        <ul class="nav child_menu" style="display: none">
                            <li><a href="general_elements.html">General Elements</a></li>
                            <li><a href="media_gallery.html">Media Gallery</a></li>
                            <li><a href="typography.html">Typography</a></li>
                            <li><a href="icons.html">Icons</a></li>
                            <li><a href="glyphicons.html">Glyphicons</a></li>
                            <li><a href="widgets.html">Widgets</a></li>
                            <li><a href="invoice.html">Invoice</a></li>
                            <li><a href="inbox.html">Inbox</a></li>
                            <li><a href="calender.html">Calender</a></li>
                        </ul>
                    </li>
                    <li><a><i class="fa fa-table"></i> Tables <span class="fa fa-chevron-down"></span></a>
                        <ul class="nav child_menu" style="display: none">
                            <li><a href="tables.html">Tables</a></li>
                            <li><a href="tables_dynamic.html">Table Dynamic</a></li>
                        </ul>
                    </li>
                    <li><a><i class="fa fa-bar-chart-o"></i> Data Presentation <span class="fa fa-chevron-down"></span></a>
                        <ul class="nav child_menu" style="display: none">
                            <li><a href="chartjs.html">Chart JS</a></li>
                            <li><a href="chartjs2.html">Chart JS2</a></li>
                            <li><a href="morisjs.html">Moris JS</a></li>
                            <li><a href="echarts.html">ECharts </a></li>
                            <li><a href="other_charts.html">Other Charts </a></li>
                        </ul>
                    </li>
                </ul>
            </div>
            <div class="menu_section">
                <h3>Live On</h3>
                <ul class="nav side-menu">
                    <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">
                            <li><a href="e_commerce.html">E-commerce</a></li>
                            <li><a href="e_commerce_backend.html">E-commerce Backend</a></li>
                            <li><a href="projects.html">Projects</a></li>
                            <li><a href="project_detail.html">Project Detail</a></li>
                            <li><a href="contacts.html">Contacts</a></li>
                            <li><a href="profile.html">Profile</a></li>
                            <li><a href="real_estate.html">Real Estate</a></li>
 
                        </ul>
                    </li>
                    <li><a><i class="fa fa-windows"></i> Extras <span class="fa fa-chevron-down"></span></a>
                        <ul class="nav child_menu" style="display: none">
                            <li><a href="page_404.html">404 Error</a></li>
                            <li><a href="page_500.html">500 Error</a></li>
                            <li><a href="coming_soon.html">Coming Soon</a></li>
                            <li><a href="plain_page.html">Plain Page</a></li>
                            <li><a href="login.html">Login Page</a></li>
                            <li><a href="sign_up.html">SignUp Page</a></li>
                            <li><a href="pricing_tables.html">Pricing Tables</a></li>
 
                        </ul>
                    </li>
                    <li><a><i class="fa fa-laptop"></i> Landing Page <span class="label label-success pull-right">Coming Soon</span></a></li>
                </ul>
            </div>
 
        </div>
 
        <div class="sidebar-footer hidden-small">
            <a data-toggle="tooltip" data-placement="top" title="Settings">
                <span class="glyphicon glyphicon-cog" aria-hidden="true"></span>
            </a>
            <a data-toggle="tooltip" data-placement="top" title="FullScreen">
                <span class="glyphicon glyphicon-fullscreen" aria-hidden="true"></span>
            </a>
            <a data-toggle="tooltip" data-placement="top" title="Lock">
                <span class="glyphicon glyphicon-eye-close" aria-hidden="true"></span>
            </a>
            <a data-toggle="tooltip" data-placement="top" title="Logout">
                <span class="glyphicon glyphicon-off" aria-hidden="true"></span>
            </a>
        </div>
    </div>
</div>
<div class="menu_section">
<h3>Live On</h3>
<ul class="nav side-menu">
<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">
<li><a href="e_commerce.html">E-commerce</a>
</li>
<li><a href="projects.html">Projects</a>
</li>
<li><a href="project_detail.html">Project Detail</a>
</li>
<li><a href="contacts.html">Contacts</a>
</li>
<li><a href="profile.html">Profile</a>
</li>
</ul>
</li>
<li><a><i class="fa fa-windows"></i> Extras <span class="fa fa-chevron-down"></span></a>
<ul class="nav child_menu" style="display: none">
<li><a href="page_404.html">404 Error</a>
</li>
<li><a href="page_500.html">500 Error</a>
</li>
<li><a href="plain_page.html">Plain Page</a>
</li>
<li><a href="login.html">Login Page</a>
</li>
<li><a href="pricing_tables.html">Pricing Tables</a>
</li>
</ul>
</li>
<li><a><i class="fa fa-laptop"></i> Landing Page <span class="label label-success pull-right">Coming Soon</span></a>
</li>
</ul>
</div>
</div>
<!-- /sidebar menu -->

11
main.go
View File

@ -17,7 +17,6 @@ package main
import (
"github.com/gin-gonic/gin"
"github.com/Sirupsen/logrus"
"github.com/gin-gonic/contrib/ginrus"
"runtime"
"time"
"flag"
@ -31,6 +30,7 @@ import (
var argIp = flag.String("listen_ip", "", "IP to listen on, defaults to all IPs")
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 logger = logrus.New()
func main() {
flag.Parse()
@ -38,7 +38,7 @@ func main() {
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())
@ -47,10 +47,9 @@ func main() {
})
logger := logrus.New()
logger.Level = logrus.ErrorLevel
logger.SetOutput(os.Stderr)
r.Use(ginrus.Ginrus(logger, time.RFC3339, false))
logger.Out=os.Stderr
r.Use(util.Ginrus(logger, time.RFC3339, false))
r.StaticFS("/static", route.Static(""))
r.GET("/api", route.Api)
@ -84,6 +83,6 @@ func setMaxProcs() {
// Check if the setting was successful.
actualNumProcs := runtime.GOMAXPROCS(0)
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)
}
}

51
util/ginrus.go Normal file
View File

@ -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()
}
}
}