deletions: index page: hide deleted pages until you click a button
This commit is contained in:
parent
6e63285a54
commit
0a332642d7
22
rIndex.go
22
rIndex.go
@ -14,6 +14,9 @@ func (this *WikiServer) routeIndex(w http.ResponseWriter, r *http.Request) {
|
||||
return
|
||||
}
|
||||
|
||||
showDeleted := (r.FormValue("deleted") == "1")
|
||||
anyDeleted := false
|
||||
|
||||
totalRevs, err := this.db.TotalRevisions()
|
||||
if err != nil {
|
||||
this.serveInternalError(w, r, err)
|
||||
@ -22,10 +25,27 @@ func (this *WikiServer) routeIndex(w http.ResponseWriter, r *http.Request) {
|
||||
|
||||
content := fmt.Sprintf(`<h2>Article Index</h2><br><em>There are %d edits to %d pages.</em><br><br><ul>`, totalRevs, len(titles))
|
||||
for _, title := range titles {
|
||||
content += `<li><a href="` + template.HTMLEscapeString(this.opts.ExpectBaseURL+`view/`+url.PathEscape(title)) + `">` + template.HTMLEscapeString(title) + `</a></li>`
|
||||
classAttr := ""
|
||||
if title.IsDeleted {
|
||||
anyDeleted = true
|
||||
if !showDeleted {
|
||||
continue
|
||||
}
|
||||
classAttr = `class="deleted"`
|
||||
}
|
||||
content += `<li><a ` + classAttr + ` href="` + template.HTMLEscapeString(this.opts.ExpectBaseURL+`view/`+url.PathEscape(title.Title)) + `">` + template.HTMLEscapeString(title.Title) + `</a></li>`
|
||||
}
|
||||
content += `</ul>`
|
||||
|
||||
if anyDeleted {
|
||||
content += `<br>`
|
||||
if !showDeleted {
|
||||
content += `<a href="` + template.HTMLEscapeString(this.opts.ExpectBaseURL+`index?deleted=1`) + `">Show deleted pages</a>`
|
||||
} else {
|
||||
content += `<a href="` + template.HTMLEscapeString(this.opts.ExpectBaseURL+`index`) + `">Hide deleted pages</a>`
|
||||
}
|
||||
}
|
||||
|
||||
pto := DefaultPageTemplateOptions(this.opts)
|
||||
pto.CurrentPageName = "Index"
|
||||
pto.Content = template.HTML(content)
|
||||
|
Loading…
Reference in New Issue
Block a user