From dbff3f19efefa1488dbd811d702069add21f264d Mon Sep 17 00:00:00 2001 From: Wilfried Goesgens Date: Tue, 6 Jan 2015 23:12:53 +0100 Subject: [PATCH] when entering the blog view via gotonext, utilize seen information to determine which blog post has new comments; if only one has unseen comments, view this post. --- webcit/blogview_renderer.c | 35 ++++++++++++++++++++------ webcit/static/styles/blog.css | 8 ++++++ webcit/static/t/view_blog/comment.html | 2 +- 3 files changed, 37 insertions(+), 8 deletions(-) diff --git a/webcit/blogview_renderer.c b/webcit/blogview_renderer.c index b57d9d963..9caccc9ca 100644 --- a/webcit/blogview_renderer.c +++ b/webcit/blogview_renderer.c @@ -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(" | %s", _("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) { diff --git a/webcit/static/styles/blog.css b/webcit/static/styles/blog.css index 9242b55f6..ad3613189 100644 --- a/webcit/static/styles/blog.css +++ b/webcit/static/styles/blog.css @@ -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; } diff --git a/webcit/static/t/view_blog/comment.html b/webcit/static/t/view_blog/comment.html index 26c42a07c..7f47c2582 100644 --- a/webcit/static/t/view_blog/comment.html +++ b/webcit/static/t/view_blog/comment.html @@ -1,4 +1,4 @@ -
+
-- 2.30.2