aboutsummaryrefslogtreecommitdiff
path: root/pkg/handler/random.go
diff options
context:
space:
mode:
authorAlexander Neonxp Kiryukhin <i@neonxp.ru>2024-10-08 03:43:08 +0300
committerAlexander Neonxp Kiryukhin <i@neonxp.ru>2024-10-08 03:50:53 +0300
commite849e705c30cceec3cf7336a21bed96c8a911e90 (patch)
tree93f559bcd4cf3e53193930d112e564a2b7462ac8 /pkg/handler/random.go
parent3ee654f6fb3cdf119630bfba8066c96ec26428c3 (diff)
Добавил рейтинг
Добавил страницу топа Добавил rss/xml/json feed
Diffstat (limited to 'pkg/handler/random.go')
-rw-r--r--pkg/handler/random.go31
1 files changed, 0 insertions, 31 deletions
diff --git a/pkg/handler/random.go b/pkg/handler/random.go
deleted file mode 100644
index 29c5f6f..0000000
--- a/pkg/handler/random.go
+++ /dev/null
@@ -1,31 +0,0 @@
-package handler
-
-import (
- "github.com/a-h/templ"
- "github.com/labstack/echo/v4"
- "sh.org.ru/pkg/model"
- "sh.org.ru/pkg/tpl"
-)
-
-func (h *Handler) Random(c echo.Context) error {
- quotes := make([]model.Quote, 0, 20)
- err := h.DB.NewRaw(`select q.* from quotes q where q.approved = true order by random() limit 20`).
- Scan(c.Request().Context(), &quotes)
- if err != nil {
- return err
- }
-
- comp := tpl.Random(quotes)
-
- if c.Request().Header.Get("Hx-Request") == "true" {
- return comp.Render(c.Request().Context(), c.Response())
- }
-
- ctx := templ.WithChildren(c.Request().Context(), comp)
-
- return tpl.Layout(tpl.HeaderParams{
- Title: "Цитатник Рунета",
- Description: "Новый цитатник Рунета",
- URL: "https://sh.org.ru/",
- }).Render(ctx, c.Response())
-}