summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndinus <andinus@inventati.org>2020-03-14 13:54:35 +0530
committerAndinus <andinus@inventati.org>2020-03-14 13:54:35 +0530
commit82a53c3c5b5ffd8af9c69c6184134f100f80b89a (patch)
tree9c7ad91cef786151786cafefd1b050df1b8e3972
parent6ccfe4931a3e71c2f22fc04ce0efb9a9f554abdd (diff)
downloadcetus-82a53c3c5b5ffd8af9c69c6184134f100f80b89a.tar.gz
Unexport GetPathFromID & further break it in 2 functions
appendSizeToPath will get repeated later so seperated it into a
different function
-rw-r--r--pkg/unsplash/unsplash.go28
1 files changed, 16 insertions, 12 deletions
diff --git a/pkg/unsplash/unsplash.go b/pkg/unsplash/unsplash.go
index 689f8c4..a284ebc 100644
--- a/pkg/unsplash/unsplash.go
+++ b/pkg/unsplash/unsplash.go
@@ -20,23 +20,27 @@ import (
 	"framagit.org/andinus/cetus/pkg"
 )
 
-// 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)
+	path = getPathFromID(photoID)
+	path = appendSizeToPath(path, width, height)
 	err = background.Set(path)
-
 	return err
 }
+
+func getPathFromID(photoID string) string {
+	var path string
+	path = fmt.Sprintf("%s/%s", "https://source.unsplash.com", photoID)
+	return path
+}
+
+func appendSizeToPath(path string, width int, height int) string {
+	var size string
+
+	size = fmt.Sprintf("%dx%d", width, height)
+	path = fmt.Sprintf("%s/%s", path, size)
+	return path
+}