Changeset 99

Show
Ignore:
Timestamp:
04/06/08 13:59:47 (8 months ago)
Author:
pragma
Message:
  • Fixed display for message synopsis and forum synopsis
  • Forum latest-post synopsis still (mysteriously) broken
  • Added synopsis_length to tracforums ini settings
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/tracforums/model.py

    r98 r99  
    171171        self.req.session[name] = value 
    172172        
    173     def wikiToOneLiner(self,text,shorten=True,absurls=False): 
     173    def wikiToOneLiner(self,text,shorten=False,absurls=False): 
    174174        return wiki_to_oneliner(text,self.env,self.env.get_db_cnx(),shorten,absurls) 
    175175                      
     
    220220        return self.env.config.get("tracforums","profilepath",'/') 
    221221         
     222    def getSynopsisLength(self): 
     223        return int(self.env.config.get("tracforums","synopsis_length",'100'))         
     224         
    222225    def getAvatarMetrics(self): 
    223226        return { 
    224             "number": self.env.config.get("tracforums","max_avatars",10), 
    225             "size": self.env.config.get("tracforums","max_avatar_bytes",15000), 
    226             "width": self.env.config.get("tracforums","max_avatar_width",100), 
    227             "height": self.env.config.get("tracforums","max_avatar_height",100)         
     227            "number": int(self.env.config.get("tracforums","max_avatars",10)), 
     228            "size": int(self.env.config.get("tracforums","max_avatar_bytes",15000)), 
     229            "width": int(self.env.config.get("tracforums","max_avatar_width",100)), 
     230            "height": int(self.env.config.get("tracforums","max_avatar_height",100))         
    228231        } 
    229232         
  • trunk/tracforums/models/forum.py

    r98 r99  
    6464        self.moderatorsList = ", ".join(map(lambda x: x.username,self.moderators)) 
    6565        self.userIsModerator = self.formatContext.getAuthname() in self.moderators 
     66         
     67        synopsisLength = self.formatContext.getSynopsisLength() 
     68        self.synopsis = self.description 
     69        if self.synopsis and len(self.synopsis) > synopsisLength: 
     70            self.synopsis = self.synopsis[:synopsisLength] + "..." 
     71        self.synopsishtml = self.formatContext.wikiToOneLiner(self.synopsis) 
    6672                 
    6773    def _canView(self): 
  • trunk/tracforums/models/main.py

    r98 r99  
    5454        for forum in ForumModelWithRecentPost(self.db,self).getMany({"projectid": self.getProjectId(),"categoryid":0}): 
    5555            if forum.canView: plainForums.append(forum) 
    56          
    57          
     56                 
    5857        return ("main/index.cs",{ 
    5958            "returnto": self.req.abs_href.forums() + "main/index", 
     
    6463            "canWatch": self.isForumUser(), 
    6564            "watching": ProjectWatchModelWithProfile(self.db,self).getMany({"projectid": self.getProjectId()}), 
    66         })                       
     65        })    
    6766                 
    6867    def doManage(self): 
  • trunk/tracforums/models/message.py

    r98 r99  
    2222            "avatarid":   ORMColumn(type="int"), 
    2323            "modifiedby": ORMColumn(type="str"), 
    24             "modcount":   ORMColumn(type="int", default=-1), 
     24            "modcount":   ORMColumn(type="int"), 
    2525             
    2626            # synthetic columns 
     
    4747    def format(self): 
    4848        #TODO: replace with a smarter, wiki 'null formatter' 
    49         self.synopsis = self.body 
    50         if self.synopsis and len(self.synopsis) > 100: self.synopsis = self.synopsis[:97] + "..." 
     49        self.synopsis = self.body        
     50        synopsisLength = self.formatContext.getSynopsisLength() 
     51        if self.synopsis and len(self.synopsis) > synopsisLength: 
     52            self.synopsis = self.synopsis[:synopsisLength] + "..." 
    5153        self.synopsishtml = self.formatContext.wikiToOneLiner(self.synopsis) 
    5254        if self.modcount == None: 
     
    7274            # set the author as an editor 
    7375            self.modifiedby = profileModel.username; 
    74             self.modcount = self.modcount + 1 
    7576        self.modified = self.formatContext.epochNow() 
    7677                 
     
    161162                        if x.id == message.avatarid: 
    162163                            message.avatar = x 
    163                         print "X: ",message.avatarid,x,"\n" 
    164                              
     164                            message.avatarid = x.id                             
    165165                    preview = True 
    166166                elif action == "save": 
     167                    message.modcount = message.modcount + 1 
    167168                    authorProfile.save() 
    168169                    message.save() 
  • trunk/tracforums/models/topic.py

    r98 r99  
    245245        if args.get("viewid",0) != 0: 
    246246            topic.load({"topicid": args["viewid"]}) 
    247             topic.leadmessage = MessageModel(self.db,self).load({"id":topic.leadmessageid}
     247            topic.leadmessage = MessageModel(self.db,self).load({"id":topic.leadmessageid},debug=True
    248248            messageAuthor = topic.leadmessage.author 
    249249        else: 
  • trunk/tracforums/orm.py

    r97 r99  
    130130    @staticmethod 
    131131    def wiki(formatContext,value): 
    132         return wiki_to_html(value, formatContext.env, formatContext.req
     132        return formatContext.wikiToHTML(value
    133133         
    134134    @staticmethod 
    135135    def oneliner(formatContext,value): 
    136         return wiki_to_oneliner(value,formatContext.env,shorten=False,absurls=False) 
     136        return formatContext.wikiToOneLiner(value,shorten=False,absurls=False) 
    137137         
    138138    @staticmethod 
  • trunk/tracforums/templates/tracforums/forum/_defs.cs

    r85 r99  
    2121        </a> 
    2222        <div class='description'> 
    23             <?cs var:forum.descriptionhtml ?> 
     23            <?cs var:forum.synopsishtml ?> 
    2424            <?cs if:len(forum.moderators) > 0?> 
    2525                <div class="moderators"> 
     
    3939    </td> 
    4040    <td class="forum-listing-lastpost"> 
     41    [<?cs var:forum.recentpostid?>] 
    4142        <?cs if: forum.recentPostId != 0?> 
    4243            <?cs call:displayMessagePreview(forum.recentpost)?>              
  • trunk/tracforums/templates/tracforums/forum/edit.cs

    r98 r99  
    5252        <input type="hidden" id="returnto" name="returnto" value="<?cs var:forums.returnto?>"> 
    5353        <input type="hidden" id="action" name="action" value="preview"> 
    54          
    55         <fieldset> 
    56             <legend>General</legend> 
    57              
     54       
     55        <fieldset id="general"> 
     56            <legend>General <a href="#edit"></a></legend> 
     57         
     58         
    5859            <label for="name">Forum Name:</label> 
    5960            <input type="text" name="name" id="name" value="<?cs var:forums.forum.name?>"> 
    6061             
    61             <br
     62            <br/
    6263            <label for="hidden">Hidden:</label> 
    6364            <select name="hidden" id="hidden"> 
     
    103104        <fieldset id="edit"> 
    104105            <legend>Forum Description</legend> 
    105             <?cs call:displayWikiField(80,"description",forums.forum.description,"forum_description_rows",forum.forum_description_rows)?> 
     106            <?cs var:forums.forum_description_rows?> 
     107            <?cs call:displayWikiField(80,"description",forums.forum.description,"forum_description_rows",forums.forum_description_rows)?> 
    106108        </fieldset> 
    107109        <br> 
  • trunk/tracforums/templates/tracforums/message/_defs.cs

    r98 r99  
    33<?cs def:displayMessagePreview(message)?> 
    44    <div class="description">    
    5         <?cs var:message.synopsis?> 
     5        <?cs var:message.synopsishtml?> 
    66        <br> 
    77        <?cs call:displayMiniPortrait(message.profile,message.avatar)?> 
     
    6060            <legend>Message Properties</legend> 
    6161            <div class="field"> 
    62                 <label for="avatarid">Default Avatar:</label> 
     62                <label for="avatarid">Avatar:</label> 
    6363                <select id="avatarid" name="avatarid" onchange=" 
    6464                    value = this.options[this.selectedIndex].value; 
  • trunk/tracforums/templates/tracforums/profile/_defs.cs

    r98 r99  
    2323    <div class="portrait">   
    2424        <a href="<?cs var:trac.href.forums ?>/profile/view/<?cs var:profile.username?>"> 
    25             <?cs if: !avatar && profile.defaultavatarid != 0 && profile.defaultAvatar.id != 0 ?> 
     25            <?cs if: len(avatar) == 0 && profile.defaultavatarid != 0 && profile.defaultAvatar.id != 0 ?> 
    2626                <?cs call:displayAvatar(profile,profile.defaultAvatar,"portrait")?> 
    2727            <?cs /if?> 
    28             <?cs if: avatar?> 
     28            <?cs if: len(avatar) != 0?> 
    2929                <?cs call:displayAvatar(profile,avatar,"portrait")?> 
    3030            <?cs /if?> 
  • trunk/tracforums/templates/tracforums/topic/_defs.cs

    r97 r99  
    2929    <td class="forum-listing-lastpost"> 
    3030        <?cs if: topic.recentPostId != 0 && topic.recentPostId != topic.leadmessageid?> 
    31             <?cs call:displayMessagePreview(topic.leadmessage)?>               
     31            <?cs call:displayMessagePreview(topic.recentpost)?>                
    3232        <?cs /if?> 
    3333    </td> 
  • trunk/tracforums/templates/tracforums/topic/view.cs

    r97 r99  
    2121    </div> 
    2222    <br/>    
    23     <div class='description'>           
     23    <div class='description'> 
    2424        <div class="moderators"> 
    2525            <?cs if:len(forums.forum.moderators) > 0?>