diff --git a/scripts/generate-templates.go b/scripts/generate-templates.go index f88bc61..772a713 100644 --- a/scripts/generate-templates.go +++ b/scripts/generate-templates.go @@ -17,7 +17,7 @@ func main() { out.Write([]byte("package templates\n\nvar Get = map[string]string{\n")) for _, fileInfo := range files { if strings.HasSuffix(fileInfo.Name(), ".html") { - out.Write([]byte(strings.TrimSuffix(fileInfo.Name(), ".html") + ": `")) + out.Write([]byte("\"" + strings.TrimSuffix(fileInfo.Name(), ".html") + "\"" + ": `")) file, _ := os.Open(path.Join(templatesDir, fileInfo.Name())) io.Copy(out, file) out.Write([]byte("`,\n")) diff --git a/server/web-preview.go b/server/web-preview.go index 042220f..1d5cab6 100644 --- a/server/web-preview.go +++ b/server/web-preview.go @@ -347,14 +347,27 @@ func (serv *UploadServer) handleWebPreview(c *gin.Context) { item.wg.Wait() // Prepare html and send it to the client - style := "display: flex; justify-content: center;" + style := ` + body { + display: flex; justify-content: center; + }` if !center { - style = "" + style = ` + body { + overflow: hidden; + } + #kiwi-embed-container { + position: absolute; + top: 0; + left: 0; + bottom: 0; + overflow: auto; + }` } templateLock.RLock() htmlData := strings.Replace(template, "{{body.html}}", item.html, -1) templateLock.RUnlock() - htmlData = strings.Replace(htmlData, "/* style.body */", style, -1) + htmlData = strings.Replace(htmlData, "/* style.extras */", style, -1) c.Data(http.StatusOK, "text/html; charset=utf-8", []byte(htmlData)) } diff --git a/templates/embed.html b/templates/embed.html index 12c5bcb..73ca15a 100644 --- a/templates/embed.html +++ b/templates/embed.html @@ -6,12 +6,10 @@ margin: 0; padding: 0; } - body { - /* style.body */ - } .kiwi-embed-image { display: block; } + /* style.extras */