Opened 9 years ago

Closed 9 years ago

#1651 closed enhancement (fixed)

BlogShow option to limit the entries shown by username.

Reported by: kckrinke Owned by: pacopablo
Priority: normal Component: TracBlogPlugin
Severity: normal Keywords:
Cc: kckrinke Trac Release: 0.10


Below is a patch to add the feature requested. Being that I'm already using this feature, I'm only submitting it here for other people who may want something of the like.

This is particularly great for when the site has pages dedicated to each user (ie: wiki/Username) where by using this option on such pages will essentially provide for a blog dedicated to just that user. No one else's blogs would show up and the calendar even works as expected, ie: only showing tallies of their entries as well as when you click a day/date it redisplay's the same page with only that day's entries from that user being displayed.

Wonderful plugin by the way!

Index: blog/
--- blog/      (revision 15)
+++ blog/      (revision 16)
@@ -120,6 +120,7 @@
     have been updated.[[br]]
     '''format''' - Show as RSS feed ('rss') or HTML (else).[[br]]
     '''post_size''' - Number of bytes to show before truncating the post and providing a ''(...)'' link.  Posts are truncated at the next line break after the byte count is reached.
+    '''poster''' - Show only entries made by a single named user.[[br]]

     If specifying dates with {{{year}}}, {{{month}}}, and/or {{{day}}}, the
@@ -135,6 +136,9 @@
     are shown.  If a date option is not specified, then it will show the last
     {{{num_posts}}} posts.

+    The {{{poster}}} option is bounded by all of the above options and also
+    limits the calendar to display tallies respective of the named user.
     === Examples ===
@@ -146,6 +150,7 @@
+    [[BlogShow(blog,poster=UserName)]]

@@ -264,11 +269,19 @@
         macro_bl = [name.strip() for name in macro_bl if name.strip()]

-        # Get the email addresses of all known users
+        # Get the email addresses of all known users and validate the "poster"
+        # BlogShow optional argument at the same time (avoids looping the user
+        # list twice).
+        is_poster = None
+        limit_poster = self._choose_value('poster', req, kwargs, convert=None)
         email_map = {}
         for username, name, email in self.env.get_known_users():
             if email:
                 email_map[username] = email
+            if limit_poster != None:
+                if username == limit_poster:
+                    is_poster = username

         num_posts = self._choose_value('num_posts', req, kwargs, convert=int)
         if num_posts and default_times:
@@ -281,7 +294,12 @@
                 page = WikiPage(self.env, version=1, name=blog_entry)
                 version, post_time, author, comment, ipnr = page.get_history(
+                # if we're limiting by poster, do so now so that the calendar
+                # only shows the number of entries the specific poster made.
+                if is_poster != None:
+                    if is_poster != author:
+                        continue
                 self._add_to_tallies(tallies, post_time, blog_entry)
                 page = WikiPage(self.env, name=blog_entry)
                 version, modified, author, comment, ipnr = page.get_history(

Attachments (1)

tblog_poster.patch (2.8 KB) - added by kckrinke 9 years ago.
proper patch for poster BlogShow argument

Download all attachments as: .zip

Change History (4)

Changed 9 years ago by kckrinke

proper patch for poster BlogShow argument

comment:1 in reply to: ↑ description Changed 9 years ago by kckrinke

Replying to kckrinke:

Below is a patch to add the feature requested.

I believe the patch I pasted into my original post was broken, I've attached a proper patch for the feature request. Sorry about that.


comment:2 Changed 9 years ago by pacopablo

  • Status changed from new to assigned

Thanks for the patch. Looks good. I'll try to apply it this weekend.

Sorry it's taken me so long to address this. Thanks again

comment:3 Changed 9 years ago by pacopablo

  • Resolution set to fixed
  • Status changed from assigned to closed

(In [2399])

  • Feature: Limit BlogShow entries by user name.
  • Feature: Added SplitPost macro to allow for hard splitting of blog posts

Add Comment

Modify Ticket

as closed The owner will remain pacopablo.
The resolution will be deleted. Next status will be 'reopened'.

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.