From e53a6719aa62a2c1f761d2adedecc4b0c230dd72 Mon Sep 17 00:00:00 2001
From: =?utf8?q?David=20=E2=80=98Bombe=E2=80=99=20Roden?=
Date: Wed, 7 Dec 2011 07:23:25 +0100
Subject: [PATCH] Make avatar configurable.
---
.../java/net/pterodactylus/sone/web/OptionsPage.java | 3 +++
src/main/resources/i18n/sone.en.properties | 1 +
src/main/resources/static/css/sone.css | 20 ++++++++++++++++++++
src/main/resources/templates/options.html | 12 ++++++++++++
4 files changed, 36 insertions(+)
diff --git a/src/main/java/net/pterodactylus/sone/web/OptionsPage.java b/src/main/java/net/pterodactylus/sone/web/OptionsPage.java
index 49b1275..2a23236 100644
--- a/src/main/java/net/pterodactylus/sone/web/OptionsPage.java
+++ b/src/main/java/net/pterodactylus/sone/web/OptionsPage.java
@@ -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());
diff --git a/src/main/resources/i18n/sone.en.properties b/src/main/resources/i18n/sone.en.properties
index 3bb04b7..c7bd539 100644
--- a/src/main/resources/i18n/sone.en.properties
+++ b/src/main/resources/i18n/sone.en.properties
@@ -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.
diff --git a/src/main/resources/static/css/sone.css b/src/main/resources/static/css/sone.css
index e46540a..fc09d95 100644
--- a/src/main/resources/static/css/sone.css
+++ b/src/main/resources/static/css/sone.css
@@ -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;
+}
diff --git a/src/main/resources/templates/options.html b/src/main/resources/templates/options.html
index 57f3c5f..76954eb 100644
--- a/src/main/resources/templates/options.html
+++ b/src/main/resources/templates/options.html
@@ -66,6 +66,18 @@
<%= Page.Options.Option.ShowNotificationNewReplies.Description|l10n|html>
+ <%ifnull !currentSone>
+
+ <%/if>
+
<%= Page.Options.Section.RuntimeOptions.Title|l10n|html>
<%= Page.Options.Option.InsertionDelay.Description|l10n|html>
--
2.7.4