Download:
child 20:5d830ac627fc
parent 18:95430744fb8d
19:617cf0ab60ed
Anton Shestakov <av6@dwimlabs.net>, Wed, 15 Jun 2016 20:53:22 +0800
viewer: status.svg view

2 файлов изменено, 50 вставок(+), 0 удалений(-) [+]
templates/status.svg file | annotate | diff | comparison | revisions
viewer.py file | annotate | diff | comparison | revisions
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/templates/status.svg Wed Jun 15 20:53:22 2016 +0800
@@ -0,0 +1,25 @@
+<svg xmlns="http://www.w3.org/2000/svg" width="{{ width }}" height="{{ height }}">
+ <linearGradient id="b" x2="0" y2="100%">
+ <stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
+ <stop offset="1" stop-opacity=".1"/>
+ </linearGradient>
+ <mask id="a">
+ <rect width="{{ width }}" height="{{ height }}" rx="3" fill="#fff"/>
+ </mask>
+ <g mask="url(#a)">
+ {% set accx = 0 %}
+ {% for c, w, x, t in parts %}
+ <path fill="{{ c }}" d="M{{ accx }} 0h{{ w }}v{{ height }}H{{ accx }}z"/>
+ {% set accx += w %}
+ {% end %}
+ <path fill="url(#b)" d="M0 0h{{ width }}v{{ height }}H0z"/>
+ </g>
+ <g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11">
+ {% set accx = 0 %}
+ {% for c, w, x, t in parts %}
+ <text x="{{ accx + x }}" y="15" fill="#010101" fill-opacity=".3">{{ t }}</text>
+ <text x="{{ accx + x }}" y="14">{{ t }}</text>
+ {% set accx += w %}
+ {% end %}
+ </g>
+</svg>
--- a/viewer.py Wed Jun 15 20:50:33 2016 +0800
+++ b/viewer.py Wed Jun 15 20:53:22 2016 +0800
@@ -69,12 +69,37 @@
self.render('check.html', project=project, check=check, lines=lines)
+class StatusHandler(BaseHandler):
+ def get(self, domain, user, name):
+ project = Project.select().where(
+ Project.domain == domain,
+ Project.user == (user if user != '-' else None),
+ Project.name == name).get()
+ check = Check.get(project=project)
+ parts = [('#555', 30, 14.5, 'lint')]
+ if not check.success:
+ parts.append(('#777', 62, 30.5, 'unknown'))
+ elif check.errors or check.warnings:
+ if check.errors:
+ w = 7 + 6 * len(str(check.errors)) + 7
+ parts.append(('#da314b', w, w / 2 - 0.5, check.errors))
+ if check.warnings:
+ w = 7 + 6 * len(str(check.warnings)) + 7
+ parts.append(('#faa732', w, w / 2 - 0.5, check.warnings))
+ else:
+ parts.append(('#8cc14c', 40, 19.5, 'none'))
+ width = sum(p[1] for p in parts)
+ self.set_header('Content-Type', 'image/svg+xml; charset=utf-8')
+ self.render('status.svg', width=width, parts=parts, height=20)
+
+
class CandolintViewer(Application):
def __init__(self):
handlers = [
URLSpec(r'/', IndexHandler),
URLSpec(r'/([.a-z0-9_-]+)/([^/]+)/([^/]+)', ProjectHandler),
URLSpec(r'/([.a-z0-9_-]+)/([^/]+)/([^/]+)/([\d]+|latest)', CheckHandler),
+ URLSpec(r'/([.a-z0-9_-]+)/([^/]+)/([^/]+)/status\.svg', StatusHandler),
]
settings = dict(
static_path=rel('static'),