Changeset 647
- Timestamp:
- 04/12/06 15:35:36 (3 years ago)
- Files:
-
- tracblogplugin/0.10/blog/admin.py (modified) (2 diffs)
- tracblogplugin/0.10/blog/templates/blog_admin.cs (modified) (1 diff)
- tracblogplugin/0.10/blog/templates/blog.cs (modified) (1 diff)
- tracblogplugin/0.10/blog/web_ui.py (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
tracblogplugin/0.10/blog/admin.py
r626 r647 61 61 'new_blog_link' : 'New Blog Post', 62 62 'first_week_day' : 'SUNDAY', 63 'mark_updated' : 'true', 63 64 } 64 65 if req.method == 'POST': … … 91 92 '''Calendar Week Start Day''':: 92 93 name of day that acts as the first day of the week. Must be full day name. 94 '''Mark Updated Posts''':: 95 whether or not to mark posts that have been updated with an "Updated on" message. 93 96 94 97 '''strftime formatting''':: tracblogplugin/0.10/blog/templates/blog_admin.cs
r628 r647 49 49 </label> 50 50 </div> 51 <div class="field"> 52 <label>Mark Updated Posts:<br/> 53 <input type="text" name="mark_updated" 54 value="<?cs var:blogadmin.mark_updated ?>" /> 55 </label> 56 </div> 51 57 <div class="buttons"> 52 58 <input type="submit" value="Apply Changes" /> tracblogplugin/0.10/blog/templates/blog.cs
r629 r647 50 50 </ul> 51 51 </div> 52 <hr width="75%" /> 52 <?cs if ! bentry.last ?> 53 <hr width="75%" /> 54 <?cs /if ?> 53 55 </div> 54 56 <?cs /each ?> tracblogplugin/0.10/blog/web_ui.py
r632 r647 15 15 # Author: John Hampton <pacopablo@asylumware.com> 16 16 17 import sys 17 18 import time 18 19 import datetime … … 31 32 from tractags.parseargs import parseargs 32 33 34 BOOLS_TRUE = ['true', 'yes', 'ok', 'on', 'enabled', '1'] 35 33 36 __all__ = ['TracBlogPlugin'] 37 38 def bool_val(val): 39 """Returns whether or not a values represents a boolen value 40 41 """ 42 43 return val.strip().lower() in BOOLS_TRUE 44 34 45 35 46 class TracBlogPlugin(Component): … … 37 48 38 49 The list of tags to be shown can be specified as arguments to the macro. 39 An options keyword argument of union can be secified. If specified, then40 the resulting blog will be a {{{union}}} of pages with the specified tags.41 If the {{{union}}} parameter is omitted, then an intersection of the42 specified tags is returned.43 44 50 If no tags are specified as parameters, then the default 'blog' tag is 45 51 used. 52 53 The following options can be specified: 54 55 '''union''' - Specify whether the join for the tags listed should be a 56 union or intersection(default).[[br]] 57 '''num_posts''' - Number of posts to display.[[br]] 58 '''year''' - Year for which to show posts.[[br]] 59 '''month''' - Month for which to show posts.[[br]] 60 '''day''' - Day of the month for which to show posts.[[br]] 61 '''delta''' - How many days of posts should be shown.[[br]] 62 '''mark_update''' - Specify whether to show "Updated on" for posts that 63 have been updated.[[br]] 64 65 If specifying dates with {{{year}}}, {{{month}}}, and/or {{{day}}}, the 66 current value is specified if missing. For example, if {{{day}}} is 67 specified but {{{year}}} and {{{month}}} are not, then {{{year}}} will be 68 filled in with the current year and {{{month}}} will be filled with the 69 current month. If only {{{year}}} and {{{month}}} are specified, then that 70 indicates the whole month is desired. 71 72 The {{{num_posts}}} options is bounded by the date options if combined. For 73 example, if {{{num_posts=5}}} and {{{month=4}}} is specified, it will show 74 up to 5 posts from the month of April. If only 3 posts exist, then only 3 75 are shown. If a date option is not specified, then it will show the last 76 {{{num_posts}}} posts. 46 77 47 78 === Examples === … … 50 81 [[BlogShow(blog,pacopablo)]] 51 82 [[BlogShow(blog,pacopablo,union=True)]] 83 [[BlogShow(blog,pacopablo,num_posts=5)]] 84 [[BlogShow(blog,pacopablo,month=4,num_posts=5)]] 85 [[BlogShow(blog,pacopablo,year=2006,month=4)]] 86 [[BlogShow(blog,pacopablo,year=2006,month=4,day=12)]] 87 [[BlogShow(blog,pacopablo,delta=5)]] 88 [[BlogShow(blog,pacopablo,delta=5,mark_updated=False)]] 52 89 }}} 53 90 """ … … 102 139 tags = req.args.getlist('tag') 103 140 kwargs = {} 104 #for key,value in req.args.items():105 141 for key in req.args.keys(): 106 142 if key != 'tag': 107 #kwargs[key] = value108 143 kwargs[key] = req.args[key] 109 144 continue … … 138 173 blog = tags.get_tagged_names(tlist, operation='intersection') 139 174 140 poststart, postend = self._get_time_range(req, **kwargs) 175 poststart, postend, default_times = self._get_time_range(req, **kwargs) 176 mark_updated = self._choose_value('mark_updated', req, kwargs, 177 convert=bool_val) 178 if not mark_updated and (not isinstance(mark_updated, bool)): 179 mark_updated = bool_val(self.env.config.get('blog', 'mark_updated', 180 True)) 181 182 num_posts = self._choose_value('num_posts', req, kwargs, convert=int) 183 self.log.debug('num_posts: %s' % str(num_posts)) 184 if num_posts and default_times: 185 poststart = sys.maxint 186 postend = 0 141 187 for blog_entry in blog: 142 188 page = WikiPage(self.env, version=1, name=blog_entry) … … 161 207 'comment' : wiki_to_oneliner(comment, self.env), 162 208 } 163 if modified != post_time:209 if (modified != post_time) and mark_updated: 164 210 data['modified'] = 1 165 mod_str = format_datetime( post_time, format=time_format)211 mod_str = format_datetime(modified, format=time_format) 166 212 data['mod_time'] = mod_str 167 213 entries[post_time] = data 168 214 continue 169 215 tlist = entries.keys() 170 # Python 2.4ism171 # tlist.sort(reverse=True)172 216 tlist.sort() 173 217 tlist.reverse() 218 if num_posts and (num_posts <= len(tlist)): 219 tlist = tlist[:num_posts] 220 self.log.debug("tlist: %s" % str(tlist)) 221 self.log.debug("last index: %s" % str(tlist[-1])) 222 entries[tlist[-1]]['last'] = 1 174 223 req.hdf['blog.entries'] = [entries[x] for x in tlist] 175 224 bloglink = self.env.config.get('blog', 'new_blog_link', 'New Blog Post') … … 342 391 month = self._choose_value('month', req, kwargs, convert=int) 343 392 day = self._choose_value('day', req, kwargs, convert=int) 393 defaults = not (startdate or enddate or delta or year or month or day) 344 394 now = datetime.datetime.now() 345 395 oneday = datetime.timedelta(days=1) … … 365 415 else: 366 416 end = start - HISTORY 367 return start, end 417 return start, end, defaults 368 418 369 419 def _choose_value(self, key, req, kwargs, convert=None):
