package yatwiki import ( "errors" "fmt" "html/template" "math" "net/http" "net/url" ) func (this *WikiServer) routeRecentChanges(w http.ResponseWriter, r *http.Request, pageNum int) { totalEdits, err := this.db.TotalRevisions() if err != nil { this.serveInternalError(w, r, err) return } minPage := 1 maxPage := int(math.Ceil(float64(totalEdits) / float64(this.opts.RecentChanges))) if pageNum < minPage || pageNum > maxPage { this.serveErrorMessage(w, errors.New("Invalid page.")) return } recents, err := this.db.GetRecentChanges((pageNum-1)*this.opts.RecentChanges, this.opts.RecentChanges) if err != nil { this.serveErrorMessage(w, err) return } // pto := DefaultPageTemplateOptions(this.opts) pto.CurrentPageName = "Recent Changes" content := `
` + template.HTMLEscapeString(rev.Title) + `` + ` [a]` + ` | ` + `` + this.formatTimestamp(rev.Modified) + ` by ` + template.HTMLEscapeString(rev.Author) + ` | ` + `|
` if pageNum > 1 { content += `« Newer` } content += ` | ` if pageNum < maxPage { content += `Older »` } content += ` |