From fa92edbc70cb91d0cfa84dfa591e66444dc0d005 Mon Sep 17 00:00:00 2001 From: Krio Date: Fri, 20 Aug 2021 09:00:51 +0700 Subject: [PATCH] =?UTF-8?q?=D0=A1=D1=82=D0=B0=D1=82=D0=B8=D1=87=D0=B5?= =?UTF-8?q?=D1=81=D0=BA=D0=B8=D0=B5=20=D1=84=D0=B0=D0=B9=D0=BB=D1=8B=20?= =?UTF-8?q?=D0=B4=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5=D0=BD=D1=8B=20=D0=B2?= =?UTF-8?q?=20=D0=B1=D0=B8=D0=BD=D0=B0=D1=80=D0=BD=D0=B8=D0=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- main.go | 9 +- {html => static}/favicon.png | Bin {html => static}/index.html | 54 ++++++------ {html => static}/styles.css | 158 +++++++++++++++++------------------ 4 files changed, 113 insertions(+), 108 deletions(-) rename {html => static}/favicon.png (100%) rename {html => static}/index.html (74%) rename {html => static}/styles.css (92%) diff --git a/main.go b/main.go index 588c217..8818851 100644 --- a/main.go +++ b/main.go @@ -1,18 +1,22 @@ package main import ( + "embed" "html/template" "log" "net/http" ) +//go:embed static +var staticFiles embed.FS + type Guestbook struct { Comments []string Count int } func indexHandler(writer http.ResponseWriter, request *http.Request) { - html, err := template.ParseFiles("html/index.html") + html, err := template.ParseFS(staticFiles, "static/index.html") check(err) store := TxtStore("comments.txt") @@ -37,7 +41,8 @@ func main() { http.HandleFunc("/", indexHandler) http.HandleFunc("/new", newHandler) - http.Handle("/html/", http.StripPrefix("/html/", http.FileServer(http.Dir("html")))) + var staticFS = http.FS(staticFiles) + http.Handle("/static/", http.FileServer(staticFS)) err := http.ListenAndServe("0.0.0.0:80", nil) log.Fatal(err) diff --git a/html/favicon.png b/static/favicon.png similarity index 100% rename from html/favicon.png rename to static/favicon.png diff --git a/html/index.html b/static/index.html similarity index 74% rename from html/index.html rename to static/index.html index 14390d7..5152d9b 100644 --- a/html/index.html +++ b/static/index.html @@ -1,27 +1,27 @@ - - - - - - Книга отзывов - - - - - -
-

Книга отзывов

- - -
-

Всего записей - {{ .Count }}

- - -
- - -
- - + + + + + + Книга отзывов + + + + + +
+

Книга отзывов

+ + +
+

Всего записей - {{ .Count }}

+ + +
+ + +
+ + diff --git a/html/styles.css b/static/styles.css similarity index 92% rename from html/styles.css rename to static/styles.css index f10e160..8224c11 100644 --- a/html/styles.css +++ b/static/styles.css @@ -1,79 +1,79 @@ -* { - margin: 0; - padding: 0; - - font-family: 'Raleway', serif; -} - -body { - padding: 1%; - - color: #2E3E50; - background: #D8DDDD; - - text-align: center; - letter-spacing: 1px; -} - -.main { - margin: auto; - padding: 1% 2%; - max-width: 800px; - border-radius: 5px; - background: #ECF0F1; - box-shadow: 0 2px 6px 0 rgba(0, 0, 0, .3); -} - -form { - width: 100%; - display: flex; - margin: 2% 0; - -} - -form p { - text-align: left; - padding: 1%; - font-size: 18px; -} - -input { - padding: 1%; - border-radius: 4px; - border: 1px solid #CCC; - font-size: 18px; -} - -input[type=text] { - flex-grow: 1; - - margin: 0 .5%; -} - -input[type=submit] { - cursor: pointer; -} - -input[type=submit]:hover { - background-color: #D8DDDD; -} - -h1 { - font-family: 'Baloo Tamma', cursive; -} - -li{ - list-style-type: none; - - font-size: 18px; - min-width: 24%; - margin: 2% 0; - box-shadow: 0 2px 4px rgba(0, 0, 0, .2); - padding: 1% 2%; - background: #FFF; - box-sizing: border-box; -} - -li:hover { - box-shadow:0 5px 10px rgba(0, 0, 0, .15); -} +* { + margin: 0; + padding: 0; + + font-family: 'Raleway', serif; +} + +body { + padding: 1%; + + color: #2E3E50; + background: #D8DDDD; + + text-align: center; + letter-spacing: 1px; +} + +.main { + margin: auto; + padding: 1% 2%; + max-width: 800px; + border-radius: 5px; + background: #ECF0F1; + box-shadow: 0 2px 6px 0 rgba(0, 0, 0, .3); +} + +form { + width: 100%; + display: flex; + margin: 2% 0; + +} + +form p { + text-align: left; + padding: 1%; + font-size: 18px; +} + +input { + padding: 1%; + border-radius: 4px; + border: 1px solid #CCC; + font-size: 18px; +} + +input[type=text] { + flex-grow: 1; + + margin: 0 .5%; +} + +input[type=submit] { + cursor: pointer; +} + +input[type=submit]:hover { + background-color: #D8DDDD; +} + +h1 { + font-family: 'Baloo Tamma', cursive; +} + +li{ + list-style-type: none; + + font-size: 18px; + min-width: 24%; + margin: 2% 0; + box-shadow: 0 2px 4px rgba(0, 0, 0, .2); + padding: 1% 2%; + background: #FFF; + box-sizing: border-box; +} + +li:hover { + box-shadow:0 5px 10px rgba(0, 0, 0, .15); +}