Overview
Comment: | Better handling to the kit_url |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA1: | 01ff48e5061547d716de041840fbc0da5fa8108e |
User & Date: | rkeene on 2019-02-28 07:41:22 |
Other Links: | manifest | tags |
Context
2019-02-28
| ||
08:55 | Added a simple API client check-in: c0f939a115 user: rkeene tags: trunk | |
07:41 | Better handling to the kit_url check-in: 01ff48e506 user: rkeene tags: trunk | |
06:47 | Improve web interface check-in: 06c059eb4a user: rkeene tags: trunk | |
Changes
Modified build/web/building.cgi from [c7e1a0c441] to [fa17a7dcc9].
1 1 #! /usr/bin/env tclsh 2 2 3 3 set outdir "/web/customers/kitcreator.rkeene.org/kits" 4 -set key "" 4 +set info [list] 5 5 if {[info exists ::env(PATH_INFO)]} { 6 - set key [lindex [split $::env(PATH_INFO) "/"] 1] 6 + set info [lmap item [split $::env(PATH_INFO) /] { 7 + if {$item eq ""} { 8 + continue 9 + } 10 + return -level 0 $item 11 + }] 12 +} 13 +set key [lindex $info end] 14 +set resultFormat "html" 15 +if {[llength $info] > 1} { 16 + set resultFormat [lindex $info 0] 7 17 } 8 18 9 19 set status "Unknown" 10 20 set terminal 0 11 21 if {![regexp {^[0-9a-f]+$} $key]} { 12 22 set status "Invalid Key" 23 + set terminal 1 13 24 14 25 unset key 15 26 } 16 27 17 28 if {[info exists key]} { 18 29 set workdir [file join $outdir $key] 19 30 } ................................................................................ 111 122 } elseif {[file exists "${outfile}.buildfail"]} { 112 123 set status "Failed" 113 124 set terminal 1 114 125 } else { 115 126 set status "Building" 116 127 } 117 128 } 129 + 130 +if {$resultFormat in {json dict}} { 131 + set terminalBoolean [lindex {false true} $terminal] 132 +} 133 + 134 +switch -exact -- $resultFormat { 135 + "html" { 136 + # Handled below 137 + } 138 + "json" { 139 + puts "Content-Type: application/json" 140 + puts "" 141 + if {$status eq "Complete"} { 142 + puts "{\"status\":\"[string tolower $status]\", \"terminal\": $terminalBoolean, \"kit_url\":\"$url\"}" 143 + } else { 144 + puts "{\"status\":\"[string tolower $status]\", \"terminal\": $terminalBoolean}" 145 + } 146 + exit 0 147 + } 148 + "dict" { 149 + puts "Content-Type: text/plain" 150 + puts "" 151 + if {$status eq "Complete"} { 152 + puts [dict create \ 153 + status [string tolower $status] \ 154 + terminal $terminalBoolean \ 155 + kit_url $url \ 156 + ] 157 + } else { 158 + puts [dict create \ 159 + status [string tolower $status] \ 160 + terminal $terminalBoolean \ 161 + ] 162 + } 163 + exit 0 164 + } 165 + default { 166 + exit 1 167 + } 168 +} 118 169 119 170 puts "Content-Type: text/html" 120 171 if {[info exists url]} { 121 172 # Use a refresh here instead of a "Location" so that 122 173 # the client can see the page 123 174 puts "Refresh: 0;url=$url" 124 175 } else {
Modified build/web/kitcreator.vfs/index.rvt from [ff68791fbb] to [6e02118269].
178 178 catch { 179 179 set apiMethod [dict get $args(dict) action] 180 180 } 181 181 182 182 switch -exact -- $apiMethod { 183 183 build { 184 184 # Do nothing, handled below 185 + } 186 + storages { 187 + set apiResultDict { 188 + mk4 {Metakit} 189 + zip {Zip} 190 + cvfs {C-VFS} 191 + auto {Automatically Determine} 192 + } 185 193 } 186 194 platforms { 187 195 set apiResultDict [array get platforms] 188 196 } 189 197 tcl_versions { 190 198 set apiResultDict [array get tcl_versions] 191 199 dict set apiResultDict default $tcl_version_selected ................................................................................ 199 207 } 200 208 packages { 201 209 set apiResultDict [array get packages] 202 210 } 203 211 help { 204 212 set apiResultDict { 205 213 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]} 214 + storages {Get a list of supported storage mechanisms to use as the "storage" argument to build} 206 215 platforms {Get a list of platforms to use as the "platform" argument to build} 207 216 tcl_versions {Get a list of Tcl versions and their descriptions to use as the "tcl_version" argument to build} 208 217 kitcreator_versions {Get a list of KitCreator versions and their descriptions to use as the "kitcreator_version" argument to build} 209 218 options {Get a list of options and their descriptions} 210 219 packages {Get a list of packages and their descriptions} 211 220 examples {A few examples} 212 221 help {This help} ................................................................................ 446 455 447 456 # Queue build up and wait for it to complete 448 457 set fd [open $queue a+] 449 458 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]] 450 459 close $fd 451 460 452 461 set url "http://kitcreator.rkeene.org/kits/building/$key/" 453 - set kiturl "http://kitcreator.rkeene.org/kits/$key/$filename" 454 462 455 463 if {!$resultIsAPI} { 456 464 headers redirect $url 457 465 ?><html> 458 466 <head> 459 467 <title>KitCreator, Web Interface</title> 460 468 </head> ................................................................................ 461 469 <body> 462 470 <h1>KitCreator Web Interface</h1> 463 471 <p>Build in progress, see <a href="<? puts -nonewline $url ?>"><? puts -nonewline $url ?></a> for build information</p> 464 472 </body> 465 473 </html> 466 474 <? 467 475 } else { 476 + set kiturl "http://kitcreator.rkeene.org/kits/building/$apiReturnFormat/$key/" 477 + 468 478 switch -exact -- $apiReturnFormat { 469 479 "json" { 470 - puts "{\"kit_url\": \"${kiturl}\"}" 480 + puts "{\"url\": \"${kiturl}\"}" 471 481 } 472 482 "dict" { 473 - puts [dict create kit_url $kiturl] 483 + puts [dict create url $kiturl] 474 484 } 475 485 } 476 486 } 477 487 } else { 478 488 ?><html> 479 489 <head> 480 490 <title>KitCreator, Web Interface</title>