Compare commits

...

2 Commits

Author SHA1 Message Date
036e9fa4a1 Increased font size 2021-05-11 18:05:02 +01:00
262e4ec4d7 Updated server with better handling and caching 2021-05-11 17:48:47 +01:00
2 changed files with 26 additions and 12 deletions

19
main.go
View File

@ -11,8 +11,12 @@ import (
"time" "time"
"github.com/canhlinh/svg2png" "github.com/canhlinh/svg2png"
"github.com/gofiber/fiber/v2"
"github.com/patrickmn/go-cache" "github.com/patrickmn/go-cache"
"github.com/gofiber/fiber/v2"
"github.com/gofiber/fiber/v2/middleware/compress"
"github.com/gofiber/fiber/v2/middleware/cors"
"github.com/gofiber/fiber/v2/middleware/logger"
) )
//go:embed index.html svg.tmpl //go:embed index.html svg.tmpl
@ -21,7 +25,11 @@ var content embed.FS
func main() { func main() {
app := fiber.New() app := fiber.New()
ch := cache.New(5*24*time.Hour, 7*24*time.Hour) app.Use(compress.New())
app.Use(cors.New())
app.Use(logger.New())
ch := cache.New(6*time.Hour, 24*time.Hour)
app.Get("/", func(c *fiber.Ctx) error { app.Get("/", func(c *fiber.Ctx) error {
c.Type("html", "UTF8") c.Type("html", "UTF8")
@ -45,13 +53,14 @@ func main() {
key := generateKey(vars) key := generateKey(vars)
png, found := ch.Get(key) png, found := ch.Get(key)
if !found { if !found || len(png.([]byte)) == 0 {
var err error var err error
png, err = generateImage(vars) png, err = generateImage(vars)
if err != nil { if err != nil {
return err fmt.Println(err)
return c.SendStatus(500)
} }
ch.Set(key, png, -1) ch.Set(key, png, 0)
} }
c.Type("png") c.Type("png")

View File

@ -42,15 +42,19 @@
font-family: 'Roboto Bold'; font-family: 'Roboto Bold';
margin: 0; margin: 0;
position: fixed; position: fixed;
top: 80px; top: 100px;
left: 50px; left: 50px;
height: 300px; height: 300px;
width: 800px; width: 800px;
font-size: 70px; font-size: 80px;
font-weight: 900; font-weight: 900;
line-height: 70px; line-height: 75px;
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
display: -webkit-box !important;
-webkit-line-clamp: 4;
-webkit-box-orient: vertical;
white-space: normal;
} }
h2 { h2 {
font-family: 'Roboto Medium'; font-family: 'Roboto Medium';
@ -58,6 +62,7 @@
position: fixed; position: fixed;
top: 50px; top: 50px;
left: 50px; left: 50px;
font-size: 40px;
font-weight: 900; font-weight: 900;
} }
#profilePic { #profilePic {
@ -70,11 +75,11 @@
.tags { .tags {
position: fixed; position: fixed;
left: 50px; left: 50px;
top: 400px; top: 420px;
width: 800px; width: 800px;
height: 25px; height: 25px;
line-height: 25px; line-height: 25px;
font-size: 15px; font-size: 25px;
font-weight: 200; font-weight: 200;
display: flex; display: flex;
flex-direction: row; flex-direction: row;
@ -90,7 +95,7 @@
bottom: 25px; bottom: 25px;
height: 25px; height: 25px;
line-height: 25px; line-height: 25px;
font-size: 15px; font-size: 20px;
font-weight: 200; font-weight: 200;
display: flex; display: flex;
flex-direction: row; flex-direction: row;
@ -99,7 +104,7 @@
fill: var(--foreground-color); fill: var(--foreground-color);
} }
.social span { .social span {
margin: 0 3px; margin: 0 5px;
} }
.social svg:not(:first-of-type) { .social svg:not(:first-of-type) {
margin-left: 20px; margin-left: 20px;