This commit is contained in:
parent
66719c58fc
commit
e80383911d
25
main.go
25
main.go
|
@ -41,10 +41,14 @@ type Revision struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type Change struct {
|
type Change struct {
|
||||||
Page string
|
Page string
|
||||||
Date time.Time
|
Date time.Time
|
||||||
Body string
|
EndDate time.Time
|
||||||
Count int
|
Body string
|
||||||
|
Count int
|
||||||
|
|
||||||
|
DateSummary string
|
||||||
|
TimeSummary string
|
||||||
}
|
}
|
||||||
|
|
||||||
type PagesRepository interface {
|
type PagesRepository interface {
|
||||||
|
@ -429,10 +433,11 @@ func (h *recentHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
i := f
|
i := f
|
||||||
|
|
||||||
for {
|
for {
|
||||||
if changes[f].Page == changes[i].Page {
|
if changes[f].Page == changes[i].Page && changes[f].Date.Truncate(24*time.Hour) == changes[i].Date.Truncate(24*time.Hour) {
|
||||||
changes[f].Count++
|
changes[f].Count++
|
||||||
i--
|
i--
|
||||||
} else {
|
} else {
|
||||||
|
changes[f].EndDate = changes[i+1].Date
|
||||||
f--
|
f--
|
||||||
changes[f] = changes[i]
|
changes[f] = changes[i]
|
||||||
}
|
}
|
||||||
|
@ -445,6 +450,16 @@ func (h *recentHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||||
changes = changes[f:]
|
changes = changes[f:]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for i, c := range changes {
|
||||||
|
if c.Count == 1 {
|
||||||
|
changes[i].DateSummary = c.Date.Format("Mon, 2 Jan 2006")
|
||||||
|
changes[i].TimeSummary = c.Date.Format("15:04")
|
||||||
|
} else {
|
||||||
|
changes[i].DateSummary = c.Date.Format("Mon, 2 Jan 2006")
|
||||||
|
changes[i].TimeSummary = fmt.Sprintf("%s - %s", c.Date.Format("15:04"), c.EndDate.Format("15:04"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
t, err := template.New("layout.html").ParseFiles("templates/layout.html", "templates/recent.html")
|
t, err := template.New("layout.html").ParseFiles("templates/layout.html", "templates/recent.html")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
http.Error(w, err.Error(), 500)
|
http.Error(w, err.Error(), 500)
|
||||||
|
|
|
@ -7,9 +7,10 @@
|
||||||
<table class="table">
|
<table class="table">
|
||||||
{{ range $index, $change := .Recent }}
|
{{ range $index, $change := .Recent }}
|
||||||
<tr>
|
<tr>
|
||||||
<td>{{ $change.Date }}</td>
|
<td>{{ $change.DateSummary }}</td>
|
||||||
<td><a href="/{{ $change.Page }}">{{ $change.Page }}</a></td>
|
<td>{{ $change.TimeSummary }}</td>
|
||||||
<td>{{ $change.Count }}</td>
|
<td>{{ $change.Count }}</td>
|
||||||
|
<td><a href="/{{ $change.Page }}">{{ $change.Page }}</a></td>
|
||||||
<td>{{ $change.Body }}</td>
|
<td>{{ $change.Body }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user