Skip to content

Commit

Permalink
enable new polymer user interface
Browse files Browse the repository at this point in the history
  • Loading branch information
bradrydzewski committed Jul 16, 2017
1 parent 587b07c commit b078f1a
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
3 changes: 3 additions & 0 deletions server/template/files/index_polymer.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
<meta name="author" content="bradrydzewski">
<meta name="viewport" content="width=device-width, minimum-scale=1, initial-scale=1, user-scalable=yes">

<link rel="shortcut icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="shortcut icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">

<title></title>
<script>
window.ENV = {};
Expand Down
3 changes: 3 additions & 0 deletions server/template/template_gen.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,9 @@ var indexpolymer = `<!DOCTYPE html>
<meta name="author" content="bradrydzewski">
<meta name="viewport" content="width=device-width, minimum-scale=1, initial-scale=1, user-scalable=yes">
<link rel="shortcut icon" type="image/png" sizes="32x32" href="/favicon-32x32.png">
<link rel="shortcut icon" type="image/png" sizes="16x16" href="/favicon-16x16.png">
<title></title>
<script>
window.ENV = {};
Expand Down
18 changes: 9 additions & 9 deletions server/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ type website struct {

// NewWebsite returns a new website loader.
func NewWebsite() Website {
// TODO change to DRONE_WEB_PATH and add DRONE_WEB_PROXY
path := os.Getenv("DRONE_WWW")
if path != "" {
return NewLocalWebsite(path)
}
return &website{
fs: http.FileServer(dist.AssetFS()),
fs: http.FileServer(dist.New()),
}
}

Expand All @@ -38,14 +39,9 @@ func (w *website) Page(rw http.ResponseWriter, r *http.Request, u *model.User) {

path := r.URL.Path
switch path {
case "/login/form":
params := map[string]interface{}{}
template.T.ExecuteTemplate(rw, "login.html", params)

case "/login":
if err := r.FormValue("error"); err != "" {
params := map[string]interface{}{"error": err}
template.T.ExecuteTemplate(rw, "error.html", params)
// TODO login error
} else {
http.Redirect(rw, r, "/authorize", 303)
}
Expand All @@ -62,7 +58,8 @@ func (w *website) Page(rw http.ResponseWriter, r *http.Request, u *model.User) {
"user": u,
"csrf": csrf,
}
template.T.ExecuteTemplate(rw, "index.html", params)

template.T.ExecuteTemplate(rw, "index_polymer.html", params)
}
}

Expand All @@ -73,6 +70,9 @@ func (w *website) File(rw http.ResponseWriter, r *http.Request) {

func (w *website) Routes() []string {
return []string{
"/static/*filepath",
"/favicon-32x32.png",
"/favicon-16x16.png",
"/src/*filepath",
"/bower_components/*filepath",
}
}

0 comments on commit b078f1a

Please sign in to comment.