From: David ‘Bombe’ Roden Date: Fri, 26 Nov 2010 23:48:44 +0000 (+0100) Subject: Merge commit '0.3.1' into message-recipient X-Git-Tag: 0.3.2-RC1~15^2 X-Git-Url: https://git.pterodactylus.net/?p=Sone.git;a=commitdiff_plain;h=96fcb6d250349cb1c02df44d6e3acdb93c8e7370;hp=bd56e01d9efa9b54074dad9b698e98e7dc2be46d Merge commit '0.3.1' into message-recipient Conflicts: src/main/resources/templates/viewSone.html --- diff --git a/pom.xml b/pom.xml index 421e0bb..510ec62 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ 4.0.0 net.pterodactylus sone - 0.3.1-RC3 + 0.3.1 net.pterodactylus diff --git a/src/main/java/net/pterodactylus/sone/main/SonePlugin.java b/src/main/java/net/pterodactylus/sone/main/SonePlugin.java index ff14193..b1ae788 100644 --- a/src/main/java/net/pterodactylus/sone/main/SonePlugin.java +++ b/src/main/java/net/pterodactylus/sone/main/SonePlugin.java @@ -79,7 +79,7 @@ public class SonePlugin implements FredPlugin, FredPluginL10n, FredPluginBaseL10 } /** The version. */ - public static final Version VERSION = new Version("RC3", 0, 3, 1); + public static final Version VERSION = new Version(0, 3, 1); /** The logger. */ private static final Logger logger = Logging.getLogger(SonePlugin.class); diff --git a/src/main/java/net/pterodactylus/sone/web/ajax/GetPostAjaxPage.java b/src/main/java/net/pterodactylus/sone/web/ajax/GetPostAjaxPage.java index b0d8ec5..452fc5a 100644 --- a/src/main/java/net/pterodactylus/sone/web/ajax/GetPostAjaxPage.java +++ b/src/main/java/net/pterodactylus/sone/web/ajax/GetPostAjaxPage.java @@ -87,6 +87,7 @@ public class GetPostAjaxPage extends JsonPage { private JsonObject createJsonPost(Post post) { JsonObject jsonPost = new JsonObject(); jsonPost.put("id", post.getId()); + jsonPost.put("sone", post.getSone().getId()); jsonPost.put("time", post.getTime()); postTemplate.set("post", post); StringWriter stringWriter = new StringWriter(); diff --git a/src/main/resources/static/javascript/sone.js b/src/main/resources/static/javascript/sone.js index 75facb3..01dd77c 100644 --- a/src/main/resources/static/javascript/sone.js +++ b/src/main/resources/static/javascript/sone.js @@ -601,6 +601,45 @@ function getStatus() { }) } +/** + * Returns the content of the page-id attribute. + * + * @returns The page ID + */ +function getPageId() { + return $("#sone .page-id").text(); +} + +/** + * Returns whether the current page is the index page. + * + * @returns {Boolean} true if the current page is the index page, + * false otherwise + */ +function isIndexPage() { + return getPageId() == "index"; +} + +/** + * Returns whether the current page is a “view Sone” page. + * + * @returns {Boolean} true if the current page is a “view Sone” + * page, false otherwise + */ +function isViewSonePage() { + return getPageId() == "view-sone"; +} + +/** + * Returns the ID of the currently shown Sone. This will only return a sensible + * value if isViewSonePage() returns true. + * + * @returns The ID of the currently shown Sone + */ +function getSoneId() { + return $("#sone .sone-id").text(); +} + var loadedPosts = {}; var loadedReplies = {}; @@ -611,6 +650,9 @@ function loadNewPost(postId) { loadedPosts[postId] = true; $.getJSON("ajax/getPost.ajax", { "post" : postId }, function(data, textStatus) { if ((data != null) && data.success) { + if (!isIndexPage() && !(isViewSonePage() && (getSoneId() == data.post.sone))) { + return; + } var firstOlderPost = null; $("#sone .post").each(function() { if (getPostTime(this) < data.post.time) { @@ -622,7 +664,7 @@ function loadNewPost(postId) { if (firstOlderPost != null) { newPost.insertBefore(firstOlderPost); } else { - $("#sone #posts").append(newPost); + $("#sone .post:last").append(newPost); } ajaxifyPost(newPost); newPost.slideDown(); diff --git a/src/main/resources/templates/index.html b/src/main/resources/templates/index.html index 5c2fca0..39d53f1 100644 --- a/src/main/resources/templates/index.html +++ b/src/main/resources/templates/index.html @@ -1,5 +1,7 @@ <%include include/head.html> + +

<%= Page.Index.PostList.Title|l10n|html>

diff --git a/src/main/resources/templates/viewSone.html b/src/main/resources/templates/viewSone.html index 6830836..884fa0f 100644 --- a/src/main/resources/templates/viewSone.html +++ b/src/main/resources/templates/viewSone.html @@ -1,6 +1,7 @@ <%include include/head.html> - + + <%ifnull sone>