Add WoT identicons as avatars.
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 5 Nov 2010 08:58:47 +0000 (09:58 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 5 Nov 2010 08:58:47 +0000 (09:58 +0100)
src/main/resources/static/css/sone.css
src/main/resources/static/javascript/sone.js
src/main/resources/templates/include/head.html
src/main/resources/templates/include/viewPost.html

index 875d6aa..22e411b 100644 (file)
@@ -138,6 +138,16 @@ textarea {
        border-bottom: none;
 }
 
+#sone .post > .avatar {
+       position: absolute;
+}
+
+#sone .post > .inner-part {
+       margin-left: 48px;
+       padding-left: 0.5em;
+       min-height: 48px;
+}
+
 #sone .post .author {
        display: inline;
        font-weight: bold;
@@ -149,7 +159,6 @@ textarea {
 }
 
 #sone .post .status-line {
-       clear: both;
        margin-top: 0.5ex;
        font-size: 85%;
 }
@@ -201,6 +210,16 @@ textarea {
        padding-top: 0.2ex;
 }
 
+#sone .post .reply > .avatar {
+       position: absolute;
+}
+
+#sone .post .reply > .inner-part {
+       margin-left: 36px;
+       padding-left: 0.5em;
+       min-height: 36px;
+}
+
 #sone .post .reply {
        clear: both;
        background-color: #f0f0ff;
index 695503c..66314e1 100644 (file)
@@ -297,16 +297,16 @@ function getReplyId(element) {
 
 function likePost(postId) {
        $.getJSON("ajax/like.ajax", { "type": "post", "post" : postId, "formPassword": getFormPassword() }, function() {
-               $("#sone .post#" + postId + " > .status-line .like").addClass("hidden");
-               $("#sone .post#" + postId + " > .status-line .unlike").removeClass("hidden");
+               $("#sone .post#" + postId + " > .inner-part > .status-line .like").addClass("hidden");
+               $("#sone .post#" + postId + " > .inner-part > .status-line .unlike").removeClass("hidden");
                updatePostLikes(postId);
        });
 }
 
 function unlikePost(postId) {
        $.getJSON("ajax/unlike.ajax", { "type": "post", "post" : postId, "formPassword": getFormPassword() }, function() {
-               $("#sone .post#" + postId + " > .status-line .unlike").addClass("hidden");
-               $("#sone .post#" + postId + " > .status-line .like").removeClass("hidden");
+               $("#sone .post#" + postId + " > .inner-part > .status-line .unlike").addClass("hidden");
+               $("#sone .post#" + postId + " > .inner-part > .status-line .like").removeClass("hidden");
                updatePostLikes(postId);
        });
 }
@@ -314,9 +314,9 @@ function unlikePost(postId) {
 function updatePostLikes(postId) {
        $.getJSON("ajax/getLikes.ajax", { "type": "post", "post": postId }, function(data, textStatus) {
                if (data.success) {
-                       $("#sone .post#" + postId + " > .status-line .likes").toggleClass("hidden", data.likes == 0)
-                       $("#sone .post#" + postId + " > .status-line .likes span.like-count").text(data.likes);
-                       $("#sone .post#" + postId + " > .status-line .likes > span").attr("title", generateSoneList(data.sones));
+                       $("#sone .post#" + postId + " > .inner-part > .status-line .likes").toggleClass("hidden", data.likes == 0)
+                       $("#sone .post#" + postId + " > .inner-part > .status-line .likes span.like-count").text(data.likes);
+                       $("#sone .post#" + postId + " > .inner-part > .status-line .likes > span").attr("title", generateSoneList(data.sones));
                }
        });
 }
index 5f0d567..19a5f38 100644 (file)
@@ -34,7 +34,7 @@
                $(document).ready(function() {
                        $("#sone .post").each(function() {
                                postId = $(this).attr("id");
-                               enhanceDeletePostButton("#sone .post#" + postId + " > .status-line .delete button", postId);
+                               enhanceDeletePostButton("#sone .post#" + postId + " > .inner-part > .status-line .delete button", postId);
                                (function(postId) {
                                        $("#sone .post#" + postId + " .reply").each(function() {
                                                replyId = $(this).attr("id");
        <script language="javascript">
                /* convert all “like” buttons to javascript functions. */
                $(document).ready(function() {
-                       $("#sone .post > .status-line .like").submit(function() {
+                       $("#sone .post > .inner-part > .status-line .like").submit(function() {
                                likePost(getPostId(this));
                                return false;
                        });
-                       $("#sone .post > .status-line .unlike").submit(function() {
+                       $("#sone .post > .inner-part > .status-line .unlike").submit(function() {
                                unlikePost(getPostId(this));
                                return false;
                        });
index 3d4b409..c5df1f0 100644 (file)
@@ -1,4 +1,8 @@
 <div id="<% post.id|html>" class="post<%if loop.last> last<%/if>">
+       <div class="avatar">
+               <img src="/WoT/GetIdenticon?identity=<% post.sone.id|html>&amp;width=48&height=48" width="48" height="48" alt="Avatar Image" />
+       </div>
+       <div class="inner-part">
        <div>
                <div class="author profile-link"><a href="viewSone.html?sone=<% post.sone.id|html>"><% post.sone.niceName|html></a></div>
                <div class="text"><% post.text|html></div>
        <div class="replies">
                <%foreach post.replies reply>
                        <div id="<% reply.id|html>" class="reply">
+                               <div class="avatar">
+                                       <img src="/WoT/GetIdenticon?identity=<% reply.sone.id|html>&amp;width=36&height=36" width="36" height="36" alt="Avatar Image" />
+                               </div>
+                               <div class="inner-part">
                                <div>
                                        <div class="author profile-link"><a href="viewSone.html?sone=<% reply.sone.id|html>"><% reply.sone.niceName|html></a></div>
                                        <div class="text"><% reply.text|html></div>
@@ -66,6 +74,7 @@
                                                </form>
                                        <%/if>
                                </div>
+                               </div>
                        </div>
                <%/foreach>
                <%ifnull ! currentSone>
@@ -80,4 +89,5 @@
                        </div>
                <%/if>
        </div>
+       </div>
 </div>