6 Commits

Author SHA1 Message Date
ae36903e73 add cups to path
All checks were successful
Go / build (push) Successful in 12m26s
2025-04-15 16:41:23 +02:00
1a5df21fa8 lazy load images
All checks were successful
Go / build (push) Successful in 12m52s
2025-04-15 15:54:41 +02:00
9c15514758 rename to zines
All checks were successful
Go / build (push) Successful in 12m28s
2025-04-15 14:10:00 +02:00
27cf7c37cf resize preview images on upload
Some checks failed
Go / build (push) Has been cancelled
2025-04-15 13:57:28 +02:00
03f1ce361a add missing return in registerhandler
All checks were successful
Go / build (push) Successful in 12m35s
2025-04-15 10:46:46 +02:00
c55cf4480b Merge pull request 'userhandling' (#16) from userhandling into master
All checks were successful
Go / build (push) Successful in 12m35s
Reviewed-on: #16
2025-04-15 01:06:11 +02:00
5 changed files with 26 additions and 3 deletions

View File

@@ -68,6 +68,9 @@ func (rc *shopItemController) GetById(c *gin.Context) {
ReplyOK(c, shopItem)
}
// this currently creates quite big preview images
// workaround is running the following command in the uploads folder:
// for file in *.png; do convert "$file" -resize 35% "$file"; done
func (rc *shopItemController) NewShopItemFromForm(ctx *gin.Context) (models.ShopItem, error) {
defaultImagePath := "static/img/zine.jpg"
name := ctx.PostForm("name")
@@ -106,6 +109,14 @@ func (rc *shopItemController) NewShopItemFromForm(ctx *gin.Context) (models.Shop
if err != nil {
fmt.Println("Error during pdftoppm: ", err.Error())
}
cmd2 := exec.Command("convert", dstImage, "-resize", "35%", dstImage)
_, err = cmd2.Output()
if err != nil {
fmt.Println("Error during resizing preview image: ", err.Error())
}
}
} else {
fmt.Println(err)
@@ -365,6 +376,13 @@ func (rc *shopItemController) AddItemsHandler(c *gin.Context) {
fmt.Println("Error during pdftoppm: ", err.Error())
}
cmd2 := exec.Command("convert", dstImage, "-resize", "35%", dstImage)
_, err = cmd2.Output()
if err != nil {
fmt.Println("Error during resizing preview image: ", err.Error())
}
category, err := models.ParseCategory("Zine")
if err != nil {
errorHandler(err)

View File

@@ -188,6 +188,7 @@ func (rc *UserController) RegisterHandler(c *gin.Context) {
}
c.HTML(http.StatusOK, "register.html", data)
return
}
tokenExists, err := repositories.Tokens.Exists(token)

View File

@@ -20,6 +20,8 @@
go
gotools
poppler_utils #get first pdf page to png
cups
imagemagick
tailwindcss
];
};
@@ -71,6 +73,8 @@
environment.systemPackages = [
zineshop-pkg
pkgs.poppler_utils #get first pdf page to png
pkgs.cups
pkgs.imagemagick
];
systemd.tmpfiles.rules = [
@@ -100,7 +104,7 @@
WorkingDirectory = "/var/lib/zineshop";
ExecStart = pkgs.writeScript "start-zineshop" ''
#! ${pkgs.bash}/bin/bash
PATH="$PATH:${lib.makeBinPath [ pkgs.poppler_utils ]}"
PATH="$PATH:${lib.makeBinPath [ pkgs.poppler_utils pkgs.cups pkgs.imagemagick ]}"
${zineshop-pkg}/bin/zineshop
'';
Restart = "on-failure";

View File

@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html lang="en">
<head>
<title>Zine Shop</title>
<title>Zines</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link href="/static/output.css" rel="stylesheet">

View File

@@ -8,7 +8,7 @@
<div class="myClass group relative">
<a href="/shopitems/{{ .ID }}">
<img src="/{{ .Image }}" alt="Product Image" class="aspect-4/5 mx-auto rounded bg-gray-200 object-cover group-hover:opacity-75 lg:aspect-auto lg:h-80">
<img loading="lazy" src="/{{ .Image }}" alt="Product Image" class="aspect-4/5 mx-auto rounded bg-gray-200 object-cover group-hover:opacity-75 lg:aspect-auto lg:h-80">
</a>
<div class="mt-4 flex justify-between">
<div>