Class Avatars
java.lang.Object
io.github.jbastgen.stemma.app.avatar.Avatars
The pictures and profile pages of the authors (feature 59). Two services, both off until the user turns them on, GitHub first:
- GitHub: the account is found from a GitHub no-reply address (
123+name@users.noreply.github.com, no request at all) or from the commit on the GitHub repository of the open repository (GET /repos/o/r/commits/sha: the request names the commit, never an e-mail address). The picture isgithub.com/<login>.png, the pagegithub.com/<login>. - Gravatar: the SHA-256 hash of the e-mail address is asked for at gravatar.com, never the address itself. The profile page is the one of the author's Gravatar profile, if there is one.
Results are kept in the configuration folder (avatars/): a profile for a week, "there is none" for a day, so a table of
hundreds of commits asks once per author and an opened repository needs no network.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordAn author on screen: who, and a commit of his on the GitHub repository (both may be null) to find the account.static final recordA GitHub repository: the commits of an author on it tell the account. -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionAvatars(Path dir, BooleanSupplier githubOn, BooleanSupplier gravatarOn, io.github.jbastgen.stemma.app.avatar.Avatars.Source source, Consumer<String> opener) Avatars(Path dir, BooleanSupplier githubOn, BooleanSupplier gravatarOn, io.github.jbastgen.stemma.app.avatar.Avatars.Source source, Consumer<String> opener, Clock clock) -
Method Summary
Modifier and TypeMethodDescriptionbooleanenabled()Whether any service is switched on; without one nothing is asked and nothing is shown.<N extends javafx.scene.Node>
Nlink(N node, Avatars.Lookup who) Makes a node (the name of an author) open the profile page when the author has one; otherwise it stays as it is.javafx.scene.Nodenode(Avatars.Lookup who, double size) The avatar of an author: the initials at once, replaced by the picture when it is there; a click on it opens the profile page when the author has one.
-
Field Details
-
NOTHING
public static final io.github.jbastgen.stemma.app.avatar.Avatars.Source NOTHINGA source that knows nothing. -
NONE
No pictures at all: the avatars show the initials.
-
-
Constructor Details
-
Avatars
public Avatars(Path dir, BooleanSupplier githubOn, BooleanSupplier gravatarOn, io.github.jbastgen.stemma.app.avatar.Avatars.Source source, Consumer<String> opener) - Parameters:
dir- the cache folder, or null for none; @param opener opens a web address in the browser
-
Avatars
public Avatars(Path dir, BooleanSupplier githubOn, BooleanSupplier gravatarOn, io.github.jbastgen.stemma.app.avatar.Avatars.Source source, Consumer<String> opener, Clock clock) - Parameters:
dir- the folder of the picture cache;nullfor no cachegithubOn- whether GitHub may be askedgravatarOn- whether Gravatar may be askedsource- where the pictures come fromopener- opens a profile page in the browserclock- the time, for the age of cached entries
-
-
Method Details
-
enabled
public boolean enabled()Whether any service is switched on; without one nothing is asked and nothing is shown. -
node
The avatar of an author: the initials at once, replaced by the picture when it is there; a click on it opens the profile page when the author has one.- Parameters:
size- the diameter in px
-
link
Makes a node (the name of an author) open the profile page when the author has one; otherwise it stays as it is.
-