Changeset 2928

Show
Ignore:
Timestamp:
12/20/07 19:27:21 (1 year ago)
Author:
osimons
Message:

FullBlogPlugin: Adding a wiki macro to display posts in various forms - [[BlogList]]:

  • An inline list (like in the blog archive) (format=inline).
  • Full-text posts (as in all other views inside the blog module) (format=full).
  • A 'blogflash' as a floating box that renders full-text posts in scaled down format, typically for project or section front pages (format=float).

Read the macro documentation for details on the various options.

(Also includes various refactoring to make it easier to read and maintain by reusing as much as practical in the new macro. Lastly there are a few minor bug fixes.)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • fullblogplugin/0.11/setup.py

    r2922 r2928  
    2626            'tracfullblog.core = tracfullblog.core', 
    2727            'tracfullblog.db = tracfullblog.db', 
     28            'tracfullblog.macros = tracfullblog.macros', 
    2829            'tracfullblog.tags = tracfullblog.tags[tags]', 
    2930            'tracfullblog.web_ui = tracfullblog.web_ui']}, 
  • fullblogplugin/0.11/tracfullblog/admin.py

    r2919 r2928  
    5353         
    5454        blog_admin['bloginfotext'] = blog_core.get_bloginfotext() 
    55         blog_admin['numpostsfront'] = self.env.config.get
    56                         'fullblog', 'num_items_front') 
     55        blog_admin['numpostsfront'] = self.env.config.getint
     56                                            'fullblog', 'num_items_front') 
    5757         
    5858        return ('fullblog_admin.html', {'blog_admin': blog_admin}) 
  • fullblogplugin/0.11/tracfullblog/htdocs/css/fullblog.css

    r2791 r2928  
    2020    font-size: smaller; 
    2121    text-align: right; 
     22} 
     23 
     24.metainfo span { 
     25    padding: 0; 
     26    margin: 0; 
    2227} 
    2328 
     
    4853} 
    4954 
    50 #blog-list-title { 
     55.blog-list-title { 
    5156    text-align: center; 
    5257    color: gray; 
     58    padding-bottom: 0.5em; 
    5359} 
    5460     
     
    8187    background-image: url(../blog.png); 
    8288} 
     89 
     90/* 
     91** Style used for a blog macros 
     92*/  
     93 
     94div.blogflash { 
     95    background: #F3F3F3 none repeat scroll 0%; 
     96    border: 2px solid gray; 
     97    float: right; 
     98    font-size: 0.8em; 
     99    margin: 0em; 
     100    padding: 0.5em 1em; 
     101    width: 400px; 
     102} 
     103 
     104div.blogflash .blog-title { 
     105    font-size: 1.35em; 
     106    margin-left: inherit; 
     107} 
  • fullblogplugin/0.11/tracfullblog/templates/fullblog_archive.html

    r2919 r2928  
    1616 
    1717      <xi:include href="fullblog_sidebar.html" /> 
     18      <xi:include href="fullblog_macro_monthlist.html" /> 
    1819 
    1920      <div id="main"> 
    2021        <h1>Blog Archive</h1> 
    21         <p py:if="not blog_archive[0]">No posts.</p> 
     22        <p py:if="not blog_archive[0]">No blog posts.</p> 
    2223        <py:if test="blog_archive[0]"> 
    23           <div class="monthlist" py:for="period, posts in blog_archive"> 
    24               <h3>${to_unicode("%s %d" % (blog_month_names[period.month-1], period.year))}</h3> 
    25               <ul> 
    26                 <li py:for="name, version, time, author, title, body, categories in posts"> 
    27                   <a href="${req.href.blog(name)}">${title}</a> 
    28                   <span class="metainfo"> 
    29                     &nbsp;-- Posted on ${format_datetime(time, '%Y-%m-%d %H:%M')} : author 
    30                     <a href="${req.href.blog('author', author)}">${author}</a> 
    31                     <py:if test="categories"> 
    32                       : categories 
    33                       <span py:for="cat in categories"> 
    34                         <a href="${req.href.blog('category', cat)}">${cat}</a> 
    35                       </span> 
    36                     </py:if> 
    37                   </span> 
    38                 </li> 
    39               </ul> 
     24          <div py:for="period, posts in blog_archive" py:strip="True"> 
     25            ${render_monthlist(to_unicode("%s %d" % (blog_month_names[period.month-1], period.year)), posts)} 
    4026          </div> 
    4127        </py:if> 
  • fullblogplugin/0.11/tracfullblog/templates/fullblog_edit.html

    r2919 r2928  
    1313  <body> 
    1414 
    15     <xi:include href="fullblog_macros.html" /> 
     15    <xi:include href="fullblog_macro_post.html" /> 
    1616 
    1717    <div id="content" class="blog wiki"> 
  • fullblogplugin/0.11/tracfullblog/templates/fullblog_macro_post.html

    r2779 r2928  
    1 <div xmlns="http://www.w3.org/1999/xhtml" 
    2      xmlns:py="http://genshi.edgewall.org/" py:strip="True"> 
     1<div xmlns:py="http://genshi.edgewall.org/" py:strip="True"> 
    32 
    43  <!--! Macro to render a post --> 
    54  <div py:def="render_blog_post(post, list_mode=False)"> 
    6     <h1 id="blog-title"><a href="${req.href.blog(post.name)}" 
     5    <h1 class="blog-title"><a href="${req.href.blog(post.name)}" 
    76        py:strip="not list_mode">${post.title}</a></h1> 
    87    <div id="blog-body"> 
     
    109    </div> 
    1110    <p class="metainfo">Posted on: ${format_datetime(post.publish_time, '%Y-%m-%d %H:%M')} 
    12       -- Last updated: ${format_datetime(post.version_time, '%Y-%m-%d %H:%M')}<br/> 
    13       Author: <a href="${req.href.blog('author', post.author)}">${post.author}</a><br /> 
    14       Categories: <span py:for="cat in post.category_list" py:if="post.category_list"> 
    15             <a href="${req.href.blog('category', cat)}">${cat}</a> 
    16             </span
    17             <span py:if="not post.category_list"> (none)</span
     11      -- Last updated: ${format_datetime(post.version_time, '%Y-%m-%d %H:%M')} <br/> 
     12      Author: <a href="${req.href.blog('author', post.author)}">${post.author}</a> <br /> 
     13      Categories: <py:for each="cat in post.category_list"> 
     14                    <a href="${req.href.blog('category', cat)}">${cat}</a> 
     15                  </py:for
     16            <py:if test="not post.category_list"> (none)</py:if
    1817      <py:if test="list_mode"> 
    1918        <br /> 
     
    2423  </div> 
    2524 
     25  <!--! Directly execute the macro on import if 'execute_blog_macro' is set. 
     26        For this not to throw errors it presumes variables to be called 
     27        already exists in the data dictionary. --> 
     28  <py:if test="defined('execute_blog_macro') and execute_blog_macro"> 
     29    ${render_blog_post(post, list_mode)} 
     30  </py:if> 
     31 
    2632</div> 
  • fullblogplugin/0.11/tracfullblog/templates/fullblog_view.html

    r2919 r2928  
    1313  <body> 
    1414 
    15     <xi:include href="fullblog_macros.html" /> 
     15    <xi:include href="fullblog_macro_post.html" /> 
    1616 
    1717    <div id="content" class="blog wiki"> 
     
    122122 
    123123        <py:if test="defined('blog_post_list')"> 
    124           <div id="blog-list-title">${blog_list_title}</div> 
     124          <div class="blog-list-title">${blog_list_title}</div> 
    125125          <p py:if="not len(blog_post_list)"> 
    126126            No blog posts available. 
  • fullblogplugin/0.11/tracfullblog/web_ui.py

    r2919 r2928  
    1111# Imports from standard lib 
    1212import datetime 
    13 import calendar 
    1413import re 
    1514from pkg_resources import resource_filename 
     
    3635from model import * 
    3736from core import FullBlogCore 
     37from util import map_month_names, parse_period 
    3838 
    3939__all__ = ['FullBlogModule'] 
    4040 
    41 # Utility functions 
    42  
    43 def add_months(thedate, months): 
    44     """ Add <months> months to <thedate>. """ 
    45     y, m, d = thedate.timetuple()[:3] 
    46     y2, m2 = divmod(m + months - 1, 12) 
    47     return datetime.datetime(y + y2, m2 + 1, d, tzinfo=thedate.tzinfo) 
    48  
    49 def map_month_names(month_list): 
    50     """ Returns a list containing the 12 month names. """ 
    51     if len(month_list) == 12: 
    52         # A list of 12 names is passed in, use that 
    53         return month_list 
    54     else: 
    55         # Use list from default locale setting 
    56         return [calendar.month_name[i+1] for i in range(12)] 
    57  
    58 # UI class 
    5941 
    6042class FullBlogModule(Component): 
     
    10890         
    10991        # Parse out the path and actions from args 
    110         path_items = req.args.get('blog_path').split('/') 
     92        path_items = req.args.get('blog_path', '').split('/') 
    11193        path_items = [item for item in path_items if item] # clean out empties 
    11294        action = req.args.get('action', 'view').lower() 
     
    245227            # 2007/10 or category/something or author/theuser 
    246228            title = category = author = '' 
    247             try: 
    248                 # Test for year and month values 
    249                 year = int(path_items[0]) 
    250                 month = int(path_items[1]) 
    251                 from_dt = datetime.datetime(year, month, 1, tzinfo=utc) 
    252                 to_dt = add_months(from_dt, months=1) 
     229            from_dt, to_dt = parse_period(path_items) 
     230            if from_dt: 
    253231                title = "Posts for the month of %s %d" % ( 
    254232                        blog_month_names[from_dt.month -1], from_dt.year) 
    255             except ValueError: 
    256                 # Not integers, ignore 
    257                 to_dt = from_dt = None 
     233 
    258234            category = (path_items[0].lower() == 'category' 
    259235                        and path_items[1]) or ''