when entering the blog view via gotonext, utilize seen information to determine which...
authorWilfried Goesgens <dothebart@citadel.org>
Tue, 6 Jan 2015 22:12:53 +0000 (23:12 +0100)
committerWilfried Goesgens <dothebart@citadel.org>
Tue, 6 Jan 2015 22:12:53 +0000 (23:12 +0100)
webcit/blogview_renderer.c
webcit/static/styles/blog.css
webcit/static/t/view_blog/comment.html

index b57d9d963c6629e4790587128c1c625d166737e4..9caccc9ca30523cbef17f39f005c46a9a16d7950 100644 (file)
@@ -81,6 +81,7 @@ void blogpost_render(struct blogpost *bp, int with_comments)
                urlescputs(ChrPtr(WC->CurRoom.name));
                wc_printf("#comments\">");
                wc_printf(_("%d comments"), bp->num_msgs - 1);
+               wc_printf(" %d %s", bp->unread_oments, _("new"));
                wc_printf("</a> | <a class=\"blog_permalink_link\" href=\"");
                tmplput_blog_permalink(NULL, NULL);
                wc_printf("\">%s</a>", _("permalink"));
@@ -197,8 +198,6 @@ int blogview_LoadMsgFromServer(SharedMessageStatus *Stat,
                }
                bp->msgs[bp->num_msgs++] = Msg->msgnum;
                if ((Msg->Flags & MSGFLAG_READ) != 0) {
-                       syslog(LOG_DEBUG, "****************** unread %ld", Msg->msgnum);
-                       
                        bp->unread_oments++;
                }
        }
@@ -246,15 +245,37 @@ int blogview_render(SharedMessageStatus *Stat, void **ViewSpecific, long oper)
        /* Comments are shown if we are only viewing a single blog post */
        with_comments = (BL->p != 0);
 
-       firstp = atoi(BSTR("firstp"));  /* start reading at... */
-       maxp = atoi(BSTR("maxp"));      /* max posts to show... */
-       if (maxp < 1) maxp = 5;         /* default; move somewhere else? */
+       firstp = ibstr("firstp");   /* start reading at... */
+       maxp   = ibstr("maxp");     /* max posts to show... */
+       if (maxp < 1) maxp = 5;     /* default; move somewhere else? */
 
+       it = GetNewHashPos(BL->BLOG, 0);
 
-       //// bp->unread_oments++;
+       if ((BL->gotonext) && (BL->p == 0)) {
+               /* did we come here via gotonext? lets find out whether
+                * this blog has just one blogpost with new comments just display 
+                * this one.
+                */
+               struct blogpost *unread_bp = NULL;
+               int unread_count = 0;
+               while (GetNextHashPos(BL->BLOG, it, &len, &Key, &Data)) {
+                       struct blogpost *one_bp = (struct blogpost *) Data;
+                       if (one_bp->unread_oments > 0) {
+                               unread_bp = one_bp;
+                               unread_count++;
+                       }
+               }
+               if (unread_count == 1) {
+                       blogpost_render(unread_bp, 1);
+
+                       DeleteHashPos(&it);
+                       return 0;
+               }
+
+               RewindHashPos(BL->BLOG, it, 0);
+       }
 
        /* Iterate through the hash list and copy the data pointers into an array */
-       it = GetNewHashPos(BL->BLOG, 0);
        while (GetNextHashPos(BL->BLOG, it, &len, &Key, &Data)) {
                if (num_blogposts >= num_blogposts_alloc) {
                        if (num_blogposts_alloc == 0) {
index 9242b55f6c55afa6927c5da05aa1c566dc10b833..ad36131891fd1b3d1597d965e65690724c4291c8 100644 (file)
@@ -53,6 +53,14 @@ a.blog_show_comments_link:link, a.blog_show_comments_link:active, a.blog_show_co
        background-color: #EDEDE0;
 }
 
+.blog_comment_unread {
+       margin: 0.5em;
+       padding: 0.5em 0.25em 0.25em;
+       width: 35em;
+       border-top: 1px dotted grey;
+       background-color: #EFEFE0;
+}
+
 .blog_comment_header {
        font-size: smaller;
 }
index 26c42a07cba387ec861343f8bf3d7992b94afa5b..7f47c2582fe8e40e22b18b6336545848501b9df6 100644 (file)
@@ -1,4 +1,4 @@
-<div class="blog_comment" id="blog_comment_<?MAIL:SUMM:N>">
+<div class='<?%("COND:MAIL:SUMM:UNREAD", 1, 0, 0, "blog_comment", "blog_comment">' id="blog_comment_<?MAIL:SUMM:N>">
        <div class="blog_comment_header">
                <span class="blog_commenter_name">
                <??("COND:MAIL:ANON",1)>