PageRenderTime 215ms CodeModel.GetById 101ms app.highlight 6ms RepoModel.GetById 65ms app.codeStats 0ms

/kai/templates/tracebacks/show.mako

https://bitbucket.org/bbangert/kai/
Mako | 98 lines | 95 code | 3 blank | 0 comment | 9 complexity | 7d5ac4fa923cecb1620ed81c9841b831 MD5 | raw file
 1<div class="yui-b content">
 2    <% combined_exc = '%s: %s' % (c.traceback.exception_type, h.truncate(c.traceback.exception_value, 100)) %>
 3    <h1>${h.link_to(combined_exc, url=url.current())}\
 4        <span class="subtle">(${h.link_to('comments', url='#comments')})</span></h1>
 5    <div class="traceback_posted">\
 6        % if c.is_owner or (c.user and c.user.in_group('admin')):
 7        <div class="traceback_delete">${h.link_to('Delete', id_='delete_traceback')}</div>
 8        % endif
 9        ${widgets.format_timestamp(c.traceback.created)} by
10        <span class="traceback_author">${c.author.displayname if c.author else 'Anonymous'}</span>\
11        </div>
12    <div class="traceback">
13        <% 
14            sort = request.GET.get('sort')
15            options = ['In Call Order', 'Reverse Call Order']
16            if sort and sort not in options:
17                sort = options[0]
18        %>
19        <div class="sort_order">${h.select('order', sort, options, id='sort_order',
20            onchange="document.location='%s?sort=' + document.getElementById('sort_order').value" % url.current())}</div>
21        <%
22            if sort == options[1]:
23                frames = c.traceback.frames[::-1]
24            else:
25                frames = c.traceback.frames
26        %>
27        <div class="traceback_frames">
28            % if sort == options[1]:
29            <blockquote>${c.traceback.exception_type}: ${c.traceback.exception_value}</blockquote>
30            % endif
31            <ul>
32            % for frame in frames:
33            <li><h4>
34                <cite>${frame['module']}</cite> : <em>${frame['line']}</em>, in <code>${frame['function']}</code></h4>
35                ${highlight(frame['operation'], py_lexer, html_formatter) if frame['operation'] else '' | n}\
36            </li>
37            % endfor
38            </ul>
39            % if not sort or sort == options[0]:
40            <blockquote>${c.traceback.exception_type}: ${c.traceback.exception_value}</blockquote>
41            % endif
42        </div>
43        <div class="description">
44            <h2>Description</h2>
45            <p>${c.traceback.description if c.traceback.description else 'No Description Entered'}</p>
46        </div>
47        <div class="sysinfo">
48            <div class="language"><span class="language">${c.traceback.language} on ${c.traceback.platform}</span>: <span class="version">${c.traceback.version}</span></div>
49            <table id="traceback_libs">
50                <tbody>
51                    <%
52                        libs = sorted(list(c.traceback.libraries), lambda x,y: cmp(x.name, y.name))
53                    %>
54                    % for lib in libs:
55                    <tr><td>${lib.name}</td><td class="version">${lib.version}</td></tr>
56                    % endfor
57                </tbody>
58            </table>
59        </div>
60    </div>
61    
62    ${widgets.show_comments(c.traceback.id, poster_id=c.traceback.human_id, message="Suggest a fix or tip to help solve this traceback.")}
63</div>
64<%namespace name="widgets" file="/widgets.mako"/>
65<%def name="title()">${parent.title()} - ${_('Traceback %s' % c.traceback.id)}</%def>\
66<%def name="javascript()">
67${parent.javascript()}
68<script>
69$(document).ready(function() {
70    $('#delete_traceback').click(function() {
71        var answer = window.confirm("Are you sure you want to delete this traceback?");
72        if (answer) {
73            $.ajax({
74                data: {"_method":"DELETE"},
75                type: "POST",
76                url: location.pathname,
77                success: function(data, textStatus) {
78                    window.location = '/tracebacks';
79                }
80            });
81        }
82        return false;
83    });
84    ${widgets.comment_js(c.traceback.id)}
85});
86</script>
87</%def>
88<%inherit file="../layout.mako" />\
89<%!
90from datetime import datetime
91
92from pygments import highlight
93from pygments.lexers import PythonLexer
94from pygments.formatters import HtmlFormatter
95
96py_lexer = PythonLexer()
97html_formatter = HtmlFormatter()
98%>