Skip to content

Commit

Permalink
remove details links (#473)
Browse files Browse the repository at this point in the history
  • Loading branch information
rbren committed Jan 15, 2021
1 parent 6ca4e8a commit 744e40a
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 60 deletions.
43 changes: 0 additions & 43 deletions pkg/dashboard/dashboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import (
packr "github.com/gobuffalo/packr/v2"
"github.com/gorilla/mux"
"github.com/sirupsen/logrus"
"gitlab.com/golang-commonmark/markdown"
)

const (
Expand All @@ -45,8 +44,6 @@ const (
DashboardTemplateName = "dashboard.gohtml"
// FooterTemplateName contains the footer
FooterTemplateName = "footer.gohtml"
// CheckDetailsTemplateName is a page for rendering details about a given check
CheckDetailsTemplateName = "check-details.gohtml"
)

var (
Expand All @@ -71,14 +68,6 @@ func GetTemplateBox() *packr.Box {
return templateBox
}

// GetMarkdownBox returns a binary-friendly set of markdown files with error details
func GetMarkdownBox() *packr.Box {
if markdownBox == (*packr.Box)(nil) {
markdownBox = packr.New("Markdown", "../../docs-md/checks")
}
return markdownBox
}

// templateData is passed to the dashboard HTML template
type templateData struct {
BasePath string
Expand Down Expand Up @@ -206,7 +195,6 @@ func GetRouter(c config.Configuration, auditPath string, port int, basePath stri
vars := mux.Vars(r)
category := vars["category"]
category = strings.Replace(category, ".md", "", -1)
DetailsHandler(w, r, category, basePath)
})

router.HandleFunc("/", func(w http.ResponseWriter, r *http.Request) {
Expand Down Expand Up @@ -276,34 +264,3 @@ func JSONHandler(w http.ResponseWriter, r *http.Request, auditData *validator.Au
w.WriteHeader(http.StatusOK)
json.NewEncoder(w).Encode(auditData)
}

// DetailsHandler returns details for a given error type
func DetailsHandler(w http.ResponseWriter, r *http.Request, category string, basePath string) {
box := GetMarkdownBox()
contents, err := box.Find(category + ".md")
if err != nil {
http.Error(w, "Error details not found for category "+category, http.StatusNotFound)
return
}
md := markdown.New(markdown.XHTMLOutput(true))
detailsHTML := "{{ define \"details\" }}" + md.RenderToString(contents) + "{{ end }}"

templateFileNames := []string{
HeadTemplateName,
NavbarTemplateName,
CheckDetailsTemplateName,
FooterTemplateName,
}
tmpl := template.New("check-details")
tmpl, err = parseTemplateFiles(tmpl, templateFileNames)
if err != nil {
logrus.Printf("Error getting template data %v", err)
http.Error(w, "Error getting template data", 500)
return
}
tmpl.Parse(detailsHTML)
data := templateData{
BasePath: basePath,
}
writeTemplate(tmpl, &data, w)
}
17 changes: 0 additions & 17 deletions pkg/dashboard/templates/check-details.gohtml

This file was deleted.

0 comments on commit 744e40a

Please sign in to comment.