Pinned photo gallery support
This commit is contained in:
parent
0db69983fe
commit
22b8cf0594
|
@ -76,6 +76,7 @@ func Edit() http.HandlerFunc {
|
||||||
altText = strings.TrimSpace(r.FormValue("alt_text"))
|
altText = strings.TrimSpace(r.FormValue("alt_text"))
|
||||||
isExplicit = r.FormValue("explicit") == "true"
|
isExplicit = r.FormValue("explicit") == "true"
|
||||||
isGallery = r.FormValue("gallery") == "true"
|
isGallery = r.FormValue("gallery") == "true"
|
||||||
|
isPinned = r.FormValue("pinned") == "true"
|
||||||
visibility = models.PhotoVisibility(r.FormValue("visibility"))
|
visibility = models.PhotoVisibility(r.FormValue("visibility"))
|
||||||
|
|
||||||
// Profile pic fields
|
// Profile pic fields
|
||||||
|
@ -101,6 +102,7 @@ func Edit() http.HandlerFunc {
|
||||||
models.NewFieldDiff("Caption", photo.Caption, caption),
|
models.NewFieldDiff("Caption", photo.Caption, caption),
|
||||||
models.NewFieldDiff("Explicit", photo.Explicit, isExplicit),
|
models.NewFieldDiff("Explicit", photo.Explicit, isExplicit),
|
||||||
models.NewFieldDiff("Gallery", photo.Gallery, isGallery),
|
models.NewFieldDiff("Gallery", photo.Gallery, isGallery),
|
||||||
|
models.NewFieldDiff("Pinned", photo.Pinned, isPinned),
|
||||||
models.NewFieldDiff("Visibility", photo.Visibility, visibility),
|
models.NewFieldDiff("Visibility", photo.Visibility, visibility),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,6 +110,7 @@ func Edit() http.HandlerFunc {
|
||||||
photo.AltText = altText
|
photo.AltText = altText
|
||||||
photo.Explicit = isExplicit
|
photo.Explicit = isExplicit
|
||||||
photo.Gallery = isGallery
|
photo.Gallery = isGallery
|
||||||
|
photo.Pinned = isPinned
|
||||||
photo.Visibility = visibility
|
photo.Visibility = visibility
|
||||||
|
|
||||||
// Can not use a GIF as profile pic.
|
// Can not use a GIF as profile pic.
|
||||||
|
|
|
@ -66,6 +66,7 @@ func Upload() http.HandlerFunc {
|
||||||
isExplicit = r.PostFormValue("explicit") == "true"
|
isExplicit = r.PostFormValue("explicit") == "true"
|
||||||
visibility = r.PostFormValue("visibility")
|
visibility = r.PostFormValue("visibility")
|
||||||
isGallery = r.PostFormValue("gallery") == "true"
|
isGallery = r.PostFormValue("gallery") == "true"
|
||||||
|
isPinned = r.PostFormValue("pinned") == "true"
|
||||||
cropCoords = r.PostFormValue("crop")
|
cropCoords = r.PostFormValue("crop")
|
||||||
confirm1 = r.PostFormValue("confirm1") == "true"
|
confirm1 = r.PostFormValue("confirm1") == "true"
|
||||||
confirm2 = r.PostFormValue("confirm2") == "true"
|
confirm2 = r.PostFormValue("confirm2") == "true"
|
||||||
|
@ -144,6 +145,7 @@ func Upload() http.HandlerFunc {
|
||||||
AltText: altText,
|
AltText: altText,
|
||||||
Visibility: models.PhotoVisibility(visibility),
|
Visibility: models.PhotoVisibility(visibility),
|
||||||
Gallery: isGallery,
|
Gallery: isGallery,
|
||||||
|
Pinned: isPinned,
|
||||||
Explicit: isExplicit,
|
Explicit: isExplicit,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ func UserPhotos() http.HandlerFunc {
|
||||||
|
|
||||||
// Whitelist for ordering options.
|
// Whitelist for ordering options.
|
||||||
var sortWhitelist = []string{
|
var sortWhitelist = []string{
|
||||||
|
"pinned desc nulls last, updated_at desc",
|
||||||
"created_at desc",
|
"created_at desc",
|
||||||
"created_at asc",
|
"created_at asc",
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,6 +24,7 @@ type Photo struct {
|
||||||
Visibility PhotoVisibility `gorm:"index"`
|
Visibility PhotoVisibility `gorm:"index"`
|
||||||
Gallery bool `gorm:"index"` // photo appears in the public gallery (if public)
|
Gallery bool `gorm:"index"` // photo appears in the public gallery (if public)
|
||||||
Explicit bool `gorm:"index"` // is an explicit photo
|
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"`
|
CreatedAt time.Time `gorm:"index"`
|
||||||
UpdatedAt time.Time
|
UpdatedAt time.Time
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,6 +19,13 @@
|
||||||
<small class="has-text-grey">Uploaded {{.CreatedAt.Format "Jan _2 2006 15:04:05"}}</small>
|
<small class="has-text-grey">Uploaded {{.CreatedAt.Format "Jan _2 2006 15:04:05"}}</small>
|
||||||
</div>
|
</div>
|
||||||
<div class="mt-2">
|
<div class="mt-2">
|
||||||
|
{{if .Pinned}}
|
||||||
|
<span class="tag is-success is-light">
|
||||||
|
<span class="icon"><i class="fa fa-thumbtack"></i></span>
|
||||||
|
<span>Pinned</span>
|
||||||
|
</span>
|
||||||
|
{{end}}
|
||||||
|
|
||||||
{{if .Explicit}}
|
{{if .Explicit}}
|
||||||
<span class="tag is-danger is-light">
|
<span class="tag is-danger is-light">
|
||||||
<span class="icon"><i class="fa fa-fire"></i></span>
|
<span class="icon"><i class="fa fa-fire"></i></span>
|
||||||
|
@ -420,6 +427,11 @@
|
||||||
<label class="label" for="sort">Sort by:</label>
|
<label class="label" for="sort">Sort by:</label>
|
||||||
<div class="select is-fullwidth">
|
<div class="select is-fullwidth">
|
||||||
<select id="sort" name="sort">
|
<select id="sort" name="sort">
|
||||||
|
{{if not .IsSiteGallery}}
|
||||||
|
<option value="pinned desc nulls last, updated_at desc"{{if eq .Sort "pinned desc nulls last, updated_at desc"}} selected{{end}}>
|
||||||
|
Pinned, recently updated
|
||||||
|
</option>
|
||||||
|
{{end}}
|
||||||
<option value="created_at desc"{{if eq .Sort "created_at desc"}} selected{{end}}>Most recent</option>
|
<option value="created_at desc"{{if eq .Sort "created_at desc"}} selected{{end}}>Most recent</option>
|
||||||
<option value="created_at asc"{{if eq .Sort "created_at asc"}} selected{{end}}>Oldest first</option>
|
<option value="created_at asc"{{if eq .Sort "created_at asc"}} selected{{end}}>Oldest first</option>
|
||||||
</select>
|
</select>
|
||||||
|
|
|
@ -260,6 +260,25 @@
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="field mb-5">
|
||||||
|
<label class="label">
|
||||||
|
<i class="fa fa-thumbtack mr-1 has-text-success"></i>
|
||||||
|
Pinned Photo
|
||||||
|
<span class="tag is-success ml-2">New!</span>
|
||||||
|
</label>
|
||||||
|
<label class="checkbox">
|
||||||
|
<input type="checkbox"
|
||||||
|
name="pinned"
|
||||||
|
value="true"
|
||||||
|
{{if or (not .EditPhoto) (.EditPhoto.Pinned)}}checked{{end}}>
|
||||||
|
Keep this photo at the top of my gallery
|
||||||
|
</label>
|
||||||
|
<p class="help">
|
||||||
|
You may "pin" your favorite photos to keep them always at the front of
|
||||||
|
your photo gallery.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div class="field mb-5">
|
<div class="field mb-5">
|
||||||
<label class="label">Photo Visibility</label>
|
<label class="label">Photo Visibility</label>
|
||||||
<div>
|
<div>
|
||||||
|
|
Loading…
Reference in New Issue
Block a user