mirror of
https://github.com/aljazceru/njump.git
synced 2025-12-17 06:14:22 +01:00
Load profiles last notes asynchronously
This commit is contained in:
@@ -23,6 +23,12 @@ func renderProfile(w http.ResponseWriter, r *http.Request, code string) {
|
||||
isRSS = true
|
||||
}
|
||||
|
||||
isLastNotes := false
|
||||
if strings.HasPrefix(code, "profile-last-notes") {
|
||||
code = code[19:]
|
||||
isLastNotes = true
|
||||
}
|
||||
|
||||
data, err := grabData(r.Context(), code, isSitemap)
|
||||
if err != nil {
|
||||
w.Header().Set("Cache-Control", "max-age=60")
|
||||
@@ -35,10 +41,6 @@ func renderProfile(w http.ResponseWriter, r *http.Request, code string) {
|
||||
return
|
||||
}
|
||||
|
||||
if len(data.renderableLastNotes) != 0 {
|
||||
w.Header().Set("Cache-Control", "max-age=3600")
|
||||
}
|
||||
|
||||
if isSitemap {
|
||||
w.Header().Add("content-type", "text/xml")
|
||||
w.Header().Set("Cache-Control", "max-age=86400")
|
||||
@@ -60,6 +62,14 @@ func renderProfile(w http.ResponseWriter, r *http.Request, code string) {
|
||||
Metadata: data.metadata,
|
||||
LastNotes: data.renderableLastNotes,
|
||||
})
|
||||
} else if isLastNotes {
|
||||
w.Header().Add("content-type", "text/html")
|
||||
if len(data.renderableLastNotes) != 0 {
|
||||
w.Header().Set("Cache-Control", "max-age=3600")
|
||||
}
|
||||
LastNotesTemplate.Render(w, &LastNotesPage{
|
||||
LastNotes: data.renderableLastNotes,
|
||||
})
|
||||
} else {
|
||||
w.Header().Add("content-type", "text/html")
|
||||
w.Header().Set("Cache-Control", "max-age=86400")
|
||||
|
||||
Reference in New Issue
Block a user