ADDED .fossil-settings/ignore-glob
Index: .fossil-settings/ignore-glob
==================================================================
--- /dev/null
+++ .fossil-settings/ignore-glob
@@ -0,0 +1,1 @@
+icons/static/*
ADDED icons/Makefile
Index: icons/Makefile
==================================================================
--- /dev/null
+++ icons/Makefile
@@ -0,0 +1,24 @@
+RIVET := /usr/lib64/rivet0.5.0/cgi-bin/rivet.cgi
+
+ACTION_LIST := build tests
+STATUS_LIST := pass fail
+PLATFORM_LIST := x86_64-linux x86_64-macos x86_64-freebsd
+
+ICONS = $(shell for action in $(ACTION_LIST); do for status in $(STATUS_LIST); do for platform in $(PLATFORM_LIST); do echo "static/icon-$${action}-$${status}-$${platform}.svg"; done; done; done)
+
+all: $(ICONS)
+
+static/%.svg: $(RIVET) status-icons.rvt $(shell find os -type f -name '*.svg')
+ @if ! test -d static; then mkdir static; fi
+ QUERY_STRING='action=$(shell echo '$@' | cut -f 2 -d -)&status=$(shell echo '$@' | cut -f 3 -d -)&os=$(shell echo '$@' | cut -f 5 -d - | cut -f 1 -d .)' PATH_TRANSLATED='$(shell pwd)/status-icons.rvt' '$(RIVET)' ./status-icons.rvt | tail -n +5 > '$@'
+
+static/%.png: static/%.svg
+ echo TODO Add support for making '$@' from '$^'
+ exit 1
+
+clean:
+ rm -rf static
+
+distclean: clean
+
+.PHONY: all clean distclean
ADDED icons/os/freebsd.svg
Index: icons/os/freebsd.svg
==================================================================
--- /dev/null
+++ icons/os/freebsd.svg
@@ -0,0 +1,11 @@
+
ADDED icons/os/linux.svg
Index: icons/os/linux.svg
==================================================================
--- /dev/null
+++ icons/os/linux.svg
@@ -0,0 +1,12 @@
+
ADDED icons/os/macos.svg
Index: icons/os/macos.svg
==================================================================
--- /dev/null
+++ icons/os/macos.svg
@@ -0,0 +1,18 @@
+
ADDED icons/os/unknown.svg
Index: icons/os/unknown.svg
==================================================================
--- /dev/null
+++ icons/os/unknown.svg
@@ -0,0 +1,6 @@
+
ADDED icons/status-icons.rvt
Index: icons/status-icons.rvt
==================================================================
--- /dev/null
+++ icons/status-icons.rvt
@@ -0,0 +1,96 @@
+
+ proc iconfile {type name {checkUnknown true}} {
+ 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"
+ }
+ }
+
+ return $file
+ }
+
+ proc icon {type name {x 5px} {y 2px} {width 16px} {height 16px}} {
+ set file [iconfile $type $name]
+
+ set fd [open $file]
+ set data [read $fd]
+ close $fd
+
+ puts -nonewline [string map [list @@XPOS@@ $x @@YPOS@@ $y @@WIDTH@@ $width @@HEIGHT@@ $height] $data]
+ }
+
+ proc textColorFromBackground {color} {
+ return "#fff"
+ }
+
+ 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} {
+ if {![info exists args($arg)]} {
+ continue
+ }
+
+ set args($arg) [lindex [set args($arg)] end]
+ }
+
+ foreach arg {status_color action_color} {
+ if {![info exists args($arg)]} {
+ catch {
+ set args($arg) $mapping([list $arg $args([lindex [split $arg _] 0])])
+ } err
+ lappend errList $err
+
+ }
+
+ if {![info exists args($arg)]} {
+ set args($arg) [set ${arg}_default]
+ }
+ }
+
+ set timestamp "Tue, 24 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}>"
+?>
+