1. Miki Tebeka
  2. go-meetup

Commits

Miki Tebeka  committed ba7a32d

form

  • Participants
  • Parent commits b3c0f36
  • Branches default

Comments (0)

Files changed (2)

File 2-template/shortie/html.go

View file
     <body>
         <div class="header">
             The URL Shortener
-            <span class="right">
-				<a href="{{ .LoginURL }}">{{ .LoginTitle }}</a>
-            </span>
         </div>
 
-        {{ if .ShortURL }}
-        <div class="short">
-            Url shortened to <a href="{{ .ShortURL }}">{{ .ShortURL }}</a>
-        </div>
-        {{ end }}
-
-        {{ if .Error }}
-        <div class="error">
-            ERROR: {{ .Error | html}}
-        </div>
-        {{ end }}
-
         <form method="post">
             <label for="url">Url:</label><input name="url" /> 
             <input type="submit" value="Shorten">
         </form>
 
-		{{ with .URLs }}
-        <b>Your Urls</b>
-        <table class="urls">
-            <tr><th>URL</th><th>Created</th><th>Hits</th></tr>
-			{{ range $idx, $url := . }}
-				<tr class="{{ $idx | oddeven }}">
-					<td title="{{ .Long | html }}">
-						<a href="{{ .Long }}">{{ .Short }}</a>
-					</td>
-					<td>{{ .Created | strftime }}</td>
-					<td>{{ .Hits }}</td>
-            </tr>
-            {{ end }}
-        </table>
-        {{ end }}
-
         <div class="footer">
-            G'day {{ .User }}, we've shortened {{ .Count }} urls so far.
+            G'day
         </div>
 	</body>
 </html>

File 2-template/shortie/shortie.go

View file
 package shortie
 
 import (
-	"fmt"
+	"html/template"
 	"net/http"
 )
 
+var homeTemplate *template.Template
+
 func init() {
+	homeTemplate = template.Must(template.New("home").Parse(homeHTML))
 	http.HandleFunc("/", rootHandler)
 }
 
 // rootHandler handles the main page.
 func rootHandler(w http.ResponseWriter, r *http.Request) {
-	fmt.Fprintf(w, "Hello AppEngine\n")
+	homeTemplate.Execute(w, nil)
 }