Compare commits
39 Commits
37ffeaa0f3
...
trifold
| Author | SHA1 | Date | |
|---|---|---|---|
|
977926a059
|
|||
|
8f89c14961
|
|||
|
6f5c0354cc
|
|||
|
6ef7c53001
|
|||
|
d4e7401586
|
|||
|
1688e61ccb
|
|||
|
861343b338
|
|||
|
68c8654bf3
|
|||
|
e62a45372f
|
|||
|
d17c33f6ee
|
|||
|
ae36903e73
|
|||
|
1a5df21fa8
|
|||
|
9c15514758
|
|||
|
27cf7c37cf
|
|||
|
03f1ce361a
|
|||
| c55cf4480b | |||
|
bcbb091dfb
|
|||
|
adfb3df283
|
|||
|
1525f44687
|
|||
|
3955d8626a
|
|||
|
6d63e53200
|
|||
|
cca0b2775c
|
|||
|
98c75c111f
|
|||
|
b2735e178f
|
|||
|
1c9fc230b1
|
|||
|
6c2b3964fe
|
|||
|
19ce41aca7
|
|||
|
763bb35a45
|
|||
|
6130843aa7
|
|||
|
667c3eba13
|
|||
|
e22cc0b243
|
|||
|
202c845bee
|
|||
|
d839416fdd
|
|||
|
821f4e526f
|
|||
|
9d2819cac4
|
|||
|
fd46f35023
|
|||
|
6943e3c9b7
|
|||
|
a90131c8be
|
|||
|
a04d057bce
|
@@ -1,19 +1,17 @@
|
||||
name: "Build"
|
||||
on:
|
||||
push:
|
||||
env:
|
||||
HOME: /tmp
|
||||
name: Go
|
||||
on: [push]
|
||||
|
||||
jobs:
|
||||
test:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- name: Install dependencies for Nix setup action
|
||||
with:
|
||||
enable_kvm: true
|
||||
extra_nix_config: "system-features = nixos-test benchmark big-parallel kvm"
|
||||
run: |
|
||||
apt update -y
|
||||
apt install sudo -y
|
||||
- uses: cachix/install-nix-action@v31
|
||||
- run: nix build .#
|
||||
- uses: actions/checkout@v4
|
||||
- name: Setup Go
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: '1.24.x'
|
||||
- name: Install dependencies
|
||||
run: go get .
|
||||
- name: Build
|
||||
run: go build -v ./...
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"encoding/hex"
|
||||
"errors"
|
||||
"fmt"
|
||||
"net/http"
|
||||
@@ -15,6 +13,7 @@ import (
|
||||
"git.dynamicdiscord.de/kalipso/zineshop/models"
|
||||
//"git.dynamicdiscord.de/kalipso/zineshop/services"
|
||||
"git.dynamicdiscord.de/kalipso/zineshop/repositories"
|
||||
"git.dynamicdiscord.de/kalipso/zineshop/utils"
|
||||
)
|
||||
|
||||
type CartItemController interface {
|
||||
@@ -53,15 +52,6 @@ func getSetCookieValue(c *gin.Context, cookieName string) string {
|
||||
return "" // Return empty string if cookie is not found
|
||||
}
|
||||
|
||||
func generateSessionId(length int) string {
|
||||
bytes := make([]byte, length) // 16 bytes = 128 bits
|
||||
_, err := rand.Read(bytes)
|
||||
if err != nil {
|
||||
panic("failed to generate session ID")
|
||||
}
|
||||
return hex.EncodeToString(bytes)
|
||||
}
|
||||
|
||||
func GetSessionId(ctx *gin.Context) string {
|
||||
sessionId, err := ctx.Cookie("session_id")
|
||||
|
||||
@@ -73,17 +63,13 @@ func GetSessionId(ctx *gin.Context) string {
|
||||
return responseCookie
|
||||
}
|
||||
|
||||
sessionId = generateSessionId(16)
|
||||
sessionId = utils.GenerateSessionId(16)
|
||||
ctx.SetCookie("session_id", sessionId, 3600, "/", "", false, true)
|
||||
}
|
||||
|
||||
return sessionId
|
||||
}
|
||||
|
||||
func GenerateToken() string {
|
||||
return generateSessionId(16)
|
||||
}
|
||||
|
||||
func (rc *cartItemController) NewCartItemFromForm(ctx *gin.Context) (models.CartItem, error) {
|
||||
sessionId := GetSessionId(ctx)
|
||||
shopItemIdStr := ctx.PostForm("ShopItemId")
|
||||
@@ -162,7 +148,7 @@ func (rc *cartItemController) NewAddressFromForm(ctx *gin.Context) (models.Addre
|
||||
func (rc *cartItemController) NewOrderFromForm(ctx *gin.Context) (models.Order, error) {
|
||||
sessionId := GetSessionId(ctx)
|
||||
status := models.OrderStatus("AwaitingConfirmation")
|
||||
token := GenerateToken()
|
||||
token := utils.GenerateToken()
|
||||
email := ctx.PostForm("email")
|
||||
comment := ctx.PostForm("comment")
|
||||
firstName := ctx.PostForm("firstName")
|
||||
@@ -337,6 +323,27 @@ func (rc *cartItemController) EditItemHandler(c *gin.Context) {
|
||||
|
||||
action := c.PostForm("action")
|
||||
|
||||
if action == "setAmount" {
|
||||
amountStr := c.PostForm("amount")
|
||||
amount, err := strconv.Atoi(amountStr)
|
||||
|
||||
if err != nil {
|
||||
c.HTML(http.StatusBadRequest, "error.html", gin.H{"error": err})
|
||||
return
|
||||
}
|
||||
|
||||
if amount < 0 {
|
||||
c.HTML(http.StatusBadRequest, "error.html", gin.H{"error": "amount cant be negative"})
|
||||
return
|
||||
}
|
||||
if amount > 500 {
|
||||
c.HTML(http.StatusBadRequest, "error.html", gin.H{"error": "amount cant be over 500"})
|
||||
return
|
||||
}
|
||||
|
||||
cartItem.Quantity = amount
|
||||
}
|
||||
|
||||
if action == "increase" {
|
||||
cartItem.Quantity += 1
|
||||
}
|
||||
|
||||
@@ -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)
|
||||
@@ -249,14 +260,16 @@ func (rc *shopItemController) ShopItemView(c *gin.Context) {
|
||||
shopItem, err := repositories.ShopItems.GetById(c.Param("id"))
|
||||
|
||||
if err != nil {
|
||||
c.HTML(http.StatusBadRequest, "shopitem.html", gin.H{"data": gin.H{"error": err}})
|
||||
c.HTML(http.StatusBadRequest, "error.html", gin.H{"data": gin.H{"error": "Item does not exist"}})
|
||||
return
|
||||
}
|
||||
|
||||
//TODO: get tags by item
|
||||
tags, err := repositories.Tags.GetAll()
|
||||
|
||||
if err != nil {
|
||||
c.HTML(http.StatusBadRequest, "shopitem.html", gin.H{"data": gin.H{"error": err}})
|
||||
c.HTML(http.StatusBadRequest, "error.html", gin.H{"data": gin.H{"error": err}})
|
||||
return
|
||||
}
|
||||
|
||||
data := CreateSessionData(c, gin.H{
|
||||
@@ -264,10 +277,6 @@ func (rc *shopItemController) ShopItemView(c *gin.Context) {
|
||||
"tags": tags,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
c.HTML(http.StatusBadRequest, "shopitem.html", data)
|
||||
}
|
||||
|
||||
c.HTML(http.StatusOK, "shopitem.html", data)
|
||||
}
|
||||
|
||||
@@ -365,6 +374,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)
|
||||
@@ -414,23 +430,93 @@ func (rc *shopItemController) AddItemsHandler(c *gin.Context) {
|
||||
c.HTML(http.StatusOK, "batchupload.html", data)
|
||||
}
|
||||
|
||||
func (rc *shopItemController) EditItemView(c *gin.Context) {
|
||||
shopItem, err := repositories.ShopItems.GetById(c.Param("id"))
|
||||
tags, err := repositories.Tags.GetAll()
|
||||
func GetCheckedTags(item models.ShopItem) ([]models.CheckedTag, error) {
|
||||
allTags, err := repositories.Tags.GetAll()
|
||||
|
||||
if err != nil {
|
||||
c.HTML(http.StatusBadRequest, "edititem.html", gin.H{"error": err})
|
||||
return nil, err
|
||||
}
|
||||
|
||||
fmt.Println(shopItem)
|
||||
var tags []models.CheckedTag
|
||||
for _, tag := range allTags {
|
||||
tmpTag := models.CheckedTag{
|
||||
Tag: tag,
|
||||
Checked: "",
|
||||
}
|
||||
|
||||
data := CreateSessionData(c, gin.H{
|
||||
"error": "",
|
||||
"success": "",
|
||||
"shopItem": shopItem,
|
||||
"tags": tags,
|
||||
})
|
||||
for _, itemTag := range item.Tags {
|
||||
if itemTag.Name == tmpTag.Name {
|
||||
tmpTag.Checked = "checked"
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
tags = append(tags, tmpTag)
|
||||
}
|
||||
|
||||
return tags, nil
|
||||
}
|
||||
|
||||
func (rc *shopItemController) getEditTemplatData(shopItem models.ShopItem) (gin.H, error) {
|
||||
tags, err := GetCheckedTags(shopItem)
|
||||
|
||||
if err != nil {
|
||||
return gin.H{}, err
|
||||
}
|
||||
|
||||
priceBW := ""
|
||||
priceColored := ""
|
||||
for _, variant := range shopItem.Variants {
|
||||
if variant.Name == "B/W" {
|
||||
priceBW = fmt.Sprintf("%.2f", variant.Price)
|
||||
}
|
||||
|
||||
if variant.Name == "Colored" {
|
||||
priceColored = fmt.Sprintf("%.2f", variant.Price)
|
||||
}
|
||||
}
|
||||
|
||||
templateData := gin.H{
|
||||
"error": "",
|
||||
"success": "",
|
||||
"shopItem": shopItem,
|
||||
"tags": tags,
|
||||
"priceBW": priceBW,
|
||||
"priceColored": priceColored,
|
||||
}
|
||||
|
||||
id := fmt.Sprintf("%d", shopItem.ID)
|
||||
nextShopItem, err := repositories.ShopItems.GetNextOfId(id)
|
||||
|
||||
if err == nil {
|
||||
fmt.Println("Setting nextitem")
|
||||
fmt.Println(nextShopItem)
|
||||
templateData["nextShopItem"] = nextShopItem
|
||||
}
|
||||
|
||||
previousShopItem, err := repositories.ShopItems.GetPreviousOfId(id)
|
||||
if err == nil {
|
||||
templateData["previousShopItem"] = previousShopItem
|
||||
}
|
||||
|
||||
return templateData, nil
|
||||
}
|
||||
|
||||
func (rc *shopItemController) EditItemView(c *gin.Context) {
|
||||
id := c.Param("id")
|
||||
shopItem, err := repositories.ShopItems.GetById(id)
|
||||
|
||||
if err != nil {
|
||||
c.HTML(http.StatusBadRequest, "error.html", gin.H{"error": err})
|
||||
}
|
||||
|
||||
templateData, err := rc.getEditTemplatData(shopItem)
|
||||
|
||||
if err != nil {
|
||||
c.HTML(http.StatusBadRequest, "error.html", gin.H{"error": err})
|
||||
}
|
||||
|
||||
data := CreateSessionData(c, templateData)
|
||||
c.HTML(http.StatusOK, "edititem.html", data)
|
||||
}
|
||||
|
||||
@@ -456,35 +542,37 @@ func (rc *shopItemController) EditItemHandler(c *gin.Context) {
|
||||
newShopItem.Variants = shopItem.Variants
|
||||
newShopItem.BasePrice = shopItem.BasePrice
|
||||
newShopItem.IsPublic = shopItem.IsPublic
|
||||
newShopItem.Tags = shopItem.Tags
|
||||
newShopItem.Image = shopItem.Image
|
||||
newShopItem.Pdf = shopItem.Pdf
|
||||
|
||||
if len(shopItem.Tags) != 0 {
|
||||
newShopItem.Tags = shopItem.Tags
|
||||
}
|
||||
|
||||
if shopItem.Image != "static/img/zine.jpg" {
|
||||
newShopItem.Image = shopItem.Image
|
||||
}
|
||||
|
||||
if shopItem.Pdf != "" {
|
||||
newShopItem.Pdf = shopItem.Pdf
|
||||
}
|
||||
|
||||
newShopItem.PrintMode = shopItem.PrintMode
|
||||
|
||||
tags, err := repositories.Tags.GetAll()
|
||||
templateData, err := rc.getEditTemplatData(newShopItem)
|
||||
|
||||
if err != nil {
|
||||
c.HTML(http.StatusBadRequest, "edititem.html", gin.H{"error": err})
|
||||
return
|
||||
c.HTML(http.StatusBadRequest, "error.html", gin.H{"error": err})
|
||||
}
|
||||
|
||||
_, err = repositories.ShopItems.Update(newShopItem)
|
||||
if err != nil {
|
||||
data := CreateSessionData(c, gin.H{
|
||||
"error": err,
|
||||
"success": "",
|
||||
"tags": tags,
|
||||
})
|
||||
|
||||
templateData["error"] = err
|
||||
data := CreateSessionData(c, templateData)
|
||||
c.HTML(http.StatusOK, "edititem.html", data)
|
||||
return
|
||||
}
|
||||
|
||||
data := CreateSessionData(c, gin.H{
|
||||
"error": "",
|
||||
"success": fmt.Sprintf("Item '%s' Updated", newShopItem.Name),
|
||||
"tags": tags,
|
||||
})
|
||||
|
||||
templateData["success"] = fmt.Sprintf("Item '%s' Updated", newShopItem.Name)
|
||||
data := CreateSessionData(c, templateData)
|
||||
c.HTML(http.StatusOK, "edititem.html", data)
|
||||
}
|
||||
|
||||
@@ -535,6 +623,7 @@ func (rc *shopItemController) DeleteItemHandler(c *gin.Context) {
|
||||
|
||||
func (rc *shopItemController) TagHandler(ctx *gin.Context) {
|
||||
name := ctx.PostForm("name")
|
||||
color := ctx.PostForm("color")
|
||||
action := ctx.PostForm("action")
|
||||
|
||||
tag, err := repositories.Tags.GetById(ctx.Param("id"))
|
||||
@@ -547,6 +636,7 @@ func (rc *shopItemController) TagHandler(ctx *gin.Context) {
|
||||
|
||||
if action == "update" {
|
||||
tag.Name = name
|
||||
tag.Color = color
|
||||
tag, err = repositories.Tags.Update(tag)
|
||||
|
||||
if err != nil {
|
||||
|
||||
@@ -1,11 +1,12 @@
|
||||
package controllers
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"math/rand"
|
||||
"net/http"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
"gorm.io/gorm"
|
||||
|
||||
"git.dynamicdiscord.de/kalipso/zineshop/models"
|
||||
"git.dynamicdiscord.de/kalipso/zineshop/repositories"
|
||||
@@ -36,7 +37,7 @@ func (uc *UserController) Register(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
_, err = services.Users.Register(body.Name, body.Email, body.Password)
|
||||
_, err = services.Users.Register(body.Name, body.Email, body.Password, false)
|
||||
|
||||
if err != nil {
|
||||
fmt.Println("Error: ", err)
|
||||
@@ -140,10 +141,12 @@ func (rc *UserController) LoginHandler(c *gin.Context) {
|
||||
}
|
||||
|
||||
func CreateSessionData(c *gin.Context, extra any) gin.H {
|
||||
_, exists := c.Get("user")
|
||||
user, exists := c.Get("user")
|
||||
userImpl, _ := user.(models.User)
|
||||
|
||||
return gin.H{
|
||||
"loggedIn": exists,
|
||||
"isAdmin": userImpl.IsAdmin,
|
||||
"data": extra,
|
||||
}
|
||||
}
|
||||
@@ -153,11 +156,34 @@ func (rc *UserController) RegisterHandler(c *gin.Context) {
|
||||
email := c.PostForm("email")
|
||||
password := c.PostForm("password")
|
||||
|
||||
_, err := services.Users.Register(name, email, password)
|
||||
//first registered user is admin
|
||||
isEmpty, _ := repositories.Users.IsEmpty()
|
||||
if isEmpty {
|
||||
_, err := services.Users.Register(name, email, password, true)
|
||||
if err != nil {
|
||||
data := gin.H{
|
||||
"error": "Registering Failed.",
|
||||
"success": "",
|
||||
}
|
||||
c.HTML(http.StatusOK, "register.html", data)
|
||||
return
|
||||
}
|
||||
|
||||
if err != nil {
|
||||
data := gin.H{
|
||||
"error": "Registering Failed.",
|
||||
"error": "",
|
||||
"success": "You successfully registered as Admin. Try logging in.",
|
||||
}
|
||||
|
||||
c.HTML(http.StatusOK, "register.html", data)
|
||||
return
|
||||
}
|
||||
|
||||
//for any other user token is required
|
||||
token := c.PostForm("token")
|
||||
|
||||
if token == "" {
|
||||
data := gin.H{
|
||||
"error": "No token. No register.",
|
||||
"success": "",
|
||||
}
|
||||
|
||||
@@ -165,6 +191,43 @@ func (rc *UserController) RegisterHandler(c *gin.Context) {
|
||||
return
|
||||
}
|
||||
|
||||
tokenExists, err := repositories.Tokens.Exists(token)
|
||||
|
||||
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
||||
data := gin.H{
|
||||
"error": err,
|
||||
"success": "",
|
||||
}
|
||||
|
||||
c.HTML(http.StatusOK, "register.html", data)
|
||||
return
|
||||
}
|
||||
|
||||
if !tokenExists {
|
||||
data := gin.H{
|
||||
"error": "Invalid Token.",
|
||||
"success": "",
|
||||
}
|
||||
c.HTML(http.StatusOK, "register.html", data)
|
||||
return
|
||||
}
|
||||
|
||||
_, err = services.Users.Register(name, email, password, false)
|
||||
if err != nil {
|
||||
data := gin.H{
|
||||
"error": "Registering Failed.",
|
||||
"success": "",
|
||||
}
|
||||
c.HTML(http.StatusOK, "register.html", data)
|
||||
return
|
||||
}
|
||||
|
||||
err = repositories.Tokens.Delete(token)
|
||||
|
||||
if err != nil {
|
||||
fmt.Println("Could not delete RegisterToken: ", err)
|
||||
}
|
||||
|
||||
data := gin.H{
|
||||
"error": "",
|
||||
"success": "You successfully registered. Try logging in.",
|
||||
@@ -174,6 +237,39 @@ func (rc *UserController) RegisterHandler(c *gin.Context) {
|
||||
}
|
||||
|
||||
func (rc *UserController) RegisterView(c *gin.Context) {
|
||||
data := gin.H{
|
||||
"error": "",
|
||||
"success": "",
|
||||
"token": c.Param("token"),
|
||||
}
|
||||
|
||||
c.HTML(http.StatusOK, "registertoken.html", data)
|
||||
}
|
||||
|
||||
func (rc *UserController) InitAdmin(c *gin.Context) {
|
||||
isEmpty, err := repositories.Users.IsEmpty()
|
||||
|
||||
if err != nil {
|
||||
data := gin.H{
|
||||
"error": err,
|
||||
"success": "",
|
||||
}
|
||||
|
||||
c.HTML(http.StatusInternalServerError, "error.html", data)
|
||||
return
|
||||
}
|
||||
|
||||
if !isEmpty {
|
||||
data := gin.H{
|
||||
"error": "Registration is closed",
|
||||
"success": "",
|
||||
}
|
||||
|
||||
c.HTML(http.StatusInternalServerError, "error.html", data)
|
||||
return
|
||||
|
||||
}
|
||||
|
||||
data := gin.H{
|
||||
"error": "",
|
||||
"success": "",
|
||||
@@ -204,80 +300,71 @@ func (rc *UserController) ResetHandler(c *gin.Context) {
|
||||
c.HTML(http.StatusOK, "passwordreset.html", data)
|
||||
}
|
||||
|
||||
func (rc *UserController) InviteView(c *gin.Context) {
|
||||
tokens, _ := repositories.Tokens.GetAll()
|
||||
fmt.Println(tokens)
|
||||
|
||||
data := gin.H{
|
||||
"tokens": tokens,
|
||||
}
|
||||
|
||||
c.HTML(http.StatusOK, "invites.html", data)
|
||||
}
|
||||
|
||||
func (rc *UserController) InviteHandler(c *gin.Context) {
|
||||
action := c.PostForm("action")
|
||||
|
||||
if action == "create" {
|
||||
_, err := repositories.Tokens.Create()
|
||||
|
||||
if err != nil {
|
||||
fmt.Println(err)
|
||||
c.HTML(http.StatusBadRequest, "error.html", gin.H{"error": err})
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if action == "delete" {
|
||||
token := c.PostForm("token")
|
||||
repositories.Tokens.Delete(token)
|
||||
}
|
||||
|
||||
rc.InviteView(c)
|
||||
}
|
||||
|
||||
func (rc *UserController) MainView(c *gin.Context) {
|
||||
shopItems, _ := repositories.ShopItems.GetAll()
|
||||
fmt.Println(len(shopItems))
|
||||
itemOrder := c.Query("order")
|
||||
|
||||
var shopItems []models.ShopItem
|
||||
if itemOrder == "newestFirst" {
|
||||
shopItems, _ = repositories.ShopItems.GetAllNewestFirst()
|
||||
} else if itemOrder == "oldestFirst" {
|
||||
shopItems, _ = repositories.ShopItems.GetAllNewestLast()
|
||||
} else if itemOrder == "az" {
|
||||
shopItems, _ = repositories.ShopItems.GetAllLexicalFirst()
|
||||
} else if itemOrder == "za" {
|
||||
shopItems, _ = repositories.ShopItems.GetAllLexicalLast()
|
||||
} else {
|
||||
shopItems, _ = repositories.ShopItems.GetAllNewestFirst()
|
||||
}
|
||||
|
||||
data := CreateSessionData(c, gin.H{
|
||||
"title": "shopItem Page",
|
||||
"shopItems": shopItems,
|
||||
})
|
||||
|
||||
fmt.Println(data)
|
||||
|
||||
c.HTML(http.StatusOK, "index.html", data)
|
||||
}
|
||||
|
||||
type booking struct {
|
||||
Booked bool
|
||||
}
|
||||
|
||||
type calendarbooking struct {
|
||||
Time string
|
||||
Bookings []booking
|
||||
}
|
||||
|
||||
func (rc *UserController) CalendarView(c *gin.Context) {
|
||||
shopItems, _ := repositories.ShopItems.GetAll()
|
||||
fmt.Println(len(shopItems))
|
||||
|
||||
generateBookings := func(amountShopItems int) []calendarbooking {
|
||||
var result []calendarbooking
|
||||
time := 6
|
||||
for _ = range 18 {
|
||||
book := calendarbooking{
|
||||
Time: fmt.Sprintf("%d:00", time),
|
||||
Bookings: []booking{},
|
||||
}
|
||||
for _ = range amountShopItems {
|
||||
book.Bookings = append(book.Bookings, booking{Booked: rand.Float32() < 0.5})
|
||||
}
|
||||
|
||||
time += 1
|
||||
result = append(result, book)
|
||||
}
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
bookings := gin.H{
|
||||
"head": []string{
|
||||
"malobeo",
|
||||
"hole of fame",
|
||||
"BK",
|
||||
"AZ Conni",
|
||||
},
|
||||
"bookings": generateBookings(4),
|
||||
//"bookings": []calendarbooking{
|
||||
// {
|
||||
// Time: "10:00",
|
||||
// Bookings: []booking{
|
||||
// { Booked: true },
|
||||
// { Booked: false },
|
||||
// },
|
||||
// },
|
||||
//},
|
||||
}
|
||||
func (rc *UserController) TagView(c *gin.Context) {
|
||||
shopItems, _ := repositories.ShopItems.GetByTagId(c.Param("id"))
|
||||
|
||||
data := CreateSessionData(c, gin.H{
|
||||
"title": "shopItem Page",
|
||||
"bookings": bookings,
|
||||
"shopItemcount": len(bookings["head"].([]string)) + 1,
|
||||
"title": "shopItem Page",
|
||||
"shopItems": shopItems,
|
||||
})
|
||||
|
||||
fmt.Println(data)
|
||||
|
||||
c.HTML(http.StatusOK, "calendar.html", data)
|
||||
c.HTML(http.StatusOK, "index.html", data)
|
||||
}
|
||||
|
||||
func (rc *UserController) Logout(c *gin.Context) {
|
||||
|
||||
6
flake.lock
generated
6
flake.lock
generated
@@ -2,11 +2,11 @@
|
||||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1742669843,
|
||||
"narHash": "sha256-G5n+FOXLXcRx+3hCJ6Rt6ZQyF1zqQ0DL0sWAMn2Nk0w=",
|
||||
"lastModified": 1744463964,
|
||||
"narHash": "sha256-LWqduOgLHCFxiTNYi3Uj5Lgz0SR+Xhw3kr/3Xd0GPTM=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "1e5b653dff12029333a6546c11e108ede13052eb",
|
||||
"rev": "2631b0b7abcea6e640ce31cd78ea58910d31e650",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
||||
@@ -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";
|
||||
|
||||
77
main.go
77
main.go
@@ -55,65 +55,50 @@ func main() {
|
||||
server.Static("/static", os.Getenv("STATIC"))
|
||||
server.LoadHTMLGlob(fmt.Sprintf("%s/*.html", os.Getenv("VIEWS")))
|
||||
|
||||
apiRoutes := server.Group("/api")
|
||||
//apiRoutes.Use(middlewares.BasicAuth())
|
||||
{
|
||||
apiRoutes.POST("/tags", authValidator.RequireAuth, shopItemController.CreateTag)
|
||||
apiRoutes.GET("/tags", authValidator.OptionalAuth, shopItemController.GetAllTags)
|
||||
apiRoutes.POST("/shopitems", authValidator.RequireAuth, shopItemController.Create)
|
||||
apiRoutes.GET("/shopitems", authValidator.OptionalAuth, shopItemController.GetAll)
|
||||
apiRoutes.GET("/shopitems/:id", authValidator.OptionalAuth, shopItemController.GetById)
|
||||
apiRoutes.PUT("/shopitems/:id", authValidator.RequireAuth, shopItemController.Update)
|
||||
apiRoutes.DELETE("/shopitems/:id", authValidator.RequireAuth, shopItemController.Delete)
|
||||
|
||||
//apiRoutes.GET("/rooms/:id/users", authValidator.RequireAuth, authValidator.RequireRoomAdmin, shopItemController.GetUsers)
|
||||
//apiRoutes.POST("/rooms/:id/users", authValidator.RequireAuth, shopItemController.AddUser)
|
||||
|
||||
apiRoutes.POST("/users/register", userController.Register)
|
||||
apiRoutes.POST("/users/login", userController.Login)
|
||||
apiRoutes.GET("/users/validate", authValidator.OptionalAuth, userController.Validate)
|
||||
}
|
||||
|
||||
viewRoutes := server.Group("/", authValidator.OptionalAuth)
|
||||
{
|
||||
viewRoutes.GET("/", userController.MainView)
|
||||
viewRoutes.GET("/shopitems/:id", shopItemController.ShopItemView)
|
||||
viewRoutes.GET("/shopitems/:id/edit", authValidator.RequireAuth, shopItemController.EditItemView)
|
||||
viewRoutes.POST("/shopitems/:id/edit", authValidator.RequireAuth, shopItemController.EditItemHandler)
|
||||
viewRoutes.GET("/shopitems/:id/delete", authValidator.RequireAuth, shopItemController.DeleteItemView)
|
||||
viewRoutes.POST("/shopitems/:id/delete", authValidator.RequireAuth, shopItemController.DeleteItemHandler)
|
||||
viewRoutes.GET("/variant/:id/print", authValidator.RequireAuth, printController.PrintVariantView)
|
||||
viewRoutes.GET("/cart/print", authValidator.RequireAuth, printController.PrintCartView)
|
||||
viewRoutes.POST("/print", authValidator.RequireAuth, printController.PrintHandler)
|
||||
viewRoutes.GET("/shopitems/:id/edit", authValidator.RequireAdmin, shopItemController.EditItemView)
|
||||
viewRoutes.POST("/shopitems/:id/edit", authValidator.RequireAdmin, shopItemController.EditItemHandler)
|
||||
viewRoutes.GET("/shopitems/:id/delete", authValidator.RequireAdmin, shopItemController.DeleteItemView)
|
||||
viewRoutes.POST("/shopitems/:id/delete", authValidator.RequireAdmin, shopItemController.DeleteItemHandler)
|
||||
viewRoutes.GET("/variant/:id/print", authValidator.RequireAdmin, printController.PrintVariantView)
|
||||
viewRoutes.GET("/cart/print", authValidator.RequireAdmin, printController.PrintCartView)
|
||||
viewRoutes.POST("/print", authValidator.RequireAdmin, printController.PrintHandler)
|
||||
|
||||
viewRoutes.GET("/tags", authValidator.RequireAuth, shopItemController.TagView)
|
||||
viewRoutes.POST("/tags/:id", authValidator.RequireAuth, shopItemController.TagHandler)
|
||||
viewRoutes.POST("/tags", authValidator.RequireAuth, shopItemController.AddTagHandler)
|
||||
viewRoutes.GET("/cart", cartItemController.CartItemView)
|
||||
viewRoutes.POST("/cart", cartItemController.AddItemHandler)
|
||||
viewRoutes.POST("/cart/delete", cartItemController.DeleteItemHandler)
|
||||
viewRoutes.POST("/cart/edit", cartItemController.EditItemHandler)
|
||||
viewRoutes.GET("/checkout", cartItemController.CheckoutView)
|
||||
viewRoutes.POST("/checkout", cartItemController.CheckoutHandler)
|
||||
viewRoutes.POST("/order", cartItemController.OrderHandler)
|
||||
viewRoutes.GET("/order/:token", cartItemController.OrderView)
|
||||
viewRoutes.GET("/tags", authValidator.RequireAdmin, shopItemController.TagView)
|
||||
viewRoutes.POST("/tags/:id", authValidator.RequireAdmin, shopItemController.TagHandler)
|
||||
viewRoutes.GET("/tags/:id", userController.TagView)
|
||||
viewRoutes.POST("/tags", authValidator.RequireAdmin, shopItemController.AddTagHandler)
|
||||
viewRoutes.GET("/cart", authValidator.RequireAuth, cartItemController.CartItemView)
|
||||
viewRoutes.POST("/cart", authValidator.RequireAuth, cartItemController.AddItemHandler)
|
||||
viewRoutes.POST("/cart/delete", authValidator.RequireAuth, cartItemController.DeleteItemHandler)
|
||||
viewRoutes.POST("/cart/edit", authValidator.RequireAuth, cartItemController.EditItemHandler)
|
||||
viewRoutes.GET("/checkout", authValidator.RequireAuth, cartItemController.CheckoutView)
|
||||
viewRoutes.POST("/checkout", authValidator.RequireAuth, cartItemController.CheckoutHandler)
|
||||
viewRoutes.POST("/order", authValidator.RequireAuth, cartItemController.OrderHandler)
|
||||
viewRoutes.GET("/order/:token", authValidator.RequireAuth, cartItemController.OrderView)
|
||||
viewRoutes.GET("/order/:token/print", authValidator.RequireAuth, printController.PrintOrderView)
|
||||
|
||||
viewRoutes.GET("/orders", authValidator.RequireAuth, cartItemController.OrdersView)
|
||||
viewRoutes.POST("/order/:token/edit", authValidator.RequireAuth, cartItemController.OrdersHandler)
|
||||
viewRoutes.GET("/orders", authValidator.RequireAdmin, cartItemController.OrdersView)
|
||||
viewRoutes.POST("/order/:token/edit", authValidator.RequireAdmin, cartItemController.OrdersHandler)
|
||||
|
||||
//write middleware that redirects to homescreen on register/login/reset for logged in users
|
||||
viewRoutes.GET("/login", userController.LoginView)
|
||||
viewRoutes.GET("/logout", userController.Logout)
|
||||
viewRoutes.GET("/register", userController.RegisterView)
|
||||
viewRoutes.GET("/passwordreset", userController.ResetView)
|
||||
viewRoutes.GET("/additem", authValidator.RequireAuth, shopItemController.AddItemView)
|
||||
viewRoutes.GET("/batchupload", authValidator.RequireAuth, shopItemController.AddItemsView)
|
||||
viewRoutes.GET("/register", userController.InitAdmin)
|
||||
viewRoutes.GET("/register/:token", userController.RegisterView)
|
||||
viewRoutes.GET("/invites", authValidator.RequireAdmin, userController.InviteView)
|
||||
viewRoutes.POST("/invites", authValidator.RequireAdmin, userController.InviteHandler)
|
||||
viewRoutes.GET("/passwordreset", authValidator.RequireAuth, userController.ResetView)
|
||||
viewRoutes.GET("/additem", authValidator.RequireAdmin, shopItemController.AddItemView)
|
||||
viewRoutes.GET("/batchupload", authValidator.RequireAdmin, shopItemController.AddItemsView)
|
||||
viewRoutes.POST("/login", userController.LoginHandler)
|
||||
viewRoutes.POST("/register", userController.RegisterHandler)
|
||||
viewRoutes.POST("/additem", authValidator.RequireAuth, shopItemController.AddItemHandler)
|
||||
viewRoutes.POST("/batchupload", authValidator.RequireAuth, shopItemController.AddItemsHandler)
|
||||
viewRoutes.POST("/passwordreset", userController.ResetHandler)
|
||||
viewRoutes.POST("/additem", authValidator.RequireAdmin, shopItemController.AddItemHandler)
|
||||
viewRoutes.POST("/batchupload", authValidator.RequireAdmin, shopItemController.AddItemsHandler)
|
||||
viewRoutes.POST("/passwordreset", authValidator.RequireAuth, userController.ResetHandler)
|
||||
}
|
||||
|
||||
server.Run(":" + os.Getenv("PORT"))
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
package middlewares
|
||||
|
||||
import(
|
||||
"os"
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"time"
|
||||
//"strconv"
|
||||
"net/http"
|
||||
"github.com/gin-gonic/gin"
|
||||
"github.com/golang-jwt/jwt/v5"
|
||||
"net/http"
|
||||
|
||||
//"git.dynamicdiscord.de/kalipso/zineshop/models"
|
||||
"git.dynamicdiscord.de/kalipso/zineshop/repositories"
|
||||
@@ -70,7 +70,7 @@ func (av *AuthValidator) RequireAuth(c *gin.Context) {
|
||||
c.AbortWithStatus(http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
if claims, ok := token.Claims.(jwt.MapClaims); ok {
|
||||
//Check Expiration
|
||||
if float64(time.Now().Unix()) > claims["exp"].(float64) {
|
||||
@@ -78,7 +78,7 @@ func (av *AuthValidator) RequireAuth(c *gin.Context) {
|
||||
c.AbortWithStatus(http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
//Find user
|
||||
user, err := repositories.Users.GetById(claims["sub"])
|
||||
|
||||
@@ -86,15 +86,72 @@ func (av *AuthValidator) RequireAuth(c *gin.Context) {
|
||||
c.AbortWithStatus(http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
//Attach to req
|
||||
c.Set("user", user)
|
||||
|
||||
|
||||
// Coninue
|
||||
c.Next()
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
c.AbortWithStatus(http.StatusUnauthorized)
|
||||
}
|
||||
|
||||
func (av *AuthValidator) RequireAdmin(c *gin.Context) {
|
||||
// Get Cookie
|
||||
tokenString, err := c.Cookie("Authorization")
|
||||
|
||||
if err != nil {
|
||||
c.AbortWithStatus(http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
|
||||
//Validate
|
||||
token, err := jwt.Parse(tokenString, func(token *jwt.Token) (interface{}, error) {
|
||||
// Don't forget to validate the alg is what you expect:
|
||||
if _, ok := token.Method.(*jwt.SigningMethodHMAC); !ok {
|
||||
return nil, fmt.Errorf("Unexpected signing method: %v", token.Header["alg"])
|
||||
}
|
||||
|
||||
// hmacSampleSecret is a []byte containing your secret, e.g. []byte("my_secret_key")
|
||||
return []byte(os.Getenv("SECRET")), nil
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
c.AbortWithStatus(http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
|
||||
if claims, ok := token.Claims.(jwt.MapClaims); ok {
|
||||
//Check Expiration
|
||||
if float64(time.Now().Unix()) > claims["exp"].(float64) {
|
||||
//expired
|
||||
c.AbortWithStatus(http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
|
||||
//Find user
|
||||
user, err := repositories.Users.GetById(claims["sub"])
|
||||
|
||||
if err != nil {
|
||||
c.AbortWithStatus(http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
|
||||
if !user.IsAdmin {
|
||||
c.AbortWithStatus(http.StatusUnauthorized)
|
||||
return
|
||||
}
|
||||
|
||||
//Attach to req
|
||||
c.Set("user", user)
|
||||
|
||||
// Coninue
|
||||
c.Next()
|
||||
return
|
||||
}
|
||||
|
||||
c.AbortWithStatus(http.StatusUnauthorized)
|
||||
}
|
||||
|
||||
@@ -119,19 +176,19 @@ func (av *AuthValidator) OptionalAuth(c *gin.Context) {
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
if claims, ok := token.Claims.(jwt.MapClaims); ok {
|
||||
if float64(time.Now().Unix()) > claims["exp"].(float64) {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
//Find user
|
||||
user, err := repositories.Users.GetById(claims["sub"])
|
||||
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
//Attach to req
|
||||
c.Set("user", user)
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@ const (
|
||||
LongEdge PrintOption = ""
|
||||
ShortEdge PrintOption = "-o Binding=TopBinding"
|
||||
CreateBooklet PrintOption = "-o Combination=Booklet -o PageSize=A5"
|
||||
TriFold PrintOption = "-o Fold=TriFold -o Binding=RightBinding"
|
||||
)
|
||||
|
||||
type PrintJob struct {
|
||||
@@ -32,6 +33,10 @@ func GetPrintMode(mode string) PrintOption {
|
||||
return ShortEdge
|
||||
}
|
||||
|
||||
if mode == "TriFold" {
|
||||
return TriFold
|
||||
}
|
||||
|
||||
return CreateBooklet
|
||||
}
|
||||
|
||||
@@ -62,7 +67,7 @@ func NewPrintJob(shopItem ShopItem, variant ItemVariant, coverPage bool, amount
|
||||
}
|
||||
|
||||
func (p *PrintJob) Execute() error {
|
||||
baseCommand := "lp -d KONICA_MINOLTA_KONICA_MINOLTA_bizhub_C258/BookletPrint"
|
||||
baseCommand := "lp -d KonicaBooklet"
|
||||
baseCommand += fmt.Sprintf(" -n %v ", p.Amount)
|
||||
|
||||
for _, option := range p.Options {
|
||||
|
||||
@@ -2,22 +2,56 @@ package models
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"gorm.io/gorm"
|
||||
"github.com/gin-gonic/gin"
|
||||
"gorm.io/gorm"
|
||||
"math/rand"
|
||||
)
|
||||
|
||||
type Tag struct {
|
||||
gorm.Model
|
||||
Name string `json:"name" binding:"required" gorm:"not null"`
|
||||
Name string `json:"name" binding:"required" gorm:"not null"`
|
||||
Color string `json:"color" binding:"required" gorm:"default:pink"`
|
||||
ShopItems []ShopItem `gorm:"many2many:item_tags;"`
|
||||
}
|
||||
|
||||
type CheckedTag struct {
|
||||
Tag
|
||||
Checked string
|
||||
}
|
||||
|
||||
func NewTag(ctx *gin.Context) (Tag, error) {
|
||||
colors := []string{
|
||||
"red",
|
||||
"orange",
|
||||
"amber",
|
||||
"yellow",
|
||||
"lime",
|
||||
"green",
|
||||
"emerald",
|
||||
"teal",
|
||||
"cyan",
|
||||
"sky",
|
||||
"blue",
|
||||
"indigo",
|
||||
"violet",
|
||||
"purple",
|
||||
"fuchsia",
|
||||
"pink",
|
||||
"rose",
|
||||
"slate",
|
||||
"gray",
|
||||
"zinc",
|
||||
"neutral",
|
||||
"stone",
|
||||
}
|
||||
n := rand.Int() % len(colors)
|
||||
|
||||
name := ctx.PostForm("name")
|
||||
|
||||
// Convert the price string to float64
|
||||
// Convert the price string to float64
|
||||
tag := Tag{
|
||||
Name: name,
|
||||
Name: name,
|
||||
Color: colors[n],
|
||||
}
|
||||
|
||||
if name == "" {
|
||||
@@ -27,14 +61,13 @@ func NewTag(ctx *gin.Context) (Tag, error) {
|
||||
return tag, nil
|
||||
}
|
||||
|
||||
|
||||
func NewTagByJson(ctx *gin.Context) (Tag, error) {
|
||||
var tag Tag
|
||||
err := ctx.ShouldBindJSON(&tag)
|
||||
|
||||
|
||||
if err != nil {
|
||||
return Tag{}, err
|
||||
}
|
||||
|
||||
|
||||
return tag, nil
|
||||
}
|
||||
|
||||
@@ -4,9 +4,15 @@ import (
|
||||
"gorm.io/gorm"
|
||||
)
|
||||
|
||||
type RegisterToken struct {
|
||||
gorm.Model
|
||||
Token string `json:"token" binding:"required" gorm:"unique;not null"`
|
||||
}
|
||||
|
||||
type User struct {
|
||||
gorm.Model
|
||||
Name string `json:"name" binding:"required" gorm:"unique;not null"`
|
||||
Name string `json:"name" binding:"required" gorm:"unique;not null"`
|
||||
Password string `json:"password" binding:"required" gorm:"not null"`
|
||||
Email string `json:"email" binding:"required,email" gorm:"unique;not null"`
|
||||
Email string `json:"email" binding:"required,email" gorm:"unique;not null"`
|
||||
IsAdmin bool `json:"isAdmin" gorm:"default:false;not null"`
|
||||
}
|
||||
|
||||
86
repositories/registerTokenRepository.go
Normal file
86
repositories/registerTokenRepository.go
Normal file
@@ -0,0 +1,86 @@
|
||||
package repositories
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
|
||||
"gorm.io/gorm"
|
||||
|
||||
"git.dynamicdiscord.de/kalipso/zineshop/models"
|
||||
"git.dynamicdiscord.de/kalipso/zineshop/utils"
|
||||
)
|
||||
|
||||
type RegisterTokenRepository interface {
|
||||
Create() (models.RegisterToken, error)
|
||||
GetAll() ([]models.RegisterToken, error)
|
||||
Exists(string) (bool, error)
|
||||
Delete(string) error
|
||||
}
|
||||
|
||||
type GORMRegisterTokenRepository struct {
|
||||
DB *gorm.DB
|
||||
}
|
||||
|
||||
func NewGORMRegisterTokenRepository(db *gorm.DB) RegisterTokenRepository {
|
||||
return &GORMRegisterTokenRepository{
|
||||
DB: db,
|
||||
}
|
||||
}
|
||||
|
||||
func (t *GORMRegisterTokenRepository) Create() (models.RegisterToken, error) {
|
||||
token := utils.GenerateToken()
|
||||
|
||||
exists, err := t.Exists(token)
|
||||
if err != nil {
|
||||
return models.RegisterToken{}, err
|
||||
}
|
||||
|
||||
if exists {
|
||||
return t.Create()
|
||||
}
|
||||
|
||||
newToken := models.RegisterToken{
|
||||
Token: token,
|
||||
}
|
||||
result := t.DB.Create(&newToken)
|
||||
|
||||
if result.Error != nil {
|
||||
return models.RegisterToken{}, result.Error
|
||||
}
|
||||
|
||||
return newToken, nil
|
||||
}
|
||||
|
||||
func (t *GORMRegisterTokenRepository) GetAll() ([]models.RegisterToken, error) {
|
||||
var tokens []models.RegisterToken
|
||||
result := t.DB.Find(&tokens)
|
||||
|
||||
return tokens, result.Error
|
||||
}
|
||||
|
||||
func (t *GORMRegisterTokenRepository) Exists(tokenString string) (bool, error) {
|
||||
var token models.RegisterToken
|
||||
result := t.DB.First(&token, "token = ?", tokenString)
|
||||
|
||||
if result.Error != nil {
|
||||
if errors.Is(result.Error, gorm.ErrRecordNotFound) {
|
||||
return false, nil
|
||||
}
|
||||
|
||||
return false, result.Error
|
||||
}
|
||||
|
||||
return true, nil
|
||||
}
|
||||
|
||||
func (t *GORMRegisterTokenRepository) Delete(token string) error {
|
||||
result := t.DB.Where("token = ?", token).Delete(&models.RegisterToken{})
|
||||
|
||||
if result.Error != nil {
|
||||
return result.Error
|
||||
} else if result.RowsAffected == 0 {
|
||||
return fmt.Errorf("Token not found, could not be deleted")
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
@@ -14,6 +14,7 @@ var (
|
||||
Tags TagRepository
|
||||
CartItems CartItemRepository
|
||||
Orders OrderRepository
|
||||
Tokens RegisterTokenRepository
|
||||
)
|
||||
|
||||
func InitRepositories() {
|
||||
@@ -27,7 +28,8 @@ func InitRepositories() {
|
||||
&models.User{},
|
||||
&models.Tag{},
|
||||
&models.CartItem{},
|
||||
&models.Order{})
|
||||
&models.Order{},
|
||||
&models.RegisterToken{})
|
||||
|
||||
if err != nil {
|
||||
panic("failed to migrate database")
|
||||
@@ -38,4 +40,5 @@ func InitRepositories() {
|
||||
Tags = NewGORMTagRepository(db)
|
||||
CartItems = NewGORMCartItemRepository(db)
|
||||
Orders = NewGORMOrderRepository(db)
|
||||
Tokens = NewGORMRegisterTokenRepository(db)
|
||||
}
|
||||
|
||||
@@ -1,19 +1,27 @@
|
||||
package repositories
|
||||
|
||||
import(
|
||||
"strconv"
|
||||
import (
|
||||
"fmt"
|
||||
"gorm.io/gorm"
|
||||
"strconv"
|
||||
|
||||
"git.dynamicdiscord.de/kalipso/zineshop/models"
|
||||
)
|
||||
)
|
||||
|
||||
type ShopItemRepository interface {
|
||||
Create(models.ShopItem) (models.ShopItem, error)
|
||||
Create(models.ShopItem) (models.ShopItem, error)
|
||||
GetAll() ([]models.ShopItem, error)
|
||||
GetAllSorted(string) ([]models.ShopItem, error)
|
||||
GetAllNewestFirst() ([]models.ShopItem, error)
|
||||
GetAllNewestLast() ([]models.ShopItem, error)
|
||||
GetAllLexicalFirst() ([]models.ShopItem, error)
|
||||
GetAllLexicalLast() ([]models.ShopItem, error)
|
||||
GetAllPublic() ([]models.ShopItem, error)
|
||||
GetById(string) (models.ShopItem, error)
|
||||
GetNextOfId(string) (models.ShopItem, error)
|
||||
GetPreviousOfId(string) (models.ShopItem, error)
|
||||
GetByTagId(string) ([]models.ShopItem, error)
|
||||
GetVariantById(string) (models.ItemVariant, error)
|
||||
//GetByTagId(string) ([]models.ShopItem, error)
|
||||
Update(models.ShopItem) (models.ShopItem, error)
|
||||
DeleteById(string) error
|
||||
}
|
||||
@@ -31,7 +39,7 @@ func NewGORMShopItemRepository(db *gorm.DB) ShopItemRepository {
|
||||
func (r *GORMShopItemRepository) Create(shopItem models.ShopItem) (models.ShopItem, error) {
|
||||
result := r.DB.Create(&shopItem)
|
||||
if result.Error != nil {
|
||||
return models.ShopItem{}, result.Error
|
||||
return models.ShopItem{}, result.Error
|
||||
}
|
||||
|
||||
return shopItem, nil
|
||||
@@ -44,6 +52,29 @@ func (r *GORMShopItemRepository) GetAll() ([]models.ShopItem, error) {
|
||||
return shopItems, result.Error
|
||||
}
|
||||
|
||||
func (r *GORMShopItemRepository) GetAllSorted(sortString string) ([]models.ShopItem, error) {
|
||||
var shopItems []models.ShopItem
|
||||
result := r.DB.Preload("Tags").Preload("Variants").Order(sortString).Find(&shopItems)
|
||||
|
||||
return shopItems, result.Error
|
||||
}
|
||||
|
||||
func (r *GORMShopItemRepository) GetAllNewestFirst() ([]models.ShopItem, error) {
|
||||
return r.GetAllSorted("created_at desc")
|
||||
}
|
||||
|
||||
func (r *GORMShopItemRepository) GetAllNewestLast() ([]models.ShopItem, error) {
|
||||
return r.GetAllSorted("created_at asc")
|
||||
}
|
||||
|
||||
func (r *GORMShopItemRepository) GetAllLexicalFirst() ([]models.ShopItem, error) {
|
||||
return r.GetAllSorted("name asc")
|
||||
}
|
||||
|
||||
func (r *GORMShopItemRepository) GetAllLexicalLast() ([]models.ShopItem, error) {
|
||||
return r.GetAllSorted("name desc")
|
||||
}
|
||||
|
||||
func (r *GORMShopItemRepository) GetAllPublic() ([]models.ShopItem, error) {
|
||||
var shopItems []models.ShopItem
|
||||
result := r.DB.Preload("Tags").Preload("Variants").Where("is_public = 1").Find(&shopItems)
|
||||
@@ -68,6 +99,47 @@ func (r *GORMShopItemRepository) GetById(id string) (models.ShopItem, error) {
|
||||
return shopItem, nil
|
||||
}
|
||||
|
||||
func (r *GORMShopItemRepository) GetNextOfId(id string) (models.ShopItem, error) {
|
||||
var nextItem models.ShopItem
|
||||
if err := r.DB.Where("id > ?", id).Order("id asc").First(&nextItem).Error; err != nil {
|
||||
if err != gorm.ErrRecordNotFound {
|
||||
return models.ShopItem{}, err
|
||||
} else {
|
||||
return models.ShopItem{}, fmt.Errorf("No Item found")
|
||||
}
|
||||
}
|
||||
return nextItem, nil
|
||||
}
|
||||
|
||||
func (r *GORMShopItemRepository) GetPreviousOfId(id string) (models.ShopItem, error) {
|
||||
var previousItem models.ShopItem
|
||||
if err := r.DB.Where("id < ?", id).Order("id desc").First(&previousItem).Error; err != nil {
|
||||
if err != gorm.ErrRecordNotFound {
|
||||
return models.ShopItem{}, err
|
||||
} else {
|
||||
return models.ShopItem{}, fmt.Errorf("No Item found")
|
||||
}
|
||||
}
|
||||
return previousItem, nil
|
||||
}
|
||||
|
||||
func (r *GORMShopItemRepository) GetByTagId(id string) ([]models.ShopItem, error) {
|
||||
tagId, err := strconv.Atoi(id)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var shopItems []models.ShopItem
|
||||
result := r.DB.Joins("JOIN item_tags ON item_tags.shop_item_id = shop_items.id").Where("item_tags.tag_id = ?", tagId).Preload("Tags").Preload("Variants").Find(&shopItems)
|
||||
|
||||
if result.Error != nil {
|
||||
return nil, result.Error
|
||||
}
|
||||
|
||||
return shopItems, nil
|
||||
}
|
||||
|
||||
func (r *GORMShopItemRepository) GetVariantById(id string) (models.ItemVariant, error) {
|
||||
itemVariantId, err := strconv.Atoi(id)
|
||||
|
||||
@@ -85,7 +157,6 @@ func (r *GORMShopItemRepository) GetVariantById(id string) (models.ItemVariant,
|
||||
return itemVariant, nil
|
||||
}
|
||||
|
||||
|
||||
func (r *GORMShopItemRepository) Update(shopItem models.ShopItem) (models.ShopItem, error) {
|
||||
err := r.DB.Model(&shopItem).Association("Tags").Replace(shopItem.Tags)
|
||||
if err != nil {
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
package repositories
|
||||
|
||||
import(
|
||||
import (
|
||||
"gorm.io/gorm"
|
||||
|
||||
"git.dynamicdiscord.de/kalipso/zineshop/models"
|
||||
)
|
||||
)
|
||||
|
||||
type UserRepository interface {
|
||||
Create(models.User) (models.User, error)
|
||||
Create(models.User) (models.User, error)
|
||||
GetByEmail(string) (models.User, error)
|
||||
GetById(interface{}) (models.User, error)
|
||||
IsEmpty() (bool, error)
|
||||
}
|
||||
|
||||
type GORMUserRepository struct {
|
||||
@@ -22,7 +23,7 @@ func NewGORMUserRepository(db *gorm.DB) UserRepository {
|
||||
}
|
||||
}
|
||||
|
||||
func (u *GORMUserRepository) Create(user models.User) (models.User, error) {
|
||||
func (u *GORMUserRepository) Create(user models.User) (models.User, error) {
|
||||
result := u.DB.Create(&user)
|
||||
|
||||
if result.Error != nil {
|
||||
@@ -53,3 +54,18 @@ func (u *GORMUserRepository) GetById(id interface{}) (models.User, error) {
|
||||
|
||||
return user, nil
|
||||
}
|
||||
|
||||
func (u *GORMUserRepository) IsEmpty() (bool, error) {
|
||||
var user models.User
|
||||
result := u.DB.First(&user)
|
||||
|
||||
if result.Error != nil {
|
||||
if result.Error == gorm.ErrRecordNotFound {
|
||||
return true, nil
|
||||
} else {
|
||||
return false, result.Error
|
||||
}
|
||||
}
|
||||
|
||||
return false, nil
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package services
|
||||
|
||||
import(
|
||||
import (
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
"os"
|
||||
"time"
|
||||
"golang.org/x/crypto/bcrypt"
|
||||
|
||||
"github.com/golang-jwt/jwt/v5"
|
||||
|
||||
@@ -11,13 +11,13 @@ import(
|
||||
"git.dynamicdiscord.de/kalipso/zineshop/repositories"
|
||||
)
|
||||
|
||||
var(
|
||||
var (
|
||||
Users UserService = UserService{}
|
||||
)
|
||||
|
||||
type UserService struct {}
|
||||
type UserService struct{}
|
||||
|
||||
func (u *UserService) Register(name string, email string, password string) (models.User, error) {
|
||||
func (u *UserService) Register(name string, email string, password string, isAdmin bool) (models.User, error) {
|
||||
//hash pw
|
||||
hash, err := bcrypt.GenerateFromPassword([]byte(password), 10)
|
||||
|
||||
@@ -25,7 +25,7 @@ func (u *UserService) Register(name string, email string, password string) (mode
|
||||
return models.User{}, err
|
||||
}
|
||||
|
||||
user := models.User{Name: name, Email: email, Password: string(hash)}
|
||||
user := models.User{Name: name, Email: email, Password: string(hash), IsAdmin: isAdmin}
|
||||
_, err = repositories.Users.Create(user)
|
||||
|
||||
if err != nil {
|
||||
@@ -35,7 +35,7 @@ func (u *UserService) Register(name string, email string, password string) (mode
|
||||
return user, nil
|
||||
}
|
||||
|
||||
//return jwt tokenstring on success
|
||||
// return jwt tokenstring on success
|
||||
func (u *UserService) Login(email string, password string) (string, error) {
|
||||
//lookup requested user
|
||||
user, err := repositories.Users.GetByEmail(email)
|
||||
|
||||
BIN
static/img/logo-black.png
Normal file
BIN
static/img/logo-black.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.2 KiB |
BIN
static/img/logo-white.png
Normal file
BIN
static/img/logo-white.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 2.9 KiB |
@@ -574,10 +574,6 @@ video {
|
||||
position: relative;
|
||||
}
|
||||
|
||||
.inset-0 {
|
||||
inset: 0px;
|
||||
}
|
||||
|
||||
.inset-y-0 {
|
||||
top: 0px;
|
||||
bottom: 0px;
|
||||
@@ -591,6 +587,10 @@ video {
|
||||
grid-column: span 12 / span 12;
|
||||
}
|
||||
|
||||
.col-span-3 {
|
||||
grid-column: span 3 / span 3;
|
||||
}
|
||||
|
||||
.m-2 {
|
||||
margin: 0.5rem;
|
||||
}
|
||||
@@ -634,6 +634,10 @@ video {
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
|
||||
.me-2 {
|
||||
margin-inline-end: 0.5rem;
|
||||
}
|
||||
|
||||
.ml-2 {
|
||||
margin-left: 0.5rem;
|
||||
}
|
||||
@@ -650,10 +654,6 @@ video {
|
||||
margin-right: 1rem;
|
||||
}
|
||||
|
||||
.ms-2 {
|
||||
margin-inline-start: 0.5rem;
|
||||
}
|
||||
|
||||
.mt-1 {
|
||||
margin-top: 0.25rem;
|
||||
}
|
||||
@@ -738,10 +738,6 @@ video {
|
||||
width: 33.333333%;
|
||||
}
|
||||
|
||||
.w-10 {
|
||||
width: 2.5rem;
|
||||
}
|
||||
|
||||
.w-12 {
|
||||
width: 3rem;
|
||||
}
|
||||
@@ -790,6 +786,10 @@ video {
|
||||
flex: 1 1 0%;
|
||||
}
|
||||
|
||||
.flex-shrink-0 {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
|
||||
.shrink-0 {
|
||||
flex-shrink: 0;
|
||||
}
|
||||
@@ -810,12 +810,12 @@ video {
|
||||
grid-template-columns: repeat(12, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
.flex-col {
|
||||
flex-direction: column;
|
||||
.grid-cols-6 {
|
||||
grid-template-columns: repeat(6, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
.items-start {
|
||||
align-items: flex-start;
|
||||
.flex-col {
|
||||
flex-direction: column;
|
||||
}
|
||||
|
||||
.items-center {
|
||||
@@ -908,10 +908,6 @@ video {
|
||||
border-radius: 1.5rem;
|
||||
}
|
||||
|
||||
.rounded-\[50px\] {
|
||||
border-radius: 50px;
|
||||
}
|
||||
|
||||
.rounded-full {
|
||||
border-radius: 9999px;
|
||||
}
|
||||
@@ -924,6 +920,10 @@ video {
|
||||
border-radius: 0.375rem;
|
||||
}
|
||||
|
||||
.rounded-sm {
|
||||
border-radius: 0.125rem;
|
||||
}
|
||||
|
||||
.rounded-l-md {
|
||||
border-top-left-radius: 0.375rem;
|
||||
border-bottom-left-radius: 0.375rem;
|
||||
@@ -959,6 +959,21 @@ video {
|
||||
border-color: rgb(209 213 219 / var(--tw-border-opacity, 1));
|
||||
}
|
||||
|
||||
.bg-amber-100 {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(254 243 199 / var(--tw-bg-opacity, 1));
|
||||
}
|
||||
|
||||
.bg-amber-900 {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(120 53 15 / var(--tw-bg-opacity, 1));
|
||||
}
|
||||
|
||||
.bg-blue-100 {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(219 234 254 / var(--tw-bg-opacity, 1));
|
||||
}
|
||||
|
||||
.bg-blue-600 {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(37 99 235 / var(--tw-bg-opacity, 1));
|
||||
@@ -969,6 +984,36 @@ video {
|
||||
background-color: rgb(30 58 138 / var(--tw-bg-opacity, 1));
|
||||
}
|
||||
|
||||
.bg-cyan-100 {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(207 250 254 / var(--tw-bg-opacity, 1));
|
||||
}
|
||||
|
||||
.bg-cyan-900 {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(22 78 99 / var(--tw-bg-opacity, 1));
|
||||
}
|
||||
|
||||
.bg-emerald-100 {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(209 250 229 / var(--tw-bg-opacity, 1));
|
||||
}
|
||||
|
||||
.bg-emerald-900 {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(6 78 59 / var(--tw-bg-opacity, 1));
|
||||
}
|
||||
|
||||
.bg-fuchsia-100 {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(250 232 255 / var(--tw-bg-opacity, 1));
|
||||
}
|
||||
|
||||
.bg-fuchsia-900 {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(112 26 117 / var(--tw-bg-opacity, 1));
|
||||
}
|
||||
|
||||
.bg-gray-100 {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(243 244 246 / var(--tw-bg-opacity, 1));
|
||||
@@ -999,16 +1044,96 @@ video {
|
||||
background-color: rgb(17 24 39 / var(--tw-bg-opacity, 1));
|
||||
}
|
||||
|
||||
.bg-green-100 {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(220 252 231 / var(--tw-bg-opacity, 1));
|
||||
}
|
||||
|
||||
.bg-green-600 {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(22 163 74 / var(--tw-bg-opacity, 1));
|
||||
}
|
||||
|
||||
.bg-green-900 {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(20 83 45 / var(--tw-bg-opacity, 1));
|
||||
}
|
||||
|
||||
.bg-indigo-100 {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(224 231 255 / var(--tw-bg-opacity, 1));
|
||||
}
|
||||
|
||||
.bg-indigo-500 {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(99 102 241 / var(--tw-bg-opacity, 1));
|
||||
}
|
||||
|
||||
.bg-indigo-600 {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(79 70 229 / var(--tw-bg-opacity, 1));
|
||||
}
|
||||
|
||||
.bg-indigo-900 {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(49 46 129 / var(--tw-bg-opacity, 1));
|
||||
}
|
||||
|
||||
.bg-lime-100 {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(236 252 203 / var(--tw-bg-opacity, 1));
|
||||
}
|
||||
|
||||
.bg-lime-900 {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(54 83 20 / var(--tw-bg-opacity, 1));
|
||||
}
|
||||
|
||||
.bg-neutral-100 {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(245 245 245 / var(--tw-bg-opacity, 1));
|
||||
}
|
||||
|
||||
.bg-neutral-900 {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(23 23 23 / var(--tw-bg-opacity, 1));
|
||||
}
|
||||
|
||||
.bg-orange-100 {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(255 237 213 / var(--tw-bg-opacity, 1));
|
||||
}
|
||||
|
||||
.bg-orange-900 {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(124 45 18 / var(--tw-bg-opacity, 1));
|
||||
}
|
||||
|
||||
.bg-pink-100 {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(252 231 243 / var(--tw-bg-opacity, 1));
|
||||
}
|
||||
|
||||
.bg-pink-900 {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(131 24 67 / var(--tw-bg-opacity, 1));
|
||||
}
|
||||
|
||||
.bg-purple-100 {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(243 232 255 / var(--tw-bg-opacity, 1));
|
||||
}
|
||||
|
||||
.bg-purple-900 {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(88 28 135 / var(--tw-bg-opacity, 1));
|
||||
}
|
||||
|
||||
.bg-red-100 {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(254 226 226 / var(--tw-bg-opacity, 1));
|
||||
}
|
||||
|
||||
.bg-red-800 {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(153 27 27 / var(--tw-bg-opacity, 1));
|
||||
@@ -1019,17 +1144,93 @@ video {
|
||||
background-color: rgb(127 29 29 / var(--tw-bg-opacity, 1));
|
||||
}
|
||||
|
||||
.bg-rose-100 {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(255 228 230 / var(--tw-bg-opacity, 1));
|
||||
}
|
||||
|
||||
.bg-rose-900 {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(136 19 55 / var(--tw-bg-opacity, 1));
|
||||
}
|
||||
|
||||
.bg-sky-100 {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(224 242 254 / var(--tw-bg-opacity, 1));
|
||||
}
|
||||
|
||||
.bg-sky-900 {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(12 74 110 / var(--tw-bg-opacity, 1));
|
||||
}
|
||||
|
||||
.bg-slate-100 {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(241 245 249 / var(--tw-bg-opacity, 1));
|
||||
}
|
||||
|
||||
.bg-slate-900 {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(15 23 42 / var(--tw-bg-opacity, 1));
|
||||
}
|
||||
|
||||
.bg-stone-100 {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(245 245 244 / var(--tw-bg-opacity, 1));
|
||||
}
|
||||
|
||||
.bg-stone-900 {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(28 25 23 / var(--tw-bg-opacity, 1));
|
||||
}
|
||||
|
||||
.bg-teal-100 {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(204 251 241 / var(--tw-bg-opacity, 1));
|
||||
}
|
||||
|
||||
.bg-teal-900 {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(19 78 74 / var(--tw-bg-opacity, 1));
|
||||
}
|
||||
|
||||
.bg-violet-100 {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(237 233 254 / var(--tw-bg-opacity, 1));
|
||||
}
|
||||
|
||||
.bg-violet-900 {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(76 29 149 / var(--tw-bg-opacity, 1));
|
||||
}
|
||||
|
||||
.bg-white {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(255 255 255 / var(--tw-bg-opacity, 1));
|
||||
}
|
||||
|
||||
.fill-red-50 {
|
||||
fill: #fef2f2;
|
||||
.bg-yellow-100 {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(254 249 195 / var(--tw-bg-opacity, 1));
|
||||
}
|
||||
|
||||
.stroke-gray-900 {
|
||||
stroke: #111827;
|
||||
.bg-yellow-900 {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(113 63 18 / var(--tw-bg-opacity, 1));
|
||||
}
|
||||
|
||||
.bg-zinc-100 {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(244 244 245 / var(--tw-bg-opacity, 1));
|
||||
}
|
||||
|
||||
.bg-zinc-900 {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(24 24 27 / var(--tw-bg-opacity, 1));
|
||||
}
|
||||
|
||||
.fill-red-50 {
|
||||
fill: #fef2f2;
|
||||
}
|
||||
|
||||
.stroke-red-500 {
|
||||
@@ -1058,6 +1259,11 @@ video {
|
||||
padding-right: 0.5rem;
|
||||
}
|
||||
|
||||
.px-2\.5 {
|
||||
padding-left: 0.625rem;
|
||||
padding-right: 0.625rem;
|
||||
}
|
||||
|
||||
.px-3 {
|
||||
padding-left: 0.75rem;
|
||||
padding-right: 0.75rem;
|
||||
@@ -1078,6 +1284,11 @@ video {
|
||||
padding-right: 1.5rem;
|
||||
}
|
||||
|
||||
.py-0\.5 {
|
||||
padding-top: 0.125rem;
|
||||
padding-bottom: 0.125rem;
|
||||
}
|
||||
|
||||
.py-1\.5 {
|
||||
padding-top: 0.375rem;
|
||||
padding-bottom: 0.375rem;
|
||||
@@ -1241,11 +1452,61 @@ video {
|
||||
letter-spacing: -0.025em;
|
||||
}
|
||||
|
||||
.text-amber-300 {
|
||||
--tw-text-opacity: 1;
|
||||
color: rgb(252 211 77 / var(--tw-text-opacity, 1));
|
||||
}
|
||||
|
||||
.text-amber-800 {
|
||||
--tw-text-opacity: 1;
|
||||
color: rgb(146 64 14 / var(--tw-text-opacity, 1));
|
||||
}
|
||||
|
||||
.text-black {
|
||||
--tw-text-opacity: 1;
|
||||
color: rgb(0 0 0 / var(--tw-text-opacity, 1));
|
||||
}
|
||||
|
||||
.text-blue-300 {
|
||||
--tw-text-opacity: 1;
|
||||
color: rgb(147 197 253 / var(--tw-text-opacity, 1));
|
||||
}
|
||||
|
||||
.text-blue-800 {
|
||||
--tw-text-opacity: 1;
|
||||
color: rgb(30 64 175 / var(--tw-text-opacity, 1));
|
||||
}
|
||||
|
||||
.text-cyan-300 {
|
||||
--tw-text-opacity: 1;
|
||||
color: rgb(103 232 249 / var(--tw-text-opacity, 1));
|
||||
}
|
||||
|
||||
.text-cyan-800 {
|
||||
--tw-text-opacity: 1;
|
||||
color: rgb(21 94 117 / var(--tw-text-opacity, 1));
|
||||
}
|
||||
|
||||
.text-emerald-300 {
|
||||
--tw-text-opacity: 1;
|
||||
color: rgb(110 231 183 / var(--tw-text-opacity, 1));
|
||||
}
|
||||
|
||||
.text-emerald-800 {
|
||||
--tw-text-opacity: 1;
|
||||
color: rgb(6 95 70 / var(--tw-text-opacity, 1));
|
||||
}
|
||||
|
||||
.text-fuchsia-300 {
|
||||
--tw-text-opacity: 1;
|
||||
color: rgb(240 171 252 / var(--tw-text-opacity, 1));
|
||||
}
|
||||
|
||||
.text-fuchsia-800 {
|
||||
--tw-text-opacity: 1;
|
||||
color: rgb(134 25 143 / var(--tw-text-opacity, 1));
|
||||
}
|
||||
|
||||
.text-gray-300 {
|
||||
--tw-text-opacity: 1;
|
||||
color: rgb(209 213 219 / var(--tw-text-opacity, 1));
|
||||
@@ -1276,16 +1537,86 @@ video {
|
||||
color: rgb(17 24 39 / var(--tw-text-opacity, 1));
|
||||
}
|
||||
|
||||
.text-green-300 {
|
||||
--tw-text-opacity: 1;
|
||||
color: rgb(134 239 172 / var(--tw-text-opacity, 1));
|
||||
}
|
||||
|
||||
.text-green-500 {
|
||||
--tw-text-opacity: 1;
|
||||
color: rgb(34 197 94 / var(--tw-text-opacity, 1));
|
||||
}
|
||||
|
||||
.text-green-800 {
|
||||
--tw-text-opacity: 1;
|
||||
color: rgb(22 101 52 / var(--tw-text-opacity, 1));
|
||||
}
|
||||
|
||||
.text-indigo-300 {
|
||||
--tw-text-opacity: 1;
|
||||
color: rgb(165 180 252 / var(--tw-text-opacity, 1));
|
||||
}
|
||||
|
||||
.text-indigo-600 {
|
||||
--tw-text-opacity: 1;
|
||||
color: rgb(79 70 229 / var(--tw-text-opacity, 1));
|
||||
}
|
||||
|
||||
.text-indigo-800 {
|
||||
--tw-text-opacity: 1;
|
||||
color: rgb(55 48 163 / var(--tw-text-opacity, 1));
|
||||
}
|
||||
|
||||
.text-lime-300 {
|
||||
--tw-text-opacity: 1;
|
||||
color: rgb(190 242 100 / var(--tw-text-opacity, 1));
|
||||
}
|
||||
|
||||
.text-lime-800 {
|
||||
--tw-text-opacity: 1;
|
||||
color: rgb(63 98 18 / var(--tw-text-opacity, 1));
|
||||
}
|
||||
|
||||
.text-neutral-300 {
|
||||
--tw-text-opacity: 1;
|
||||
color: rgb(212 212 212 / var(--tw-text-opacity, 1));
|
||||
}
|
||||
|
||||
.text-neutral-800 {
|
||||
--tw-text-opacity: 1;
|
||||
color: rgb(38 38 38 / var(--tw-text-opacity, 1));
|
||||
}
|
||||
|
||||
.text-orange-300 {
|
||||
--tw-text-opacity: 1;
|
||||
color: rgb(253 186 116 / var(--tw-text-opacity, 1));
|
||||
}
|
||||
|
||||
.text-orange-800 {
|
||||
--tw-text-opacity: 1;
|
||||
color: rgb(154 52 18 / var(--tw-text-opacity, 1));
|
||||
}
|
||||
|
||||
.text-pink-300 {
|
||||
--tw-text-opacity: 1;
|
||||
color: rgb(249 168 212 / var(--tw-text-opacity, 1));
|
||||
}
|
||||
|
||||
.text-pink-800 {
|
||||
--tw-text-opacity: 1;
|
||||
color: rgb(157 23 77 / var(--tw-text-opacity, 1));
|
||||
}
|
||||
|
||||
.text-purple-300 {
|
||||
--tw-text-opacity: 1;
|
||||
color: rgb(216 180 254 / var(--tw-text-opacity, 1));
|
||||
}
|
||||
|
||||
.text-purple-800 {
|
||||
--tw-text-opacity: 1;
|
||||
color: rgb(107 33 168 / var(--tw-text-opacity, 1));
|
||||
}
|
||||
|
||||
.text-red-300 {
|
||||
--tw-text-opacity: 1;
|
||||
color: rgb(252 165 165 / var(--tw-text-opacity, 1));
|
||||
@@ -1296,13 +1627,94 @@ video {
|
||||
color: rgb(239 68 68 / var(--tw-text-opacity, 1));
|
||||
}
|
||||
|
||||
.text-red-800 {
|
||||
--tw-text-opacity: 1;
|
||||
color: rgb(153 27 27 / var(--tw-text-opacity, 1));
|
||||
}
|
||||
|
||||
.text-rose-300 {
|
||||
--tw-text-opacity: 1;
|
||||
color: rgb(253 164 175 / var(--tw-text-opacity, 1));
|
||||
}
|
||||
|
||||
.text-rose-800 {
|
||||
--tw-text-opacity: 1;
|
||||
color: rgb(159 18 57 / var(--tw-text-opacity, 1));
|
||||
}
|
||||
|
||||
.text-sky-300 {
|
||||
--tw-text-opacity: 1;
|
||||
color: rgb(125 211 252 / var(--tw-text-opacity, 1));
|
||||
}
|
||||
|
||||
.text-sky-800 {
|
||||
--tw-text-opacity: 1;
|
||||
color: rgb(7 89 133 / var(--tw-text-opacity, 1));
|
||||
}
|
||||
|
||||
.text-slate-300 {
|
||||
--tw-text-opacity: 1;
|
||||
color: rgb(203 213 225 / var(--tw-text-opacity, 1));
|
||||
}
|
||||
|
||||
.text-slate-800 {
|
||||
--tw-text-opacity: 1;
|
||||
color: rgb(30 41 59 / var(--tw-text-opacity, 1));
|
||||
}
|
||||
|
||||
.text-stone-300 {
|
||||
--tw-text-opacity: 1;
|
||||
color: rgb(214 211 209 / var(--tw-text-opacity, 1));
|
||||
}
|
||||
|
||||
.text-stone-800 {
|
||||
--tw-text-opacity: 1;
|
||||
color: rgb(41 37 36 / var(--tw-text-opacity, 1));
|
||||
}
|
||||
|
||||
.text-teal-300 {
|
||||
--tw-text-opacity: 1;
|
||||
color: rgb(94 234 212 / var(--tw-text-opacity, 1));
|
||||
}
|
||||
|
||||
.text-teal-800 {
|
||||
--tw-text-opacity: 1;
|
||||
color: rgb(17 94 89 / var(--tw-text-opacity, 1));
|
||||
}
|
||||
|
||||
.text-violet-300 {
|
||||
--tw-text-opacity: 1;
|
||||
color: rgb(196 181 253 / var(--tw-text-opacity, 1));
|
||||
}
|
||||
|
||||
.text-violet-800 {
|
||||
--tw-text-opacity: 1;
|
||||
color: rgb(91 33 182 / var(--tw-text-opacity, 1));
|
||||
}
|
||||
|
||||
.text-white {
|
||||
--tw-text-opacity: 1;
|
||||
color: rgb(255 255 255 / var(--tw-text-opacity, 1));
|
||||
}
|
||||
|
||||
.underline {
|
||||
text-decoration-line: underline;
|
||||
.text-yellow-300 {
|
||||
--tw-text-opacity: 1;
|
||||
color: rgb(253 224 71 / var(--tw-text-opacity, 1));
|
||||
}
|
||||
|
||||
.text-yellow-800 {
|
||||
--tw-text-opacity: 1;
|
||||
color: rgb(133 77 14 / var(--tw-text-opacity, 1));
|
||||
}
|
||||
|
||||
.text-zinc-300 {
|
||||
--tw-text-opacity: 1;
|
||||
color: rgb(212 212 216 / var(--tw-text-opacity, 1));
|
||||
}
|
||||
|
||||
.text-zinc-800 {
|
||||
--tw-text-opacity: 1;
|
||||
color: rgb(39 39 42 / var(--tw-text-opacity, 1));
|
||||
}
|
||||
|
||||
.antialiased {
|
||||
@@ -1316,11 +1728,6 @@ video {
|
||||
box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow);
|
||||
}
|
||||
|
||||
.shadow-transparent {
|
||||
--tw-shadow-color: transparent;
|
||||
--tw-shadow: var(--tw-shadow-colored);
|
||||
}
|
||||
|
||||
.outline {
|
||||
outline-style: solid;
|
||||
}
|
||||
@@ -1337,6 +1744,10 @@ video {
|
||||
outline-color: #d1d5db;
|
||||
}
|
||||
|
||||
.filter {
|
||||
filter: var(--tw-blur) var(--tw-brightness) var(--tw-contrast) var(--tw-grayscale) var(--tw-hue-rotate) var(--tw-invert) var(--tw-saturate) var(--tw-sepia) var(--tw-drop-shadow);
|
||||
}
|
||||
|
||||
.transition-all {
|
||||
transition-property: all;
|
||||
transition-timing-function: cubic-bezier(0.4, 0, 0.2, 1);
|
||||
@@ -1362,10 +1773,6 @@ video {
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
.focus-within\:outline-gray-300:focus-within {
|
||||
outline-color: #d1d5db;
|
||||
}
|
||||
|
||||
.focus-within\:outline-red-500:focus-within {
|
||||
outline-color: #ef4444;
|
||||
}
|
||||
@@ -1385,11 +1792,6 @@ video {
|
||||
--tw-ring-offset-width: 2px;
|
||||
}
|
||||
|
||||
.hover\:border-gray-300:hover {
|
||||
--tw-border-opacity: 1;
|
||||
border-color: rgb(209 213 219 / var(--tw-border-opacity, 1));
|
||||
}
|
||||
|
||||
.hover\:bg-blue-700:hover {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(29 78 216 / var(--tw-bg-opacity, 1));
|
||||
@@ -1405,11 +1807,6 @@ video {
|
||||
background-color: rgb(156 163 175 / var(--tw-bg-opacity, 1));
|
||||
}
|
||||
|
||||
.hover\:bg-gray-50:hover {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(249 250 251 / var(--tw-bg-opacity, 1));
|
||||
}
|
||||
|
||||
.hover\:bg-gray-700:hover {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(55 65 81 / var(--tw-bg-opacity, 1));
|
||||
@@ -1454,15 +1851,6 @@ video {
|
||||
text-decoration-line: underline;
|
||||
}
|
||||
|
||||
.hover\:no-underline:hover {
|
||||
text-decoration-line: none;
|
||||
}
|
||||
|
||||
.hover\:shadow-gray-200:hover {
|
||||
--tw-shadow-color: #e5e7eb;
|
||||
--tw-shadow: var(--tw-shadow-colored);
|
||||
}
|
||||
|
||||
.focus\:z-10:focus {
|
||||
z-index: 10;
|
||||
}
|
||||
@@ -1499,12 +1887,6 @@ video {
|
||||
box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000);
|
||||
}
|
||||
|
||||
.focus\:ring-2:focus {
|
||||
--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);
|
||||
--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(2px + var(--tw-ring-offset-width)) var(--tw-ring-color);
|
||||
box-shadow: var(--tw-ring-offset-shadow), var(--tw-ring-shadow), var(--tw-shadow, 0 0 #0000);
|
||||
}
|
||||
|
||||
.focus\:ring-4:focus {
|
||||
--tw-ring-offset-shadow: var(--tw-ring-inset) 0 0 0 var(--tw-ring-offset-width) var(--tw-ring-offset-color);
|
||||
--tw-ring-shadow: var(--tw-ring-inset) 0 0 0 calc(4px + var(--tw-ring-offset-width)) var(--tw-ring-color);
|
||||
@@ -1541,10 +1923,6 @@ video {
|
||||
fill: #f87171;
|
||||
}
|
||||
|
||||
.group:hover .group-hover\:stroke-black {
|
||||
stroke: #000;
|
||||
}
|
||||
|
||||
.group:hover .group-hover\:stroke-white {
|
||||
stroke: #fff;
|
||||
}
|
||||
@@ -1620,10 +1998,6 @@ video {
|
||||
max-width: 24rem;
|
||||
}
|
||||
|
||||
.sm\:grid-cols-2 {
|
||||
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
.sm\:items-center {
|
||||
align-items: center;
|
||||
}
|
||||
@@ -1715,10 +2089,6 @@ video {
|
||||
grid-template-columns: repeat(3, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
.lg\:grid-cols-4 {
|
||||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
.lg\:p-8 {
|
||||
padding: 2rem;
|
||||
}
|
||||
@@ -1742,11 +2112,6 @@ video {
|
||||
.xl\:grid-cols-4 {
|
||||
grid-template-columns: repeat(4, minmax(0, 1fr));
|
||||
}
|
||||
|
||||
.xl\:gap-x-8 {
|
||||
-moz-column-gap: 2rem;
|
||||
column-gap: 2rem;
|
||||
}
|
||||
}
|
||||
|
||||
@media (min-width: 1536px) {
|
||||
@@ -1836,10 +2201,6 @@ video {
|
||||
color: rgb(156 163 175 / var(--tw-placeholder-opacity, 1));
|
||||
}
|
||||
|
||||
.dark\:ring-offset-gray-800 {
|
||||
--tw-ring-offset-color: #1f2937;
|
||||
}
|
||||
|
||||
.dark\:hover\:bg-gray-600:hover {
|
||||
--tw-bg-opacity: 1;
|
||||
background-color: rgb(75 85 99 / var(--tw-bg-opacity, 1));
|
||||
|
||||
19
utils/utils.go
Normal file
19
utils/utils.go
Normal file
@@ -0,0 +1,19 @@
|
||||
package utils
|
||||
|
||||
import (
|
||||
"crypto/rand"
|
||||
"encoding/hex"
|
||||
)
|
||||
|
||||
func GenerateSessionId(length int) string {
|
||||
bytes := make([]byte, length) // 16 bytes = 128 bits
|
||||
_, err := rand.Read(bytes)
|
||||
if err != nil {
|
||||
panic("failed to generate session ID")
|
||||
}
|
||||
return hex.EncodeToString(bytes)
|
||||
}
|
||||
|
||||
func GenerateToken() string {
|
||||
return GenerateSessionId(16)
|
||||
}
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
<div class="flex min-h-full flex-col justify-center px-6 py-12 lg:px-8">
|
||||
<div class="sm:mx-auto sm:w-full sm:max-w-sm">
|
||||
<img class="mx-auto h-10 w-auto" src="/static/img/circlea.png" alt="Your Company">
|
||||
<img class="mx-auto h-10 w-auto" src="/static/img/logo-black.png" alt="Your Company">
|
||||
<h2 class="mt-10 text-center text-2xl/9 font-bold tracking-tight text-gray-900">Add an Item</h2>
|
||||
</div>
|
||||
|
||||
@@ -131,6 +131,7 @@
|
||||
<option selected value="CreateBooklet">Create Booklet</option>
|
||||
<option value="LongEdge">Long Edge</option>
|
||||
<option value="ShortEdge">Short Edge</option>
|
||||
<option value="TriFold">Tri-Fold (Flyer)</option>
|
||||
</select>
|
||||
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
<div class="flex min-h-full flex-col justify-center px-6 py-12 lg:px-8">
|
||||
<div class="sm:mx-auto sm:w-full sm:max-w-sm">
|
||||
<img class="mx-auto h-10 w-auto" src="/static/img/circlea.png" alt="Your Company">
|
||||
<img class="mx-auto h-10 w-auto" src="/static/img/logo-black.png" alt="Your Company">
|
||||
<h2 class="mt-10 text-center text-2xl/9 font-bold tracking-tight text-gray-900">Add Tag</h2>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
<div class="flex min-h-full flex-col justify-center px-6 py-12 lg:px-8">
|
||||
<div class="sm:mx-auto sm:w-full sm:max-w-sm">
|
||||
<img class="mx-auto h-10 w-auto" src="/static/img/circlea.png" alt="Your Company">
|
||||
<img class="mx-auto h-10 w-auto" src="/static/img/logo-black.png" alt="Your Company">
|
||||
<h2 class="mt-10 text-center text-2xl/9 font-bold tracking-tight text-gray-900">Batch Upload</h2>
|
||||
Select multiple files on the upload. For each a new Shop Item will be created with the Filename as Name, Abstract
|
||||
and Description.<br>
|
||||
|
||||
@@ -33,28 +33,14 @@
|
||||
</p>
|
||||
<form action="/cart/edit" method="POST">
|
||||
<div class="flex justify-between items-center">
|
||||
<div class="flex items-center gap-4">
|
||||
<input type="hidden" id="{{ .ID }}" name="id" value="{{ .ID }}">
|
||||
<button type="submit" name="action" value="decrease"
|
||||
class="group rounded-[50px] border border-gray-200 shadow-sm shadow-transparent p-2.5 flex items-center justify-center bg-white transition-all duration-500 hover:shadow-gray-200 hover:bg-gray-50 hover:border-gray-300 focus-within:outline-gray-300">
|
||||
<svg class="stroke-gray-900 transition-all duration-500 group-hover:stroke-black"
|
||||
width="18" height="19" viewBox="0 0 18 19" fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M4.5 9.5H13.5" stroke="" stroke-width="1.6" stroke-linecap="round"
|
||||
stroke-linejoin="round" />
|
||||
</svg>
|
||||
<div class="flex items-center gap-4">
|
||||
<input type="number" name="amount" value="{{ .Quantity }}" step="1" min="0" required class="block w-full rounded-md bg-white px-3 py-1.5 text-base text-gray-900 outline outline-1 -outline-offset-1 outline-gray-300 placeholder:text-gray-400 focus:outline focus:outline-2 focus:-outline-offset-2 focus:outline-indigo-600 sm:text-sm/6">
|
||||
<button type="submit" name="action" value="setAmount"
|
||||
class="block w-full bg-indigo-500 rounded-md px-3 py-1.5 text-base text-white placeholder:text-gray-400 sm:text-sm/6 duration-500 hover:bg-indigo-700">
|
||||
Set Amount
|
||||
</button>
|
||||
<p class="border border-gray-200 text-center rounded-full w-10 text-gray-900 font-semibold text-sm py-1.5 px-3 bg-gray-100 text-center">{{ .Quantity }}</p>
|
||||
<button type="submit" name="action" value="increase"
|
||||
class="group rounded-[50px] border border-gray-200 shadow-sm shadow-transparent p-2.5 flex items-center justify-center bg-white transition-all duration-500 hover:shadow-gray-200 hover:bg-gray-50 hover:border-gray-300 focus-within:outline-gray-300">
|
||||
<svg class="stroke-gray-900 transition-all duration-500 group-hover:stroke-black"
|
||||
width="18" height="19" viewBox="0 0 18 19" fill="none"
|
||||
xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M3.75 9.5H14.25M9 14.75V4.25" stroke="" stroke-width="1.6"
|
||||
stroke-linecap="round" stroke-linejoin="round" />
|
||||
</svg>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<h6 class="text-indigo-600 font-manrope font-bold text-2xl leading-9 text-right">{{ .Quantity}} x {{ .ItemVariant.Price }}€</h6>
|
||||
</div>
|
||||
</form>
|
||||
@@ -88,7 +74,7 @@
|
||||
<div class="max-lg:max-w-lg max-lg:mx-auto">
|
||||
<p class="font-normal text-base leading-7 text-gray-500 text-center mb-5 mt-6">Shipping calculated at checkout</p>
|
||||
<button type="submit"
|
||||
class="rounded-full py-4 px-6 bg-indigo-600 text-white font-semibold text-lg w-full text-center transition-all duration-500 hover:bg-indigo-700 ">Checkout</button>
|
||||
class="rounded py-4 px-6 bg-indigo-500 text-white font-semibold text-lg w-full text-center transition-all duration-500 hover:bg-indigo-700 ">Checkout</button>
|
||||
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
<div class="flex min-h-full flex-col justify-center px-6 py-12 lg:px-8">
|
||||
<div class="sm:mx-auto sm:w-full sm:max-w-sm">
|
||||
<img class="mx-auto h-10 w-auto" src="/static/img/circlea.png" alt="Logo">
|
||||
<img class="mx-auto h-10 w-auto" src="/static/img/logo-black.png" alt="Logo">
|
||||
<h2 class="mt-10 text-center text-2xl/9 font-bold tracking-tight text-gray-900">Checkout</h2>
|
||||
</div>
|
||||
|
||||
|
||||
23
views/colors.html
Normal file
23
views/colors.html
Normal file
@@ -0,0 +1,23 @@
|
||||
<span class="bg-red-100 text-red-800 bg-red-900 text-red-300">FOO</span>
|
||||
<span class="bg-orange-100 text-orange-800 bg-orange-900 text-orange-300">FOO</span>
|
||||
<span class="bg-amber-100 text-amber-800 bg-amber-900 text-amber-300">FOO</span>
|
||||
<span class="bg-yellow-100 text-yellow-800 bg-yellow-900 text-yellow-300">FOO</span>
|
||||
<span class="bg-lime-100 text-lime-800 bg-lime-900 text-lime-300">FOO</span>
|
||||
<span class="bg-green-100 text-green-800 bg-green-900 text-green-300">FOO</span>
|
||||
<span class="bg-emerald-100 text-emerald-800 bg-emerald-900 text-emerald-300">FOO</span>
|
||||
<span class="bg-teal-100 text-teal-800 bg-teal-900 text-teal-300">FOO</span>
|
||||
<span class="bg-cyan-100 text-cyan-800 bg-cyan-900 text-cyan-300">FOO</span>
|
||||
<span class="bg-sky-100 text-sky-800 bg-sky-900 text-sky-300">FOO</span>
|
||||
<span class="bg-blue-100 text-blue-800 bg-blue-900 text-blue-300">FOO</span>
|
||||
<span class="bg-indigo-100 text-indigo-800 bg-indigo-900 text-indigo-300">FOO</span>
|
||||
<span class="bg-violet-100 text-violet-800 bg-violet-900 text-violet-300">FOO</span>
|
||||
<span class="bg-purple-100 text-purple-800 bg-purple-900 text-purple-300">FOO</span>
|
||||
<span class="bg-fuchsia-100 text-fuchsia-800 bg-fuchsia-900 text-fuchsia-300">FOO</span>
|
||||
<span class="bg-pink-100 text-pink-800 bg-pink-900 text-pink-300">FOO</span>
|
||||
<span class="bg-rose-100 text-rose-800 bg-rose-900 text-rose-300">FOO</span>
|
||||
<span class="bg-slate-100 text-slate-800 bg-slate-900 text-slate-300">FOO</span>
|
||||
<span class="bg-gray-100 text-gray-800 bg-gray-900 text-gray-300">FOO</span>
|
||||
<span class="bg-zinc-100 text-zinc-800 bg-zinc-900 text-zinc-300">FOO</span>
|
||||
<span class="bg-neutral-100 text-neutral-800 bg-neutral-900 text-neutral-300">FOO</span>
|
||||
<span class="bg-stone-100 text-stone-800 bg-stone-900 text-stone-300">FOO</span>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<h3 class="text-lg">{{ .data.shopItem.Name }}</h3>
|
||||
<i class="text-xs">{{ .data.shopItem.Description }}</i>
|
||||
<p class="">Price: {{ .data.shopItem.BasePrice }}</p>
|
||||
{{ if .loggedIn }}
|
||||
{{ if .isAdmin }}
|
||||
|
||||
<p class="mt-10 text-center text-sm/6 text-red-500">
|
||||
Do you really want to delete this item??
|
||||
|
||||
@@ -1,9 +1,46 @@
|
||||
{{ template "header.html" . }}
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="flex min-h-full flex-col justify-center px-6 py-12 lg:px-8">
|
||||
<div class="sm:mx-auto sm:w-full sm:max-w-sm">
|
||||
<img class="mx-auto h-10 w-auto" src="/static/img/circlea.png" alt="Your Company">
|
||||
<img class="mx-auto h-10 w-auto" src="/static/img/logo-black.png" alt="Your Company">
|
||||
<h2 class="mt-10 text-center text-2xl/9 font-bold tracking-tight text-gray-900">Edit Item</h2>
|
||||
|
||||
<p class="mt-10 text-center text-sm/6 text-red-500">
|
||||
{{ .data.error }}
|
||||
</p>
|
||||
<p class="mt-10 text-center text-sm/6 text-green-500">
|
||||
{{ .data.success }}
|
||||
</p>
|
||||
|
||||
|
||||
<a href="/{{ .data.shopItem.Pdf }}" target="_blank">
|
||||
<img src="/{{ .data.shopItem.Image }}" alt="Product Image" class="aspect-4/5 mx-auto rounded-md bg-gray-200 object-cover group-hover:opacity-75 lg:aspect-auto lg:h-80">
|
||||
</a>
|
||||
|
||||
|
||||
<div class="grid grid-cols-6 gap-4 mb-4">
|
||||
<div class="col-span-3">
|
||||
{{ if .data.previousShopItem }}
|
||||
<form action="/shopitems/{{ .data.previousShopItem.ID }}/edit">
|
||||
<button type="submit" class="flex w-full justify-center rounded-md bg-indigo-600 px-3 py-1.5 text-sm/6 font-semibold text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600">Previous</button>
|
||||
</form>
|
||||
{{ end }}
|
||||
</div>
|
||||
<div class="col-span-3">
|
||||
{{ if .data.nextShopItem }}
|
||||
<form action="/shopitems/{{ .data.nextShopItem.ID }}/edit">
|
||||
<button type="submit" class="flex w-full justify-center rounded-md bg-indigo-600 px-3 py-1.5 text-sm/6
|
||||
font-semibold text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2
|
||||
focus-visible:outline-offset-2 focus-visible:outline-indigo-600">Next</button>
|
||||
</form>
|
||||
{{ end }}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
|
||||
@@ -28,12 +65,25 @@
|
||||
<textarea id="description" name="description" type="textarea" class="block w-full px-4 py-2 mt-2 text-gray-900 bg-white border border-gray-300 rounded-md dark:bg-gray-800 dark:text-gray-900 dark:border-gray-600 focus:border-blue-500 dark:focus:border-blue-500 focus:outline-none focus:ring">{{ .data.shopItem.Description}}</textarea>
|
||||
</div>
|
||||
|
||||
<label class="block text-sm/6 font-medium text-gray-900">
|
||||
Print Mode
|
||||
</label>
|
||||
<select name="print-mode" required class="bg-white border border-gray-300 text-gray-900 text-sm rounded-lg
|
||||
focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500">
|
||||
<option selected value="{{ .data.shopItem.PrintMode }}">{{ .data.shopItem.PrintMode }}</option>
|
||||
<option value="CreateBooklet">CreateBooklet</option>
|
||||
<option value="LongEdge">Long Edge</option>
|
||||
<option value="ShortEdge">Short Edge</option>
|
||||
<option value="TriFold">Tri-Fold (Flyer)</option>
|
||||
</select>
|
||||
|
||||
|
||||
<div class="mb-4">
|
||||
<label class="block text-sm/6 text-gray-900">Select Categories</label>
|
||||
<div class="space-y-2">
|
||||
{{ range .data.tags }}
|
||||
<label class="flex text-sm/6 items-center">
|
||||
<input type="checkbox" class="form-checkbox h-4 w-4 text-gray-900" value="{{ .ID }}" name="tags[]">
|
||||
<input type="checkbox" {{ .Checked }} class="form-checkbox h-4 w-4 text-gray-900" value="{{ .ID }}" name="tags[]">
|
||||
<span class="ml-2 text-sm/6 text-gray-900">{{ .Name }}</span>
|
||||
</label>
|
||||
{{ end }}
|
||||
@@ -61,7 +111,7 @@
|
||||
<label for="variant-value1" class="block text-sm/6 font-medium text-gray-900">Price B/W</label>
|
||||
</div>
|
||||
<div class="mt-2">
|
||||
<input type="number" name="variant-value[]" id="variant-value1" step="0.01" min="0.00" required class="block w-full rounded-md bg-white px-3 py-1.5 text-base text-gray-900 outline outline-1 -outline-offset-1 outline-gray-300 placeholder:text-gray-400 focus:outline focus:outline-2 focus:-outline-offset-2 focus:outline-indigo-600 sm:text-sm/6">
|
||||
<input type="number" value="{{ .data.priceBW }}" name="variant-value[]" id="variant-value1" step="0.01" min="0.00" required class="block w-full rounded-md bg-white px-3 py-1.5 text-base text-gray-900 outline outline-1 -outline-offset-1 outline-gray-300 placeholder:text-gray-400 focus:outline focus:outline-2 focus:-outline-offset-2 focus:outline-indigo-600 sm:text-sm/6">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -72,7 +122,7 @@
|
||||
<label for="variant-value2" class="block text-sm/6 font-medium text-gray-900">Price Colored</label>
|
||||
</div>
|
||||
<div class="mt-2">
|
||||
<input type="number" name="variant-value[]" id="variant-value2" step="0.01" min="0.00" class="block w-full rounded-md bg-white px-3 py-1.5 text-base text-gray-900 outline outline-1 -outline-offset-1 outline-gray-300 placeholder:text-gray-400 focus:outline focus:outline-2 focus:-outline-offset-2 focus:outline-indigo-600 sm:text-sm/6">
|
||||
<input type="number" value="{{ .data.priceColored }}" name="variant-value[]" id="variant-value2" step="0.01" min="0.00" class="block w-full rounded-md bg-white px-3 py-1.5 text-base text-gray-900 outline outline-1 -outline-offset-1 outline-gray-300 placeholder:text-gray-400 focus:outline focus:outline-2 focus:-outline-offset-2 focus:outline-indigo-600 sm:text-sm/6">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -123,24 +173,6 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<label class="block text-sm font-medium text-gray-900">
|
||||
Print Mode
|
||||
</label>
|
||||
<select name="print-mode" required class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500">
|
||||
<option selected value="CreateBooklet">Create Booklet</option>
|
||||
<option value="LongEdge">Long Edge</option>
|
||||
<option value="ShortEdge">Short Edge</option>
|
||||
</select>
|
||||
|
||||
|
||||
<p class="mt-10 text-center text-sm/6 text-red-500">
|
||||
{{ .data.error }}
|
||||
</p>
|
||||
<p class="mt-10 text-center text-sm/6 text-green-500">
|
||||
{{ .data.success }}
|
||||
</p>
|
||||
|
||||
|
||||
<div>
|
||||
<button type="submit" class="flex w-full justify-center rounded-md bg-indigo-600 px-3 py-1.5 text-sm/6 font-semibold text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600">Update Item</button>
|
||||
</div>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
<div class="flex min-h-full flex-col justify-center px-6 py-12 lg:px-8">
|
||||
<div class="sm:mx-auto sm:w-full sm:max-w-sm">
|
||||
<img class="mx-auto h-10 w-auto" src="/static/img/circlea.png" alt="Your Company">
|
||||
<img class="mx-auto h-10 w-auto" src="/static/img/logo-black.png" alt="Your Company">
|
||||
<h2 class="mt-10 text-center text-2xl/9 font-bold tracking-tight text-gray-900">Edit Orders</h2>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -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">
|
||||
@@ -12,8 +12,8 @@
|
||||
<div class="mx-auto max-w-7xl px-4 sm:px-8 lg:px-8">
|
||||
<div class="relative flex h-16 items-center justify-between">
|
||||
<div class="flex flex-1 items-center">
|
||||
<a href="/"><div class="flex shrink-0">
|
||||
<img class="h-8 w-auto" src="/static/img/circlea.png" alt="Your Company">
|
||||
<a href="/"><div class="flex-shrink-0 w-full h-full">
|
||||
<img class="h-8 w-auto" src="/static/img/logo-white.png" alt="Your Company">
|
||||
</div></a>
|
||||
<!--
|
||||
{{ if .loggedIn }}
|
||||
@@ -25,7 +25,7 @@
|
||||
{{ end }}
|
||||
-->
|
||||
</div>
|
||||
{{ if .loggedIn }}
|
||||
{{ if .isAdmin }}
|
||||
<div class="absolute inset-y-0 right-0 flex items-center pr-2 sm:static sm:inset-auto sm:ml-6 sm:pr-0 px-4 sm:px-8">
|
||||
<a href="/additem" class="rounded-md bg-gray-900 m-2 px-3 py-2 text-sm font-medium text-gray-300 hover:bg-gray-700 hover:text-white">Add Item</a>
|
||||
<a href="/batchupload" class="rounded-md bg-gray-900 m-2 px-3 py-2 text-sm font-medium text-gray-300
|
||||
@@ -33,13 +33,15 @@
|
||||
<a href="/orders" class="rounded-md bg-gray-900 m-2 px-3 py-2 text-sm font-medium text-gray-300
|
||||
hover:bg-gray-700 hover:text-white">Orders</a>
|
||||
<a href="/tags" class="rounded-md bg-gray-900 m-2 px-3 py-2 text-sm font-medium text-gray-300 hover:bg-gray-700 hover:text-white">Tags</a>
|
||||
<a href="/invites" class="rounded-md bg-gray-900 m-2 px-3 py-2 text-sm font-medium text-gray-300 hover:bg-gray-700 hover:text-white">Invites</a>
|
||||
<a href="/cart/print" class="rounded-md bg-gray-900 m-2 px-3 py-2 text-sm font-medium text-gray-300 hover:bg-gray-700
|
||||
hover:text-white">Print</a>
|
||||
<a href="/cart" class="rounded-md bg-gray-900 m-2 px-3 py-2 text-sm font-medium text-gray-300 hover:bg-gray-700
|
||||
hover:text-white">Cart</a>
|
||||
<a href="/logout" class="rounded-md bg-gray-900 m-2 px-3 py-2 text-sm font-medium text-red-300 hover:bg-gray-700 hover:text-white">Logout</a>
|
||||
</div>
|
||||
{{ else }}
|
||||
{{ end }}
|
||||
{{ if .loggedIn }}
|
||||
<div class="absolute inset-y-0 right-0 flex items-center pr-2 sm:static sm:inset-auto sm:ml-6 sm:pr-0 px-4 sm:px-8">
|
||||
<a href="/cart" class="rounded-md bg-gray-900 m-2 px-3 py-2 text-sm font-medium text-gray-300 hover:bg-gray-700 hover:text-white">🛒 Cart</a>
|
||||
</div>
|
||||
|
||||
28
views/invites.html
Normal file
28
views/invites.html
Normal file
@@ -0,0 +1,28 @@
|
||||
{{ template "header.html" . }}
|
||||
|
||||
|
||||
<div class="flex min-h-full flex-col justify-center px-6 py-12 lg:px-8">
|
||||
<div class="sm:mx-auto sm:w-full sm:max-w-sm">
|
||||
<img class="mx-auto h-10 w-auto" src="/static/img/logo-black.png" alt="Your Company">
|
||||
<h2 class="mt-10 text-center text-2xl/9 font-bold tracking-tight text-gray-900">Create/Delete Invites</h2>
|
||||
</div>
|
||||
|
||||
<div class="mt-10 sm:mx-auto sm:w-full sm:max-w-sm">
|
||||
{{ range .tokens }}
|
||||
<form action="/invites" method="POST">
|
||||
<div class="max-w-md mx-auto mt-4">
|
||||
<div class="flex">
|
||||
<input type="text" id="token" name="token" value="{{ .Token }}" readonly="readonly" class="flex-grow border border-gray-300 rounded-md p-2 focus:outline-none focus:ring focus:ring-blue-500">
|
||||
<button type="submit" name="action" value="delete" class="bg-red-800 text-white rounded px-4 hover:bg-red-900">Delete</button>
|
||||
</div>
|
||||
</form>
|
||||
{{ end }}
|
||||
<form action="/invites" method="POST">
|
||||
<div class="max-w-md mx-auto mt-4">
|
||||
<div class="flex">
|
||||
<button type="submit" name="action" value="create" class="bg-green-600 text-white ml-4 mr-4 rounded px-4 hover:bg-green-700">Create</button>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
{{ template "footer.html" . }}
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
<div class="flex min-h-full flex-col justify-center px-6 py-12 lg:px-8">
|
||||
<div class="sm:mx-auto sm:w-full sm:max-w-sm">
|
||||
<img class="mx-auto h-10 w-auto" src="/static/img/circlea.png" alt="Logo">
|
||||
<img class="mx-auto h-10 w-auto" src="/static/img/logo-black.png" alt="Logo">
|
||||
<h2 class="mt-10 text-center text-2xl/9 font-bold tracking-tight text-gray-900">Login to your account</h2>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -74,11 +74,6 @@
|
||||
</dl>
|
||||
</div>
|
||||
|
||||
<div class="flex items-start sm:items-center">
|
||||
<input id="terms-checkbox-2" type="checkbox" value="" class="h-4 w-4 rounded border-gray-300 bg-gray-100 text-primary-600 focus:ring-2 focus:ring-primary-500 dark:border-gray-600 dark:bg-gray-700 dark:ring-offset-gray-800 dark:focus:ring-primary-600" />
|
||||
<label for="terms-checkbox-2" class="ms-2 text-sm font-medium text-gray-900 dark:text-gray-300"> I agree with the <a href="#" title="" class="text-primary-700 underline hover:no-underline dark:text-primary-500">Terms and Conditions</a> of use of the Flowbite marketplace </label>
|
||||
</div>
|
||||
|
||||
<div class="gap-4 sm:flex sm:items-center">
|
||||
<button type="button" class="w-full rounded-lg border border-gray-200 bg-white px-5 py-2.5 text-sm font-medium text-gray-900 hover:bg-gray-100 hover:text-primary-700 focus:z-10 focus:outline-none focus:ring-4 focus:ring-gray-100 dark:border-gray-600 dark:bg-gray-800 dark:text-gray-400 dark:hover:bg-gray-700 dark:hover:text-white dark:focus:ring-gray-700"><a href="/">Return to Shopping</a></button>
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
<div class="flex min-h-full flex-col justify-center px-6 py-12 lg:px-8">
|
||||
<div class="sm:mx-auto sm:w-full sm:max-w-sm">
|
||||
<img class="mx-auto h-10 w-auto" src="/static/img/circlea.png" alt="Logo">
|
||||
<img class="mx-auto h-10 w-auto" src="/static/img/logo-black.png" alt="Logo">
|
||||
<h2 class="mt-10 text-center text-2xl/9 font-bold tracking-tight text-gray-900">Register your account</h2>
|
||||
</div>
|
||||
|
||||
|
||||
59
views/registertoken.html
Normal file
59
views/registertoken.html
Normal file
@@ -0,0 +1,59 @@
|
||||
{{ template "header.html" . }}
|
||||
|
||||
<div class="flex min-h-full flex-col justify-center px-6 py-12 lg:px-8">
|
||||
<div class="sm:mx-auto sm:w-full sm:max-w-sm">
|
||||
<img class="mx-auto h-10 w-auto" src="/static/img/logo-black.png" alt="Logo">
|
||||
<h2 class="mt-10 text-center text-2xl/9 font-bold tracking-tight text-gray-900">Register your account</h2>
|
||||
</div>
|
||||
|
||||
<div class="mt-10 sm:mx-auto sm:w-full sm:max-w-sm">
|
||||
<form class="space-y-6" action="/register" method="POST">
|
||||
<div>
|
||||
<label for="token" class="block text-sm/6 font-medium text-gray-900">Token</label>
|
||||
<div class="mt-2">
|
||||
<input type="text" name="token" id="token" value="{{ .token }}" required class="block w-full rounded-md bg-white px-3 py-1.5 text-base text-gray-900 outline outline-1 -outline-offset-1 outline-gray-300 placeholder:text-gray-400 focus:outline focus:outline-2 focus:-outline-offset-2 focus:outline-indigo-600 sm:text-sm/6">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div>
|
||||
<label for="name" class="block text-sm/6 font-medium text-gray-900">Username</label>
|
||||
<div class="mt-2">
|
||||
<input type="text" name="name" id="name" required class="block w-full rounded-md bg-white px-3 py-1.5 text-base text-gray-900 outline outline-1 -outline-offset-1 outline-gray-300 placeholder:text-gray-400 focus:outline focus:outline-2 focus:-outline-offset-2 focus:outline-indigo-600 sm:text-sm/6">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<label for="email" class="block text-sm/6 font-medium text-gray-900">Email address</label>
|
||||
<div class="mt-2">
|
||||
<input type="email" name="email" id="email" autocomplete="email" required class="block w-full rounded-md bg-white px-3 py-1.5 text-base text-gray-900 outline outline-1 -outline-offset-1 outline-gray-300 placeholder:text-gray-400 focus:outline focus:outline-2 focus:-outline-offset-2 focus:outline-indigo-600 sm:text-sm/6">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div>
|
||||
<div class="flex items-center justify-between">
|
||||
<label for="password" class="block text-sm/6 font-medium text-gray-900">Password</label>
|
||||
</div>
|
||||
<div class="mt-2">
|
||||
<input type="password" name="password" id="password" autocomplete="current-password" required class="block w-full rounded-md bg-white px-3 py-1.5 text-base text-gray-900 outline outline-1 -outline-offset-1 outline-gray-300 placeholder:text-gray-400 focus:outline focus:outline-2 focus:-outline-offset-2 focus:outline-indigo-600 sm:text-sm/6">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<p class="mt-10 text-center text-sm/6 text-red-500">
|
||||
{{ .error }}
|
||||
</p>
|
||||
<p class="mt-10 text-center text-sm/6 text-green-500">
|
||||
{{ .success }}
|
||||
</p>
|
||||
|
||||
|
||||
|
||||
<div>
|
||||
<button type="submit" class="flex w-full justify-center rounded-md bg-indigo-600 px-3 py-1.5 text-sm/6 font-semibold text-white shadow-sm hover:bg-indigo-500 focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-indigo-600">Register</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
{{ template "footer.html" . }}
|
||||
@@ -9,15 +9,18 @@
|
||||
<img class="w-full h-full object-cover" src="/{{ .data.shopItem.Image}}" alt="Product Image">
|
||||
</div>
|
||||
<div class="flex -mx-2 mb-4">
|
||||
{{ if .loggedIn }}
|
||||
<input type="hidden" id="{{ .data.shopItem.ID}}" name="ShopItemId" value="{{ .data.shopItem.ID }}">
|
||||
<div class="w-1/3 px-2">
|
||||
<button type="submit" class="w-full bg-gray-900 dark:bg-gray-600 text-white py-2 px-4 rounded-lg font-bold hover:bg-gray-800 dark:hover:bg-gray-700">Add to Cart</button>
|
||||
</div>
|
||||
{{ end }}
|
||||
|
||||
<div class="w-1/3 px-2">
|
||||
<button type="button" class="w-full bg-blue-900 dark:bg-gray-600 text-white py-2 px-4 rounded-lg font-bold hover:bg-gray-800 dark:hover:bg-gray-700"><a href="/{{ .data.shopItem.Pdf }}">View</a></button>
|
||||
</div>
|
||||
{{ if .loggedIn }}
|
||||
|
||||
{{ if .isAdmin }}
|
||||
<div class="w-1/3 px-2">
|
||||
<button type="button" class="w-full bg-blue-900 dark:bg-gray-600 text-white py-2 px-4 rounded-lg font-bold hover:bg-gray-800 dark:hover:bg-gray-700"><a href="{{ .data.shopItem.ID }}/edit">Edit</a></button>
|
||||
</div>
|
||||
@@ -34,6 +37,7 @@
|
||||
{{ .data.shopItem.Abstract }}
|
||||
</p>
|
||||
|
||||
{{ if .loggedIn }}
|
||||
<div class="flex mb-4">
|
||||
<label for="ItemVariantId" class="block mb-2 text-sm font-medium text-gray-900 dark:text-white"></label>
|
||||
<select name="ItemVariantId" id="ItemVariantId" required class="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-full p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500">
|
||||
@@ -43,15 +47,16 @@
|
||||
{{ end }}
|
||||
</select>
|
||||
</div>
|
||||
{{ end }}
|
||||
|
||||
<div class="flex mb-4">
|
||||
<div class="mr-4">
|
||||
<span class="font-bold text-gray-700 dark:text-gray-300">Tags:</span>
|
||||
<span class="text-gray-600 dark:text-gray-300">
|
||||
<p class="mt-1 text-sm text-gray-500">
|
||||
{{ range .data.shopItem.Tags }}
|
||||
{{ .Name }}
|
||||
<a href="/tags/{{ .ID }}"><span class="bg-{{ .Color }}-100 text-{{ .Color }}-800 text-xs font-medium me-2 px-2.5 py-0.5 rounded-sm dark:bg-{{ .Color }}-900 dark:text-{{ .Color }}-300">{{ .Name }}</span></a>
|
||||
{{ end }}
|
||||
</span>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<!--
|
||||
|
||||
@@ -1,28 +1,61 @@
|
||||
<div class="bg-white">
|
||||
<div class="mx-auto max-w-2xl px-4 py-16 sm:px-6 sm:py-24 lg:max-w-7xl lg:px-8">
|
||||
<h2 class="text-2xl font-bold tracking-tight text-gray-900">Available Zines</h2>
|
||||
<div class="mx-auto max-w-2xl px-4 py-16 sm:px-6 sm:py-24 lg:max-w-7xl">
|
||||
<h2 class="text-2xl font-bold tracking-tight text-gray-900">Available Zines</h2>
|
||||
|
||||
<div class="mt-6 grid grid-cols-1 gap-x-6 gap-y-10 sm:grid-cols-2 lg:grid-cols-4 xl:gap-x-8">
|
||||
<input type="text" id="myInput" onkeyup="myFunction()" placeholder="Search for names..">
|
||||
<div class="mt-6 grid grid-cols-1 gap-x-6 gap-y-10 md:grid-cols-2 xl:grid-cols-4">
|
||||
{{ range .data.shopItems }}
|
||||
|
||||
<div class="group relative">
|
||||
<img src="/{{ .Image }}" alt="Product Image" class="aspect-4/5 w-full rounded-md bg-gray-200 object-cover group-hover:opacity-75 lg:aspect-auto lg:h-80">
|
||||
<div class="myClass group relative">
|
||||
<a href="/shopitems/{{ .ID }}">
|
||||
<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>
|
||||
<h3 class="text-sm text-gray-700">
|
||||
<a href="/shopitems/{{ .ID }}">
|
||||
<span aria-hidden="true" class="absolute inset-0"></span>
|
||||
{{ .Name }}
|
||||
</a>
|
||||
</h3>
|
||||
<p class="mt-1 text-sm text-gray-500">{{ .Abstract }}</p>
|
||||
<p class="mt-1 text-sm text-gray-500">{{ range .Tags }}{{ .Name }} {{ end }}</p>
|
||||
|
||||
<p class="mt-1 text-sm text-gray-500">
|
||||
{{ range .Tags }}
|
||||
<a href="/tags/{{ .ID }}"><span class="bg-{{ .Color }}-100 text-{{ .Color }}-800 text-xs font-medium me-2 px-2.5 py-0.5 rounded-sm dark:bg-{{ .Color }}-900 dark:text-{{ .Color }}-300">{{ .Name }}</span></a>
|
||||
{{ end }}
|
||||
</p>
|
||||
</div>
|
||||
<p class="text-sm font-medium text-gray-900">{{ .BasePrice }}€</p>
|
||||
{{ if $.loggedIn }}
|
||||
<p class="text-sm font-medium text-gray-900">{{ .BasePrice }}€</p>
|
||||
{{ end }}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{ end }}
|
||||
|
||||
<script>
|
||||
function myFunction() {
|
||||
// Declare variables
|
||||
var input, filter, ul, li, a, i, txtValue;
|
||||
input = document.getElementById('myInput');
|
||||
filter = input.value.toUpperCase();
|
||||
//ul = document.getElementById("myUL");
|
||||
//li = ul.getElementsByTagName('li');
|
||||
li = document.getElementsByClassName("myClass");
|
||||
|
||||
console.log(li)
|
||||
// Loop through all list items, and hide those who don't match the search query
|
||||
for (i = 0; i < li.length; i++) {
|
||||
a = li[i].getElementsByTagName("a")[1];
|
||||
txtValue = a.textContent || a.innerText;
|
||||
if (txtValue.toUpperCase().indexOf(filter) > -1) {
|
||||
li[i].style.display = "";
|
||||
} else {
|
||||
li[i].style.display = "none";
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
<div class="flex min-h-full flex-col justify-center px-6 py-12 lg:px-8">
|
||||
<div class="sm:mx-auto sm:w-full sm:max-w-sm">
|
||||
<img class="mx-auto h-10 w-auto" src="/static/img/circlea.png" alt="Your Company">
|
||||
<img class="mx-auto h-10 w-auto" src="/static/img/logo-black.png" alt="Your Company">
|
||||
<h2 class="mt-10 text-center text-2xl/9 font-bold tracking-tight text-gray-900">Edit Tags</h2>
|
||||
</div>
|
||||
|
||||
@@ -12,7 +12,36 @@
|
||||
<form action="/tags/{{ .ID }}" method="POST">
|
||||
<div class="max-w-md mx-auto mt-4">
|
||||
<div class="flex">
|
||||
|
||||
<span class="bg-{{ .Color }}-100 text-{{ .Color }}-800 text-xs font-medium me-2 px-2.5 py-0.5 rounded-sm
|
||||
dark:bg-{{ .Color }}-900 dark:text-{{ .Color }}-300">Preview</span>
|
||||
<input type="text" id="name" name="name" value="{{ .Name }}" class="flex-grow border border-gray-300 rounded-l-md p-2 focus:outline-none focus:ring focus:ring-blue-500">
|
||||
<select name="color" required>
|
||||
<option selected value="{{ .Color }}">{{ .Color }}</option>
|
||||
<option value="1">Default</option>
|
||||
<option value="red">red</option>
|
||||
<option value="orange">orange</option>
|
||||
<option value="amber">amber</option>
|
||||
<option value="yellow">yellow</option>
|
||||
<option value="lime">lime</option>
|
||||
<option value="green">green</option>
|
||||
<option value="emerald">emerald</option>
|
||||
<option value="teal">teal</option>
|
||||
<option value="cyan">cyan</option>
|
||||
<option value="sky">sky</option>
|
||||
<option value="blue">blue</option>
|
||||
<option value="indigo">indigo</option>
|
||||
<option value="violet">violet</option>
|
||||
<option value="purple">purple</option>
|
||||
<option value="fuchsia">fuchsia</option>
|
||||
<option value="pink">pink</option>
|
||||
<option value="rose">rose</option>
|
||||
<option value="slate">slate</option>
|
||||
<option value="gray">gray</option>
|
||||
<option value="zinc">zinc</option>
|
||||
<option value="neutral">neutral</option>
|
||||
<option value="stone">stone</option>
|
||||
</select>
|
||||
<button type="submit" name="action" value="update" class="bg-blue-600 text-white ml-4 mr-4 rounded px-4 hover:bg-blue-700">Update</button>
|
||||
<button type="submit" name="action" value="delete" class="bg-red-800 text-white rounded px-4 hover:bg-red-900">Delete</button>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user