1
2
3
4
5
6
7
8
9
10
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
+
+
+
+
|
<?
proc iconfile {type name {checkUnknown true}} {
if {![regexp {^[a-z]*$} $name]} {
set name unknown
}
set file [file join [file dirname [info script]] $type "${name}.svg"]
if {![file exists $file]} {
if {$checkUnknown} {
tailcall iconfile $type unknown false
} else {
error "No icon available for type=$type name=$name"
}
}
|
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
+
-
+
|
puts -nonewline [string map [list @@XPOS@@ $x @@YPOS@@ $y @@WIDTH@@ $width @@HEIGHT@@ $height] $data]
}
proc textColorFromBackground {color} {
return "#fff"
}
set args(background_color) "#eee"
set args(action) [list "build"]
set args(status) [list "unknown"]
set args(os) [list "unknown"]
set action_color_default "#555"
set status_color_default "#4c1"
set mapping([list status_color pass]) #00ff97
set mapping([list status_color passed]) #00ff97
set mapping([list status_color passing]) #00ff97
set mapping([list status_color fail]) #f00
set mapping([list status_color failed]) #f00
set mapping([list status_color failing]) #f00
set mapping([list status_color unknown]) #9932CC
set errList [list]
load_response args
foreach arg {action status status_color action_color os} {
foreach arg {action status status_color action_color background_color os} {
if {![info exists args($arg)]} {
continue
}
set args($arg) [lindex [set args($arg)] end]
}
|
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
|
-
+
-
+
-
-
-
+
+
+
+
+
+
+
+
|
}
if {![info exists args($arg)]} {
set args($arg) [set ${arg}_default]
}
}
set timestamp "Tue, 24 Oct 2017 00:00:00 GMT"
set timestamp "Tue, 26 Oct 2017 00:00:00 GMT"
set etag [binary encode base64 [list $timestamp $args(action) $args(status) $args(action_color) $args(status_color) $args(os)]]
set actionTextColor [textColorFromBackground $args(action_color)]
set statusTextColor [textColorFromBackground $args(status_color)]
headers type image/svg+xml
headers add Last-Modified $timestamp
headers add ETag $etag
set q [format %c 63]
puts -nonewline "<${q}xml version=\"1.0\"${q}>"
?>
<svg xmlns="http://www.w3.org/2000/svg" width="120" height="20">
<linearGradient id="a" x2="0" y2="100%">
<stop offset="0" stop-color="#bbb" stop-opacity=".1"/>
<stop offset="1" stop-opacity=".1"/>
</linearGradient>
<rect rx="3" width="120" height="20" fill="<? puts -nonewline $args(action_color) ?>"/>
<rect rx="3" width="120" height="20" fill="<? puts -nonewline $args(background_color) ?>"/>
<rect rx="3" x="65" width="55" height="20" fill="<? puts -nonewline $args(status_color) ?>"/>
<rect rx="3" width="120" height="20" fill="url(#a)"/>
<? catch {icon os $args(os)} ?>
<g fill="#fff" text-anchor="middle" font-family="DejaVu Sans,Verdana,Geneva,sans-serif" font-size="11">
<? if {[info exists args(no_action_icon)] || [catch {icon action $args(action) 36}]} { ?>
<rect rx="3" width="120" height="20" fill="<? puts -nonewline $args(action_color) ?>"/>
<text x="44" y="15" fill="#010101" fill-opacity=".3"><? puts -nonewline $args(action) ?></text>
<text x="44" y="14" fill="<? puts -nonewline $actionTextColor ?>"><? puts -nonewline $args(action) ?></text>
<? } ?>
<? if {[info exists args(no_status_icon)] || [catch {icon status $args(status) 84}]} { ?>
<rect rx="3" x="65" width="55" height="20" fill="<? puts -nonewline $args(status_color) ?>"/>
<text x="92" y="15" fill="#010101" fill-opacity=".3"><? puts -nonewline $args(status) ?></text>
<text x="92" y="14" fill="<? puts -nonewline $statusTextColor ?>"><? puts -nonewline $args(status) ?></text>
<? } ?>
<rect rx="3" width="120" height="20" fill="url(#a)"/>
<? catch {icon os $args(os)} ?>
</g>
<!-- <? #puts $errList ?> -->
</svg>
|