Better licences page

This commit is contained in:
William Bouzourène 2025-01-17 13:53:59 +01:00
parent b7f0d6f8b2
commit e550278056
Signed by: bouzoure
SSH key fingerprint: SHA256:19MbXpLua4rUtk8tunMesD8KUKb91LXLHg8E/qTooww
5 changed files with 1219 additions and 1046 deletions

View file

@ -29,3 +29,9 @@ func SetColorMode(c *fiber.Ctx) error {
colorMode,
))
}
func Licences(c *fiber.Ctx) error {
return c.Render("licences", fiber.Map{
"PageTitle": "Licences",
})
}

View file

@ -2,7 +2,7 @@
SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)
TPL_LOCATION="$SCRIPT_DIR/template.html"
STATIC_LOCATION="$SCRIPT_DIR/../static/licences.html"
STATIC_LOCATION="$SCRIPT_DIR/../views/licences.html"
PROJECT_URL="git.readonly.ch/bouzoure/pop-camarades"
go-licenses report "$PROJECT_URL" --template "$TPL_LOCATION" > "$STATIC_LOCATION"

View file

@ -1,28 +1,18 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Licences</title>
<style>
body {
font-family: serif;
}
pre {
background-color: lightgrey;
padding: 5px;
}
</style>
</head>
<body>
{% extends "layouts/main.html" %}
{% block main %}
<div class="container">
{{ range . }}
<div>
<h3>{{ .Name }}</h3>
<ul>
<li>Name: {{ .Name }}</li>
<li>Version: {{ .Version }}</li>
<li>
License:
<div class="my-5">
<span class="h3 my-3">
{{ .Name }}
</span>
<ul class="list-group my-3">
<li class="list-group-item">
<b>Version:</b> {{ .Version }}
</li>
<li class="list-group-item">
<b>License:</b>
{{ if ne .LicenseURL "Unknown" }}
<a href="{{ .LicenseURL }}">
{{ .LicenseName }}
@ -35,5 +25,5 @@
<pre>{{ .LicenseText }}</pre>
</div>
{{ end }}
</body>
</html>
</div>
{% endblock %}

View file

@ -91,6 +91,10 @@ func main() {
// Misc endpoints without auth
app.Post("/set-color-mode", controllers.SetColorMode)
// Licences page
app.Use("/licences", middlewares.TemplatesMiddleware)
app.Get("/licences", controllers.Licences)
// Security middlewares
app.Use(middlewares.SavedSessionMiddleware)
app.Use(middlewares.AuthMiddleware)

File diff suppressed because it is too large Load diff