Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/relative splitview images #300

Merged
merged 7 commits into from
Feb 11, 2025
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion internal/common/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/charmbracelet/log"
"github.com/damongolding/immich-kiosk/internal/config"
"github.com/damongolding/immich-kiosk/internal/immich"
"github.com/damongolding/immich-kiosk/internal/kiosk"
"github.com/damongolding/immich-kiosk/internal/utils"
"github.com/labstack/echo/v4"
)
Expand Down Expand Up @@ -99,7 +100,7 @@ type ViewImageData struct {
ImageData string // ImageData contains the image as base64 data
ImageBlurData string // ImageBlurData contains the blurred image as base64 data
ImageDate string // ImageDate contains the date of the image
User string
User string // User the user api key used
}

// ViewData contains all the data needed to render a view in the application
Expand All @@ -112,6 +113,13 @@ type ViewData struct {
config.Config // Config contains the instance configuration
}

type ViewImageDataOptions struct {
RelativeAssetWanted bool
RelativeAssetBucket kiosk.Source
RelativeAssetBucketID string
ImageOrientation immich.ImageOrientation
}

// ContextCopy stores a copy of key HTTP context information including URL and headers
type ContextCopy struct {
URL url.URL // The request URL
Expand Down
14 changes: 11 additions & 3 deletions internal/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -430,14 +430,22 @@ func (c *Config) Load() error {
return nil
}

// ResetBuckets clears all the asset bucket slice fields (Person, Album, Date)
// in the Config structure. This is typically used when applying new query parameters
// to ensure old values don't persist. When querying specific buckets, the previous
// values need to be cleared to avoid mixing unintended assets.
func (c *Config) ResetBuckets() {
c.Person = []string{}
c.Album = []string{}
c.Date = []string{}
}

// ConfigWithOverrides overwrites base config with ones supplied via URL queries
func (c *Config) ConfigWithOverrides(queries url.Values, e echo.Context) error {

// check for person or album in quries and empty baseconfig slice if found
if queries.Has("person") || queries.Has("album") || queries.Has("date") || queries.Has("memories") {
c.Person = []string{}
c.Album = []string{}
c.Date = []string{}
c.ResetBuckets()
}

err := e.Bind(c)
Expand Down
3 changes: 3 additions & 0 deletions internal/immich/immich.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (

"github.com/damongolding/immich-kiosk/internal/config"
"github.com/damongolding/immich-kiosk/internal/immich_open_api"
"github.com/damongolding/immich-kiosk/internal/kiosk"
)

type ImageOrientation string
Expand Down Expand Up @@ -176,6 +177,8 @@ type ImmichAsset struct {
IsLandscape bool `json:"-"`
MemoryTitle string `json:"-"`
AppearsIn []string `json:"-"`
Bucket kiosk.Source `json:"-"`
BucketID string `json:"-"`
}

type ImmichAlbum struct {
Expand Down
3 changes: 3 additions & 0 deletions internal/immich/immich_album.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,6 +269,9 @@ func (i *ImmichAsset) ImageFromAlbum(albumID string, albumAssetsOrder ImmichAsse

}

asset.Bucket = kiosk.SourceAlbums
asset.BucketID = album.ID

*i = asset

return nil
Expand Down
4 changes: 3 additions & 1 deletion internal/immich/immich_date.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ func (i *ImmichAsset) RandomImageInDateRange(dateRange, requestID, deviceID stri
continue
}


if requestConfig.Kiosk.Cache {
// Remove the current image from the slice
immichAssetsToCache := append(immichAssets[:immichAssetIndex], immichAssets[immichAssetIndex+1:]...)
Expand All @@ -137,6 +136,9 @@ func (i *ImmichAsset) RandomImageInDateRange(dateRange, requestID, deviceID stri
}
}

asset.Bucket = kiosk.SourceDateRangeAlbum
asset.BucketID = dateRange

*i = asset

return nil
Expand Down
5 changes: 4 additions & 1 deletion internal/immich/immich_favourites.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,6 @@ func (i *ImmichAsset) RandomImageFromFavourites(requestID, deviceID string, allo
continue
}


if requestConfig.Kiosk.Cache {
// Remove the current image from the slice
immichAssetsToCache := append(immichAssets[:immichAssetIndex], immichAssets[immichAssetIndex+1:]...)
Expand All @@ -206,7 +205,11 @@ func (i *ImmichAsset) RandomImageFromFavourites(requestID, deviceID string, allo
}
}

asset.Bucket = kiosk.SourceAlbums
asset.BucketID = kiosk.AlbumKeywordFavourites

*i = asset

return nil
}

Expand Down
5 changes: 3 additions & 2 deletions internal/immich/immich_memories.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,9 +156,10 @@ func (i *ImmichAsset) RandomMemoryLaneImage(requestID, deviceID string, isPrefet
}
}

*i = asset
asset.Bucket = kiosk.SourceMemories
asset.MemoryTitle = memories[pickedMemoryIndex].Title

i.MemoryTitle = memories[pickedMemoryIndex].Title
*i = asset

return nil
}
Expand Down
4 changes: 3 additions & 1 deletion internal/immich/immich_person.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,6 @@ func (i *ImmichAsset) RandomImageOfPerson(personID, requestID, deviceID string,
continue
}


if requestConfig.Kiosk.Cache {
// Remove the current image from the slice
immichAssetsToCache := append(immichAssets[:immichAssetIndex], immichAssets[immichAssetIndex+1:]...)
Expand All @@ -166,6 +165,9 @@ func (i *ImmichAsset) RandomImageOfPerson(personID, requestID, deviceID string,
}
}

asset.Bucket = kiosk.SourcePerson
asset.BucketID = personID

*i = asset

return nil
Expand Down
4 changes: 3 additions & 1 deletion internal/immich/immich_random.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ func (i *ImmichAsset) RandomImage(requestID, deviceID string, isPrefetch bool) e
continue
}


if requestConfig.Kiosk.Cache {
// Remove the current image from the slice
immichAssetsToCache := append(immichAssets[:immichAssetIndex], immichAssets[immichAssetIndex+1:]...)
Expand All @@ -126,7 +125,10 @@ func (i *ImmichAsset) RandomImage(requestID, deviceID string, isPrefetch bool) e
}
}

asset.Bucket = kiosk.SourceRandom

*i = asset

return nil
}

Expand Down
5 changes: 5 additions & 0 deletions internal/kiosk/kiosk.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,10 @@ const (
SourceRandom Source = "RANDOM"
SourceMemories Source = "MEMORIES"

LayoutLandscape string = "landscape"
LayoutPortrait string = "portrait"
LayoutSplitview string = "splitview"
LayoutSplitviewLandscape string = "splitview-landscape"

TagSkip string = "kiosk-skip"
)
7 changes: 7 additions & 0 deletions internal/routes/routes.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ type PersonOrAlbum struct {
ID string
}

// requestMetadata holds information about the current request context
type requestMetadata struct {
requestID string
deviceID string
urlString string
}

func ShouldDrawFacesOnImages() bool {
return drawFacesOnImages == "true"
}
Expand Down
Loading
Loading