diff options
author | Andinus <andinus@inventati.org> | 2020-03-14 13:40:03 +0530 |
---|---|---|
committer | Andinus <andinus@inventati.org> | 2020-03-14 13:40:03 +0530 |
commit | 6ccfe4931a3e71c2f22fc04ce0efb9a9f554abdd (patch) | |
tree | 08a556a4d0012e0d1be54cb273b0fa5af1bceffd | |
parent | f0a905d77552a740194da4582b5447af58254e26 (diff) | |
download | cetus-6ccfe4931a3e71c2f22fc04ce0efb9a9f554abdd.tar.gz |
Break SetFromID in 2 functions v0.3.0
GetPathFromID returns the path of the photo & SetFromID first gets the path from GetPathFromID then uses background.Set to set the background
-rw-r--r-- | pkg/unsplash/unsplash.go | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/pkg/unsplash/unsplash.go b/pkg/unsplash/unsplash.go index e40503d..689f8c4 100644 --- a/pkg/unsplash/unsplash.go +++ b/pkg/unsplash/unsplash.go @@ -20,17 +20,22 @@ import ( "framagit.org/andinus/cetus/pkg" ) -// SetFromID sets background from Unsplash Photo ID -func SetFromID(photoID string, width int, height int) error { - var ( - path string - size string - - err error - ) +// GetPathFromID returns path of the photo from Unsplash Photo ID +func GetPathFromID(photoID string, width int, height int) string { + var path string + var size string size = fmt.Sprintf("%dx%d", width, height) path = fmt.Sprintf("%s/%s/%s", "https://source.unsplash.com", photoID, size) + return path +} + +// SetFromID sets background from Unsplash Photo ID +func SetFromID(photoID string, width int, height int) error { + var path string + var err error + + path = GetPathFromID(photoID, width, height) err = background.Set(path) return err |