Merge commit '0.3.1' into message-recipient
authorDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 26 Nov 2010 23:48:44 +0000 (00:48 +0100)
committerDavid ‘Bombe’ Roden <bombe@pterodactylus.net>
Fri, 26 Nov 2010 23:48:44 +0000 (00:48 +0100)
Conflicts:
src/main/resources/templates/viewSone.html

pom.xml
src/main/java/net/pterodactylus/sone/main/SonePlugin.java
src/main/java/net/pterodactylus/sone/web/ajax/GetPostAjaxPage.java
src/main/resources/static/javascript/sone.js
src/main/resources/templates/index.html
src/main/resources/templates/viewSone.html

diff --git a/pom.xml b/pom.xml
index 421e0bb..510ec62 100644 (file)
--- a/pom.xml
+++ b/pom.xml
@@ -2,7 +2,7 @@
        <modelVersion>4.0.0</modelVersion>
        <groupId>net.pterodactylus</groupId>
        <artifactId>sone</artifactId>
-       <version>0.3.1-RC3</version>
+       <version>0.3.1</version>
        <dependencies>
                <dependency>
                        <groupId>net.pterodactylus</groupId>
index ff14193..b1ae788 100644 (file)
@@ -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);
index b0d8ec5..452fc5a 100644 (file)
@@ -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();
index 75facb3..01dd77c 100644 (file)
@@ -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} <code>true</code> if the current page is the index page,
+ *          <code>false</code> otherwise
+ */
+function isIndexPage() {
+       return getPageId() == "index";
+}
+
+/**
+ * Returns whether the current page is a “view Sone” page.
+ *
+ * @returns {Boolean} <code>true</code> if the current page is a “view Sone”
+ *          page, <code>false</code> 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 <code>true</code>.
+ *
+ * @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();
index 5c2fca0..39d53f1 100644 (file)
@@ -1,5 +1,7 @@
 <%include include/head.html>
 
+       <div class="page-id hidden">index</div>
+
        <h1><%= Page.Index.PostList.Title|l10n|html></h1>
 
        <div id="posts">
index 6830836..884fa0f 100644 (file)
@@ -1,6 +1,7 @@
 <%include include/head.html>
 
-       <div id="sone-id" class="hidden"><% sone.id|html></div>
+       <div class="page-id hidden">view-sone</div>
+       <div class="sone-id hidden"><% sone.id|html></div>
 
        <%ifnull sone>