Move app from server
This commit is contained in:
		
							parent
							
								
									525925691b
								
							
						
					
					
						commit
						da9ec3482e
					
				
							
								
								
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								.gitignore
									
									
									
									
										vendored
									
									
								
							@ -1,3 +1,3 @@
 | 
			
		||||
config.json
 | 
			
		||||
*.txt
 | 
			
		||||
server/app/.module-cache
 | 
			
		||||
app/.module-cache
 | 
			
		||||
 | 
			
		||||
							
								
								
									
										37
									
								
								app/app.css
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										37
									
								
								app/app.css
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,37 @@
 | 
			
		||||
section {
 | 
			
		||||
    float: left;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#menu {
 | 
			
		||||
    width: 13em;
 | 
			
		||||
}
 | 
			
		||||
#menu ul {
 | 
			
		||||
    margin: 0;
 | 
			
		||||
    padding: 0;
 | 
			
		||||
}
 | 
			
		||||
li.nav {
 | 
			
		||||
    display: block;
 | 
			
		||||
    line-height: 2.5em;
 | 
			
		||||
    padding: 0 1em;
 | 
			
		||||
    cursor: pointer;
 | 
			
		||||
}
 | 
			
		||||
.nav.empact {
 | 
			
		||||
    font-weight: 600;
 | 
			
		||||
}
 | 
			
		||||
.nav.header {
 | 
			
		||||
    color: #aaa;
 | 
			
		||||
    cursor: default;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#content {
 | 
			
		||||
    width: calc(100% - 13em);
 | 
			
		||||
}
 | 
			
		||||
#content .left, #content .right {
 | 
			
		||||
    width: 50%;
 | 
			
		||||
}
 | 
			
		||||
#content .left {
 | 
			
		||||
    background: #5500fa;
 | 
			
		||||
}
 | 
			
		||||
#content .right {
 | 
			
		||||
    background: #fa0055;
 | 
			
		||||
}
 | 
			
		||||
| 
		 Before Width: | Height: | Size: 4.2 KiB After Width: | Height: | Size: 4.2 KiB  | 
@ -1,15 +0,0 @@
 | 
			
		||||
package server
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"net/http"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func appHelloHandler(w http.ResponseWriter, r *http.Request) {
 | 
			
		||||
	w.Header().Set("Content-Type", "text/html; charset=utf8")
 | 
			
		||||
	helloTmpl.ExecuteTemplate(w, "hello", map[string]interface{}{})
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func appAppHandler(w http.ResponseWriter, r *http.Request) {
 | 
			
		||||
	w.Header().Set("Content-Type", "text/html; charset=utf8")
 | 
			
		||||
	appTmpl.ExecuteTemplate(w, "app", map[string]interface{}{})
 | 
			
		||||
}
 | 
			
		||||
@ -1,20 +0,0 @@
 | 
			
		||||
{{define "app"}}
 | 
			
		||||
<!DOCTYPE html>
 | 
			
		||||
<html>
 | 
			
		||||
<head>
 | 
			
		||||
    <meta charset="utf8">
 | 
			
		||||
    <title>Empact</title>
 | 
			
		||||
    <link rel="stylesheet" href="/app/hello.css">
 | 
			
		||||
</head>
 | 
			
		||||
<body>
 | 
			
		||||
 | 
			
		||||
<h1>Please Sign in with your GitHub account</h1>
 | 
			
		||||
<a href="/auth/signin">
 | 
			
		||||
    <img src="/app/github_mark_120.png">
 | 
			
		||||
</a>
 | 
			
		||||
 | 
			
		||||
<script src="/app/hello.js"></script>
 | 
			
		||||
 | 
			
		||||
</body>
 | 
			
		||||
</html>
 | 
			
		||||
{{end}}
 | 
			
		||||
@ -1,20 +0,0 @@
 | 
			
		||||
{{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}}
 | 
			
		||||
@ -2,26 +2,11 @@ package server
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
	"encoding/json"
 | 
			
		||||
	"html/template"
 | 
			
		||||
	"log"
 | 
			
		||||
	"net/http"
 | 
			
		||||
 | 
			
		||||
	"github.com/GeertJohan/go.rice"
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
var (
 | 
			
		||||
	helloTmpl = template.New("hello")
 | 
			
		||||
	appTmpl   = template.New("app")
 | 
			
		||||
	box       = rice.MustFindBox("app")
 | 
			
		||||
)
 | 
			
		||||
 | 
			
		||||
func init() {
 | 
			
		||||
	parseTemplate("hello.tmpl", helloTmpl)
 | 
			
		||||
	parseTemplate("app.tmpl", appTmpl)
 | 
			
		||||
 | 
			
		||||
	// Serving static files
 | 
			
		||||
	http.Handle("/app/", http.StripPrefix("/app/", http.FileServer(box.HTTPBox())))
 | 
			
		||||
 | 
			
		||||
	http.HandleFunc("/", sessionHandler)
 | 
			
		||||
	http.HandleFunc("/hello", appHelloHandler)
 | 
			
		||||
	http.HandleFunc("/app", appAppHandler)
 | 
			
		||||
@ -43,20 +28,13 @@ func Start() {
 | 
			
		||||
	http.ListenAndServe(":8080", nil)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func parseTemplate(file string, tmpl *template.Template) {
 | 
			
		||||
	if tmplText, err := box.String(file); err == nil {
 | 
			
		||||
		tmpl, _ = tmpl.Parse(tmplText)
 | 
			
		||||
	} else {
 | 
			
		||||
		panic(err)
 | 
			
		||||
	}
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func respondWith(w http.ResponseWriter, resp interface{}) {
 | 
			
		||||
	b, err := json.Marshal(resp)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		panic(err)
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	w.Header().Set("Access-Control-Allow-Origin", "*")
 | 
			
		||||
	w.Header().Set("Content-Type", "application/json; charset=utf8")
 | 
			
		||||
	w.Write(b)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user