diff --git a/pkg/controller/photo/edit_delete.go b/pkg/controller/photo/edit_delete.go index 1f1affe..ee87457 100644 --- a/pkg/controller/photo/edit_delete.go +++ b/pkg/controller/photo/edit_delete.go @@ -76,6 +76,7 @@ func Edit() http.HandlerFunc { altText = strings.TrimSpace(r.FormValue("alt_text")) isExplicit = r.FormValue("explicit") == "true" isGallery = r.FormValue("gallery") == "true" + isPinned = r.FormValue("pinned") == "true" visibility = models.PhotoVisibility(r.FormValue("visibility")) // Profile pic fields @@ -101,6 +102,7 @@ func Edit() http.HandlerFunc { models.NewFieldDiff("Caption", photo.Caption, caption), models.NewFieldDiff("Explicit", photo.Explicit, isExplicit), models.NewFieldDiff("Gallery", photo.Gallery, isGallery), + models.NewFieldDiff("Pinned", photo.Pinned, isPinned), models.NewFieldDiff("Visibility", photo.Visibility, visibility), } @@ -108,6 +110,7 @@ func Edit() http.HandlerFunc { photo.AltText = altText photo.Explicit = isExplicit photo.Gallery = isGallery + photo.Pinned = isPinned photo.Visibility = visibility // Can not use a GIF as profile pic. diff --git a/pkg/controller/photo/upload.go b/pkg/controller/photo/upload.go index 17590c4..2595b61 100644 --- a/pkg/controller/photo/upload.go +++ b/pkg/controller/photo/upload.go @@ -66,6 +66,7 @@ func Upload() http.HandlerFunc { isExplicit = r.PostFormValue("explicit") == "true" visibility = r.PostFormValue("visibility") isGallery = r.PostFormValue("gallery") == "true" + isPinned = r.PostFormValue("pinned") == "true" cropCoords = r.PostFormValue("crop") confirm1 = r.PostFormValue("confirm1") == "true" confirm2 = r.PostFormValue("confirm2") == "true" @@ -144,6 +145,7 @@ func Upload() http.HandlerFunc { AltText: altText, Visibility: models.PhotoVisibility(visibility), Gallery: isGallery, + Pinned: isPinned, Explicit: isExplicit, } diff --git a/pkg/controller/photo/user_gallery.go b/pkg/controller/photo/user_gallery.go index d233307..c380838 100644 --- a/pkg/controller/photo/user_gallery.go +++ b/pkg/controller/photo/user_gallery.go @@ -16,6 +16,7 @@ func UserPhotos() http.HandlerFunc { // Whitelist for ordering options. var sortWhitelist = []string{ + "pinned desc nulls last, updated_at desc", "created_at desc", "created_at asc", } diff --git a/pkg/models/photo.go b/pkg/models/photo.go index 973418f..0693b1b 100644 --- a/pkg/models/photo.go +++ b/pkg/models/photo.go @@ -24,6 +24,7 @@ type Photo struct { Visibility PhotoVisibility `gorm:"index"` Gallery bool `gorm:"index"` // photo appears in the public gallery (if public) Explicit bool `gorm:"index"` // is an explicit photo + Pinned bool `gorm:"index"` // user pins it to the front of their gallery CreatedAt time.Time `gorm:"index"` UpdatedAt time.Time } diff --git a/web/templates/photo/gallery.html b/web/templates/photo/gallery.html index 72fdd25..c7d1733 100644 --- a/web/templates/photo/gallery.html +++ b/web/templates/photo/gallery.html @@ -19,6 +19,13 @@ Uploaded {{.CreatedAt.Format "Jan _2 2006 15:04:05"}}
+ {{if .Pinned}} + + + Pinned + + {{end}} + {{if .Explicit}} @@ -420,6 +427,11 @@
diff --git a/web/templates/photo/upload.html b/web/templates/photo/upload.html index 02c7fa8..a8cae92 100644 --- a/web/templates/photo/upload.html +++ b/web/templates/photo/upload.html @@ -260,6 +260,25 @@

+
+ + +

+ You may "pin" your favorite photos to keep them always at the front of + your photo gallery. +

+
+