Skip to content
This repository has been archived by the owner on Apr 24, 2024. It is now read-only.
/ gravatar Public archive

Simple Java Gravatar-Library

License

Notifications You must be signed in to change notification settings

rynr/gravatar

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

72 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gravatar

Simple class to generate Gravatar URL for a email-address.

Usage:

import org.rjung.util.Gravatar;

class GravatarExample {
  public void main(String[] args) {
    System.out.println(Gravatar.forEmail("[email protected]").toUrl());
  }
}

There are other parameters you can set for the generation, like size, Default and Rating.
Default gives a alternative to the default gravatar-default-image, if no gravatar is defined.
To define a Rating or Default, add the information before you build the url using toUrl().
If you need a https-URL, you can also set the protocol via with(Protocol). There are three Protocol-definitions, HTTP provides a http://..-url, accordingly HTTPS provides the https://..-url. The default is NONE, the url now starts with ://.., a browser will choose the same protocol as currently used.

import org.rjung.util.Gravatar;
import org.rjung.util.gravatar.Default;
import org.rjung.util.gravatar.Protocol;
import org.rjung.util.gravatar.Rating;

class GravatarExample {
  public void main(String[] args) {
    System.out.println(
      Gravatar.forEmail("[email protected]")
          .with(Protocol.HTTPS)     // prepend https://
          .size(123)                // set the size to 123 pixel
          .defaultImage(Default.MM) // if not available show mystery man image
          .with(Rating.X)           // set rating to X
          .toUrl());
  }
}

Links:

About

Simple Java Gravatar-Library

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages