Safe Haskell | None |
---|---|
Language | Haskell2010 |
- data UserAddress
- data SpecialImage
- data DefaultImage
- data Size
- = Size Int
- | DefaultSize
- data AvatarOptions = AvatarOptions {
- optSecure :: Bool
- optDefault :: DefaultImage
- optSize :: Size
- avatarUrl :: UserAddress -> AvatarOptions -> IO (Maybe String)
Documentation
data UserAddress Source
User address for which to generate an avatar URL. Email or OpenID.
Email String | For example |
OpenID String | For example |
data SpecialImage Source
Special values available for the default image. The comments briefly explain the origin of the image/technique.
SpecialMysteryPerson | A very simple outline of a person (constant image, does not vary by user address). Sometimes referred to as “mystery man”. |
SpecialIdenticon | Geometric pattern based on a user address hash. Origin: A visual representation of a hash value, usually of an IP address, that serves to identify a user of a computer system as a form of avatar while protecting the users' privacy. |
SpecialMonsterID | A generated monster image with different colors, faces, etc. Origin: A method to generate a unique monster image based upon a certain identifier (IP address, email address, etc.). It can be used to automatically provide personal avatar images in blog comments or other community services. |
SpecialWavatar | A generated face with differing features and backgrounds. Origin: Wavatars is a Wordpress plugin that will generate and assign icons to the visitors leaving comments at your site. The icons are based on email, so a given visitor will get the same icon each time they comment. It livens up comment threads and gives people memorable “faces” to aid in following conversation threads. It’s also fun. |
SpecialRetro | A generated, 8-bit arcade-style pixelated face. Origin: I don't know :P |
data DefaultImage Source
What to do if the user's address isn't found in the Libravatar server's database.
ImgLibravatarLogo | Don't specify a default image, let the server send its default image, which is the Libravatar logo (the orange butterfly). |
ImgNotFound | Return HTTP 404 error (i.e. file not found) instead of an image. |
ImgSpecial SpecialImage | Use one of the available special images or image generators. |
ImgCustom String | Use the given image URL as the default. |
Image size in pixels.
Size Int | Use the given size. Acceptable values are between 1 and 512. Note that this library doesn't check the size you pass here, so make sure you pass a size within that range. |
DefaultSize | Use the default size, which is 80 pixels. |
data AvatarOptions Source
Avatar details in addition to the user address itself.
AvatarOptions | |
|
avatarUrl :: UserAddress -> AvatarOptions -> IO (Maybe String) Source
Return a URL to the avatar image.
If an error occurs, return Nothing
. Currently, this happens only if the
user address fails to be parsed.
Examples:
Email, HTTP, default fallback image (the libravatar logo), default size (80):
>>>
avatarUrl (Email "john@doe.org") AvatarOptions
>>>
{ optSecure = False
>>>
, optDefault = ImgLibravatarLogo
>>>
, optSize = DefaultSize
>>>
}
Just "http://cdn.libravatar.org/avatar/bc6a715808d9aae0ddeefb1e47e482a6"
Email, HTTPS, default fallback image, size 100. But now use an email with a domain which has SRV records for avatars:
>>>
avatarUrl (Email "fr33domlover@rel4tion.org") AvatarOptions
>>>
{ optSecure = True
>>>
, optDefault = ImgLibravatarLogo
>>>
, optSize = Size 100
>>>
}
Just "https://avatars.rel4tion.org:5679/avatar/e9e9ccabc2a166b1783bd7f4f9ceb376?s=100"
OpenID, HTTPS, specified fallback (special value "retro"), default size (80):
>>>
avatarUrl (OpenID "https://examplibre.org/accounts/xyz/id") AvatarOptions
>>>
{ optSecure = True
>>>
, optDefault = ImgSpecial SpecialRetro
>>>
, optSize = DefaultSize
>>>
}
Just "https://seccdn.libravatar.org/avatar/c2cbc5f5a1784fa7105380e550360d73f15c4c1f9c7ca1ac436c45a33027fcd7?d=retro"
(Note that the 2nd example uses dummy SRV records created by the author, and he isn't really running a Libravatar provider. This is just an example, the specific URL here will probably result with 404.)