Make avatar configurable.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 7 Dec 2011 06:23:25 +0000 (07:23 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Wed, 7 Dec 2011 06:23:25 +0000 (07:23 +0100)
src/main/java/net/pterodactylus/sone/web/OptionsPage.java
src/main/resources/i18n/sone.en.properties
src/main/resources/static/css/sone.css
src/main/resources/templates/options.html

index 49b1275..2a23236 100644 (file)
@@ -73,6 +73,8 @@ public class OptionsPage extends SoneTemplatePage {
                                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));
@@ -139,6 +141,7 @@ public class OptionsPage extends SoneTemplatePage {
                        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());
index 3bb04b7..c7bd539 100644 (file)
@@ -43,6 +43,7 @@ Page.Options.Option.EnableSoneInsertNotifications.Description=If enabled, this w
 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.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.
index e46540a..fc09d95 100644 (file)
@@ -294,6 +294,13 @@ textarea {
        position: absolute;
 }
 
+#sone .post-avatar {
+       display: inline-block;
+       width: 48px;
+       height: 48px;
+       overflow: hidden;
+}
+
 #sone .post > .inner-part {
        margin-left: 48px;
        padding-left: 0.5em;
@@ -816,3 +823,16 @@ textarea {
 #sone #sort-options {
        margin-bottom: 1em;
 }
+
+#sone ul#avatar-selection {
+       padding: 0;
+}
+
+#sone #avatar-selection li {
+       display: inline-block;
+}
+
+#sone #avatar-selection li .post-avatar {
+       vertical-align: middle;
+       margin-bottom: 0.5em;
+}
index 57f3c5f..76954eb 100644 (file)
                        <%= Page.Options.Option.ShowNotificationNewReplies.Description|l10n|html>
                </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>
 
                <p><%= Page.Options.Option.InsertionDelay.Description|l10n|html></p>