Better licences page

This commit is contained in:
William Bouzourène 2025-01-17 13:53:59 +01:00
parent 150c289741
commit 8155b54f99
5 changed files with 1219 additions and 1046 deletions

View file

@ -29,3 +29,9 @@ func SetColorMode(c *fiber.Ctx) error {
colorMode, 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) SCRIPT_DIR=$(cd -- "$(dirname -- "${BASH_SOURCE[0]}")" &> /dev/null && pwd)
TPL_LOCATION="$SCRIPT_DIR/template.html" 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" PROJECT_URL="git.readonly.ch/bouzoure/pop-camarades"
go-licenses report "$PROJECT_URL" --template "$TPL_LOCATION" > "$STATIC_LOCATION" go-licenses report "$PROJECT_URL" --template "$TPL_LOCATION" > "$STATIC_LOCATION"

View file

@ -1,39 +1,29 @@
<!DOCTYPE html> {% extends "layouts/main.html" %}
<html lang="en">
<head> {% block main %}
<meta charset="UTF-8"> <div class="container">
<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>
{{ range . }} {{ range . }}
<div> <div class="my-5">
<h3>{{ .Name }}</h3> <span class="h3 my-3">
<ul> {{ .Name }}
<li>Name: {{ .Name }}</li> </span>
<li>Version: {{ .Version }}</li> <ul class="list-group my-3">
<li> <li class="list-group-item">
License: <b>Version:</b> {{ .Version }}
{{ if ne .LicenseURL "Unknown" }} </li>
<a href="{{ .LicenseURL }}"> <li class="list-group-item">
<b>License:</b>
{{ if ne .LicenseURL "Unknown" }}
<a href="{{ .LicenseURL }}">
{{ .LicenseName }}
</a>
{{ else }}
{{ .LicenseName }} {{ .LicenseName }}
</a> {{ end }}
{{ else }} </li>
{{ .LicenseName }} </ul>
{{ end }} <pre>{{ .LicenseText }}</pre>
</li> </div>
</ul>
<pre>{{ .LicenseText }}</pre>
</div>
{{ end }} {{ end }}
</body> </div>
</html> {% endblock %}

View file

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

File diff suppressed because it is too large Load diff