Footer with souce code link & generation time
This commit is contained in:
parent
da0114fbcb
commit
fdc1740126
5 changed files with 61 additions and 7 deletions
19
helpers/templates.go
Normal file
19
helpers/templates.go
Normal file
|
|
@ -0,0 +1,19 @@
|
||||||
|
package helpers
|
||||||
|
|
||||||
|
import (
|
||||||
|
"time"
|
||||||
|
|
||||||
|
"github.com/flosch/pongo2/v6"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TemplTimeDiff(in *pongo2.Value, param *pongo2.Value) (*pongo2.Value, *pongo2.Error) {
|
||||||
|
if !in.IsTime() {
|
||||||
|
return pongo2.AsSafeValue("invalid time"), nil
|
||||||
|
}
|
||||||
|
|
||||||
|
start := in.Time()
|
||||||
|
now := time.Now()
|
||||||
|
diff := now.Sub(start)
|
||||||
|
|
||||||
|
return pongo2.AsSafeValue(diff.Milliseconds()), nil
|
||||||
|
}
|
||||||
3
main.go
3
main.go
|
|
@ -10,6 +10,7 @@ import (
|
||||||
"git.readonly.ch/bouzoure/popvaud-people/controllers"
|
"git.readonly.ch/bouzoure/popvaud-people/controllers"
|
||||||
"git.readonly.ch/bouzoure/popvaud-people/helpers"
|
"git.readonly.ch/bouzoure/popvaud-people/helpers"
|
||||||
"git.readonly.ch/bouzoure/popvaud-people/middlewares"
|
"git.readonly.ch/bouzoure/popvaud-people/middlewares"
|
||||||
|
"github.com/flosch/pongo2/v6"
|
||||||
"github.com/gofiber/fiber/v2"
|
"github.com/gofiber/fiber/v2"
|
||||||
"github.com/gofiber/fiber/v2/middleware/filesystem"
|
"github.com/gofiber/fiber/v2/middleware/filesystem"
|
||||||
loggerMiddleware "github.com/gofiber/fiber/v2/middleware/logger"
|
loggerMiddleware "github.com/gofiber/fiber/v2/middleware/logger"
|
||||||
|
|
@ -67,6 +68,8 @@ func main() {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pongo2.RegisterFilter("time_diff", helpers.TemplTimeDiff)
|
||||||
|
|
||||||
app := fiber.New(fiber.Config{
|
app := fiber.New(fiber.Config{
|
||||||
Views: engine,
|
Views: engine,
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ package middlewares
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"time"
|
||||||
|
|
||||||
"git.readonly.ch/bouzoure/popvaud-people/helpers"
|
"git.readonly.ch/bouzoure/popvaud-people/helpers"
|
||||||
"git.readonly.ch/bouzoure/popvaud-people/models"
|
"git.readonly.ch/bouzoure/popvaud-people/models"
|
||||||
|
|
@ -15,10 +16,12 @@ type TemplatesGlobals struct {
|
||||||
UserEmail string
|
UserEmail string
|
||||||
UserFullname string
|
UserFullname string
|
||||||
UserIsAdmin bool
|
UserIsAdmin bool
|
||||||
|
TimeStart time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
func TemplatesMiddleware(c *fiber.Ctx) error {
|
func TemplatesMiddleware(c *fiber.Ctx) error {
|
||||||
globals := TemplatesGlobals{}
|
globals := TemplatesGlobals{}
|
||||||
|
globals.TimeStart = c.Context().Time()
|
||||||
|
|
||||||
sess, err := helpers.GetSessionStore(c)
|
sess, err := helpers.GetSessionStore(c)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
||||||
|
|
@ -31,4 +31,8 @@ a {
|
||||||
|
|
||||||
.item-click {
|
.item-click {
|
||||||
cursor: pointer;
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.text-bold {
|
||||||
|
font-weight: bold;
|
||||||
}
|
}
|
||||||
|
|
@ -1,5 +1,5 @@
|
||||||
<!doctype html>
|
<!doctype html>
|
||||||
<html lang="fr" data-bs-theme="dark">
|
<html lang="fr" class="h-100" data-bs-theme="dark">
|
||||||
{% include "partials/easter_egg.html" %}
|
{% include "partials/easter_egg.html" %}
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
|
|
@ -18,14 +18,39 @@
|
||||||
<link rel="stylesheet" href="/static/main.css">
|
<link rel="stylesheet" href="/static/main.css">
|
||||||
{% block stylesheet %}{% endblock %}
|
{% block stylesheet %}{% endblock %}
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body class="d-flex flex-column h-100">
|
||||||
{% block header %}
|
<main class="flex-shrink-0">
|
||||||
{% include "partials/header.html" %}
|
{% block body %}
|
||||||
{% endblock %}
|
{% block header %}
|
||||||
|
{% include "partials/header.html" %}
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
{% block main %}
|
{% block main %}{% endblock %}
|
||||||
<!-- Content goes here -->
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
</main>
|
||||||
|
|
||||||
|
<footer class="footer mt-auto py-2 bg-body-tertiary">
|
||||||
|
<div class="container">
|
||||||
|
<span class="text-body-secondary">
|
||||||
|
<a
|
||||||
|
class="link-secondary text-bold"
|
||||||
|
target="_blank"
|
||||||
|
href="https://git.readonly.ch/bouzoure/popvaud-people"
|
||||||
|
>
|
||||||
|
<i class="bi-code-slash"></i>
|
||||||
|
Code source
|
||||||
|
</a>
|
||||||
|
</span>
|
||||||
|
|
||||||
|
<div class="float-end">
|
||||||
|
<span class="text-body-secondary">
|
||||||
|
<i class="bi-stopwatch me-1"></i>
|
||||||
|
{{ Globals.TimeStart | time_diff }}
|
||||||
|
<span>ms</span>
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</footer>
|
||||||
|
|
||||||
<script src="/static/jquery/jquery.min.js"></script>
|
<script src="/static/jquery/jquery.min.js"></script>
|
||||||
<script src="/static/bootstrap/js/bootstrap.bundle.min.js"></script>
|
<script src="/static/bootstrap/js/bootstrap.bundle.min.js"></script>
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue