diff --git a/server/auth.go b/server/auth.go index 134fa7f..518d94c 100644 --- a/server/auth.go +++ b/server/auth.go @@ -11,6 +11,11 @@ import ( "github.com/localhots/empact/task" ) +func authHelloHandler(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "text/html; charset=utf8") + helloTmpl.ExecuteTemplate(w, "hello", map[string]interface{}{}) +} + func authSigninHandler(w http.ResponseWriter, r *http.Request) { params := url.Values{} params.Set("client_id", config.C().ClientID) diff --git a/server/server.go b/server/server.go index 2272fad..27ac7cb 100644 --- a/server/server.go +++ b/server/server.go @@ -2,21 +2,36 @@ package server import ( "fmt" + "html/template" "net/http" "time" "code.google.com/p/go-uuid/uuid" + "github.com/GeertJohan/go.rice" ) const ( sessionCookie = "session_id" ) -func Start() { - fmt.Println("Starting server at http://localhost:8080") +var ( + helloTmpl = template.New("hello") +) + +func init() { + box := rice.MustFindBox("static") + http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(box.HTTPBox()))) + tmplText, _ := box.String("hello.tmpl") + helloTmpl, _ = helloTmpl.Parse(tmplText) + http.HandleFunc("/", sessionHandler) + http.HandleFunc("/auth/hello", authHelloHandler) http.HandleFunc("/auth/signin", authSigninHandler) http.HandleFunc("/auth/callback", authCallbackHandler) +} + +func Start() { + fmt.Println("Starting server at http://localhost:8080") http.ListenAndServe(":8080", nil) } diff --git a/server/static/github_mark_120.png b/server/static/github_mark_120.png new file mode 100644 index 0000000..ea6ff54 Binary files /dev/null and b/server/static/github_mark_120.png differ diff --git a/server/static/hello.css b/server/static/hello.css new file mode 100644 index 0000000..ed6fde6 --- /dev/null +++ b/server/static/hello.css @@ -0,0 +1,29 @@ +* { + box-sizing: border-box; + font-family: 'Helvetica Neue', Helvetica, sans-serif; + font-weight: 400; +} +html, body { + margin: 0; + padding: 0; +} + +h1 { + position: absolute; + left: 15%; + top: 20%; + width: 70%; + text-align: center; + color: #aaa; +} + +a { + position: absolute; + top: 40%; + width: 100%; + text-align: center; +} + +img { + width: 60px; +} diff --git a/server/static/hello.js b/server/static/hello.js new file mode 100644 index 0000000..e69de29 diff --git a/server/static/hello.tmpl b/server/static/hello.tmpl new file mode 100644 index 0000000..2e42433 --- /dev/null +++ b/server/static/hello.tmpl @@ -0,0 +1,20 @@ +{{define "hello"}} + + +
+ +