Opened 18 years ago
Closed 17 years ago
#1651 closed enhancement (fixed)
BlogShow option to limit the entries shown by username.
Reported by: | Kevin C. Krinke | Owned by: | John Hampton |
---|---|---|---|
Priority: | normal | Component: | TracBlogPlugin |
Severity: | normal | Keywords: | |
Cc: | Kevin C. Krinke | Trac Release: | 0.10 |
Description
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/web_ui.py =================================================================== --- blog/web_ui.py (revision 15) +++ blog/web_ui.py (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 === {{{ [[BlogShow()]] @@ -146,6 +150,7 @@ [[BlogShow(blog,pacopablo,year=2006,month=4,day=12)]] [[BlogShow(blog,pacopablo,delta=5)]] [[BlogShow(blog,pacopablo,delta=5,mark_updated=False)]] + [[BlogShow(blog,poster=UserName)]] }}} """ @@ -264,11 +269,19 @@ macro_bl = [name.strip() for name in macro_bl if name.strip()] macro_bl.append('BlogShow') - # 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( ).next() - + # 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)
Change History (4)
Changed 18 years ago by
Attachment: | tblog_poster.patch added |
---|
comment:1 Changed 18 years ago by
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.
Cheers!
comment:2 Changed 17 years ago by
Status: | new → 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
proper patch for poster BlogShow argument