1、修复导出文档后缀错误的BUG

2、增加自定义导出文档的头部
pull/219/head
Minho 2018-01-30 13:21:27 +08:00
parent 9be6d9d437
commit 5f13063346
3 changed files with 20 additions and 10 deletions

View File

@ -123,18 +123,19 @@ func (c *BookController) SaveBook() {
c.JsonResult(6002, err.Error())
}
book_name := strings.TrimSpace(c.GetString("book_name"))
bookName := strings.TrimSpace(c.GetString("book_name"))
description := strings.TrimSpace(c.GetString("description", ""))
comment_status := c.GetString("comment_status")
commentStatus := c.GetString("comment_status")
tag := strings.TrimSpace(c.GetString("label"))
editor := strings.TrimSpace(c.GetString("editor"))
auto_release := strings.TrimSpace(c.GetString("auto_release")) == "on"
autoRelease := strings.TrimSpace(c.GetString("auto_release")) == "on"
publisher := strings.TrimSpace(c.GetString("publisher"))
if strings.Count(description, "") > 500 {
c.JsonResult(6004, "项目描述不能大于500字")
}
if comment_status != "open" && comment_status != "closed" && comment_status != "group_only" && comment_status != "registered_only" {
comment_status = "closed"
if commentStatus != "open" && commentStatus != "closed" && commentStatus != "group_only" && commentStatus != "registered_only" {
commentStatus = "closed"
}
if tag != "" {
tags := strings.Split(tag, ",")
@ -146,12 +147,13 @@ func (c *BookController) SaveBook() {
editor = "markdown"
}
book.BookName = book_name
book.BookName = bookName
book.Description = description
book.CommentStatus = comment_status
book.CommentStatus = commentStatus
book.Publisher = publisher
book.Label = tag
book.Editor = editor
if auto_release {
if autoRelease {
book.AutoRelease = 1
} else {
book.AutoRelease = 0
@ -160,9 +162,9 @@ func (c *BookController) SaveBook() {
if err := book.Update(); err != nil {
c.JsonResult(6006, "保存失败")
}
bookResult.BookName = book_name
bookResult.BookName = bookName
bookResult.Description = description
bookResult.CommentStatus = comment_status
bookResult.CommentStatus = commentStatus
bookResult.Label = tag
c.JsonResult(0, "ok", bookResult)
}

View File

@ -263,6 +263,9 @@ func (m *BookResult) Converter(sessionId string) (ConvertBookResult, error) {
Toc: tocList,
More: []string{},
}
if m.Publisher != "" {
ebookConfig.Footer = "\"<p style='color:#8E8E8E;font-size:12px;'>本文档由 <span style='text-decoration:none;color:#1abc9c;font-weight:bold;'>"+ m.Publisher +"</span> 生成<span style='float:right'>- _PAGENUM_ -</span></p>\""
}
if tempOutputPath, err = filepath.Abs(tempOutputPath); err != nil {
beego.Error("导出目录配置错误:" + err.Error())

View File

@ -63,6 +63,11 @@
<label>标识</label>
<input type="text" class="form-control" value="{{.BaseUrl}}{{urlfor "DocumentController.Index" ":key" .Model.Identify}}" placeholder="项目唯一标识" disabled>
</div>
<div class="form-group">
<label>公司标识</label>
<input type="text" class="form-control" name="publisher" value="{{.Model.publisher}}" placeholder="公司名称" disabled>
<p class="text">导出文档时的标识</p>
</div>
<div class="form-group">
<label>描述</label>
<textarea rows="3" class="form-control" name="description" style="height: 90px" placeholder="项目描述">{{.Model.Description}}</textarea>