String lastInsertFingerprint = configuration.getStringValue(sonePrefix + "/LastInsertFingerprint").getValue("");
/* load profile. */
- Profile profile = new Profile();
+ Profile profile = new Profile(sone);
profile.setFirstName(configuration.getStringValue(sonePrefix + "/Profile/FirstName").getValue(null));
profile.setMiddleName(configuration.getStringValue(sonePrefix + "/Profile/MiddleName").getValue(null));
profile.setLastName(configuration.getStringValue(sonePrefix + "/Profile/LastName").getValue(null));
/* load avatar. */
String avatarId = configuration.getStringValue(sonePrefix + "/Profile/Avatar").getValue(null);
if (avatarId != null) {
- sone.setAvatar(getImage(avatarId, false));
+ profile.setAvatar(getImage(avatarId, false));
}
/* load options. */
configuration.getIntValue(sonePrefix + "/Profile/BirthDay").setValue(profile.getBirthDay());
configuration.getIntValue(sonePrefix + "/Profile/BirthMonth").setValue(profile.getBirthMonth());
configuration.getIntValue(sonePrefix + "/Profile/BirthYear").setValue(profile.getBirthYear());
- configuration.getStringValue(sonePrefix + "/Profile/Avatar").setValue(sone.getAvatar());
+ configuration.getStringValue(sonePrefix + "/Profile/Avatar").setValue(profile.getAvatar());
/* save profile fields. */
int fieldCounter = 0;
Integer profileBirthDay = Numbers.safeParseInteger(profileXml.getValue("birth-day", null));
Integer profileBirthMonth = Numbers.safeParseInteger(profileXml.getValue("birth-month", null));
Integer profileBirthYear = Numbers.safeParseInteger(profileXml.getValue("birth-year", null));
- Profile profile = new Profile().setFirstName(profileFirstName).setMiddleName(profileMiddleName).setLastName(profileLastName);
+ Profile profile = new Profile(sone).setFirstName(profileFirstName).setMiddleName(profileMiddleName).setLastName(profileLastName);
profile.setBirthDay(profileBirthDay).setBirthMonth(profileBirthMonth).setBirthYear(profileBirthYear);
/* avatar is processed after images are loaded. */
String avatarId = profileXml.getValue("avatar", null);
/* process avatar. */
if (avatarId != null) {
- sone.setAvatar(core.getImage(avatarId, false));
+ profile.setAvatar(core.getImage(avatarId, false));
}
/* okay, apparently everything was parsed correctly. Now import. */
soneProperties.put("likedPostIds", new HashSet<String>(sone.getLikedPostIds()));
soneProperties.put("likedReplyIds", new HashSet<String>(sone.getLikedReplyIds()));
soneProperties.put("albums", sone.getAllAlbums());
- soneProperties.put("avatar", sone.getAvatar());
}
//
*/
public class Profile implements Fingerprintable {
+ /** The Sone this profile belongs to. */
+ private final Sone sone;
+
/** The first name. */
private volatile String firstName;
/** The year of the birth date. */
private volatile Integer birthYear;
+ /** The ID of the avatar image. */
+ private volatile String avatar;
+
/** Additional fields in the profile. */
private final List<Field> fields = Collections.synchronizedList(new ArrayList<Field>());
/**
* Creates a new empty profile.
+ *
+ * @param sone
+ * The Sone this profile belongs to
*/
- public Profile() {
- /* do nothing. */
+ public Profile(Sone sone) {
+ this.sone = sone;
}
/**
* The profile to copy
*/
public Profile(Profile profile) {
- if (profile == null) {
- return;
- }
+ this.sone = profile.sone;
this.firstName = profile.firstName;
this.middleName = profile.middleName;
this.lastName = profile.lastName;
this.birthDay = profile.birthDay;
this.birthMonth = profile.birthMonth;
this.birthYear = profile.birthYear;
+ this.avatar = profile.avatar;
this.fields.addAll(profile.fields);
}
}
/**
+ * Returns the ID of the currently selected avatar image.
+ *
+ * @return The ID of the currently selected avatar image, or {@code null} if
+ * no avatar is selected.
+ */
+ public String getAvatar() {
+ return avatar;
+ }
+
+ /**
+ * Sets the avatar image.
+ *
+ * @param avatar
+ * The new avatar image, or {@code null} to not select an avatar
+ * image.
+ * @return This Sone
+ */
+ public Profile setAvatar(Image avatar) {
+ if (avatar == null) {
+ this.avatar = null;
+ return this;
+ }
+ Validation.begin().isEqual("Image Owner", avatar.getSone(), sone).check();
+ this.avatar = avatar.getId();
+ return this;
+ }
+
+ /**
* Sets the year of the birth date.
*
* @param birthYear
if (birthYear != null) {
fingerprint.append("BirthYear(").append(birthYear).append(')');
}
+ if (avatar != null) {
+ fingerprint.append("Avatar(").append(avatar).append(')');
+ }
fingerprint.append("ContactInformation(");
for (Field field : fields) {
fingerprint.append(field.getName()).append('(').append(field.getValue()).append(')');
private volatile long time;
/** The profile of this Sone. */
- private volatile Profile profile = new Profile();
+ private volatile Profile profile = new Profile(this);
/** The client used by the Sone. */
private volatile Client client;
/** Sone-specific options. */
private final Options options = new Options();
- /** The avatar of this Sone. */
- private volatile String avatar;
-
/**
* Creates a new Sone.
*
}
/**
- * Returns the ID of the currently selected avatar image.
- *
- * @return The ID of the currently selected avatar image, or {@code null} if
- * no avatar is selected.
- */
- public String getAvatar() {
- return avatar;
- }
-
- /**
- * Sets the avatar image.
- *
- * @param avatar
- * The new avatar image, or {@code null} to not select an avatar
- * image.
- * @return This Sone
- */
- public Sone setAvatar(Image avatar) {
- if (avatar == null) {
- this.avatar = null;
- return this;
- }
- Validation.begin().isEqual("Image Owner", avatar.getSone(), this).check();
- this.avatar = avatar.getId();
- return this;
- }
-
- /**
* Returns Sone-specific options.
*
* @return The options of this Sone
}
fingerprint.append(')');
- fingerprint.append("Avatar(").append(avatar).append(')');
-
return fingerprint.toString();
}
return new Trust(null, null, null);
}
return trust;
- } else if (member.equals("avatar")) {
- String avatarId = sone.getAvatar();
- if (avatarId == null) {
- return null;
- }
- return core.getImage(avatarId);
}
return super.get(templateContext, object, member);
}
Integer birthDay = profile.getBirthDay();
Integer birthMonth = profile.getBirthMonth();
Integer birthYear = profile.getBirthYear();
+ String avatarId = profile.getAvatar();
List<Field> fields = profile.getFields();
if (request.getMethod() == Method.POST) {
if (request.getHttpRequest().getPartAsStringFailsafe("save-profile", 4).equals("true")) {
birthDay = Numbers.safeParseInteger(request.getHttpRequest().getPartAsStringFailsafe("birth-day", 256).trim());
birthMonth = Numbers.safeParseInteger(request.getHttpRequest().getPartAsStringFailsafe("birth-month", 256).trim());
birthYear = Numbers.safeParseInteger(request.getHttpRequest().getPartAsStringFailsafe("birth-year", 256).trim());
+ avatarId = request.getHttpRequest().getPartAsStringFailsafe("avatar-id", 36);
profile.setFirstName(firstName.length() > 0 ? firstName : null);
profile.setMiddleName(middleName.length() > 0 ? middleName : null);
profile.setLastName(lastName.length() > 0 ? lastName : null);
profile.setBirthDay(birthDay).setBirthMonth(birthMonth).setBirthYear(birthYear);
+ profile.setAvatar(webInterface.getCore().getImage(avatarId, false));
for (Field field : fields) {
String value = request.getHttpRequest().getPartAsStringFailsafe("field-" + field.getId(), 400);
field.setValue(value);
templateContext.set("birthDay", birthDay);
templateContext.set("birthMonth", birthMonth);
templateContext.set("birthYear", birthYear);
+ templateContext.set("avatar-id", avatarId);
templateContext.set("fields", fields);
}
currentSone.getOptions().getBooleanOption("ShowNotification/NewPosts").set(showNotificationNewPosts);
boolean showNotificationNewReplies = request.getHttpRequest().isPartSet("show-notification-new-replies");
currentSone.getOptions().getBooleanOption("ShowNotification/NewReplies").set(showNotificationNewReplies);
- String avatarId =request.getHttpRequest().getPartAsStringFailsafe("avatar-image", 36);
- currentSone.setAvatar(webInterface.getCore().getImage(avatarId, false));
webInterface.getCore().touchConfiguration();
}
Integer insertionDelay = Numbers.safeParseInteger(request.getHttpRequest().getPartAsStringFailsafe("insertion-delay", 16));
templateContext.set("show-notification-new-sones", currentSone.getOptions().getBooleanOption("ShowNotification/NewSones").get());
templateContext.set("show-notification-new-posts", currentSone.getOptions().getBooleanOption("ShowNotification/NewPosts").get());
templateContext.set("show-notification-new-replies", currentSone.getOptions().getBooleanOption("ShowNotification/NewReplies").get());
- templateContext.set("avatar-image", currentSone.getAvatar());
}
templateContext.set("insertion-delay", preferences.getInsertionDelay());
templateContext.set("posts-per-page", preferences.getPostsPerPage());
Page.Options.Option.ShowNotificationNewSones.Description=Show notifications for new Sones.
Page.Options.Option.ShowNotificationNewPosts.Description=Show notifications for new posts.
Page.Options.Option.ShowNotificationNewReplies.Description=Show notifications for new replies.
-Page.Options.Option.Avatar.Delete=No avatar
+Page.Options.Section.AvatarOptions.Title=Avatar Options
+
Page.Options.Section.RuntimeOptions.Title=Runtime Behaviour
Page.Options.Option.InsertionDelay.Description=The number of seconds the Sone inserter waits after a modification of a Sone before it is being inserted.
Page.Options.Option.PostsPerPage.Description=The number of posts to display on a page before pagination controls are being shown.
Page.EditProfile.Birthday.Label.Day=Day:
Page.EditProfile.Birthday.Label.Month=Month:
Page.EditProfile.Birthday.Label.Year=Year:
+Page.EditProfile.Avatar.Title=Avatar
+Page.EditProfile.Avatar.Description=You can select one of your uploaded images to be shown as avatar. It should not be larger than 64×64 pixels because that is the largest size shown for other people (80×80 pixels is used for the page header).
+Page.EditProfile.Avatar.Delete=No avatar
Page.EditProfile.Fields.Title=Custom Fields
Page.EditProfile.Fields.Description=Here you can enter custom fields into your profile. These fields can contain anything you want and be as terse or as verbose as you wish. Just remember that when it comes to anonymity, sometimes less is more.
Page.EditProfile.Fields.Button.Edit=edit
#sone #avatar-selection li .post-avatar {
vertical-align: middle;
- margin-bottom: 0.5em;
+ margin-top: 0.5em;
+}
+
+#sone #avatar-selection li#no-avatar {
+ display: block;
}
<input type="text" name="birth-year" value="<% birthYear|html>" />
</div>
+ <h1><%= Page.EditProfile.Avatar.Title|l10n|html></h1>
+
+ <p><%= Page.EditProfile.Avatar.Description|l10n|html></p>
+
+ <ul id="avatar-selection">
+ <li id="no-avatar">
+ <input type="radio" name="avatar-id" value="none"<%ifnull avatar-image> checked="checked"<%/if>/>
+ <%= Page.EditProfile.Avatar.Delete|l10n|html>
+ </li>
+ <%foreach currentSone.allImages image>
+ <li>
+ <input type="radio" name="avatar-id" value="<%image.id|html>"<%if avatar-id|match key=image.id> checked="checked"<%/if>/>
+ <div class="post-avatar"><% image|image-link max-width=48 max-height=48 mode=enlarge title==image.title></div>
+ </li>
+ <%/foreach>
+ </ul>
+
<div>
<button type="submit" name="save-profile" value="true"><%= Page.EditProfile.Button.Save|l10n|html></button>
</div>
<div class="avatar profile-avatar">
<a class="picture" href="index.html">
<%ifnull !currentSone>
- <%ifnull !currentSone.avatar>
- <%currentSone.avatar|image-link max-width=80 max-height=80 mode=enlarge title="Profile Avatar">
+ <%ifnull !currentSone.profile.avatar>
+ <%currentSone.profile.avatar|image-link max-width=80 max-height=80 mode=enlarge title="Profile Avatar">
<%else>
<img src="/WebOfTrust/GetIdenticon?identity=<% currentSone.id|html>&width=80&height=80" width="80" height="80" alt="Profile Avatar" />
<%/if>
<div class="sone-menu <% class|css|html>">
<div class="sone-menu-id hidden"><%sone.id|html></div>
<div class="avatar menu-avatar">
- <%ifnull !sone.avatar>
- <%sone.avatar|image-link max-width=64 max-height=64 mode=enlarge title==sone.niceName>
+ <%ifnull !sone.profile.avatar>
+ <%sone.profile.avatar|image-link max-width=64 max-height=64 mode=enlarge title==sone.niceName>
<%else>
<img src="/WebOfTrust/GetIdenticon?identity=<%sone.id|html>&width=64&height=64" width="64" height="64" alt="Avatar Image" />
<%/if>
<%include include/soneMenu.html class=="sone-post-menu" sone=post.sone>
<div class="avatar post-avatar" >
<%if post.loaded>
- <%ifnull !post.sone.avatar>
- <%post.sone.avatar|image-link max-width=48 max-height=48 mode=enlarge title="Avatar Image">
+ <%ifnull !post.sone.profile.avatar>
+ <%post.sone.profile.avatar|image-link max-width=48 max-height=48 mode=enlarge title="Avatar Image">
<%else>
<img src="/WebOfTrust/GetIdenticon?identity=<% post.sone.id|html>&width=48&height=48" width="48" height="48" alt="Avatar Image" />
<%/if>
<div class="reply-author-local hidden"><% reply.sone.local></div>
<%include include/soneMenu.html class=="sone-reply-menu" sone=reply.sone>
<div class="avatar reply-avatar">
- <%ifnull !reply.sone.avatar>
- <% reply.sone.avatar|image-link max-width=36 max-height=36 mode=enlarge title="Avatar Image">
+ <%ifnull !reply.sone.profile.avatar>
+ <% reply.sone.profile.avatar|image-link max-width=36 max-height=36 mode=enlarge title="Avatar Image">
<%else>
<img src="/WebOfTrust/GetIdenticon?identity=<% reply.sone.id|html>&width=36&height=36" width="36" height="36" alt="Avatar Image" />
<%/if>
<birth-day><% currentSone.profile.birthDay|xml></birth-day>
<birth-month><% currentSone.profile.birthMonth|xml></birth-month>
<birth-year><% currentSone.profile.birthYear|xml></birth-year>
+ <avatar><%currentSone.profile.avatar|xml></avatar>
<fields>
<%foreach currentSone.profile.fields field>
<field>
</field>
<%/foreach>
</fields>
- <avatar><%currentSone.avatar|xml></avatar>
</profile>
<posts>
</p>
<%ifnull !currentSone>
- <ul id="avatar-selection">
- <li><input type="radio" name="avatar-image" value="none"<%ifnull avatar-image> checked="checked"<%/if>/><%= Page.Options.Option.Avatar.Delete|l10n|html></input></li>
- <%foreach currentSone.allImages image>
- <li>
- <input type="radio" name="avatar-image" value="<%image.id|html>"<%if avatar-image|match key=image.id> checked="checked"<%/if>/>
- <div class="post-avatar"><% image|image-link max-width=48 max-height=48 mode=enlarge title==image.title></div>
- </li>
- <%/foreach>
- </ul>
<%/if>
<h2><%= Page.Options.Section.RuntimeOptions.Title|l10n|html></h2>