-
Notifications
You must be signed in to change notification settings - Fork 1
/
templates.go
61 lines (54 loc) · 1.62 KB
/
templates.go
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
package main
import (
"html/template"
)
const inputTemplateStr string = `
<!DOCTYPE HTML>
<html>
<head>
<title>Model Input</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
</head>
<body>
<div class="container-fluid">
<h3>Model Input</h3>
<form action="/solve/" method="POST">
<div><label>Input your Zimpl model here:</label></div>
<div style="font-family:monospace;">
<textarea name="model" rows="24" class="form-control">{{.Model}}</textarea>
</div>
<button type="submit" class="btn btn-default">Solve</button>
</form>
</div>
</body>
</html>
`
var inputTemplate = template.Must(template.New("input").Parse(inputTemplateStr))
const resultTemplateStr string = `
<!DOCTYPE HTML>
<html>
<head>
<title>Solver Output</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
</head>
<body>
<div class="container-fluid">
<h3>Model</h3>
<div><pre>{{.Model}}</pre></div>
<form action="/input/" method="POST">
<input type="hidden" name="prefilled" value="{{.Model}}">
<button type="submit" class="btn btn-default">Edit</button>
</form>
{{if .Output}}
<h3>Solution Values</h3>
<div><pre>{{.Solution}}</pre></div>
<h3>Solver Output</h3>
<div><pre>{{.Output}}</pre></div>
{{else}}
<p>Solving not complete yet. Please retry later.</p>
{{end}}
</div>
</body>
</html>
`
var resultTemplate = template.Must(template.New("input").Parse(resultTemplateStr))