Design changed

master
kreativmonkey 8 years ago
parent 272fe3212c
commit 9da90186e7

@ -10,6 +10,7 @@ import (
)
type Page struct {
Host string
Title 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)
} else {
t, _ := template.ParseFiles("template/index.gohtml")
t.Execute(w, nil)
t.Execute(w, Page{Title: "Shrt"})
}
case "POST":
var test string
@ -42,10 +43,9 @@ func index(w http.ResponseWriter, r *http.Request) {
if err != nil {
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.Execute(w, P)
fmt.Println("Token by Url:", P)
}
}

@ -4,6 +4,12 @@
<meta charset="UTF-8">
<title>Shrt</title>
<style>
body {
height: 80vh;
display: flex;
flex-direction: column;
justify-content: center;
}
#main {
width: 1170px;
margin: 0 auto;
@ -47,13 +53,11 @@
<body>
<div id="main">
<h1>Shrt</h1>
<h1>{{.Title}}</h1>
<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>
</form>
</div>
<p>Current URL: {{.}}</p>
</body>
</html>
Loading…
Cancel
Save