From b070f19510b07636d0096ad8d5ef8d47e1fa0c0a Mon Sep 17 00:00:00 2001 From: Gregory Eremin Date: Thu, 5 Mar 2015 20:49:50 +0700 Subject: [PATCH] Hello page --- server/auth.go | 5 +++++ server/server.go | 19 +++++++++++++++++-- server/static/github_mark_120.png | Bin 0 -> 4268 bytes server/static/hello.css | 29 +++++++++++++++++++++++++++++ server/static/hello.js | 0 server/static/hello.tmpl | 20 ++++++++++++++++++++ 6 files changed, 71 insertions(+), 2 deletions(-) create mode 100644 server/static/github_mark_120.png create mode 100644 server/static/hello.css create mode 100644 server/static/hello.js create mode 100644 server/static/hello.tmpl 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 0000000000000000000000000000000000000000..ea6ff545a246caa64074ba809bbc86fcb8589071 GIT binary patch literal 4268 zcmaJ_c|25m+@2YcEGe=tO+zT_42H4qTL_VT8D=nHX3PwRki9HfBH7BIQ7JCj_beeI z(PA%IQuZumf5*MI`@VnN`<~A^=eL~adA{p8f1EgTGXqv8J|+MFz-nZuYe^f)M;9Xl z?T$df2WbN@Nzaya1?NEuL=w;dEfmfT4L0&cdZI1SNK}yDE3_&AKqrE+vL)G?nkc*D ze5H{`7-_OEp2h|MR5i$Wq`Nno1a?DvVz6qEm4+4w7=u!S*eICFn&NfPUKqn*0{Tj@ znU#C6w>ts_(NG7gl9g!!zGxB>O!oD`5|znnkUw>mY4f9P83_1K2+3Ow@|RP#rsiNB z903hhkd~8jmxV&XaJV#7UI7k=N`hgsP?(G??SxA~<&_oS$}mOn-v@+djezn{w$#=C z+ZJu52Js@1@X9hWfq{Y2fpXF~f~O1=fj}H-z+h4|gcLCdOG1*RuteeC3c6^bI{||y zVQ^URks{I!=TB0D&^-Ms1Yi6=vRLBZX`&@ehK$6^K&54mLi!CfHU0mgzP|sUi6l$( z|N8r{!bGbeJX*#QO~m;V+-ZgL5I!=6SJok*kt7_!3WxLgokepm90^DC!r{R>SKwfA zQ=~fvd$e)kPllD+ zRvxaUgpifj{ms?Ix%>N~v83Nz6pahhl84G`Y3tCq(0}C~HG?mnW?2_azyzRC`UIRW z_|Kq~G5_t0?0@_67Z>#}zWf~rt)x_q6t=RejnvErW>9V+3xJmC z`WZuvjAn72w+0gZ!c zA#ROc&m%S~RCo}xuD5jUEbXg(tZCM@w!T|#S$ju3+PKnZvOq!Te!k1i>ZlAY2d$hq zcr3hl)6*dTc>dY=Qd5hg9F-3ZJx12?th3 zY?KG;EA_?MEA`bUgvx84mEd_1K6WD6Zh&~3v&UiJT=<@uGaZ9%(IN9U?-o?uhZNz# z0#o|=;zl}_TF1jsmf+jyEQ<#bNr0KCAUYnr%4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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"}} + + + + + Empact + + + + +

Please Sign in with your GitHub account

+ + + + + + + + +{{end}}