
Facilitates access to Gravatar resources, generating avatar image URLs and initials images in the absence of Gravatar registration, with optional integration of the Gravatar REST API.
This library for set up for Kotlin Multiplatform (KMP)
This is a Kotlin Multiplatform compatible library for accessing Gravatar resources.
Generating an avatar image URL does not require any additional, but if you need to use the Gravatar REST API you will need to make sure Ktor runs properly in your project.
Feel free to fork it and make improvements, I'll keep up as best I can.
Add the dependency to your version catalog or build file:
[libraries]
gravatar = { module = "io.github.aughtone:gravatar", version.ref = "gravatar" }
gravatar-composeis not published yet. The Compose Multiplatform module lives in this repository and is built and tested with every release, but its public API has not been reviewed, so it is not available from Maven Central. The UI examples below describe it for when it ships.
The library is distributed as an XCFramework. You can integrate AughtoneGravatarKit directly into your Xcode project.
The js target is published to Maven Central alongside the other platforms and is consumed through Gradle. There is no NPM package.
Use the gravatar-compose module for seamless integration with Compose (not published yet — see Installation):
GravatarImage(
email = "user@example.com",
size = 64.dp,
circle = true
)The library is exported as a framework. You can use it in Swift as follows:
import AughtoneGravatarKit
let url = Gravatar.shared.getAvatarUrl(email: "user@example.com")Depend on the js target from a Kotlin/JS project and use the same API as every other platform:
val api = GravatarApi()
val profile = api.getProfile(emailOrHash = "user@example.com").getOrThrow()val url = gravatarUrlOf(email = "user@example.com", name = "John Doe")Every call returns a Result. A failed call carries a GravatarApiException with the HTTP status, so you can branch on the status rather than on the server's message text:
val api = GravatarApi(apiKey = "your_api_key")
api.getProfile(emailOrHash = "user@example.com").fold(
onSuccess = { profile -> println(profile.displayName) },
onFailure = { error ->
when {
error is GravatarApiException && error.isNotFound -> println("No profile for that address")
error is GravatarApiException && error.isUnauthorized -> println("Check your API key")
else -> throw error
}
}
)// Display an avatar
GravatarImage(email = "user@example.com", size = 64.dp)
// Display a profile card
GravatarProfileView(profile = userProfile)
// Edit profile form
GravatarEditProfileView(profile = userProfile, onSave = { request ->
api.updateProfile(request = request)
})Bugs can go into the issue tracker, but you are probably going to get faster support by creating a PR.
Licensed under the Apache License, Version 2.0 — see LICENSE. Copyright and attribution are recorded in NOTICE.md.
This library for set up for Kotlin Multiplatform (KMP)
This is a Kotlin Multiplatform compatible library for accessing Gravatar resources.
Generating an avatar image URL does not require any additional, but if you need to use the Gravatar REST API you will need to make sure Ktor runs properly in your project.
Feel free to fork it and make improvements, I'll keep up as best I can.
Add the dependency to your version catalog or build file:
[libraries]
gravatar = { module = "io.github.aughtone:gravatar", version.ref = "gravatar" }
gravatar-composeis not published yet. The Compose Multiplatform module lives in this repository and is built and tested with every release, but its public API has not been reviewed, so it is not available from Maven Central. The UI examples below describe it for when it ships.
The library is distributed as an XCFramework. You can integrate AughtoneGravatarKit directly into your Xcode project.
The js target is published to Maven Central alongside the other platforms and is consumed through Gradle. There is no NPM package.
Use the gravatar-compose module for seamless integration with Compose (not published yet — see Installation):
GravatarImage(
email = "user@example.com",
size = 64.dp,
circle = true
)The library is exported as a framework. You can use it in Swift as follows:
import AughtoneGravatarKit
let url = Gravatar.shared.getAvatarUrl(email: "user@example.com")Depend on the js target from a Kotlin/JS project and use the same API as every other platform:
val api = GravatarApi()
val profile = api.getProfile(emailOrHash = "user@example.com").getOrThrow()val url = gravatarUrlOf(email = "user@example.com", name = "John Doe")Every call returns a Result. A failed call carries a GravatarApiException with the HTTP status, so you can branch on the status rather than on the server's message text:
val api = GravatarApi(apiKey = "your_api_key")
api.getProfile(emailOrHash = "user@example.com").fold(
onSuccess = { profile -> println(profile.displayName) },
onFailure = { error ->
when {
error is GravatarApiException && error.isNotFound -> println("No profile for that address")
error is GravatarApiException && error.isUnauthorized -> println("Check your API key")
else -> throw error
}
}
)// Display an avatar
GravatarImage(email = "user@example.com", size = 64.dp)
// Display a profile card
GravatarProfileView(profile = userProfile)
// Edit profile form
GravatarEditProfileView(profile = userProfile, onSave = { request ->
api.updateProfile(request = request)
})Bugs can go into the issue tracker, but you are probably going to get faster support by creating a PR.
Licensed under the Apache License, Version 2.0 — see LICENSE. Copyright and attribution are recorded in NOTICE.md.