Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The LUCI Authors. All rights reserved. | 1 // Copyright 2015 The LUCI Authors. All rights reserved. |
| 2 // Use of this source code is governed under the Apache License, Version 2.0 | 2 // Use of this source code is governed under the Apache License, Version 2.0 |
| 3 // that can be found in the LICENSE file. | 3 // that can be found in the LICENSE file. |
| 4 | 4 |
| 5 package buildbot | 5 package buildbot |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "fmt" | 8 "fmt" |
| 9 "net/http" | 9 "net/http" |
| 10 "os" | 10 "os" |
| 11 "strconv" | 11 "strconv" |
| 12 | 12 |
| 13 "github.com/julienschmidt/httprouter" | 13 "github.com/julienschmidt/httprouter" |
| 14 "golang.org/x/net/context" | 14 "golang.org/x/net/context" |
| 15 | 15 |
| 16 "github.com/luci/luci-go/milo/appengine/settings" | 16 "github.com/luci/luci-go/milo/appengine/settings" |
| 17 "github.com/luci/luci-go/milo/common/miloerror" | 17 "github.com/luci/luci-go/milo/common/miloerror" |
| 18 "github.com/luci/luci-go/server/templates" | 18 "github.com/luci/luci-go/server/templates" |
| 19 ) | 19 ) |
| 20 | 20 |
| 21 // Build is the container struct for methods related to buildbot build pages. | 21 // BuildHandler Render the buildbot build page. |
|
nodir
2017/03/16 17:42:51
renders?
hinoka
2017/03/17 20:00:21
Now it does
| |
| 22 type Build struct{} | 22 func BuildHandler(c context.Context, r *http.Request, p httprouter.Params) (*tem plates.Args, error) { |
| 23 | |
| 24 // Builder is the container struct for methods related to buildbot builder pages . | |
| 25 type Builder struct{} | |
| 26 | |
| 27 // GetTemplateName returns the template name for build pages. | |
| 28 func (b Build) GetTemplateName(t settings.Theme) string { | |
| 29 » return "build.html" | |
| 30 } | |
| 31 | |
| 32 // Render Render the buildbot build page. | |
| 33 func (b Build) Render(c context.Context, r *http.Request, p httprouter.Params) ( *templates.Args, error) { | |
| 34 master := p.ByName("master") | 23 master := p.ByName("master") |
| 35 if master == "" { | 24 if master == "" { |
| 36 return nil, &miloerror.Error{ | 25 return nil, &miloerror.Error{ |
| 37 Message: "No master", | 26 Message: "No master", |
| 38 Code: http.StatusBadRequest, | 27 Code: http.StatusBadRequest, |
| 39 } | 28 } |
| 40 } | 29 } |
| 41 builder := p.ByName("builder") | 30 builder := p.ByName("builder") |
| 42 if builder == "" { | 31 if builder == "" { |
| 43 return nil, &miloerror.Error{ | 32 return nil, &miloerror.Error{ |
| (...skipping 19 matching lines...) Expand all Loading... | |
| 63 result, err := build(c, master, builder, num) | 52 result, err := build(c, master, builder, num) |
| 64 if err != nil { | 53 if err != nil { |
| 65 return nil, err | 54 return nil, err |
| 66 } | 55 } |
| 67 | 56 |
| 68 // Render into the template | 57 // Render into the template |
| 69 fmt.Fprintf(os.Stderr, "Result: %#v\n\n", result) | 58 fmt.Fprintf(os.Stderr, "Result: %#v\n\n", result) |
| 70 args := &templates.Args{ | 59 args := &templates.Args{ |
| 71 "Build": result, | 60 "Build": result, |
| 72 } | 61 } |
| 73 return args, nil | 62 return args, nil |
|
nodir
2017/03/16 17:42:51
without templates, I don't see why not render temp
hinoka
2017/03/17 20:00:21
Done.
| |
| 74 } | 63 } |
| 75 | 64 |
| 76 // GetTemplateName returns the template name for builder pages. | 65 // BuilderHandler renders the buildbot builder page. |
| 77 func (b Builder) GetTemplateName(t settings.Theme) string { | |
| 78 » return "builder.html" | |
| 79 } | |
| 80 | |
| 81 // Render renders the buildbot builder page. | |
| 82 // Note: The builder html template contains self links to "?limit=123", which co uld | 66 // Note: The builder html template contains self links to "?limit=123", which co uld |
| 83 // potentially override any other request parameters set. | 67 // potentially override any other request parameters set. |
| 84 func (b Builder) Render(c context.Context, r *http.Request, p httprouter.Params) (*templates.Args, error) { | 68 func BuilderHandler(c context.Context, r *http.Request, p httprouter.Params) (*t emplates.Args, error) { |
| 85 master := p.ByName("master") | 69 master := p.ByName("master") |
| 86 if master == "" { | 70 if master == "" { |
| 87 return nil, &miloerror.Error{ | 71 return nil, &miloerror.Error{ |
| 88 Message: "No master specified", | 72 Message: "No master specified", |
| 89 Code: http.StatusBadRequest, | 73 Code: http.StatusBadRequest, |
| 90 } | 74 } |
| 91 } | 75 } |
| 92 builder := p.ByName("builder") | 76 builder := p.ByName("builder") |
| 93 if builder == "" { | 77 if builder == "" { |
| 94 return nil, &miloerror.Error{ | 78 return nil, &miloerror.Error{ |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 108 if err != nil { | 92 if err != nil { |
| 109 return nil, err | 93 return nil, err |
| 110 } | 94 } |
| 111 | 95 |
| 112 // Render into the template | 96 // Render into the template |
| 113 args := &templates.Args{ | 97 args := &templates.Args{ |
| 114 "Builder": result, | 98 "Builder": result, |
| 115 } | 99 } |
| 116 return args, nil | 100 return args, nil |
| 117 } | 101 } |
| OLD | NEW |