Download:
child 14:9cebce155650
parent 12:2ea3583bd611
13:448ea1a0274c
Anton Shestakov <av6@dwimlabs.net>, Tue, 14 Jun 2016 13:37:38 +0800
viewer: add check view

4 файлов изменено, 120 вставок(+), 1 удалений(-) [+]
static/main.css file | annotate | diff | comparison | revisions
templates/check.html file | annotate | diff | comparison | revisions
templates/project.html file | annotate | diff | comparison | revisions
viewer.py file | annotate | diff | comparison | revisions
--- a/static/main.css Tue Jun 14 13:24:35 2016 +0800
+++ b/static/main.css Tue Jun 14 13:37:38 2016 +0800
@@ -6,3 +6,52 @@
margin-left: 130px;
}
}
+
+.check-log {
+ background: #3c3c3c;
+ color: white;
+ border-color: #2a2a2a;
+ font-size: 13px;
+ white-space: pre-wrap;
+ word-break: break-all;
+ word-wrap: break-word;
+}
+
+.check-log div {
+ padding: 0 0 0 42px;
+ margin: 0;
+}
+
+.check-log div:target {
+ background: #4c4c4c;
+}
+
+.check-log div a {
+ display: inline-block;
+ text-align: right;
+ min-width: 42px; /* 4 digits */
+ margin-left: -42px;
+ text-decoration: none;
+ color: #929292;
+}
+
+.check-log div a::before {
+ content: attr(data-line-number);
+ padding-right: 10px;
+}
+
+.check-log .error {
+ color: #f277a1;
+}
+
+.check-log .warning {
+ color: #f1bf8e;
+}
+
+.check-log .task {
+ color: #bb84b4;
+}
+
+.check-log .meta {
+ color: #929292;
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/templates/check.html Tue Jun 14 13:37:38 2016 +0800
@@ -0,0 +1,50 @@
+{% extends "base.html" %}
+
+{% block title %}Check #{{ check.ordinal }}{% end %}
+
+{% block content %}
+ <div class="uk-container uk-container-center uk-margin-large-top">
+ <h2>{{ project.name }}: check #{{ check.ordinal }}</h2>
+ <p>
+ {% if check.success %}
+ {{ locale.translate('{} error', '{} errors', check.errors).format(check.errors) }},
+ {{ locale.translate('{} warning', '{} warnings', check.warnings).format(check.warnings) }}
+ {% else %}
+ Job failed.
+ {% end %}
+ </p>
+ <div class="uk-grid">
+ <div class="uk-width-medium-1-3">
+ <dl class="uk-description-list-horizontal list-terse">
+ <dt>Started:</dt>
+ <dd>{{ check.started }}</dd>
+ <dt>Finished:</dt>
+ <dd>{{ check.finished }}</dd>
+ <dt>Duration:</dt>
+ <dd>{{ check.finished - check.started }}</dd>
+ </dl>
+ </div>
+ <div class="uk-width-medium-2-3">
+ <dl class="uk-description-list-horizontal list-terse">
+ {% set change = check.change %}
+ <dt>Commit:</dt>
+ <dd>{{ change.rev }}:{{ change.node[:12] }} {{ change.branch }}</dd>
+ <dt>Author:</dt>
+ <dd>{{ change.author }}</dd>
+ <dt>Date:</dt>
+ <dd><time>{{ change.date }}</time></dd>
+ <dt>Description:</dt>
+ <dd>{{ change.message }}</dd>
+ </dl>
+ </div>
+ </div>
+ <pre class="check-log">{#
+ #}{% for number, (cls, line) in enumerate(lines, 1) %}{#
+ #}<div id="l{{ number }}"{% if cls %} class="{{ cls }}"{% end %}>{#
+ #}<a href="#l{{ number }}" data-line-number="{{ number }}"></a>{#
+ #}{{ line }}{#
+ #}</div>{#
+ #}{% end %}{#
+ #}</pre>
+ </div>
+{% end %}
--- a/templates/project.html Tue Jun 14 13:24:35 2016 +0800
+++ b/templates/project.html Tue Jun 14 13:37:38 2016 +0800
@@ -17,7 +17,11 @@
{% set change = check.change %}
<tr>
<td>{{ check.errors }} error(s), {{ check.warnings }} warning(s)</td>
- <td>#{{ check.ordinal }}</td>
+ <td>
+ <a href="/{{ project.domain }}/{{ project.user or '-' }}/{{ project.name }}/{{ check.ordinal }}">
+ #{{ check.ordinal }}
+ </a>
+ </td>
<td>{{ change.rev }}:{{ change.node[:12] }} {{ change.branch }}</td>
<td>
<div>{{ change.message }}</div>
--- a/viewer.py Tue Jun 14 13:24:35 2016 +0800
+++ b/viewer.py Tue Jun 14 13:37:38 2016 +0800
@@ -2,6 +2,7 @@
import logging
import os
+from tornado.escape import json_decode
from tornado.ioloop import IOLoop
from tornado.options import define, options
from tornado.web import Application, RequestHandler, URLSpec
@@ -53,11 +54,26 @@
self.render('project.html', project=project, checks=checks)
+class CheckHandler(BaseHandler):
+ def get(self, domain, user, name, check_num):
+ project = Project.select().where(
+ Project.domain == domain,
+ Project.user == (user if user != '-' else None),
+ Project.name == name).get()
+ if check_num == 'latest':
+ check = Check.get(project=project)
+ else:
+ check = Check.get(project=project, ordinal=check_num)
+ lines = json_decode(check.lines)
+ self.render('check.html', project=project, check=check, lines=lines)
+
+
class CandolintViewer(Application):
def __init__(self):
handlers = [
URLSpec(r'/', IndexHandler),
URLSpec(r'/([.a-z0-9_-]+)/([^/]+)/([^/]+)', ProjectHandler),
+ URLSpec(r'/([.a-z0-9_-]+)/([^/]+)/([^/]+)/([\d]+|latest)', CheckHandler),
]
settings = dict(
static_path=rel('static'),