pretty up the generated HTML

This commit is contained in:
mappu 2017-12-10 13:25:34 +13:00
parent 672f0f606c
commit f261ca0ece

View File

@ -217,7 +217,7 @@ func (this *ArchiveState) renderTemplateHead(w http.ResponseWriter) {
<span class="area-nav">
<select onchange="window.location.pathname = this.value;">
`))
`))
for i, h := range this.svr.cfg.Logs {
slug, _ := this.svr.bestSlugFor(&this.svr.cfg.Logs[i])
@ -234,7 +234,7 @@ func (this *ArchiveState) renderTemplateHead(w http.ResponseWriter) {
targetUri += fmt.Sprintf(`%d/%d`, h.LatestDate().Year, h.LatestDate().Month)
}
w.Write([]byte(`<option value="` + html.EscapeString(targetUri) + `" ` + attr(current, "selected") + `>` + html.EscapeString(h.Description) + `</option>`))
w.Write([]byte(fmt.Sprintf("\t\t\t\t\t<option value=\"%s\"%s>%s</option>\n", html.EscapeString(targetUri), attr(current, " selected"), html.EscapeString(h.Description))))
}
w.Write([]byte(`
@ -244,7 +244,7 @@ func (this *ArchiveState) renderTemplateHead(w http.ResponseWriter) {
if showPageURLs {
w.Write([]byte(`
<select onchange="window.location.pathname = this.value;">
`))
`))
// Generate month dropdown options
@ -253,18 +253,18 @@ func (this *ArchiveState) renderTemplateHead(w http.ResponseWriter) {
for ympair := this.log.EarliestDate(); !ympair.Equals(limit); ympair = ympair.Next() {
if ympair.Year != lastY {
if lastY != -1 {
w.Write([]byte(`</optgroup>`))
w.Write([]byte("\t\t\t\t</optgroup>\n"))
}
w.Write([]byte(`<optgroup label="` + fmt.Sprintf("%d", ympair.Year) + `">`))
w.Write([]byte(fmt.Sprintf("\t\t\t\t<optgroup label=\"%d\">\n", ympair.Year)))
lastY = ympair.Year
}
targetUri := fmt.Sprintf(`/%s/%d/%d`, this.logBestSlug, ympair.Year, ympair.Month)
w.Write([]byte(fmt.Sprintf(`<option value="%s" %s>%s</option>`, html.EscapeString(targetUri), attr(ympair.Equals(this.ym), "selected"), html.EscapeString(ympair.Month.String()))))
w.Write([]byte(fmt.Sprintf("\t\t\t\t\t<option value=\"%s\"%s>%s</option>\n", html.EscapeString(targetUri), attr(ympair.Equals(this.ym), " selected"), html.EscapeString(ympair.Month.String()))))
}
if lastY != -1 {
w.Write([]byte(`</optgroup>`))
w.Write([]byte("\t\t\t\t</optgroup>\n"))
}
w.Write([]byte(`
</select>