MCPcopy
hub / github.com/edoardottt/cariddi / AppendOutputToHTML

Function AppendOutputToHTML

pkg/output/html.go:156–189  ·  view source on GitHub ↗

AppendOutputToHTML appends the output to html file.

(output string, status string, filename string, isLink bool)

Source from the content-addressed store, hash-verified

154
155// AppendOutputToHTML appends the output to html file.
156func AppendOutputToHTML(output string, status string, filename string, isLink bool) {
157 file, err := os.OpenFile(filename, os.O_APPEND|os.O_WRONLY, fileUtils.Permission0644)
158 if err != nil {
159 log.Println(err)
160 os.Exit(1)
161 }
162
163 if isLink {
164 var statusColor string
165
166 if status != "" {
167 if string(status[0]) == "2" || string(status[0]) == "3" {
168 statusColor = "<p style='color:green;display:inline'>" + html.EscapeString(status) + "</p>"
169 } else {
170 statusColor = "<p style='color:red;display:inline'>" + html.EscapeString(status) + "</p>"
171 }
172 } else {
173 statusColor = status
174 }
175
176 if _, err := file.WriteString("<li><a target='_blank' href='" +
177 html.EscapeString(output) + "'>" +
178 html.EscapeString(output) +
179 "</a> " + html.EscapeString(statusColor) + "</li>\n"); err != nil {
180 log.Fatal(err)
181 }
182 } else {
183 if _, err := file.WriteString("<li>" + html.EscapeString(output) + "</li>\n"); err != nil {
184 log.Fatal(err)
185 }
186 }
187
188 file.Close()
189}
190
191// HeaderHTML appends the html header.
192func HeaderHTML(header string, filename string) {

Callers 1

HTMLOutputFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected