AppendOutputToHTML appends the output to html file.
(output string, status string, filename string, isLink bool)
| 154 | |
| 155 | // AppendOutputToHTML appends the output to html file. |
| 156 | func 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. |
| 192 | func HeaderHTML(header string, filename string) { |