-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreport.go
65 lines (59 loc) · 1.61 KB
/
report.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
62
63
64
65
package main
import (
"html/template"
"os"
)
type HTMLData struct {
Groups [][]string
}
func generateHTMLReport(similarGroups [][]string, outputFile string) error {
tmpl := `
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Similar Images Report</title>
<style>
body { font-family: Arial, sans-serif; line-height: 1.6; padding: 20px; }
h1 { color: #333; }
.group { margin-bottom: 40px; border: 1px solid #ccc; padding: 20px; }
.group h2 { color: #666; }
.images { display: flex; flex-wrap: wrap; gap: 10px; }
.image-container { max-width: 200px; }
img { max-width: 100%; height: auto; border: 1px solid #ddd; }
.path { font-size: 0.8em; word-break: break-all; margin-top: 5px; }
</style>
</head>
<body>
<h1>Similar Images Report</h1>
{{range $index, $group := .Groups}}
<div class="group">
<h2>Group {{add $index 1}}</h2>
<div class="images">
{{range $group}}
<div class="image-container">
<img src="file://{{.}}" alt="Similar Image">
<div class="path">{{.}}</div>
</div>
{{end}}
</div>
</div>
{{end}}
</body>
</html>
`
t, err := template.New("report").Funcs(template.FuncMap{
"add": func(a, b int) int { return a + b },
}).Parse(tmpl)
if err != nil {
return err
}
file, err := os.Create(outputFile)
if err != nil {
return err
}
defer file.Close()
data := HTMLData{Groups: similarGroups}
return t.Execute(file, data)
}