Design changed

master
kreativmonkey 7 years ago
parent 272fe3212c
commit 9da90186e7

@ -10,6 +10,7 @@ import (
) )
type Page struct { type Page struct {
Host string
Title string Title string
Body string Body string
} }
@ -34,7 +35,7 @@ func index(w http.ResponseWriter, r *http.Request) {
fmt.Printf("Token: %s Redirect to: %s \n", string(r.URL.Path[1:]), redirect) fmt.Printf("Token: %s Redirect to: %s \n", string(r.URL.Path[1:]), redirect)
} else { } else {
t, _ := template.ParseFiles("template/index.gohtml") t, _ := template.ParseFiles("template/index.gohtml")
t.Execute(w, nil) t.Execute(w, Page{Title: "Shrt"})
} }
case "POST": case "POST":
var test string var test string
@ -42,10 +43,9 @@ func index(w http.ResponseWriter, r *http.Request) {
if err != nil { if err != nil {
panic(err) panic(err)
} }
P := Page{Title: r.FormValue("url"), Body: token} P := Page{Title: "Url:", Body: r.Host + "/" + token}
t, _ := template.ParseFiles("template/index.gohtml") t, _ := template.ParseFiles("template/index.gohtml")
t.Execute(w, P) t.Execute(w, P)
fmt.Println("Token by Url:", P)
} }
} }

@ -4,6 +4,12 @@
<meta charset="UTF-8"> <meta charset="UTF-8">
<title>Shrt</title> <title>Shrt</title>
<style> <style>
body {
height: 80vh;
display: flex;
flex-direction: column;
justify-content: center;
}
#main { #main {
width: 1170px; width: 1170px;
margin: 0 auto; margin: 0 auto;
@ -47,13 +53,11 @@
<body> <body>
<div id="main"> <div id="main">
<h1>Shrt</h1> <h1>{{.Title}}</h1>
<form id="shorten" action="./" method="post"> <form id="shorten" action="./" method="post">
<input type="url" name="url" pattern="^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?" placeholder="Url to shorten!" required="" autofocus> <input type="url" name="url" pattern="^(([^:/?#]+):)?(//([^/?#]*))?([^?#]*)(\?([^#]*))?(#(.*))?" placeholder="Url to shorten!" required="" autofocus value="{{if .Body}} {{.Body}} {{end}}">
<button class="button" type="submit" name="submit" value="short">Kürzen</button> <button class="button" type="submit" name="submit" value="short">Kürzen</button>
</form> </form>
</div> </div>
<p>Current URL: {{.}}</p>
</body> </body>
</html> </html>
Loading…
Cancel
Save