Trac

来自Gea-Suan Lin's Wiki
Gslin讨论 | 贡献2018年3月29日 (四) 08:24的版本 →‎安裝
跳到导航 跳到搜索

Trac是一套问题追踪系统英语:Issue tracking system)。

简介

优点

  • 简单,专注在事情的记录上,而不是限制行为上。

缺点

  • 目前还是不支援Python 3。

安装

用pip安装以下套件:

pip install Trac
pip install ​Pygments
pip install mysql-python

使用MySQL作为后端数据库时,建议用utf8mb4作为基础,这样数据库可以存所有范围的Unicode字元[1]

CREATE DATABASE trac DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_bin;

目前有安装的

除了基本安装外,还会安装这些套件:

以前有安装的

以前会安装,但现在因为自己用而没有装上:

看到的

看过但还没用过的:

设定

trac.ini

让系统吃code.jquery.com所提供的jQuery以及jQuery UI[2],稍微降低服务器的负载,另外也有机会与外部网站共用cache:

[trac]
jquery_location = https://code.jquery.com/jquery-1.12.4.min.js
jquery_ui_location = https://code.jquery.com/ui/1.12.1/jquery-ui.min.js
jquery_ui_theme_location = https://code.jquery.com/ui/1.12.1/themes/start/jquery-ui.css

site.html

templates/site.html里做了一些事情进行客制化。

CSS

  • 全部使用sans-serif字型。
  • 修正button因为CSS效果而有时会按不到的问题。
  • 针对今天到期与过期的票用不同的标示标出(配合下方的JavaScript)。
  • 将已经关掉的票变淡(配合下方的JavaScript)。
  • 让编辑区域使用等宽字型。
  • 让可用范围变宽。
    <style type="text/css">
    <!--
    body, th, tr {
        font-family: sans-serif;
    }
    input[type=button]:active, input[type=submit]:active,
    input[type=reset]:active {
        position: relative;
        top: 0;
        left: 0;
    }
    table.tickets tr.duedate_overdue {
        font-weight: bold;
    }
    table.tickets tr.duedate_today {
        border: 2px solid;
    }
    table.subtickets tr.ticket_closed, .closed.ticket {
        opacity: 0.5;
    }
    textarea {
        font-family: monospace;
    }
    #content.ticket {
        width: 78em;
    }
    -->
    </style>

JavaScript

  • 用JavaScript针对今天到期以及过期的票增加CSS。
  • 将新票里的Due Date改为零点零分零秒。
  • 将票里的attachments与modify内容展开。
  • 将日历选择器中,关闭动画效果[3],另外将每周的第一天设为星期天[3],并且允许选择其他月份的日期[3]

head的地方先加入strftime套件,后面会用到:

    <script src="https://cdn.jsdelivr.net/npm/strftime@0.10.0/strftime.min.js"></script>
    <script>
    <!--
    // Run immediately.
    (function($) {
        // Due date css handling
        var d = new Date();
        var today = (new Date(d.getTime() - d.getTimezoneOffset() * 60000)).toISOString().slice(0, 10);
        document.querySelectorAll('table.tickets td.due_date').forEach(function(el) {
            var due = el.innerText.trim();
            if (due < today) {
                el.parentElement.classList.add('duedate_overdue');
            } else if (due === today) {
                el.parentElement.classList.add('duedate_today');
            }
        });

        // Due date (newticket) set to 00:00:00 (in UTC)
        if ($('form[action$="/newticket#ticket"]').length > 0) {
            do {
                let el = $('#field-due_date');
                let t = el.val();

                if ('Z' === t.slice(-1)) {
                    console.log(t);
                    t = new Date(Date.parse(t) + 86400000);
                    t = strftime('%Y-%m-%dT00:00:00Z', t);
                    el.val(t);
                    break;
                }

                let a = t.match(/\+(\d\d:\d\d)$/);
                if (null !== a) {
                    let tz = a[1];
                    let new_str = 'T' + tz + ':00+' + tz;
                    t = new Date(Date.parse(t) + 86400000);
                    t = strftime('%Y-%m-%d' + new_str, t);
                    el.val(t);
                    break;
                }
            } while (false);
        }

        // Closed tickets handling
        $('tr:has(a.closed)').addClass('ticket_closed');
    })(jQuery);

    // Run after content loaded.
    jQuery(function() {
        // Layout
        jQuery('#attachments').removeClass('collapsed');
        jQuery('#modify').parent().removeClass('collapsed');

        // Datepicker
        if ($.datepicker) {
            $.datepicker.setDefaults({
                firstDay: 0,
                selectOtherMonths: true,
                showAnim: '',
                showOtherMonths: true
            });
        }
    });
    //-->
    </script>

参考资料

外部链接