redesign the 'recent changes' page, include diff links, "new" display, hover rows

This commit is contained in:
mappu 2017-11-18 15:30:50 +13:00
parent 51aae382b7
commit 5b533f7b40

View File

@ -37,26 +37,41 @@ func (this *WikiServer) routeRecentChanges(w http.ResponseWriter, r *http.Reques
pto.CurrentPageName = "Recent Changes" pto.CurrentPageName = "Recent Changes"
content := `<h2>Recent Changes</h2><br>` + content := `<h2>Recent Changes</h2><br>` +
`<em>Showing up to ` + fmt.Sprintf("%d", this.opts.RecentChanges) + ` changes.</em><br>` + `<em>Showing up to ` + fmt.Sprintf("%d", this.opts.RecentChanges) + ` changes.</em><br><br>` +
`<table>` `<div style="display:inline-block;">` +
`<table class="ti">` +
`<tr><td>Page</td><td>Actions</td><td>Time</td><td>Author</td></tr>`
for _, rev := range recents { for _, rev := range recents {
diffHtml := ""
diffRev, err := this.db.GetNextOldestRevision(int(rev.ID))
if err != nil {
diffHtml = `[new]`
} else {
diffHtml = `<a href="` + template.HTMLEscapeString(this.opts.ExpectBaseURL+`diff/`+fmt.Sprintf("%d/%d", diffRev, rev.ID)) + `">diff</a>`
}
content += `<tr>` + content += `<tr>` +
`<td><a href="` + template.HTMLEscapeString(this.opts.ExpectBaseURL+`view/`+url.PathEscape(rev.Title)) + `">` + template.HTMLEscapeString(rev.Title) + `</a>` + `<td><a href="` + template.HTMLEscapeString(this.opts.ExpectBaseURL+`view/`+url.PathEscape(rev.Title)) + `">` + template.HTMLEscapeString(rev.Title) + `</a></td>` +
` [<a href="` + template.HTMLEscapeString(this.opts.ExpectBaseURL+`archive/`+fmt.Sprintf("%d", rev.ID)) + `">a</a>]` + `<td>` +
`<a href="` + template.HTMLEscapeString(this.opts.ExpectBaseURL+`archive/`+fmt.Sprintf("%d", rev.ID)) + `">rev</a> &nbsp; ` +
diffHtml +
`</td>` +
`</td>` + `</td>` +
`<td>` + string(this.formatTimestamp(rev.Modified)) + `</td>` + `<td>` + string(this.formatTimestamp(rev.Modified)) + `</td>` +
`<td>` + template.HTMLEscapeString(rev.Author) + `</td>` + `<td>` + template.HTMLEscapeString(rev.Author) + `</td>` +
`</tr>` `</tr>`
} }
content += `<tr><td>` content += `</table>`
if pageNum > 1 { if pageNum > 1 {
content += `<a href="` + template.HTMLEscapeString(this.opts.ExpectBaseURL+`recent/`+fmt.Sprintf("%d", pageNum-1)) + `">&laquo; Newer</a>` content += `<span style="float:left;"><a href="` + template.HTMLEscapeString(this.opts.ExpectBaseURL+`recent/`+fmt.Sprintf("%d", pageNum-1)) + `">&laquo; Newer</a></span>`
} }
content += `</td><td></td><td style="text-align:right;">`
if pageNum < maxPage { if pageNum < maxPage {
content += `<a href="` + template.HTMLEscapeString(this.opts.ExpectBaseURL+`recent/`+fmt.Sprintf("%d", pageNum+1)) + `">Older &raquo;</a>` content += `<span style="float:right;"><a href="` + template.HTMLEscapeString(this.opts.ExpectBaseURL+`recent/`+fmt.Sprintf("%d", pageNum+1)) + `">Older &raquo;</a></span>`
} }
content += `</td></tr></table>` content += `</div>`
pto.Content = template.HTML(content) pto.Content = template.HTML(content)
this.servePageResponse(w, r, pto) this.servePageResponse(w, r, pto)