Skip to content

Commit 0168755

Browse files
committed
Fix template scrollbars
1 parent 69dd56e commit 0168755

File tree

4 files changed

+20
-11
lines changed

4 files changed

+20
-11
lines changed

scripts/generate-templates.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ func main() {
1717
out.Write([]byte("package templates\n\nvar Get = map[string]string{\n"))
1818
for _, fileInfo := range files {
1919
if strings.HasSuffix(fileInfo.Name(), ".html") {
20-
out.Write([]byte(strings.TrimSuffix(fileInfo.Name(), ".html") + ": `"))
20+
out.Write([]byte("\"" + strings.TrimSuffix(fileInfo.Name(), ".html") + "\"" + ": `"))
2121
file, _ := os.Open(path.Join(templatesDir, fileInfo.Name()))
2222
io.Copy(out, file)
2323
out.Write([]byte("`,\n"))

server/web-preview.go

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -347,14 +347,27 @@ func (serv *UploadServer) handleWebPreview(c *gin.Context) {
347347
item.wg.Wait()
348348

349349
// Prepare html and send it to the client
350-
style := "display: flex; justify-content: center;"
350+
style := `
351+
body {
352+
display: flex; justify-content: center;
353+
}`
351354
if !center {
352-
style = ""
355+
style = `
356+
body {
357+
overflow: hidden;
358+
}
359+
#kiwi-embed-container {
360+
position: absolute;
361+
top: 0;
362+
left: 0;
363+
bottom: 0;
364+
overflow: auto;
365+
}`
353366
}
354367
templateLock.RLock()
355368
htmlData := strings.Replace(template, "{{body.html}}", item.html, -1)
356369
templateLock.RUnlock()
357-
htmlData = strings.Replace(htmlData, "/* style.body */", style, -1)
370+
htmlData = strings.Replace(htmlData, "/* style.extras */", style, -1)
358371
c.Data(http.StatusOK, "text/html; charset=utf-8", []byte(htmlData))
359372
}
360373

templates/embed.html

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,10 @@
66
margin: 0;
77
padding: 0;
88
}
9-
body {
10-
/* style.body */
11-
}
129
.kiwi-embed-image {
1310
display: block;
1411
}
12+
/* style.extras */
1513
</style>
1614
<script>
1715
let last_width = 0;

templates/templates.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
package templates
22

33
var Get = map[string]string{
4-
"Embed": `<!DOCTYPE html>
4+
"Embed": `<!DOCTYPE html>
55
<html>
66
<head>
77
<style>
88
html, body {
99
margin: 0;
1010
padding: 0;
1111
}
12-
body {
13-
/* style.body */
14-
}
1512
.kiwi-embed-image {
1613
display: block;
1714
}
15+
/* style.extras */
1816
</style>
1917
<script>
2018
let last_width = 0;

0 commit comments

Comments
 (0)