feat: add support bundle notice to viewer
This commit is contained in:
@@ -81,16 +81,33 @@ var preferredColumns = map[string][]string{
|
||||
"other": {"name", "value", "unit"},
|
||||
}
|
||||
|
||||
type RenderOptions struct {
|
||||
DownloadArchiveURL string
|
||||
DownloadArchiveLabel string
|
||||
NoticeTitle string
|
||||
NoticeBody string
|
||||
}
|
||||
|
||||
func RenderHTML(snapshot []byte, title string) ([]byte, error) {
|
||||
page, err := buildPageData(snapshot, title)
|
||||
return RenderHTMLWithOptions(snapshot, title, RenderOptions{})
|
||||
}
|
||||
|
||||
func RenderHTMLWithOptions(snapshot []byte, title string, opts RenderOptions) ([]byte, error) {
|
||||
page, err := buildPageData(snapshot, title, opts)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return web.Render(page)
|
||||
}
|
||||
|
||||
func buildPageData(snapshot []byte, title string) (pageData, error) {
|
||||
page := pageData{Title: title}
|
||||
func buildPageData(snapshot []byte, title string, opts RenderOptions) (pageData, error) {
|
||||
page := pageData{
|
||||
Title: title,
|
||||
NoticeTitle: strings.TrimSpace(opts.NoticeTitle),
|
||||
NoticeBody: strings.TrimSpace(opts.NoticeBody),
|
||||
DownloadArchiveURL: strings.TrimSpace(opts.DownloadArchiveURL),
|
||||
DownloadArchiveLabel: strings.TrimSpace(opts.DownloadArchiveLabel),
|
||||
}
|
||||
if strings.TrimSpace(string(snapshot)) == "" {
|
||||
return page, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user