Footer with souce code link & generation time
This commit is contained in:
parent
0aa5b42671
commit
8657bd26bd
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/helpers"
|
||||
"git.readonly.ch/bouzoure/popvaud-people/middlewares"
|
||||
"github.com/flosch/pongo2/v6"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
"github.com/gofiber/fiber/v2/middleware/filesystem"
|
||||
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{
|
||||
Views: engine,
|
||||
})
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package middlewares
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"git.readonly.ch/bouzoure/popvaud-people/helpers"
|
||||
"git.readonly.ch/bouzoure/popvaud-people/models"
|
||||
|
|
@ -15,10 +16,12 @@ type TemplatesGlobals struct {
|
|||
UserEmail string
|
||||
UserFullname string
|
||||
UserIsAdmin bool
|
||||
TimeStart time.Time
|
||||
}
|
||||
|
||||
func TemplatesMiddleware(c *fiber.Ctx) error {
|
||||
globals := TemplatesGlobals{}
|
||||
globals.TimeStart = c.Context().Time()
|
||||
|
||||
sess, err := helpers.GetSessionStore(c)
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -32,3 +32,7 @@ a {
|
|||
.item-click {
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.text-bold {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
<!doctype html>
|
||||
<html lang="fr" data-bs-theme="dark">
|
||||
<html lang="fr" class="h-100" data-bs-theme="dark">
|
||||
{% include "partials/easter_egg.html" %}
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
|
|
@ -18,14 +18,39 @@
|
|||
<link rel="stylesheet" href="/static/main.css">
|
||||
{% block stylesheet %}{% endblock %}
|
||||
</head>
|
||||
<body>
|
||||
<body class="d-flex flex-column h-100">
|
||||
<main class="flex-shrink-0">
|
||||
{% block body %}
|
||||
{% block header %}
|
||||
{% include "partials/header.html" %}
|
||||
{% endblock %}
|
||||
|
||||
{% block main %}
|
||||
<!-- Content goes here -->
|
||||
{% block main %}{% 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/bootstrap/js/bootstrap.bundle.min.js"></script>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue