[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[no subject]
From: |
Tatiana |
Date: |
Tue, 12 Jun 2018 18:18:54 -0400 (EDT) |
branch: web-interface
commit ac0fd3c928ad0824e0f1318aada947dcade2b896
Author: TSholokhova <address@hidden>
Date: Wed Jun 13 01:18:38 2018 +0300
Change HTML5 to XHTML. Fix codestyle.
* src/cuirass/http.scm (respond-html): Add XHTML preamble and
content-type.
* src/cuirass/templates.scm (html-page): Add XHTML preamble; fix
codestyle.
* src/cuirass/database.scm: Fix codestyle.
---
src/cuirass/database.scm | 17 +++++++++--------
src/cuirass/http.scm | 19 ++++++++++---------
src/cuirass/templates.scm | 26 +++++++++++++-------------
3 files changed, 32 insertions(+), 30 deletions(-)
diff --git a/src/cuirass/database.scm b/src/cuirass/database.scm
index 79fd844..ecf9a39 100644
--- a/src/cuirass/database.scm
+++ b/src/cuirass/database.scm
@@ -46,7 +46,7 @@
db-get-build
db-get-builds
db-get-evaluations
- db-get-evaluations-info
+ db-get-evaluations-build-summary
db-get-evaluations-count
read-sql-file
read-quoted-string
@@ -561,10 +561,10 @@ FROM Evaluations ORDER BY id DESC LIMIT " limit ";"))
(#:revision . ,revision))
evaluations))))))
-(define (db-get-evaluations-info db spec limit offset)
+(define (db-get-evaluations-build-summary db spec limit offset)
(let loop ((rows (sqlite-exec db
-"SELECT E.id, E.revision, B.succ, B.fail, B.que FROM
- (SELECT id, evaluation, SUM(status=0) as succ, SUM(status>0) as fail,
SUM(status<0) as que
+"SELECT E.id, E.revision, B.succeeded, B.failed, B.scheduled FROM
+ (SELECT id, evaluation, SUM(status=0) as succeeded, SUM(status>0) as failed,
SUM(status<0) as scheduled
FROM Builds
GROUP BY evaluation) B
JOIN
@@ -578,17 +578,18 @@ ON B.evaluation=E.id;"))
(evaluations '()))
(match rows
(() evaluations)
- ((#(id revision succ fail que)
+ ((#(id revision succeeded failed scheduled)
. rest)
(loop rest
(cons `((#:id . ,id)
(#:revision . ,revision)
- (#:succ . ,succ)
- (#:fail . ,fail)
- (#:que . ,que))
+ (#:succeeded . ,succeeded)
+ (#:failed . ,failed)
+ (#:scheduled . ,scheduled))
evaluations))))))
(define (db-get-evaluations-count db spec)
+ "Return the number of evaluations of the given specification SPEC"
(let ((rows (sqlite-exec db
"SELECT COUNT(id) FROM Evaluations
WHERE specification=" spec)))
diff --git a/src/cuirass/http.scm b/src/cuirass/http.scm
index 7560f38..9cab34d 100644
--- a/src/cuirass/http.scm
+++ b/src/cuirass/http.scm
@@ -55,6 +55,7 @@
("gif" . (image/gif))
("html" . (text/html))))
+
(define (file-extension file-name)
(last (string-split file-name #\.)))
@@ -166,9 +167,9 @@ Hydra format."
`((error . ,message)))))
(define (respond-html body)
- (respond '((content-type . (text/html)))
+ (respond '((content-type . (application/xhtml+xml)))
#:body (lambda (port)
- (format port "<!DOCTYPE html>")
+ (format port "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML
1.0 Transitional//EN\"
\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">")
(sxml->xml body port))))
(define (respond-static-file path)
@@ -295,12 +296,12 @@ Hydra format."
(nr 10)
(order status+submission-time)))))))
(("jobset" name)
- (let* ((eval_cnt (with-critical-section db-channel (db)
(db-get-evaluations-count db name)))
- (page_cnt (quotient (+ eval_cnt (- PAGESIZE 1)) PAGESIZE))
+ (let* ((evaluation-count (with-critical-section db-channel (db)
(db-get-evaluations-count db name)))
+ (page-count (quotient (+ evaluation-count (- PAGESIZE 1)) PAGESIZE))
(params (request-parameters request))
- (page_ext? (assq-ref params 'page))
- (page_int? (if page_ext? (list-ref page_ext? 0) 1))
- (page (if page_int? (min (max 1 page_int?) page_cnt) 1)))
+ (page-exist? (assq-ref params 'page))
+ (page-number? (if page-exist? (list-ref page-exist? 0) 1))
+ (page (if page-number? (min (max 1 page-number?) page-count) 1)))
(respond-html
(html-page
name
@@ -308,8 +309,8 @@ Hydra format."
name
page
(with-critical-section db-channel (db)
- (db-get-evaluations-info db name PAGESIZE (* PAGESIZE (- page 1))))
- eval_cnt)))))
+ (db-get-evaluations-build-summary db name PAGESIZE (* PAGESIZE (-
page 1))))
+ evaluation-count)))))
(("eval" id)
(respond-html
diff --git a/src/cuirass/templates.scm b/src/cuirass/templates.scm
index 829e738..927c156 100644
--- a/src/cuirass/templates.scm
+++ b/src/cuirass/templates.scm
@@ -29,7 +29,7 @@
(define (html-page title body)
"Return html page with given title and body"
- `(html (@ (lang "en"))
+ `(html (@ (xmlns "http://www.w3.org/1999/xhtml") (xml:lang "en") (lang "en"))
(head
(meta (@ (charset "utf-8")))
(meta (@ (name "viewport")
@@ -65,11 +65,11 @@
,@(map
(lambda (spec)
`(tr
- (td (a (@ (href ,(string-append "/jobset/" (assq-ref spec
#:name))))) ,(assq-ref spec #:name))
+ (td (a (@ (href "/jobset/" ,(assq-ref spec #:name)))
,(assq-ref spec #:name)))
(td ,(assq-ref spec #:branch))))
specs)))))))
-(define (pagination page page_cnt)
+(define (pagination page page-count)
"Return page navigation buttons"
`(div (@ (class row))
(nav
@@ -83,19 +83,19 @@
(a (@ (class "page-link")
(href "?page=" ,(number->string (- page 1))))
"< Previous"))
- (li (@ (class "page-item",(if (= page page_cnt) " disabled" "")))
+ (li (@ (class "page-item",(if (= page page-count) " disabled" "")))
(a (@ (class "page-link")
(href "?page=" ,(number->string (+ page 1))))
"Next >"))
(li (@ (class "page-item"))
(a (@ (class "page-link")
- (href "?page=" ,(number->string page_cnt)))
+ (href "?page=" ,(number->string page-count)))
"Last >>"))))))
-(define (evaluation-info-table name page data eval_cnt)
+(define (evaluation-info-table name page data evaluation-count)
"Return body for (Evaluation) html-page"
`((p (@ (class "lead")) "Evaluations of " ,name)
- (p (@ (class "text-muted")) "Showing evaluations ",(+ 1 (* PAGESIZE (-
page 1)))"-",(min eval_cnt (* PAGESIZE page))" out of ",eval_cnt)
+ (p (@ (class "text-muted")) "Showing evaluations ",(+ 1 (* PAGESIZE (-
page 1)))"-",(min evaluation-count (* PAGESIZE page))" out of
",evaluation-count)
(table
(@ (class "table table-sm table-hover table-striped"))
,@(if (null? data)
@@ -112,11 +112,11 @@
(th (@ (scope "row")) (a (@ (href "/eval/" ,(assq-ref row
#:id))) ,(assq-ref row #:id)))
(td ,(assq-ref row #:revision))
(td
- (a (@ (href "#") (class "badge badge-success")) ,(assq-ref
row #:succ))
- (a (@ (href "#") (class "badge badge-danger")) ,(assq-ref
row #:fail))
- (a (@ (href "#") (class "badge badge-secondary"))
,(assq-ref row #:que)))))
+ (a (@ (href "#") (class "badge badge-success")) ,(assq-ref
row #:succeeded))
+ (a (@ (href "#") (class "badge badge-danger")) ,(assq-ref
row #:failed))
+ (a (@ (href "#") (class "badge badge-secondary"))
,(assq-ref row #:scheduled)))))
data)))))
- ,(pagination page (quotient (+ eval_cnt (- PAGESIZE 1)) PAGESIZE))))
+ ,(pagination page (quotient (+ evaluation-count (- PAGESIZE 1))
PAGESIZE))))
(define (build-eval-table data)
@@ -134,9 +134,9 @@
(define (table-row build)
`(tr
(td ,(case (assq-ref build #:buildstatus)
- ((0) `(span (@ (class "oi oi-check text-success") (title
"Succeded") (aria-hidden "true")) ""))
+ ((0) `(span (@ (class "oi oi-check text-success") (title
"Succeeded") (aria-hidden "true")) ""))
((1 2 3 4) `(span (@ (class "oi oi-x text-danger") (title
"Failed") (aria-hidden "true")) ""))
- (else `(span (@ (class "oi oi-clock text-warning") (title
"Sheduled") (aria-hidden "true")) ""))))
+ (else `(span (@ (class "oi oi-clock text-warning") (title
"Scheduled") (aria-hidden "true")) ""))))
(th (@ (scope "row")),(assq-ref build #:id))
(td ,(assq-ref build #:project))
(td ,(strftime "%c" (localtime (assq-ref build #:stoptime))))