Download:
child 17:ba794747cbdc
parent 15:fa08a5f4efd3
16:784e5bd0fcba
Anton Shestakov <av6@dwimlabs.net>, Wed, 15 Jun 2016 15:48:54 +0800
viewer: use a UI module for rendering time elements

6 файлов изменено, 18 вставок(+), 7 удалений(-) [+]
candolint/uimodules.py file | annotate | diff | comparison | revisions
templates/check.html file | annotate | diff | comparison | revisions
templates/index.html file | annotate | diff | comparison | revisions
templates/project.html file | annotate | diff | comparison | revisions
templates/ui/time.html file | annotate | diff | comparison | revisions
viewer.py file | annotate | diff | comparison | revisions
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/candolint/uimodules.py Wed Jun 15 15:48:54 2016 +0800
@@ -0,0 +1,8 @@
+from tornado.web import UIModule
+
+
+class Time(UIModule):
+ def render(self, value):
+ datetime = value.isoformat() + 'Z'
+ text = value.strftime('%Y-%m-%d %H:%M:%S') + ' UTC'
+ return self.render_string('ui/time.html', datetime=datetime, title=text, text=text)
--- a/templates/check.html Wed Jun 15 01:44:31 2016 +0800
+++ b/templates/check.html Wed Jun 15 15:48:54 2016 +0800
@@ -17,9 +17,9 @@
<div class="uk-width-medium-1-3">
<dl class="uk-description-list-horizontal list-terse">
<dt>Started:</dt>
- <dd>{{ check.started }}</dd>
+ <dd>{% module Time(value=check.started) %}</dd>
<dt>Finished:</dt>
- <dd>{{ check.finished }}</dd>
+ <dd>{% module Time(value=check.finished) %}</dd>
<dt>Duration:</dt>
<dd>{{ check.finished - check.started }}</dd>
</dl>
--- a/templates/index.html Wed Jun 15 01:44:31 2016 +0800
+++ b/templates/index.html Wed Jun 15 15:48:54 2016 +0800
@@ -19,8 +19,8 @@
</a>
</td>
<td>{{ change.rev }}:{{ change.node[:12] }} {{ change.branch }}</td>
- <td>{{ check.started }}</td>
- <td>{{ check.finished }}</td>
+ <td>{% module Time(value=check.started) %}</td>
+ <td>{% module Time(value=check.finished) %}</td>
<td>{{ check.finished - check.started }}</td>
</tr>
{% end %}
--- a/templates/project.html Wed Jun 15 01:44:31 2016 +0800
+++ b/templates/project.html Wed Jun 15 15:48:54 2016 +0800
@@ -7,7 +7,7 @@
<h2>{{ project.name }}</h2>
<dl class="uk-description-list-horizontal list-terse">
<dt>Last check:</dt>
- <dd>{{ checks[0].finished }}</dd>
+ <dd>{% module Time(value=checks[0].finished) %}</dd>
<dt>Clone URL:</dt>
<dd>{{ project.url }}</dd>
</dl>
@@ -27,8 +27,8 @@
<div>{{ change.message }}</div>
<div>{{ change.author }}, <time>{{ change.date }}</time></div>
</td>
- <td>{{ check.started }}</td>
- <td>{{ check.finished }}</td>
+ <td>{% module Time(value=check.started) %}</td>
+ <td>{% module Time(value=check.finished) %}</td>
<td>{{ check.finished - check.started }}</td>
</tr>
{% end %}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/templates/ui/time.html Wed Jun 15 15:48:54 2016 +0800
@@ -0,0 +1,1 @@
+<time datetime="{{ datetime }}" title="{{ title }}">{{ text }}</time>
--- a/viewer.py Wed Jun 15 01:44:31 2016 +0800
+++ b/viewer.py Wed Jun 15 15:48:54 2016 +0800
@@ -7,6 +7,7 @@
from tornado.options import define, options
from tornado.web import Application, RequestHandler, URLSpec
+from candolint import uimodules
from candolint.models import database, Project, Change, Check
@@ -78,6 +79,7 @@
settings = dict(
static_path=rel('static'),
template_path=rel('templates'),
+ ui_modules=uimodules,
debug=options.debug
)
super(CandolintViewer, self).__init__(handlers, **settings)