kontor-echo: setup project to show homepage
Gitea Actions Demo / Explore-Gitea-Actions (push) Successful in 6s
Gitea Actions Demo / build-and-test (push) Failing after 11s

This commit is contained in:
Thomas Peetz
2026-11-09 17:02:59 +01:00
parent 074abd3c85
commit debdf3d0b0
63 changed files with 2411 additions and 485 deletions
+26 -35
View File
@@ -59,33 +59,31 @@ func (handler *MediaLoFiHandler) Add(c *echo.Context) {
c.JSON(http.StatusOK, lofi)
}
func (handler *MediaLoFiHandler) Update(c *echo.Context) {
func (handler *MediaLoFiHandler) Update(c *echo.Context) error {
var input models.MediaLoFiDTO
if err := c.Bind(&input); err != nil {
c.JSON(http.StatusBadRequest, map[string]string{"error": err.Error()})
return
return c.JSON(http.StatusBadRequest, map[string]string{"error": err.Error()})
}
lofi, err := handler.Service.Update(c.Request().Context(), input)
if err != nil {
logger := c.Logger()
logger.Info("MediaLoFiHandler#Update", "error", err.Error())
c.JSON(http.StatusNotFound, map[string]string{"error": "lofi not updated"})
return
return c.JSON(http.StatusNotFound, map[string]string{"error": "lofi not updated"})
}
c.JSON(http.StatusOK, lofi)
return c.JSON(http.StatusOK, lofi)
}
func (handler *MediaLoFiHandler) Delete(c *echo.Context) {
func (handler *MediaLoFiHandler) Delete(c *echo.Context) error {
id := c.Param("id")
err := handler.Service.Delete(c.Request().Context(), id)
if err != nil {
c.JSON(http.StatusNotFound, map[string]string{"error": "lofi not found"})
return
return c.JSON(http.StatusNotFound, map[string]string{"error": "lofi not found"})
}
c.JSON(http.StatusOK, map[string]string{"ok": "true"})
return c.JSON(http.StatusOK, map[string]string{"ok": "true"})
}
func (handler *MediaLoFiHandler) ListPage(c *echo.Context) {
func (handler *MediaLoFiHandler) ListPage(c *echo.Context) error {
cookie, err := c.Cookie(globals.UserKey)
user := cookie.Value
logger := c.Logger()
@@ -113,8 +111,7 @@ func (handler *MediaLoFiHandler) ListPage(c *echo.Context) {
lofis, err := handler.Service.List(c.Request().Context())
if err != nil {
logger.Info("MediaLoFiHandler#ListPage", "error", err.Error())
c.JSON(http.StatusInternalServerError, map[string]string{"error": err.Error()})
return
return c.JSON(http.StatusInternalServerError, map[string]string{"error": err.Error()})
}
logger.Info("MediaLoFiHandler#ListPage", "lofis count", len(lofis))
data := globals.GetDefaultValues(user, "MediaFiles...")
@@ -122,10 +119,10 @@ func (handler *MediaLoFiHandler) ListPage(c *echo.Context) {
data["isReview"] = review
data["isDownload"] = download
data["MediaLinksUrl"] = globals.MediaLofiLink
c.Render(http.StatusOK, "media_links", data)
return c.Render(http.StatusOK, "media_links", data)
}
func (handler *MediaLoFiHandler) EditPage(c *echo.Context) {
func (handler *MediaLoFiHandler) EditPage(c *echo.Context) error {
cookie, err := c.Cookie(globals.UserKey)
user := cookie.Value
id := c.Param("id")
@@ -146,25 +143,23 @@ func (handler *MediaLoFiHandler) EditPage(c *echo.Context) {
lofi, err = handler.Service.Get(c.Request().Context(), id)
if err != nil {
logger.Info("MediaLoFiHandler#EditPage", "error", err.Error())
c.JSON(http.StatusInternalServerError, map[string]string{"error": err.Error()})
return
return c.JSON(http.StatusInternalServerError, map[string]string{"error": err.Error()})
}
}
logger.Info("MediaLoFiHandler#EditPage", "lofi", lofi)
data := globals.GetDefaultValues(user, "MediaLofis...")
data["media"] = lofi
data["MediaLinksUrl"] = globals.MediaLofiLink
c.Render(http.StatusOK, "media_detail", data)
return c.Render(http.StatusOK, "media_detail", data)
}
func (handler *MediaLoFiHandler) ChangeReviewPage(c *echo.Context) {
func (handler *MediaLoFiHandler) ChangeReviewPage(c *echo.Context) error {
id := c.Param("id")
logger := c.Logger()
lofi, err := handler.Service.Get(c.Request().Context(), id)
if err != nil {
logger.Info("MediaLoFiHandler#ChangeReviewPage", "error", err.Error())
c.Redirect(http.StatusNotFound, globals.MediaLofiLink)
return
return c.Redirect(http.StatusNotFound, globals.MediaLofiLink)
}
lofi.Review = !lofi.Review
handler.Service.Update(c.Request().Context(), lofi.ConvertMediaLoFiToDTO())
@@ -174,17 +169,16 @@ func (handler *MediaLoFiHandler) ChangeReviewPage(c *echo.Context) {
lofis, err := handler.Service.List(c.Request().Context())
if err != nil {
logger.Info("MediaLoFiHandler#ChangeReviewPage", "error", err.Error())
c.JSON(http.StatusInternalServerError, map[string]string{"error": err.Error()})
return
return c.JSON(http.StatusInternalServerError, map[string]string{"error": err.Error()})
}
logger.Info("MediaLoFiHandler#ListPage", "lofis count", len(lofis))
data := globals.GetDefaultValues(user, "MediaLofis...")
data["lofis"] = lofis
//c.HTML(http.StatusOK, "lofi", data)
c.Redirect(http.StatusCreated, globals.MediaLofiLink)
//c.Render(http.StatusOK, "lofi", data)
return c.Redirect(http.StatusCreated, globals.MediaLofiLink)
}
func (handler *MediaLoFiHandler) UpdatePage(c *echo.Context) {
func (handler *MediaLoFiHandler) UpdatePage(c *echo.Context) error {
cookie, err := c.Cookie(globals.UserKey)
user := cookie.Value
id := c.Param("id")
@@ -192,25 +186,23 @@ func (handler *MediaLoFiHandler) UpdatePage(c *echo.Context) {
lofi, err := handler.Service.Get(c.Request().Context(), id)
if err != nil {
logger.Info("MediaLoFiHandler#UpdatePage", "error", err.Error())
c.JSON(http.StatusInternalServerError, map[string]string{"error": err.Error()})
return
return c.JSON(http.StatusInternalServerError, map[string]string{"error": err.Error()})
}
var form models.MediaLoFiForm
if err := c.Bind(&form); err != nil {
logger.Info("MediaLoFiHandler#UpdatePage", "error", err.Error())
c.Render(http.StatusBadRequest, "lofi_detail", map[string]any{
return c.Render(http.StatusBadRequest, "lofi_detail", map[string]any{
"Form": form,
"Errors": err.Error(),
"user": user,
})
return
}
logger.Info("MediaLoFiHandler#UpdatePage", "lofi", lofi)
//handler.Service.Update(c.Request.Context(), form.ConvertFormToMediaLofiDTO())
c.Redirect(http.StatusFound, globals.MediaLofiLink)
return c.Redirect(http.StatusFound, globals.MediaLofiLink)
}
func (handler *MediaLoFiHandler) DeletePage(c *echo.Context) {
func (handler *MediaLoFiHandler) DeletePage(c *echo.Context) error {
cookie, err := c.Cookie(globals.UserKey)
user := cookie.Value
id := c.Param("id")
@@ -218,11 +210,10 @@ func (handler *MediaLoFiHandler) DeletePage(c *echo.Context) {
lofi, err := handler.Service.Get(c.Request().Context(), id)
if err != nil {
logger.Info("MediaLoFiHandler#DeletePage", "error", err.Error())
c.JSON(http.StatusInternalServerError, map[string]string{"error": err.Error()})
return
return c.JSON(http.StatusInternalServerError, map[string]string{"error": err.Error()})
}
logger.Info("MediaLoFiHandler#DeletePage", "lofi", id)
c.Render(http.StatusOK, "lofi_delete", map[string]any{
return c.Render(http.StatusOK, "lofi_delete", map[string]any{
"title": "Kontor MediaFiles",
"version": "0.4.0",
"message": "MediaFiles...",