Changeset 2848

Show
Ignore:
Timestamp:
12/04/07 08:18:29 (1 year ago)
Author:
gotoh
Message:

Applied a patch to allow inline summary dispaying. Closes #2265.
Thanks to laas<at>eenet.ee.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • ticketboxmacro/0.10/TicketBox.py

    r2768 r2848  
    3939           "width": "25%", 
    4040           } 
     41inline_styles = { "background": "#f7f7f0", } 
    4142 
    4243args_pat = [r"#?(?P<tktnum>\d+)", 
     
    4445            r"\[report:(?P<rptnum2>\d+)(?P<dv>\?.*)?\]", 
    4546            r"(?P<width>\d+(pt|px|%))", 
     47            r"(?P<summary>summary)", 
     48            r"(?P<inline>inline)", 
    4649            r"(?P<title1>'.*')", 
    4750            r'(?P<title2>".*")'] 
     
    6265        txt = '' 
    6366    items = [] 
     67    long_items = {} 
     68    show_summary = False 
     69    inline = False 
    6470    title = "Tickets" 
    6571    args_re = re.compile("^(?:" + string.join(args_pat, "|") + ")$") 
     
    7783        elif match.group('tktnum'): 
    7884            items.append(int(match.group('tktnum'))) 
     85        elif match.group('summary'): 
     86            show_summary = True 
     87        elif match.group('inline'): 
     88            inline = True 
    7989        elif match.group('rptnum') or match.group('rptnum2'): 
    8090            num = match.group('rptnum') or match.group('rptnum2') 
     
    104114                    descriptions = [desc[0] for desc in curs.description] 
    105115                    idx = descriptions.index('ticket') 
     116                    summ = descriptions.index('summary') 
    106117                    for row in rows: 
    107118                        items.append(row[idx]) 
     119                        long_items[row[idx]] = row[summ] 
    108120            finally: 
    109121                if not hasattr(env, 'get_cnx_pool'): 
     
    117129        # for trac 0.9 or later 
    118130        from trac.wiki.formatter import wiki_to_oneliner 
    119         html = wiki_to_oneliner(string.join(["#%d" % c for c in items], ", "), 
    120                                env, env.get_db_cnx()) 
    121131    except: 
    122132        # for trac 0.8.x 
    123133        from trac.WikiFormatter import wiki_to_oneliner 
     134 
     135    if show_summary: 
     136        html = string.join([wiki_to_oneliner("%s (#%d)" % (v,k), 
     137                                             env, env.get_db_cnx()) for k,v in long_items.iteritems()], "<br>") 
     138    else: 
    124139        html = wiki_to_oneliner(string.join(["#%d" % c for c in items], ", "), 
    125                                 hdf, env, env.get_db_cnx()) 
     140                                env, env.get_db_cnx()) 
     141 
    126142    if html != '': 
    127143        try: 
     
    129145        except: 
    130146            pass 
    131         style = string.join(["%s:%s" % (k,v) for k,v in styles.items() if v <> ""], "; ") 
     147        if inline: 
     148            style = string.join(["%s:%s" % (k,v) for k,v in inline_styles.items() if v <> ""], "; ") 
     149        else: 
     150            style = string.join(["%s:%s" % (k,v) for k,v in styles.items() if v <> ""], "; ") 
    132151        return '<fieldset class="ticketbox" style="%s"><legend>%s</legend>%s</fieldset>' % \ 
    133152               (style, title, html) 
  • ticketboxmacro/0.11/TicketBox.py

    r2769 r2848  
    3939           "width": "25%", 
    4040           } 
     41inline_styles = { "background": "#f7f7f0", } 
    4142 
    4243args_pat = [r"#?(?P<tktnum>\d+)", 
     
    4445            r"\[report:(?P<rptnum2>\d+)(?P<dv>\?.*)?\]", 
    4546            r"(?P<width>\d+(pt|px|%))", 
     47            r"(?P<summary>summary)", 
     48            r"(?P<inline>inline)", 
    4649            r"(?P<title1>'.*')", 
    4750            r'(?P<title2>".*")'] 
     
    6568        txt = '' 
    6669    items = [] 
     70    long_items = {} 
     71    show_summary = False 
     72    inline = False 
    6773    title = "Tickets" 
    6874    args_re = re.compile("^(?:" + string.join(args_pat, "|") + ")$") 
     
    8086        elif match.group('tktnum'): 
    8187            items.append(int(match.group('tktnum'))) 
     88        elif match.group('summary'): 
     89            show_summary = True 
     90        elif match.group('inline'): 
     91            inline = True 
    8292        elif match.group('rptnum') or match.group('rptnum2'): 
    8393            num = match.group('rptnum') or match.group('rptnum2') 
     
    107117                    descriptions = [desc[0] for desc in curs.description] 
    108118                    idx = descriptions.index('ticket') 
     119                    summ = descriptions.index('summary') 
    109120                    for row in rows: 
    110121                        items.append(row[idx]) 
     122                        long_items[row[idx]] = row[summ] 
    111123            finally: 
    112124                if not hasattr(env, 'get_cnx_pool'): 
     
    117129    items.sort() 
    118130    html = '' 
    119     from trac.wiki.formatter import wiki_to_oneliner, wiki_to_outline 
    120     html = wiki_to_oneliner(string.join(["#%d" % c for c in items], ", "), 
    121                             env, env.get_db_cnx(), req=formatter.req) 
     131    from trac.wiki.formatter import wiki_to_oneliner 
     132    if show_summary: 
     133        html = string.join([wiki_to_oneliner("%s (#%d)" % (v,k), 
     134                                             env, env.get_db_cnx()) for k,v in long_items.iteritems()], "<br>") 
     135    else: 
     136        html = wiki_to_oneliner(string.join(["#%d" % c for c in items], ", "), 
     137                                env, env.get_db_cnx(), req=formatter.req) 
    122138    if html != '': 
    123139        try: 
     
    125141        except: 
    126142            pass 
    127         style = string.join(["%s:%s" % (k,v) for k,v in styles.items() if v <> ""], "; ") 
     143        if inline: 
     144            style = string.join(["%s:%s" % (k,v) for k,v in inline_styles.items() if v <> ""], "; ") 
     145        else: 
     146            style = string.join(["%s:%s" % (k,v) for k,v in styles.items() if v <> ""], "; ") 
    128147        return '<fieldset class="ticketbox" style="%s"><legend>%s</legend>%s</fieldset>' % \ 
    129148               (style, title, html) 
  • ticketboxmacro/0.8/TicketBox.py

    r2768 r2848  
    3939           "width": "25%", 
    4040           } 
     41inline_styles = { "background": "#f7f7f0", } 
    4142 
    4243args_pat = [r"#?(?P<tktnum>\d+)", 
     
    4445            r"\[report:(?P<rptnum2>\d+)(?P<dv>\?.*)?\]", 
    4546            r"(?P<width>\d+(pt|px|%))", 
     47            r"(?P<summary>summary)", 
     48            r"(?P<inline>inline)", 
    4649            r"(?P<title1>'.*')", 
    4750            r'(?P<title2>".*")'] 
     
    6265        txt = '' 
    6366    items = [] 
     67    long_items = {} 
     68    show_summary = False 
     69    inline = False 
    6470    title = "Tickets" 
    6571    args_re = re.compile("^(?:" + string.join(args_pat, "|") + ")$") 
     
    7783        elif match.group('tktnum'): 
    7884            items.append(int(match.group('tktnum'))) 
     85        elif match.group('summary'): 
     86            show_summary = True 
     87        elif match.group('inline'): 
     88            inline = True 
    7989        elif match.group('rptnum') or match.group('rptnum2'): 
    8090            num = match.group('rptnum') or match.group('rptnum2') 
     
    104114                    descriptions = [desc[0] for desc in curs.description] 
    105115                    idx = descriptions.index('ticket') 
     116                    summ = descriptions.index('summary') 
    106117                    for row in rows: 
    107118                        items.append(row[idx]) 
     119                        long_items[row[idx]] = row[summ] 
    108120            finally: 
    109121                if not hasattr(env, 'get_cnx_pool'): 
     
    117129        # for trac 0.9 or later 
    118130        from trac.wiki.formatter import wiki_to_oneliner 
    119         html = wiki_to_oneliner(string.join(["#%d" % c for c in items], ", "), 
    120                                env, env.get_db_cnx()) 
    121131    except: 
    122132        # for trac 0.8.x 
    123133        from trac.WikiFormatter import wiki_to_oneliner 
     134 
     135    if show_summary: 
     136        html = string.join([wiki_to_oneliner("%s (#%d)" % (v,k), 
     137                                             hdf, env, env.get_db_cnx()) for k,v in long_items.iteritems()], "<br>") 
     138    else: 
    124139        html = wiki_to_oneliner(string.join(["#%d" % c for c in items], ", "), 
    125140                                hdf, env, env.get_db_cnx()) 
     141 
    126142    if html != '': 
    127143        try: 
     
    129145        except: 
    130146            pass 
    131         style = string.join(["%s:%s" % (k,v) for k,v in styles.items() if v <> ""], "; ") 
     147        if inline: 
     148            style = string.join(["%s:%s" % (k,v) for k,v in inline_styles.items() if v <> ""], "; ") 
     149        else: 
     150            style = string.join(["%s:%s" % (k,v) for k,v in styles.items() if v <> ""], "; ") 
    132151        return '<fieldset class="ticketbox" style="%s"><legend>%s</legend>%s</fieldset>' % \ 
    133152               (style, title, html) 
  • ticketboxmacro/0.9/TicketBox.py

    r2768 r2848  
    3939           "width": "25%", 
    4040           } 
     41inline_styles = { "background": "#f7f7f0", } 
    4142 
    4243args_pat = [r"#?(?P<tktnum>\d+)", 
     
    4445            r"\[report:(?P<rptnum2>\d+)(?P<dv>\?.*)?\]", 
    4546            r"(?P<width>\d+(pt|px|%))", 
     47            r"(?P<summary>summary)", 
     48            r"(?P<inline>inline)", 
    4649            r"(?P<title1>'.*')", 
    4750            r'(?P<title2>".*")'] 
     
    6265        txt = '' 
    6366    items = [] 
     67    long_items = {} 
     68    show_summary = False 
     69    inline = False 
    6470    title = "Tickets" 
    6571    args_re = re.compile("^(?:" + string.join(args_pat, "|") + ")$") 
     
    7783        elif match.group('tktnum'): 
    7884            items.append(int(match.group('tktnum'))) 
     85        elif match.group('summary'): 
     86            show_summary = True 
     87        elif match.group('inline'): 
     88            inline = True 
    7989        elif match.group('rptnum') or match.group('rptnum2'): 
    8090            num = match.group('rptnum') or match.group('rptnum2') 
     
    104114                    descriptions = [desc[0] for desc in curs.description] 
    105115                    idx = descriptions.index('ticket') 
     116                    summ = descriptions.index('summary') 
    106117                    for row in rows: 
    107118                        items.append(row[idx]) 
     119                        long_items[row[idx]] = row[summ] 
    108120            finally: 
    109121                if not hasattr(env, 'get_cnx_pool'): 
     
    117129        # for trac 0.9 or later 
    118130        from trac.wiki.formatter import wiki_to_oneliner 
    119         html = wiki_to_oneliner(string.join(["#%d" % c for c in items], ", "), 
    120                                env, env.get_db_cnx()) 
    121131    except: 
    122132        # for trac 0.8.x 
    123133        from trac.WikiFormatter import wiki_to_oneliner 
     134 
     135    if show_summary: 
     136        html = string.join([wiki_to_oneliner("%s (#%d)" % (v,k), 
     137                                             env, env.get_db_cnx()) for k,v in long_items.iteritems()], "<br>") 
     138    else: 
    124139        html = wiki_to_oneliner(string.join(["#%d" % c for c in items], ", "), 
    125                                 hdf, env, env.get_db_cnx()) 
     140                                env, env.get_db_cnx()) 
     141 
    126142    if html != '': 
    127143        try: 
     
    129145        except: 
    130146            pass 
    131         style = string.join(["%s:%s" % (k,v) for k,v in styles.items() if v <> ""], "; ") 
     147        if inline: 
     148            style = string.join(["%s:%s" % (k,v) for k,v in inline_styles.items() if v <> ""], "; ") 
     149        else: 
     150            style = string.join(["%s:%s" % (k,v) for k,v in styles.items() if v <> ""], "; ") 
    132151        return '<fieldset class="ticketbox" style="%s"><legend>%s</legend>%s</fieldset>' % \ 
    133152               (style, title, html)