Compare commits
No commits in common. "036e9fa4a1048c6d8bf8d8cc4b4b7dd56225fbf9" and "a9e9185b414b95ed770c33a2b9ea12b8e6807b4b" have entirely different histories.
036e9fa4a1
...
a9e9185b41
19
main.go
19
main.go
@ -11,12 +11,8 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/canhlinh/svg2png"
|
||||
"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"
|
||||
"github.com/patrickmn/go-cache"
|
||||
)
|
||||
|
||||
//go:embed index.html svg.tmpl
|
||||
@ -25,11 +21,7 @@ var content embed.FS
|
||||
|
||||
func main() {
|
||||
app := fiber.New()
|
||||
app.Use(compress.New())
|
||||
app.Use(cors.New())
|
||||
app.Use(logger.New())
|
||||
|
||||
ch := cache.New(6*time.Hour, 24*time.Hour)
|
||||
ch := cache.New(5*24*time.Hour, 7*24*time.Hour)
|
||||
|
||||
app.Get("/", func(c *fiber.Ctx) error {
|
||||
c.Type("html", "UTF8")
|
||||
@ -53,14 +45,13 @@ func main() {
|
||||
key := generateKey(vars)
|
||||
|
||||
png, found := ch.Get(key)
|
||||
if !found || len(png.([]byte)) == 0 {
|
||||
if !found {
|
||||
var err error
|
||||
png, err = generateImage(vars)
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
return c.SendStatus(500)
|
||||
return err
|
||||
}
|
||||
ch.Set(key, png, 0)
|
||||
ch.Set(key, png, -1)
|
||||
}
|
||||
|
||||
c.Type("png")
|
||||
|
19
svg.tmpl
19
svg.tmpl
@ -42,19 +42,15 @@
|
||||
font-family: 'Roboto Bold';
|
||||
margin: 0;
|
||||
position: fixed;
|
||||
top: 100px;
|
||||
top: 80px;
|
||||
left: 50px;
|
||||
height: 300px;
|
||||
width: 800px;
|
||||
font-size: 80px;
|
||||
font-size: 70px;
|
||||
font-weight: 900;
|
||||
line-height: 75px;
|
||||
line-height: 70px;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
display: -webkit-box !important;
|
||||
-webkit-line-clamp: 4;
|
||||
-webkit-box-orient: vertical;
|
||||
white-space: normal;
|
||||
}
|
||||
h2 {
|
||||
font-family: 'Roboto Medium';
|
||||
@ -62,7 +58,6 @@
|
||||
position: fixed;
|
||||
top: 50px;
|
||||
left: 50px;
|
||||
font-size: 40px;
|
||||
font-weight: 900;
|
||||
}
|
||||
#profilePic {
|
||||
@ -75,11 +70,11 @@
|
||||
.tags {
|
||||
position: fixed;
|
||||
left: 50px;
|
||||
top: 420px;
|
||||
top: 400px;
|
||||
width: 800px;
|
||||
height: 25px;
|
||||
line-height: 25px;
|
||||
font-size: 25px;
|
||||
font-size: 15px;
|
||||
font-weight: 200;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
@ -95,7 +90,7 @@
|
||||
bottom: 25px;
|
||||
height: 25px;
|
||||
line-height: 25px;
|
||||
font-size: 20px;
|
||||
font-size: 15px;
|
||||
font-weight: 200;
|
||||
display: flex;
|
||||
flex-direction: row;
|
||||
@ -104,7 +99,7 @@
|
||||
fill: var(--foreground-color);
|
||||
}
|
||||
.social span {
|
||||
margin: 0 5px;
|
||||
margin: 0 3px;
|
||||
}
|
||||
.social svg:not(:first-of-type) {
|
||||
margin-left: 20px;
|
||||
|
Loading…
Reference in New Issue
Block a user