Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

文档页无法查看附件信息,找不到任何信息 #850

Closed
Macfee opened this issue Apr 19, 2023 · 5 comments · Fixed by #866
Closed

文档页无法查看附件信息,找不到任何信息 #850

Macfee opened this issue Apr 19, 2023 · 5 comments · Fixed by #866

Comments

@Macfee
Copy link

Macfee commented Apr 19, 2023

请按照一下格式提交issue,谢谢!

  1. 你当前使用的是哪个版本的 MinDoc(godoc_linux_amd64 version)?

最新版本代码构建的Docker运行环境

  1. 你当前使用的是什么操作系统?

Docker

  1. 你是如何操作的?

使用最新的包,全新部署

  1. 你期望得到什么结果?

能查看附件

  1. 当前遇到的是什么结果?

详情页无法看到附件

@Mrzhuhanxin
Copy link

@Macfee 需要在详情页中有内容才可以看到附件

@Macfee
Copy link
Author

Macfee commented May 11, 2023

详情页面无法看到附件,我下载了最新的源码,编译运行,测试下来也是无法看到附件。

@Mrzhuhanxin
Copy link

你在详情页必须有内容才能看到,什么都不写是看不到的

@Macfee
Copy link
Author

Macfee commented May 19, 2023

谢谢你的回复,详情页确实有内容,而且附件也不只一个。我用了主干分支的代码进行打包的。在阅读的时候,无法看到附件。我追踪了代码,beego我不熟悉。在 models/DocumentModel.go 里:

//处理附件
if selector := docQuery.Find("div.attach-list").First(); selector.Size() <= 0 {
        //处理附件
        attachList, err := NewAttachment().FindListByDocumentId(item.DocumentId)
        if err == nil && len(attachList) > 0 {
                content := bytes.NewBufferString("<div class=\"attach-list\"><strong>" + i18n.Tr(item.Lang, "doc.attachment") + "</strong><ul>")
                for _, attach := range attachList {
                        if strings.HasPrefix(attach.HttpPath, "/") {
                                attach.HttpPath = strings.TrimSuffix(conf.BaseUrl, "/") + attach.HttpPath
                        }
                        li := fmt.Sprintf("<li><a href=\"%s\" target=\"_blank\" title=\"%s\">%s</a></li>", attach.HttpPath, attach.FileName, attach.FileName)
                        content.WriteString(li)
                }
                content.WriteString("</ul></div>")
                if docQuery == nil {
                        docQuery, err = goquery.NewDocumentFromReader(content)
                } else {
                        if selector := docQuery.Find("div.wiki-bottom").First(); selector.Size() > 0 {
                                selector.BeforeHtml(content.String())
                        } else if selector := docQuery.Find("div.markdown-article").First(); selector.Size() > 0 {
                                selector.AppendHtml(content.String())
                        } else if selector := docQuery.Find("article.markdown-article-inner").First(); selector.Size() > 0 {
                                selector.AppendHtml(content.String())
                        }
                }
        }

}
`
这里面的writeString根本没生效,导致不仅附件没有,作者信息,更新时间都没有

@Go-Go-Farther
Copy link
Contributor

你这个不能下载附件的问题是不是:

  1. 使用的是项目,不是文章;
  2. 项目使用的编辑器不是markdown,而是其他的两种;
  3. 使用markdown应该是没有问题的。

Go-Go-Farther added a commit to Go-Go-Farther/mindoc that referenced this issue Jun 6, 2023
Go-Go-Farther added a commit to Go-Go-Farther/mindoc that referenced this issue Jun 6, 2023
gsw945 pushed a commit that referenced this issue Jun 7, 2023
fixes #850
1. 修复文档为空附件不能下载
2. 修复文档设置为非markdown编辑附件不能下载
3. 兼容现存问题文档
4. 非markdown编辑文档,阅读时增加文档修改信息
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants