Changeset 3008

Show
Ignore:
Timestamp:
01/09/08 03:44:14 (11 months ago)
Author:
osimons
Message:

FullBlogPlugin: Some fixes and improvements.

  • Added shorten=True to the timeline rendering of posts and comments.
  • Some CSS fixes for h2 and h3 rendering in .blogflash style (Trac default has negative margin for these).
  • New option max_size added to [[BlogList]] macro that truncates post body at the specified number of characters with link to 'Read more'.
  • Updated RSS feed to use correct logo absolute path reference following changeset:6384.
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • fullblogplugin/0.11/tracfullblog/htdocs/css/fullblog.css

    r2956 r3008  
    116116} 
    117117 
     118div.blogflash h2, div.blogflash h3 { 
     119    margin-left: 0; 
     120    font-size: 1.2em; 
     121}  
     122 
     123div.blogflash h3 { 
     124    margin-left: 0; 
     125    font-size: 1.1em; 
     126} 
     127 
    118128div.blogflash .blog-title { 
    119129    font-size: 1.35em; 
  • fullblogplugin/0.11/tracfullblog/macros.py

    r2928 r3008  
    2727    [[BlogList]] 
    2828    }}} 
     29     
     30    Available named arguments: 
     31     * `recent=` - max. number of posts 
     32     * `category=` - a category 
     33     * `author=` - an author 
     34     * `period=` - time period of the format YYYY/MM 
     35     * `heading=` - a heading for the list 
     36     * `format=` - type of display (see below for details) 
     37     * `max_size=` - max. number of characters to render for each post 
    2938 
    30     Example showing all available named arguments: 
     39    Example showing some available named arguments: 
    3140    {{{ 
    32     [[BlogList(recent=5, category=trac, period=2007/12, author=osimons, format=float, heading=Some Trac Posts)]] 
     41    [[BlogList(recent=5, max_size=250, period=2007/12, author=osimons, format=float, heading=Some Trac Posts)]] 
    3342    }}} 
    3443     
    3544    The arguments for criteria are 'AND'-based, so the above example will render 
    36     at most 5 posts by 'osimons' in December 2007 with category 'trac'.  
     45    at most 5 posts by 'osimons' in December 2007.  
    3746     
    3847    There is no heading unless specified. 
     
    4049    Without restriction on recent number of posts, it will use the number currently 
    4150    active in the Blog module as default for 'float' and 'full' rendering, but for rendering 
    42     of 'inline' list it will render all found as default unless restricted. 
     51    of 'inline' list it will render all found as default unless restricted. Additionally for 
     52    'float' and 'full' it will truncate content if it is larger than a max_size (if set). 
    4353     
    4454    The `format=` keyword argument supports rendering these formats: 
     
    6272        format = args_dict.get('format', 'inline').lower() 
    6373        heading = args_dict.get('heading', '') 
     74        max_size = int(args_dict.get('max_size', 0)) 
    6475 
    6576        # Get blog posts 
     
    95106        elif format == 'full': 
    96107            return self._render_full_format(formatter, post_list, 
    97                                             post_instances, heading
     108                                            post_instances, heading, max_size
    98109 
    99110        elif format == 'float': 
    100111            # Essentially a 'full' list - just wrapped inside a new div 
    101112            return tag.div(self._render_full_format(formatter, post_list, 
    102                                             post_instances, heading), 
     113                                    post_instances, heading, max_size), 
    103114                            class_="blogflash") 
    104115 
     
    106117            raise TracError("Invalid 'format' argument used for macro %s." % name) 
    107118 
    108     def _render_full_format(self, formatter, post_list, post_instances, heading): 
     119    def _render_full_format(self, formatter, post_list, post_instances, heading, 
     120                                    max_size): 
    109121        """ Renters full blog posts. """ 
    110122        out = tag.div(class_="blog") 
     
    114126                    'list_mode': True, 
    115127                    'execute_blog_macro': True} 
     128            if max_size: 
     129                data['blog_max_size'] = max_size 
    116130            out.append(Chrome(self.env).render_template(formatter.req, 
    117131                'fullblog_macro_post.html', data=data, fragment=True)) 
  • fullblogplugin/0.11/tracfullblog/templates/fullblog_macro_post.html

    r2956 r3008  
    66        py:strip="not list_mode">${post.title}</a> 
    77    </h1> 
    8     <div id="blog-body"> 
    9       ${wiki_to_html(context(post.resource), post.body)} 
     8    <div id="blog-body" 
     9        py:with="do_shorten = defined('blog_max_size') and len(post.body) > blog_max_size"> 
     10      ${wiki_to_html(context(post.resource), do_shorten and post.body[:blog_max_size] + ' ... ' \ 
     11          or post.body)} 
     12        <p py:if="do_shorten"><a href="${href.blog(post.name)}">(Read more)</a></p> 
    1013    </div> 
    1114    <ul class="metainfo"> 
  • fullblogplugin/0.11/tracfullblog/templates/fullblog.rss

    r2956 r3008  
    1010    <language>en-US</language> 
    1111    <generator>Trac ${trac.version}</generator> 
    12     <image py:if="chrome.logo.src"> 
     12    <image py:if="chrome.logo.src_abs"> 
    1313      <title>${project.name}</title> 
    14       <url>$chrome.logo.src</url> 
     14      <url>$chrome.logo.src_abs</url> 
    1515      <link>${abs_href.blog()}</link> 
    1616    </image> 
  • fullblogplugin/0.11/tracfullblog/web_ui.py

    r2956 r3008  
    421421            elif field == 'description': 
    422422                return format_to_oneliner(self.env, 
    423                             context(resource=bp_resource), bc.comment) 
     423                            context(resource=bp_resource), bc.comment, 
     424                            shorten=True) 
    424425        else: # A blog post 
    425426            if field == 'url': 
     
    431432                return format_to_oneliner(self.env, 
    432433                        context(resource=bp_resource), 
    433                         bp.version==1 and bp.body or bp.version_comment) 
     434                        bp.version==1 and bp.body or bp.version_comment, 
     435                        shorten=True) 
    434436 
    435437    # ITemplateProvider methods