Skip to content

Commit

Permalink
Added experimental support for local avatars.
Browse files Browse the repository at this point in the history
Put png files in data/local_avatars rather than load them from a
web service.
  • Loading branch information
fbk-zz authored and rictic committed Mar 28, 2009
1 parent 7ab9e9b commit 478f1ca
Show file tree
Hide file tree
Showing 5 changed files with 40 additions and 0 deletions.
8 changes: 8 additions & 0 deletions COPYING
@@ -1,3 +1,11 @@
The code in this project is licensed under the GPLv3, reproduced below unless
otherwise specified, e.g. Pair.java which is released by Sun under the GPLv2
only.

The image: data/local_avatars/default.png is copyright by Everaldo Coelho
and is part of his Crystal icon set, and is licensed under the LGPL.


GNU GENERAL PUBLIC LICENSE GNU GENERAL PUBLIC LICENSE
Version 3, 29 June 2007 Version 3, 29 June 2007


Expand Down
7 changes: 7 additions & 0 deletions bin/config.template
Expand Up @@ -33,3 +33,10 @@ IsInputSorted=true


# Uncomment to not use avatars # Uncomment to not use avatars
#AvatarFetcher=NoAvatar #AvatarFetcher=NoAvatar

# To use local avatars, uncomment this line:
#AvatarFetcher=LocalAvatar

# then place png files named after the usernames of committers in
# the data/local_avatars directory
# data/local_avatars/default.png is used by default
Binary file added data/local_avatars/default.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions defaults/code_swarm.config
Expand Up @@ -111,3 +111,7 @@ GravatarFallback=identicon


#Size in pixels of the width and height of avatar images #Size in pixels of the width and height of avatar images
AvatarSize=40 AvatarSize=40

# Used by the LocalAvatar fetcher
LocalAvatarDirectory=data/local_avatars/
LocalAvatarDefaultPic=default.png
21 changes: 21 additions & 0 deletions src/LocalAvatar.java
@@ -0,0 +1,21 @@
import java.io.File;

public class LocalAvatar extends AvatarFetcher {
public String dir = "";
public String empty_pic = null;

public LocalAvatar(CodeSwarmConfig cfg) {
super(cfg);
dir = cfg.getStringProperty("LocalAvatarDirectory");
empty_pic = cfg.getStringProperty("LocalAvatarDefaultPic");
}

public String fetchUserImage(String username) {
String filename = dir+username+".png";
File f = new File(filename);
if(f.exists()) return filename;
return dir+empty_pic;
}


}

0 comments on commit 478f1ca

Please sign in to comment.