Hello page
This commit is contained in:
parent
4295811647
commit
b070f19510
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 4.2 KiB |
|
@ -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;
|
||||
}
|
|
@ -0,0 +1,20 @@
|
|||
{{define "hello"}}
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf8">
|
||||
<title>Empact</title>
|
||||
<link rel="stylesheet" href="/static/hello.css">
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<h1>Please Sign in with your GitHub account</h1>
|
||||
<a href="/auth/signin">
|
||||
<img src="/static/github_mark_120.png">
|
||||
</a>
|
||||
|
||||
<script src="/static/hello.js"></script>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
{{end}}
|
Loading…
Reference in New Issue