Check-in [01ff48e506]
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
2
3
4

5







6




7
8
9
10
11
12

13
14
15
16
17
18
19
1
2
3

4
5
6
7
8
9
10
11
12

13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30



-
+

+
+
+
+
+
+
+
-
+
+
+
+






+







#! /usr/bin/env tclsh

set outdir "/web/customers/kitcreator.rkeene.org/kits"
set key ""
set info [list]
if {[info exists ::env(PATH_INFO)]} {
	set info [lmap item [split $::env(PATH_INFO) /] {
		if {$item eq ""} {
			continue
		}
		return -level 0 $item
	}]
}
	set key [lindex [split $::env(PATH_INFO) "/"] 1]
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]} {
	set workdir [file join $outdir $key]
}
111
112
113
114
115
116
117








































118
119
120
121
122
123
124
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175







+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+







	} elseif {[file exists "${outfile}.buildfail"]} {
		set status "Failed"
		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
	puts "Refresh: 0;url=$url"
} else {

Modified build/web/kitcreator.vfs/index.rvt from [ff68791fbb] to [6e02118269].

178
179
180
181
182
183
184








185
186
187
188
189
190
191
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199







+
+
+
+
+
+
+
+







		catch {
			set apiMethod [dict get $args(dict) action]
		}

		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 {
				set apiResultDict [array get tcl_versions]
				dict set apiResultDict default $tcl_version_selected
199
200
201
202
203
204
205

206
207
208
209
210
211
212
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221







+







			}
			packages {
				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}
					examples {A few examples}
					help {This help}
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467


468
469
470

471
472
473

474
475
476
477
478
479
480
455
456
457
458
459
460
461

462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479

480
481
482

483
484
485
486
487
488
489
490







-














+
+


-
+


-
+








		# Queue build up and wait for it to complete
		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
?><html>
	<head>
		<title>KitCreator, Web Interface</title>
	</head>
	<body>
		<h1>KitCreator Web Interface</h1>
		<p>Build in progress, see <a href="<? puts -nonewline $url ?>"><? puts -nonewline $url ?></a> for build information</p>
	</body>
</html>
<?
		} else {
			set kiturl "http://kitcreator.rkeene.org/kits/building/$apiReturnFormat/$key/"

			switch -exact -- $apiReturnFormat {
				"json" {
					puts "{\"kit_url\": \"${kiturl}\"}"
					puts "{\"url\": \"${kiturl}\"}"
				}
				"dict" {
					puts [dict create kit_url $kiturl]
					puts [dict create url $kiturl]
				}
			}
		}
	} else {
?><html>
  <head>
    <title>KitCreator, Web Interface</title>