1
0
Fork 0

Hello page

This commit is contained in:
Gregory Eremin 2015-03-05 20:49:50 +07:00
parent 4295811647
commit b070f19510
6 changed files with 71 additions and 2 deletions

View File

@ -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)

View File

@ -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

29
server/static/hello.css Normal file
View File

@ -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
server/static/hello.js Normal file
View File

20
server/static/hello.tmpl Normal file
View File

@ -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}}