diff --git a/assignment.html b/assignment.html
deleted file mode 100644
index 50f7edc..0000000
--- a/assignment.html
+++ /dev/null
@@ -1,18 +0,0 @@
-
-
-
-
- Zadání šifry {{.Order}}
-
-
-
- Zadání šifry {{.Order}}
- {{.Assignment}}
-
-
-
-
-
\ No newline at end of file
diff --git a/klice.go b/klice.go
index 92b4333..758aeb8 100644
--- a/klice.go
+++ b/klice.go
@@ -5,6 +5,7 @@ import (
"database/sql"
"encoding/hex"
"fmt"
+ "html/template"
"io"
"net/http"
"os"
@@ -58,7 +59,7 @@ func loginHandler(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, "/team", http.StatusSeeOther)
}
} else if r.Method == http.MethodGet {
- loginPage, err := os.Open("login.html")
+ loginPage, err := os.Open("templates/login.html")
if err != nil {
http.Error(w, "Could not open login page", http.StatusInternalServerError)
return
@@ -153,7 +154,19 @@ func qrHandler(w http.ResponseWriter, r *http.Request) {
return
}
- fmt.Fprintf(w, "QR Code: %s, Position ID: %d, Cipher ID: %d, Assignment: %s", uid, positionID, cipherID, assignment)
+ CipherTemplateData := CipherTemplateS{
+ Order: uint(cipherID),
+ Assignment: template.HTML(assignment),
+ HelpText: "",
+ FinalClue: "",
+ Coordinates: "",
+ Solution: "",
+ }
+ err = CipherTemplate.Execute(w, CipherTemplateData)
+ if err != nil {
+ http.Error(w, "Could not render template", http.StatusInternalServerError)
+ return
+ }
}
}
diff --git a/templates.go b/templates.go
new file mode 100644
index 0000000..387b08d
--- /dev/null
+++ b/templates.go
@@ -0,0 +1,16 @@
+package main
+
+import (
+ "html/template"
+)
+
+type CipherTemplateS struct {
+ Order uint
+ Assignment template.HTML
+ HelpText string
+ FinalClue string
+ Coordinates string
+ Solution string
+}
+
+var CipherTemplate = template.Must(template.ParseFiles("templates/assignment.html"))
diff --git a/templates/assignment.html b/templates/assignment.html
new file mode 100644
index 0000000..71374aa
--- /dev/null
+++ b/templates/assignment.html
@@ -0,0 +1,40 @@
+
+
+
+
+ Zadání šifry {{.Order}}
+
+
+
+ Zadání šifry {{.Order}}
+ {{.Assignment}}
+
+ {{if eq .HelpText ""}}
+ Požádat o malou nápovědu.
+
+ {{else if eq .Coordinates ""}}
+ Nápověda: {{.HelpText}}
+ Vzdát se a ukázat pozici další šifry.
+
+ {{else}}
+ Řešení: {{.Solution}}
+ {{end}}
+
+ {{if eq .Coordinates ""}}
+
+ {{else}}
+ Souřadnice další šifry: {{.Coordinates}}
+ Nápověda k nalezení cíle: {{.FinalClue}}
+ {{end}}
+
+
+
\ No newline at end of file
diff --git a/login.html b/templates/login.html
similarity index 83%
rename from login.html
rename to templates/login.html
index 0c68620..cb6ff77 100644
--- a/login.html
+++ b/templates/login.html
@@ -3,7 +3,6 @@
-
Login