Changes between Version 2 and Version 3 of TicketMilestoneDisplayMacro


Ignore:
Timestamp:
Jun 27, 2007, 8:27:50 PM (7 years ago)
Author:
fsbojason
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • TicketMilestoneDisplayMacro

    v2 v3  
    33== Description ==
    44
    5 (I couldn't commit to track-hack subversion, so the source is attached)
    6 
    75This macro will display a linked ticket number and linked milestone.
    86
    97This is useful for svn commit messages.  If all revisions are committed with this macro, you will see the revision logs with both its related ticket number and milestone.
     8
     9{{{
     10[[tm(10)]]
     11
     12gives you
     13
     14[Ticket !#10 Milestone 1.0]
     15}}}
     16
     17== Help ==
    1018
    1119Being new to writing macros, I understand the old style macros will not be supported in v.11, but I don't quite understand how to make this macro into a plugin using eggs.  If anybody can provide a bit of help with this, I will upload the plugin after it's done.
     
    2432Any help is much appreciated!
    2533
     34== Source ==
     35
     36Save this to a file (tm.py) and place in your plugins/wiki-macros directory, just as you would do with other old style macros
     37
     38{{{
     39"""
     40Lists ticket and milestone information
     41
     42This macro takes one parameter, the ticket id
     43"""
     44
     45import time
     46import re
     47from StringIO import StringIO
     48
     49def execute(hdf, args, env):
     50    db = env.get_db_cnx()
     51    cursor = db.cursor()
     52
     53    sql = "SELECT id, milestone FROM ticket WHERE id = '%s'" % args
     54
     55    cursor.execute(sql)
     56
     57    buf = StringIO()
     58
     59    row = cursor.fetchone()
     60    if row == None:
     61      buf.write('Ticket with ID "%s" was not found' % args)
     62    else:
     63      buf.write('[<a href="%s">Ticket #%s</a>, <a href="%s">Milestone: %s</a>]' % (env.href.ticket(row[0]), row[0], env.href.milestone(row[1]), row[1]))
     64   
     65    return buf.getvalue()
     66}}}
     67
    2668== Bugs/Feature Requests ==
    2769
     
    3173If you have any issues, create a
    3274[http://trac-hacks.org/newticket?component=TicketMilestoneDisplayMacro&owner=fsbojason new ticket].
    33 
    34 == Download ==
    35 
    36 Download the zipped source from [download:ticketmilestonedisplaymacro here].
    37 
    38 == Source ==
    39 
    40 You can check out TicketMilestoneDisplayMacro from [http://trac-hacks.org/svn/ticketmilestonedisplaymacro here] using Subversion, or [source:ticketmilestonedisplaymacro browse the source] with Trac.
    41 
    42 == Example ==
    43 
    44 {{{
    45 [[tm(10)]]
    46 
    47 gives you
    48 
    49 [Ticket !#10 Milestone 1.0]
    50 }}}
    5175
    5276== Recent Changes ==