dmitri.shuralyov.com/website/gido

Convert analyticsHTML to template.HTML sooner.

This simplifies code, as fewer conversions are required.
dmitshur committed 6 years ago commit 6670923b2782fbb228d76ee5f7467fe29c4b5727
Showing partial commit. Full Commit
Collapse all
changes.go
@@ -97,11 +97,11 @@ func (h *handler) serveChanges(w http.ResponseWriter, req *http.Request, pkg str
	closedCount := uint64(len(ic.ClosedChanges))

	w.Header().Set("Content-Type", "text/html; charset=utf-8")
	err = h.executeTemplate(w, req, "Header", map[string]interface{}{
		"PageName":      pkg,
		"AnalyticsHTML": template.HTML(h.analyticsHTML),
		"AnalyticsHTML": h.analyticsHTML,
	})
	if err != nil {
		return err
	}
	heading := htmlg.NodeComponent{
issues.go
@@ -97,11 +97,11 @@ func (h *handler) serveIssues(w http.ResponseWriter, req *http.Request, pkg stri
	closedCount := uint64(len(ic.ClosedIssues))

	w.Header().Set("Content-Type", "text/html; charset=utf-8")
	err = h.executeTemplate(w, req, "Header", map[string]interface{}{
		"PageName":      pkg,
		"AnalyticsHTML": template.HTML(h.analyticsHTML),
		"AnalyticsHTML": h.analyticsHTML,
	})
	if err != nil {
		return err
	}
	heading := htmlg.NodeComponent{
main.go
@@ -74,11 +74,11 @@ func run(ctx context.Context, router Router, analyticsFile string) error {
		}
	}

	server := &http.Server{Addr: *httpFlag, Handler: top{gzipHandler{&errorHandler{handler: (&handler{
		rtr:           router,
		analyticsHTML: analyticsHTML,
		analyticsHTML: template.HTML(analyticsHTML),
		fontsHandler:  httpgzip.FileServer(assets.Fonts, httpgzip.FileServerOptions{ServeError: httpgzip.Detailed}),
		assetsHandler: httpgzip.FileServer(assets.Assets, httpgzip.FileServerOptions{ServeError: httpgzip.Detailed}),
		s:             newService(ctx),
	}).ServeHTTP}}}}

@@ -104,11 +104,11 @@ func run(ctx context.Context, router Router, analyticsFile string) error {

// handler handles all goissues requests. It acts like a request multiplexer,
// choosing from various endpoints and parsing the import path from URL.
type handler struct {
	rtr           Router
	analyticsHTML []byte
	analyticsHTML template.HTML
	fontsHandler  http.Handler
	assetsHandler http.Handler
	s             *service
}

@@ -155,11 +155,11 @@ func (h *handler) ServeIndex(w http.ResponseWriter, req *http.Request) error {
		return httperror.Method{Allowed: []string{http.MethodGet}}
	}

	w.Header().Set("Content-Type", "text/html; charset=utf-8")
	err := h.executeTemplate(w, req, "Header", map[string]interface{}{
		"AnalyticsHTML": template.HTML(h.analyticsHTML),
		"AnalyticsHTML": h.analyticsHTML,
	})
	if err != nil {
		return err
	}

@@ -238,11 +238,11 @@ func (h *handler) ServePackages(w http.ResponseWriter, req *http.Request) error
	}

	w.Header().Set("Content-Type", "text/html; charset=utf-8")
	err := h.executeTemplate(w, req, "Header", map[string]interface{}{
		"PageName":      "Packages",
		"AnalyticsHTML": template.HTML(h.analyticsHTML),
		"AnalyticsHTML": h.analyticsHTML,
	})
	if err != nil {
		return err
	}