Added history tab to nearly all editable objects
This commit is contained in:
29
pages/quote/history.go
Normal file
29
pages/quote/history.go
Normal file
@ -0,0 +1,29 @@
|
||||
package quote
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"github.com/aerogo/aero"
|
||||
"github.com/animenotifier/arn"
|
||||
"github.com/animenotifier/notify.moe/components"
|
||||
"github.com/animenotifier/notify.moe/utils"
|
||||
)
|
||||
|
||||
// History of the edits.
|
||||
func History(ctx *aero.Context) string {
|
||||
id := ctx.Get("id")
|
||||
user := utils.GetUser(ctx)
|
||||
quote, err := arn.GetQuote(id)
|
||||
|
||||
if err != nil {
|
||||
return ctx.Error(http.StatusNotFound, "Quote not found", err)
|
||||
}
|
||||
|
||||
entries := arn.FilterEditLogEntries(func(entry *arn.EditLogEntry) bool {
|
||||
return entry.ObjectType == "Quote" && entry.ObjectID == id
|
||||
})
|
||||
|
||||
arn.SortEditLogEntriesLatestFirst(entries)
|
||||
|
||||
return ctx.HTML(components.QuoteTabs(quote, user) + components.EditLog(entries, user))
|
||||
}
|
@ -53,6 +53,7 @@ component QuoteTabs(quote *arn.Quote, user *arn.User)
|
||||
TabLike(strconv.Itoa(len(quote.Likes)), "heart", "quote", quote, user)
|
||||
Tab("Quote", "quote-left", quote.Link())
|
||||
Tab("Edit", "pencil", quote.Link() + "/edit")
|
||||
Tab("History", "history", quote.Link() + "/history")
|
||||
|
||||
component QuoteAnime(anime *arn.Anime, user *arn.User)
|
||||
a.quote-anime-list-item.ajax(href=anime.Link(), title=anime.Title.ByUser(user))
|
||||
|
Reference in New Issue
Block a user