2024-08-31 17:42:51 +02:00
|
|
|
package handlers
|
|
|
|
|
|
|
|
import (
|
2024-08-31 17:45:51 +02:00
|
|
|
"git.tijl.dev/tijl/tijl.dev-core/internal/user"
|
2024-08-31 17:42:51 +02:00
|
|
|
"git.tijl.dev/tijl/tijl.dev-core/modules/i18n"
|
|
|
|
"git.tijl.dev/tijl/tijl.dev-core/modules/web"
|
|
|
|
"github.com/gofiber/fiber/v2"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Service struct {
|
|
|
|
Name string
|
2024-09-04 23:03:23 +02:00
|
|
|
Slug string
|
2024-08-31 17:42:51 +02:00
|
|
|
Description string
|
|
|
|
Url string
|
|
|
|
InfoUrl string
|
|
|
|
Color string
|
|
|
|
Scale float64
|
|
|
|
}
|
|
|
|
|
2024-09-04 23:03:23 +02:00
|
|
|
var services = []Service{
|
|
|
|
{
|
2024-08-31 17:42:51 +02:00
|
|
|
Name: "Immich",
|
2024-09-04 23:03:23 +02:00
|
|
|
Slug: "immich",
|
2024-08-31 17:42:51 +02:00
|
|
|
Description: "...",
|
|
|
|
Url: "https://fotos.tijl.dev/photos",
|
|
|
|
InfoUrl: "https://immich.app",
|
|
|
|
Color: "white",
|
|
|
|
Scale: 0,
|
|
|
|
},
|
2024-09-04 23:03:23 +02:00
|
|
|
{
|
2024-08-31 17:42:51 +02:00
|
|
|
Name: "Element",
|
2024-09-04 23:03:23 +02:00
|
|
|
Slug: "element",
|
2024-08-31 17:42:51 +02:00
|
|
|
Description: "...",
|
|
|
|
Url: "https://element.tijl.dev",
|
|
|
|
InfoUrl: "https://matrix.org",
|
|
|
|
Color: "#0DBD8B",
|
|
|
|
Scale: 0.1,
|
|
|
|
},
|
2024-09-04 23:03:23 +02:00
|
|
|
{
|
2024-08-31 17:42:51 +02:00
|
|
|
Name: "Nextcloud",
|
2024-09-04 23:03:23 +02:00
|
|
|
Slug: "nextcloud",
|
2024-08-31 17:42:51 +02:00
|
|
|
Description: "...",
|
|
|
|
Url: "https://cloud.tijl.dev",
|
|
|
|
InfoUrl: "https://nextcloud.com",
|
|
|
|
Color: "#00679e",
|
|
|
|
Scale: -0.2,
|
|
|
|
},
|
2024-09-04 23:03:23 +02:00
|
|
|
{
|
|
|
|
Name: "Gitea",
|
|
|
|
Slug: "gitea",
|
|
|
|
Description: "...",
|
|
|
|
Url: "https://git.tijl.dev",
|
|
|
|
InfoUrl: "https://about.gitea.com",
|
|
|
|
Color: "white",
|
|
|
|
Scale: -0.2,
|
|
|
|
},
|
2024-08-31 17:42:51 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
func servicesHandler(c *fiber.Ctx) error {
|
|
|
|
data := *web.Common(c)
|
|
|
|
data["Title"] = i18n.Translate(c, "services")
|
|
|
|
data["Services"] = services
|
|
|
|
return c.Render("services", data, "layouts/base")
|
|
|
|
}
|
|
|
|
|
|
|
|
func serviceHandler(c *fiber.Ctx) error {
|
2024-08-31 17:45:51 +02:00
|
|
|
_, err := user.GetSession(c)
|
|
|
|
if err != nil {
|
|
|
|
return c.Next()
|
|
|
|
}
|
2024-09-05 00:07:05 +02:00
|
|
|
for _, service := range services {
|
|
|
|
if service.Slug == c.Params("service") {
|
|
|
|
return c.Redirect(service.Url)
|
2024-09-04 23:03:23 +02:00
|
|
|
}
|
2024-09-05 00:07:05 +02:00
|
|
|
}
|
2024-08-31 17:42:51 +02:00
|
|
|
return c.Next()
|
|
|
|
}
|
|
|
|
|
|
|
|
func serviceInfoHandler(c *fiber.Ctx) error {
|
2024-08-31 17:45:51 +02:00
|
|
|
_, err := user.GetSession(c)
|
|
|
|
if err != nil {
|
|
|
|
return c.Next()
|
|
|
|
}
|
2024-09-05 00:07:05 +02:00
|
|
|
for _, service := range services {
|
|
|
|
if service.Slug == c.Params("service") {
|
|
|
|
return c.Redirect(service.InfoUrl)
|
2024-09-04 23:03:23 +02:00
|
|
|
}
|
2024-09-05 00:07:05 +02:00
|
|
|
}
|
2024-08-31 17:42:51 +02:00
|
|
|
return c.Next()
|
|
|
|
}
|