Changeset 1712

Show
Ignore:
Timestamp:
07/24/08 13:52:28 (11 months ago)
Author:
JensDiemer
Message:

blog plugin:

  • add a tag cloud ;)
  • display only tag feeds witched used in a displayed entry
  • tag ordering via django meta class
  • update the templates/CSS
Location:
trunk/pylucid
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • trunk/pylucid/media/PyLucid/internal_page/blog/display_blog.css

    r1705 r1712  
     1/* -------------------------------------------------------------------------- */ 
    12.blog fieldset { 
     3  background-color: #FFF; 
    24  padding: 0.2em 0em 0.5em 1em; 
    35  margin: 0px; 
     
    1618/* -------------------------------------------------------------------------- */ 
    1719.blog fieldset.entry { 
    18   background-color: #fff; 
    1920  margin: 1em 0 1em 0; 
    2021  padding: 0; 
     
    2930  border: 1px solid #888; 
    3031} 
    31 .content, .comment_link { 
     32.blog .content, .blog .comment_link { 
    3233  padding: 0.1em 0.5em 0.1em 0.5em; 
    3334} 
     
    4344} 
    4445/* -------------------------------------------------------------------------- */ 
    45 .dateinfo, .admin_links { 
    46   font-size: 0.9em; 
     46.blog .headline_info, .blog .date_info, .blog .admin_links { 
     47  font-size: 0.8em; 
     48  color: #666; 
    4749  padding: 0px; 
    4850  margin: 0px; 
     51} 
     52.blog .date_info, .blog .admin_links { 
    4953  line-height: 0px; 
    5054  text-align: right; 
    5155} 
    52 .admin_links { 
     56.blog .admin_links { 
    5357  float:right; 
    5458} 
    55 .admin_links a { 
     59.blog .admin_links a { 
    5660  color: #fff; 
    5761  padding: 2px; 
     
    6367  background-color: #eee; 
    6468} 
    65 .dateinfo { 
    66   color: #666; 
    67 } 
    6869.blog .taglist { 
    6970  text-decoration: none; 
     
    7475} 
    7576/* -------------------------------------------------------------------------- */ 
    76 .comment_link { 
     77.blog .comment_link { 
    7778  display: block; 
    7879  border: 0px; 
     
    8182} 
    8283/* -------------------------------------------------------------------------- */ 
    83 .comments li { 
     84.blog .comments li { 
    8485  list-style: none; 
    8586} 
    86 .comments ul { 
     87.blog .comments ul { 
    8788  padding-left: 0px; 
    8889} 
    89 .comment { 
     90.blog .comment { 
    9091  border: 0px; 
    91   padding: 0px; 
     92  padding: 0.1em 1em 0.1em 1em; 
    9293  margin: 0px; 
    9394  margin-top: 1em; 
    9495} 
    95 .user_comment * { 
    96   background-color: #e0e0e0; 
     96.blog .comment legend { 
     97  padding: 1px; 
     98  border: 1px solid #ccc; 
     99  margin-left: 2em; 
     100  padding: 0.1em 1em 0.1em 1em; 
    97101} 
    98 .anonymous_comment * { 
    99   background-color: #f5f5f5; 
    100 } 
    101 .comment legend { 
    102   padding: 1px; 
    103   border: 0px; 
    104   margin-left: 2em; 
    105   padding: 0em 2em 0em 2em; 
    106 } 
    107 .comment pre { 
     102.blog .comment pre { 
    108103  font-size: 1.2em; 
    109104  border: 0px; 
     
    111106  margin: 0px; 
    112107} 
    113 .comment .admin_info_line { 
     108.blog .admin_info_line { 
    114109  color:red; 
    115110  line-height: 0px; 
     111} 
     112.blog .user_comment, .blog .user_comment legend { 
     113  background-color: #e0e0e0; 
     114} 
     115.blog .anonymous_comment, .blog .anonymous_comment legend { 
     116  background-color: #f5f5f5; 
    116117} 
    117118/* -------------------------------------------------------------------------- */ 
     
    124125} 
    125126#input_fields .field_help_text { 
    126     font-size:0.9em; 
     127    font-size:0.8em; 
    127128    display: block; 
    128     padding-left: 9em; 
     129    padding-left: 11em; 
     130    color: #888; 
    129131} 
    130132#input_fields label { 
     
    145147    border: 1px solid red; 
    146148} 
     149.blog input, .blog textarea { 
     150  border: 1px solid #ccc; 
     151} 
     152.blog input:hover, .blog textarea:hover { 
     153  border-color: #333; 
     154} 
    147155/* -------------------------------------------------------------------------- */ 
    148 .feeds ul, .feeds * { 
     156.blog .feeds ul, .blog .tag_cloud ul { 
    149157  list-style-type:none; 
    150158  padding: 0px; 
    151159  margin: 0px; 
    152160} 
    153 .feeds, .feeds li { 
    154   display:inline; 
     161.blog .feeds li, .blog .tag_cloud li { 
     162  display: inline; 
    155163} 
    156164/* -------------------------------------------------------------------------- */ 
  • trunk/pylucid/media/PyLucid/internal_page/blog/display_blog.html

    r1709 r1712  
    44{% if not entries %}no blog entry exists{% endif %} 
    55{% for entry in entries %} 
    6     <fieldset class="entry"><legend class="headline"><a href="{{ entry.detail_url }}">{{ entry.headline }}</a></legend> 
     6    <fieldset class="entry"> 
     7        <legend class="headline"> 
     8             <a href="{{ entry.detail_url }}">{{ entry.headline }}<br /> 
     9             <small class="headline_info">{% blocktrans with entry.createtime|timesince as time %}Before {{ time }} published by{% endblocktrans %} {{ entry.createby }}.</small> 
     10             </a> 
     11        </legend> 
    712        {% if not entry.is_public %} 
    813            <p class="admin_info_line">not public</p> 
     
    2025        <div class="content">{{ entry.html }}</div> 
    2126 
    22         <small><p class="dateinfo"> 
    23             created {{ entry.createtime }} by {{ entry.createby }} 
    24             {% if entry.lastupdateby %}(Last update {{ entry.lastupdatetime }} by {{ entry.lastupdateby }}){% endif %} 
     27        <small><p class="date_info"> 
     28            {% if entry.lastupdateby %}(Last update: {{ entry.lastupdatetime|date:"D d M Y H:i" }} by {{ entry.lastupdateby }}.){% endif %} 
    2529        </p></small> 
    2630 
     
    4044            <ul> 
    4145            {% for comment in entry.all_comments %} 
    42                 <li class="{% if comment.createby %}user{% else %}anonymous{% endif %}_comment"> 
    43                   <fieldset class="comment"> 
    44                       <legend> 
    45                       {% if comment.homepage %}<a href="{{ comment.homepage }}">{% endif %} 
    46                         {{ comment.person_name }}{% if comment.homepage %}</a>{% endif %}: 
    47                       </legend> 
    48                       {% if not comment.is_public %} 
    49                           <p class="admin_info_line">not public</p> 
    50                       {% endif %} 
     46                <li> 
     47                  <fieldset class="comment {% if comment.createby %}user{% else %}anonymous{% endif %}_comment"> 
     48                    <legend class="headline"> 
     49                      {% if comment.homepage %}<a href="{{ comment.homepage }}" title="{{ comment.homepage }}">{% endif %} 
     50                        {{ comment.person_name }} 
     51                        {% if comment.homepage %}</a>{% endif %}<br /> 
     52                        <small class="headline_info"> 
     53                          {% blocktrans with comment.createtime|timesince as time %}Before {{ time }}{% endblocktrans %} 
     54                          IP: {{ comment.ip_address }} 
     55                          {% if comment.lastupdateby %}<br />(Last update {{ comment.lastupdatetime }} by {{ comment.lastupdateby }}){% endif %} 
     56                        </small> 
     57                    </legend> 
     58 
     59                      {% if not comment.is_public %}<p class="admin_info_line">not public</p>{% endif %} 
    5160 
    5261                      <div class="admin_links"> 
     
    5665 
    5766                      {{ comment.html_content }} 
    58  
    59                       <small><p class="dateinfo"> 
    60                         created {{ comment.createtime }} by {% if comment.createby %}{{ comment.createby }}{% else %}{{ comment.ip_address }}{% endif %} 
    61                         {% if comment.lastupdateby %}(Last update {{ comment.lastupdatetime }} by {{ comment.lastupdateby }}){% endif %} 
    62                       </p></small> 
    6367                  </fieldset> 
    6468                </li> 
     
    96100{% endfor %} 
    97101 
     102<fieldset class="tag_cloud"><legend>{% trans 'tag cloud' %}</legend> 
     103    <ul> 
     104    {% for tag in tag_cloud %} 
     105        <li><a href="{{ tag.url }}" style="font-size:{{ tag.font_size }}em;">{{ tag.name }}</a></li> 
     106    {% endfor %} 
     107    </ul> 
     108</fieldset> 
     109 
     110 
    98111<fieldset class="feeds"><legend>{% trans 'available syndication feeds' %}</legend> 
    99112    <ul>{% trans 'normal feeds:' %} 
  • trunk/pylucid/PyLucid/plugins_internal/blog/blog.py

    r1711 r1712  
    108108        As a list of entries and as a detail view (see internal page). 
    109109        """ 
    110         used_tags = [] 
     110        used_tags = set() 
    111111        for entry in entries: 
    112112            # add tag_info 
    113113            tags = [] 
    114114            for tag in entry.tags.all(): 
    115                 used_tags.append(tag) # Used in self._get_tag_feeds_info() 
     115                used_tags.add(tag) # Used in self._get_tag_feeds_info() 
    116116                tags.append({ 
    117117                    "name": tag.name, 
     
    717717        Build the tag cloud context. 
    718718        """ 
    719  
    720         return [] 
     719        tags = BlogTag.objects.all() 
     720 
     721        frequency = set() 
     722        # get the counter information 
     723        for tag in tags: 
     724            count = tag.blogentry_set.count() 
     725            tag.count = count 
     726            #self.page_msg(tag, count) 
     727            frequency.add(count) 
     728 
     729        min_frequency = float(min(frequency)) 
     730        max_frequency = float(max(frequency)) 
     731        diff_frequency = float(max_frequency - min_frequency) 
     732 
     733        max_font_size = self.preferences.get("max_cloud_size", 2.0) 
     734        min_font_size = self.preferences.get("min_cloud_size", 0.7) 
     735 
     736        # Calculate and add the font size 
     737        for tag in tags: 
     738            count = float(tag.count) 
     739            tag.font_size = ( 
     740                ( 
     741                    (max_font_size-min_font_size) * (count - min_frequency) 
     742                ) / diff_frequency 
     743            ) + min_font_size 
     744 
     745            tag.url = self.URLs.methodLink("tag", tag.slug) 
     746            #self.page_msg(tag, count, tag.font_size) 
     747 
     748        return tags 
    721749 
    722750    def select_feed_format(self, raw_feed_name=None): 
  • trunk/pylucid/PyLucid/plugins_internal/blog/blog_cfg.py

    r1705 r1712  
    8282        help_text=_( 
    8383            "The maximal numbers of tag feeds, displayed together." 
     84        ), 
     85    ) 
     86 
     87    max_cloud_size = forms.FloatField( 
     88        initial = 2.0, 
     89        min_value = 1, 
     90        help_text=_( 
     91            "max font size in the tag cloud (CSS 'em' unit)" 
     92        ), 
     93    ) 
     94    min_cloud_size = forms.FloatField( 
     95        initial = 0.7, 
     96        min_value = 0.1, 
     97        help_text=_( 
     98            "min font size in the tag cloud (CSS 'em' unit)" 
    8499        ), 
    85100    ) 
  • trunk/pylucid/PyLucid/plugins_internal/blog/models.py

    r1709 r1712  
    8282    class Meta: 
    8383        app_label = 'PyLucidPlugins' 
     84        ordering = ('createtime', 'lastupdatetime') 
    8485 
    8586#______________________________________________________________________________ 
     
    112113class BlogTag(models.Model): 
    113114    """ 
    114     FIXME: How can we add ordering? 
     115    A blog entry tag 
    115116    """ 
    116117    objects = BlogTagManager() 
     
    129130    class Meta: 
    130131        app_label = 'PyLucidPlugins' 
    131  
     132        ordering = ('name',) 
    132133 
    133134#______________________________________________________________________________