diff --git a/main.go b/main.go index 1f78dcb..9d441bd 100644 --- a/main.go +++ b/main.go @@ -41,9 +41,10 @@ type Revision struct { } type Change struct { - Page string - Date time.Time - Body string + Page string + Date time.Time + Body string + Count int } type PagesRepository interface { @@ -422,6 +423,28 @@ func (h *recentHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { return } + // group recentchanges on Page + if len(changes) > 0 { + f := len(changes) - 1 + i := f + + for { + if changes[f].Page == changes[i].Page { + changes[f].Count++ + i-- + } else { + f-- + changes[f] = changes[i] + } + + if i <= 0 { + break + } + } + + changes = changes[f:] + } + t, err := template.New("layout.html").ParseFiles("templates/layout.html", "templates/recent.html") if err != nil { http.Error(w, err.Error(), 500) diff --git a/templates/recent.html b/templates/recent.html index e38ed04..3d568c7 100644 --- a/templates/recent.html +++ b/templates/recent.html @@ -9,6 +9,7 @@