summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrail Finder <wohilas@gmail.com>2025-03-29 14:28:41 +0300
committerGrail Finder <wohilas@gmail.com>2025-03-29 14:28:41 +0300
commitcb8b8e80d774608c6aa7a1d28f6d948828fea806 (patch)
treec6a6b99cb2f03b69d142930ca720c24f22b8351c
parent7a3a73f2a7f2498c61c71f3242a0fcd6c56dfb69 (diff)
Chore: cleaning
-rw-r--r--components/auth.html22
-rw-r--r--components/index.html12
-rw-r--r--internal/handlers/main.go15
-rw-r--r--internal/models/models.go50
4 files changed, 14 insertions, 85 deletions
diff --git a/components/auth.html b/components/auth.html
deleted file mode 100644
index 5122919..0000000
--- a/components/auth.html
+++ /dev/null
@@ -1,22 +0,0 @@
-{{define "auth"}}
-<div id="logindiv">
- <form class="space-y-6" hx-target="#ancestor" hx-swap="outerHTML">
- <div>
- <label For="username" class="block text-sm font-medium leading-6 text-white-900">username</label>
- <div class="mt-2">
- <input id="username" name="username" autocomplete="username" class="rounded-md text-center text-black" required />
- </div>
- </div>
- <div>
- <label For="password" class="block text-sm font-medium leading-6 text-white-900">password</label>
- <div class="mt-2">
- <input id="password" name="password" type="password" required class="rounded-md text-center text-black" />
- </div>
- </div>
- <div>
- <button type="submit" hx-post="/login" class="justify-center rounded-md bg-indigo-600 px-3 py-1.5 text-sm font-semibold leading-6 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">Log in</button>
- <button type="submit" hx-post="/signup" class="justify-center rounded-md bg-indigo-600 px-3 py-1.5 text-sm font-semibold leading-6 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">Sign up</button>
- </div>
- </form>
-</div>
-{{end}}
diff --git a/components/index.html b/components/index.html
index 4562550..cd6eeeb 100644
--- a/components/index.html
+++ b/components/index.html
@@ -2,7 +2,7 @@
<!DOCTYPE html>
<html>
<head>
- <title>Action Points Journal</title>
+ <title>German exercises</title>
<meta charset="utf-8" name="viewport" content="width=device-width,initial-scale=1"/>
<link rel="stylesheet" type="text/css" href="/assets/style.css" />
<link rel="icon" sizes="64x64" href="/assets/favicon/wolfhead_negated.ico" />
@@ -10,18 +10,12 @@
</head>
<body>
<div id="ancestor">
- {{ if not .Username }}
<div>
- {{ template "auth" }}
+ {{.Text}}
</div>
- {{ else }}
<div>
- hello user
+ <!-->here we need to iterate through options and make them selectable; ai!<-->
</div>
- <div>
- some button
- </div>
- {{ end }}
</div>
</body>
</html>
diff --git a/internal/handlers/main.go b/internal/handlers/main.go
index 86f5b09..4945db8 100644
--- a/internal/handlers/main.go
+++ b/internal/handlers/main.go
@@ -3,15 +3,12 @@ package handlers
import (
"demoon/config"
"demoon/internal/database/repos"
- "demoon/internal/models"
"html/template"
"log/slog"
"net/http"
"os"
)
-var defUS = models.UserScore{}
-
// Handlers structure
type Handlers struct {
cfg config.Config
@@ -45,17 +42,5 @@ func (h *Handlers) MainPage(w http.ResponseWriter, r *http.Request) {
abortWithError(w, err.Error())
return
}
- // get recommendations
- usernameRaw := r.Context().Value("username")
- h.log.Info("got mainpage request", "username", usernameRaw)
- if usernameRaw == nil {
- tmpl.ExecuteTemplate(w, "main", defUS)
- return
- }
- username := usernameRaw.(string)
- if username == "" {
- tmpl.ExecuteTemplate(w, "main", defUS)
- return
- }
tmpl.ExecuteTemplate(w, "main", nil)
}
diff --git a/internal/models/models.go b/internal/models/models.go
index 5bc120b..8dc113c 100644
--- a/internal/models/models.go
+++ b/internal/models/models.go
@@ -1,45 +1,17 @@
package models
-import "time"
-
-type ActionType string
-
-const (
- ActionTypePlus ActionType = "ActionTypePlus"
- ActionTypeMinus ActionType = "ActionTypeMinus"
-)
-
type (
- UserScore struct {
- ID uint32 `db:"id"`
- Username string `db:"username"`
- Password string `db:"password"`
- Actions []Action
- Recommendations []Action
- BurnTime time.Time `db:"burn_time"`
- Score int8 `db:"score"`
- CreatedAt time.Time `db:"created_at"`
+ Question struct {
+ ID uint32
+ Text string
+ Options []string
+ CorrectIndex uint8
+ TopicID uint32
}
- Action struct {
- ID uint32 `db:"id"`
- Name string `db:"name"`
- Magnitude uint8 `db:"magnitude"`
- Repeatable bool `db:"repeatable"`
- Type ActionType `db:"type"`
- Done bool `db:"done"`
- Username string `db:"username"`
- CreatedAt time.Time `db:"created_at"`
+ //
+ Topic struct {
+ ID uint32
+ Name string
+ Level uint32
}
)
-
-func (us *UserScore) UpdateScore(act *Action) {
- switch act.Type {
- case ActionTypePlus:
- us.Score += int8(act.Magnitude)
- if !act.Repeatable {
- act.Done = true
- }
- case ActionTypeMinus:
- us.Score -= int8(act.Magnitude)
- }
-}