Show
Ignore:
Timestamp:
07/24/08 13:52:28 (20 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
Files:
1 modified

Legend:

Unmodified
Added
Removed
  • 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):