Subversion Repositories Koakuma

Rev

Rev 3 | Rev 5 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 3 Rev 4
Line 50... Line 50...
50
	exiting 0
50
	exiting 0
51
}
51
}
52
 
52
 
53
if { [catch {
53
if { [catch {
54
	package require tdom
54
	package require tdom
-
 
55
	dom createNodeCmd -tagName "rpc" elementNode rootXML
-
 
56
	dom createNodeCmd -tagName "version" -jsonType NONE elementNode keyVersion
-
 
57
	dom createNodeCmd -jsonType STRING textNode valueString
55
}] } {
58
}] } {
56
	crash "Failed to load tDOM"
59
	crash "Failed to load tDOM"
57
}
60
}
58
 
61
 
59
if { [catch {
62
if { [catch {
Line 203... Line 206...
203
	lappend toc "-$data"
206
	lappend toc "-$data"
204
}
207
}
205
 
208
 
206
if { [catch {
209
if { [catch {
207
	set path "[regsub -all {/+} "$env(PATH_INFO)" "/"]"
210
	set path "[regsub -all {/+} "$env(PATH_INFO)" "/"]"
-
 
211
	if { [regexp {^/rpc(/.*)?$} "$path"] } {
-
 
212
		rputs "Content-Type: application/json"
-
 
213
	} else {
208
	rputs "Content-Type: text/html"
214
		rputs "Content-Type: text/html"
-
 
215
	}
209
	if { "$path" == "/" } {
216
	if { "$path" == "/" } {
210
		add_toc "Tcl Information"
217
		add_toc "Tcl Information"
211
		tputs	"<table border=\"0\">"
218
		tputs	"<table border=\"0\">"
212
		tputs	"	<tr>"
219
		tputs	"	<tr>"
213
		tputs	"		<th>"
220
		tputs	"		<th>"
Line 255... Line 262...
255
 
262
 
256
		rputs ""
263
		rputs ""
257
		start_html "Main" 1
264
		start_html "Main" 1
258
		rputs "$content"
265
		rputs "$content"
259
		end_html 1
266
		end_html 1
260
	} elseif { [regexp {^/rpc.*$} "$path"] } {
267
	} elseif { [regexp {^/rpc(/.*)?$} "$path"] } {
-
 
268
		rputs ""
-
 
269
		regexp {^/rpc(/.*)?$} "$path" -> api
-
 
270
		set doc [dom createDocumentNode]
-
 
271
		set root $doc
-
 
272
		if { "$api" == "" || "$api" == "/" } {
-
 
273
			$root appendFromScript {
-
 
274
				keyVersion {valueString "$KOAKUMA_VERSION"}
-
 
275
			}
-
 
276
			rputs "[$doc asJSON]"
-
 
277
		}
261
	} elseif { [regexp {^/project/[^/]+.*$} "$path"] } {
278
	} elseif { [regexp {^/project/[^/]+.*$} "$path"] } {
262
		regexp {^/project/([^/]+).*$} "$path" -> projname
279
		regexp {^/project/([^/]+).*$} "$path" -> projname
263
		open_projects
280
		open_projects
264
		set has_project [project_exists "$projname"]
281
		set has_project [project_exists "$projname"]
265
		close_projects
282
		close_projects