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 := `

Recent Changes


` + `Showing up to ` + fmt.Sprintf("%d", this.opts.RecentChanges) + ` changes.

` + `
` + `` + `` for _, rev := range recents { diffHtml := "" diffRev, err := this.db.GetNextOldestRevision(int(rev.ArticleID)) if err != nil { diffHtml = `[new]` } else { diffHtml = `diff` } } content += `` + `` + `` + `` + `` + `` + `` } content += `
PageActionsTimeAuthor
` + template.HTMLEscapeString(rev.Title) + `` + `rev   ` + diffHtml + `` + string(this.formatTimestamp(rev.Modified)) + `` + template.HTMLEscapeString(rev.Author) + `
` if pageNum > 1 { content += `« Newer` } if pageNum < maxPage { content += `Older »` } content += `
` pto.Content = template.HTML(content) this.servePageResponse(w, r, pto) return }