Permalink
Browse files

Added experimental support for local avatars.

Put png files in data/local_avatars rather than load them from a
web service.
  • Loading branch information...
1 parent 7ab9e9b commit 478f1cafc7a6345fdcbb29d46cdf0a2e2b5806a2 @fbk-zz fbk-zz committed with Mar 28, 2009
Showing with 40 additions and 0 deletions.
  1. +8 −0 COPYING
  2. +7 −0 bin/config.template
  3. BIN data/local_avatars/default.png
  4. +4 −0 defaults/code_swarm.config
  5. +21 −0 src/LocalAvatar.java
View
@@ -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
Version 3, 29 June 2007
View
@@ -33,3 +33,10 @@ IsInputSorted=true
# Uncomment to not use avatars
#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
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@@ -111,3 +111,7 @@ GravatarFallback=identicon
#Size in pixels of the width and height of avatar images
AvatarSize=40
+
+# Used by the LocalAvatar fetcher
+LocalAvatarDirectory=data/local_avatars/
+LocalAvatarDefaultPic=default.png
View
@@ -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.