From 8e367d799ab88668894cda6b0f75fe4ca3466e0e Mon Sep 17 00:00:00 2001 From: lifei6671 Date: Tue, 25 Sep 2018 18:52:18 +0800 Subject: [PATCH] =?UTF-8?q?perf:=E4=BC=98=E5=8C=96=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E6=95=88=E6=9E=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- models/BookResult.go | 31 ++++++++++++++----------------- static/css/export.css | 14 ++++++++++++-- views/document/export.tpl | 6 +++--- 3 files changed, 29 insertions(+), 22 deletions(-) diff --git a/models/BookResult.go b/models/BookResult.go index cec68830..b4cd72fd 100644 --- a/models/BookResult.go +++ b/models/BookResult.go @@ -356,7 +356,7 @@ func (m *BookResult) Converter(sessionId string) (ConvertBookResult, error) { name := strconv.Itoa(item.DocumentId) fpath := filepath.Join(tempOutputPath, name+".html") - f, err := os.OpenFile(fpath, os.O_CREATE|os.O_RDWR, 0777) + f, err := os.OpenFile(fpath, os.O_CREATE|os.O_RDWR, 0755) if err != nil { return convertBookResult, err } @@ -388,9 +388,6 @@ func (m *BookResult) Converter(sessionId string) (ConvertBookResult, error) { beego.Error("复制图片失败 -> ", err, src) return } - //if ff, e := ioutil.ReadFile(spath); e == nil { - // encodeString = base64.StdEncoding.EncodeToString(ff) - //} } else { client := &http.Client{} @@ -420,15 +417,13 @@ func (m *BookResult) Converter(sessionId string) (ConvertBookResult, error) { } } } - //if encodeString != "" { - // src = "data:image/" + strings.TrimPrefix(filepath.Ext(src),".") + ";base64," + encodeString - // - // contentSelection.SetAttr("src", src) - //} - contentSelection.SetAttr("src", dstSrcString) } }) + //移除文档底部的更新信息 + if selection := doc.Find("div.wiki-bottom").First(); selection.Size() > 0 { + selection.Remove() + } html, err = doc.Html() if err != nil { @@ -448,17 +443,19 @@ func (m *BookResult) Converter(sessionId string) (ConvertBookResult, error) { if err := filetil.CopyFile(filepath.Join(conf.WorkingDirectory, "static", "editor.md", "css", "editormd.preview.css"), filepath.Join(tempOutputPath, "styles", "editor.md", "css", "editormd.preview.css")); err != nil { beego.Error("复制CSS样式出错 -> static/editor.md/css/editormd.preview.css", err) } - if err := filetil.CopyFile(filepath.Join(conf.WorkingDirectory, "static", "prettify", "themes", "prettify.css"), filepath.Join(tempOutputPath, "styles", "prettify", "themes", "prettify.css")); err != nil { - beego.Error("复制CSS样式出错 -> static/prettify/themes/prettify.css", err) - } + if err := filetil.CopyFile(filepath.Join(conf.WorkingDirectory, "static", "css", "markdown.preview.css"), filepath.Join(tempOutputPath, "styles", "css", "markdown.preview.css")); err != nil { beego.Error("复制CSS样式出错 -> static/css/markdown.preview.css", err) } - if err := filetil.CopyFile(filepath.Join(conf.WorkingDirectory, "static", "highlight", "styles", "vs.css"), filepath.Join(tempOutputPath, "styles", "highlight", "styles", "vs.css")); err != nil { - beego.Error("复制CSS样式出错 -> static/highlight/styles/vs.css", err) + if err := filetil.CopyFile(filepath.Join(conf.WorkingDirectory, "static","editor.md","lib", "highlight", "styles", "github.css"), filepath.Join(tempOutputPath, "styles","css", "github.css")); err != nil { + beego.Error("复制CSS样式出错 -> static/editor.md/lib/highlight/styles/github.css", err) } - if err := filetil.CopyFile(filepath.Join(conf.WorkingDirectory, "static", "katex", "katex.min.css"), filepath.Join(tempOutputPath, "styles", "katex", "katex.min.css")); err != nil { - beego.Error("复制CSS样式出错 -> static/katex/katex.min.css", err) + + if err := filetil.CopyDir(filepath.Join(conf.WorkingDirectory,"static","font-awesome"), filepath.Join(tempOutputPath,"styles","font-awesome")); err != nil { + beego.Error("复制CSS样式出错 -> static/font-awesome", err) + } + if err := filetil.CopyFile(filepath.Join(conf.WorkingDirectory, "static","editor.md","lib","mermaid","mermaid.css"), filepath.Join(tempOutputPath, "styles", "css", "mermaid.css")); err != nil { + beego.Error("复制CSS样式出错 -> static/editor.md/lib/mermaid/mermaid.css", err) } eBookConverter := &converter.Converter{ diff --git a/static/css/export.css b/static/css/export.css index f628d445..63bd2397 100644 --- a/static/css/export.css +++ b/static/css/export.css @@ -9,9 +9,19 @@ body{ .editormd-preview-container{ padding: 0 !important; } - +.markdown-body{ + -webkit-backface-visibility: inherit !important; + backface-visibility: inherit !important; +} .markdown-body pre{ max-height: none !important; white-space: pre-wrap !important; word-wrap: break-word !important; -} \ No newline at end of file +} +.markdown-toc{ + display: none !important; + width: 0 !important; +} +.article-body .markdown-article{ + margin-right: 0 !important; +} diff --git a/views/document/export.tpl b/views/document/export.tpl index d2b7df0a..ded5fe2d 100644 --- a/views/document/export.tpl +++ b/views/document/export.tpl @@ -7,11 +7,11 @@ {{.Model.BookName}} - Powered by MinDoc - - - + + +