glevatar

Easily create Gravatar URLs in Gleam.

Types

This type is employed when the provided email address does not correspond to any Gravatar image.

pub type DefaultImage {
  NotFound
  MysteryPerson
  Identicon
  MonsterId
  Wavatar
  Retro
  Robohash
  Blank
  CustomImage(String)
}

Constructors

  • NotFound

    Signifies that no image should be loaded.

  • MysteryPerson

    Represents a simple, cartoon-style silhouetted outline of a person.

  • Identicon

    Depicts a geometric pattern based on an email hash.

  • MonsterId

    Denotes a generated “monster” with various colours and facial features.

  • Wavatar

    Represents generated faces with distinct features and backgrounds.

  • Retro

    Displays artistically generated, 8-bit arcade-style pixelated faces.

  • Robohash

    Signifies a generated robot with different colours, faces, and so on.

  • Blank

    Denotes a transparent PNG image.

  • CustomImage(String)

    Indicates a custom default image fetched from a URL.

This type defines a Gravatar builder, which should not be manually modified.

pub type GravatarBuilder =
  #(String, dict.Dict(String, String))

This type is used for specifying image ratings.

pub type ImageRating {
  General
  Parental
  Restricted
  Adult
}

Constructors

  • General

    Suitable for display on all websites.

  • Parental

    May contain mild elements such as rude gestures, provocatively dressed individuals, or mild violence.

  • Restricted

    May contain stronger elements such as harsh profanity, intense violence, nudity, or hard drug use.

  • Adult

    May contain explicit content, including hardcore sexual imagery or extremely disturbing violence.

Functions

pub fn new(email: String) -> #(String, Dict(String, String))

Create a new GravatarBuilder based on an email address.

pub fn set_default_image(
  builder: #(String, Dict(String, String)),
  default: DefaultImage,
) -> #(String, Dict(String, String))

Set the default image to be used when the provided email address doesn’t match any image.

pub fn set_rating(
  builder: #(String, Dict(String, String)),
  rating: ImageRating,
) -> #(String, Dict(String, String))

Set image rating restrictions.

pub fn set_size(
  builder: #(String, Dict(String, String)),
  size: Int,
) -> #(String, Dict(String, String))

Set a specific image size; the default is 80.

pub fn to_string(
  builder: #(String, Dict(String, String)),
) -> String

Convert the GravatarBuilder into a Gravatar image URL.

pub fn to_uri(builder: #(String, Dict(String, String))) -> Uri

Convert the GravatarBuilder into an Uri structure.

Search Document