Index: build/web/building.cgi ================================================================== --- build/web/building.cgi +++ build/web/building.cgi @@ -1,17 +1,28 @@ #! /usr/bin/env tclsh set outdir "/web/customers/kitcreator.rkeene.org/kits" -set key "" +set info [list] if {[info exists ::env(PATH_INFO)]} { - set key [lindex [split $::env(PATH_INFO) "/"] 1] + set info [lmap item [split $::env(PATH_INFO) /] { + if {$item eq ""} { + continue + } + return -level 0 $item + }] +} +set key [lindex $info end] +set resultFormat "html" +if {[llength $info] > 1} { + set resultFormat [lindex $info 0] } set status "Unknown" set terminal 0 if {![regexp {^[0-9a-f]+$} $key]} { set status "Invalid Key" + set terminal 1 unset key } if {[info exists key]} { @@ -113,10 +124,50 @@ set terminal 1 } else { set status "Building" } } + +if {$resultFormat in {json dict}} { + set terminalBoolean [lindex {false true} $terminal] +} + +switch -exact -- $resultFormat { + "html" { + # Handled below + } + "json" { + puts "Content-Type: application/json" + puts "" + if {$status eq "Complete"} { + puts "{\"status\":\"[string tolower $status]\", \"terminal\": $terminalBoolean, \"kit_url\":\"$url\"}" + } else { + puts "{\"status\":\"[string tolower $status]\", \"terminal\": $terminalBoolean}" + } + exit 0 + } + "dict" { + puts "Content-Type: text/plain" + puts "" + if {$status eq "Complete"} { + puts [dict create \ + status [string tolower $status] \ + terminal $terminalBoolean \ + kit_url $url \ + ] + } else { + puts [dict create \ + status [string tolower $status] \ + terminal $terminalBoolean \ + ] + } + exit 0 + } + default { + exit 1 + } +} puts "Content-Type: text/html" if {[info exists url]} { # Use a refresh here instead of a "Location" so that # the client can see the page Index: build/web/kitcreator.vfs/index.rvt ================================================================== --- build/web/kitcreator.vfs/index.rvt +++ build/web/kitcreator.vfs/index.rvt @@ -180,10 +180,18 @@ } switch -exact -- $apiMethod { build { # Do nothing, handled below + } + storages { + set apiResultDict { + mk4 {Metakit} + zip {Zip} + cvfs {C-VFS} + auto {Automatically Determine} + } } platforms { set apiResultDict [array get platforms] } tcl_versions { @@ -201,10 +209,11 @@ set apiResultDict [array get packages] } help { set apiResultDict { build {Build a TclKit. Accepts arguments: platform [mandatory, string], tcl_version [string], kitcreator_version [string], storage [string, one of mk4, cvfs, zip], options [array], packages [array]} + storages {Get a list of supported storage mechanisms to use as the "storage" argument to build} platforms {Get a list of platforms to use as the "platform" argument to build} tcl_versions {Get a list of Tcl versions and their descriptions to use as the "tcl_version" argument to build} kitcreator_versions {Get a list of KitCreator versions and their descriptions to use as the "kitcreator_version" argument to build} options {Get a list of options and their descriptions} packages {Get a list of packages and their descriptions} @@ -448,11 +457,10 @@ set fd [open $queue a+] puts $fd [list filename $filename key $key platform $build_platform tcl_version $build_tcl_version kitcreator_version $build_kitcreator_version packages $build_packages options [array get build_options]] close $fd set url "http://kitcreator.rkeene.org/kits/building/$key/" - set kiturl "http://kitcreator.rkeene.org/kits/$key/$filename" if {!$resultIsAPI} { headers redirect $url ?> @@ -463,16 +471,18 @@

Build in progress, see for build information