Making Custom Strikethroughs with Trac

Posted by Linus Mon, 12 May 2008 21:41:00 GMT

I am going to make another technical post this week. We are using Trac as a way track bugs in our applications. It is extremely popular which as a result makes it a pain to find information on Google (trust me, try searching and you will get hundreds of irrelevant results).

The other day I spent a considerable amount of time trying to customize the reports to the way I want them. One problem was how to create a strikethrough for bugs that were closed. Several people have asked for this on various forums but no one had a solution. I decided to write my own.

My solution was to create a new style in the stylesheet and its corresponding tag. Though I could have overridden the existing styles but I like to keep this as OEM as possible.

In /htdocs/trac.css Add the lines:

table.listing tbody tr.even_strike td {
  background-color: #fcfcfc;
  text-decoration: line-through;
}
table.listing tbody tr.odd_strike td {
  background-color: #f7f7f7;
  text-decoration: line-through;
}

In /template/report.cs add the lines:

<?cs if row.__strikethrough__ ?>
         <?cs if idx % #2 ?>
           <?cs set row_class=$rstem+'even_strike' ?>
         <?cs else ?>
           <?cs set row_class=$rstem+'odd_strike' ?>
         <?cs /if ?>
       <?cs /if ?>

Finally in our customer report:

SELECT
  id AS ticket, 
  summary,
  priority,
  (CASE status WHEN 'closed' THEN 'true' ELSE '' END) AS __strikethrough__,
  (CASE status WHEN 'assigned' THEN owner||' *' ELSE owner END) AS owner,
  datetime(changetime, 'unixepoch') AS Closed, description AS _description,
  reporter AS _reporter
FROM
 ticket t
LEFT JOIN
 enum p ON p.name = t.priority AND p.type = 'priority'
ORDER BY owner, priority, status

If you do this right, you should be able to see something like below:

Posted in  | Tags , , , , , ,  | no comments

Comments

(leave url/email »)

   Comment Markup Help Preview comment