Noah
cd1b349fcc
* Add the user photo gallery for profile pages. Paginated, grid or full (blog style) view options. In grid view clicking a photo opens a large modal to see it; full view already shows large photos. * Edit page: can also re-crop and set an existing pic to be your profile pic. * Delete page: remove photos from the DB and hard drive. * Photos are cleaned up from disk when not needed, e.g. during a re-crop the old cropped photo is removed before the new one replaces it. * Fixed bug with cropping pictures.
39 lines
801 B
Go
39 lines
801 B
Go
package templates
|
|
|
|
import (
|
|
"net/http"
|
|
"time"
|
|
|
|
"git.kirsle.net/apps/gosocial/pkg/config"
|
|
"git.kirsle.net/apps/gosocial/pkg/session"
|
|
)
|
|
|
|
// MergeVars mixes in globally available template variables. The http.Request is optional.
|
|
func MergeVars(r *http.Request, m map[string]interface{}) {
|
|
m["Title"] = config.Title
|
|
m["Subtitle"] = config.Subtitle
|
|
m["YYYY"] = time.Now().Year()
|
|
|
|
if r == nil {
|
|
return
|
|
}
|
|
|
|
m["Request"] = r
|
|
}
|
|
|
|
// MergeUserVars mixes in global template variables: LoggedIn and CurrentUser. The http.Request is optional.
|
|
func MergeUserVars(r *http.Request, m map[string]interface{}) {
|
|
// Defaults
|
|
m["LoggedIn"] = false
|
|
m["CurrentUser"] = nil
|
|
|
|
if r == nil {
|
|
return
|
|
}
|
|
|
|
if user, err := session.CurrentUser(r); err == nil {
|
|
m["LoggedIn"] = true
|
|
m["CurrentUser"] = user
|
|
}
|
|
}
|