Add init support of orgmode document type on file view and readme (#2525)
* add init support of orgmode document type on file view and readme * fix imports * fix imports and readmeExist * fix imports order * fix format * remove unnecessary convert
This commit is contained in:
parent
66bc0ac251
commit
0d80af649a
21 changed files with 1103 additions and 66 deletions
|
@ -8,8 +8,8 @@ import (
|
|||
api "code.gitea.io/sdk/gitea"
|
||||
|
||||
"code.gitea.io/gitea/modules/context"
|
||||
"code.gitea.io/gitea/modules/markdown"
|
||||
"code.gitea.io/gitea/modules/markup"
|
||||
"code.gitea.io/gitea/modules/markup/markdown"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
)
|
||||
|
||||
|
|
|
@ -24,7 +24,7 @@ import (
|
|||
"code.gitea.io/gitea/modules/context"
|
||||
"code.gitea.io/gitea/modules/indexer"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"code.gitea.io/gitea/modules/markdown"
|
||||
"code.gitea.io/gitea/modules/markup/markdown"
|
||||
"code.gitea.io/gitea/modules/notification"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
"code.gitea.io/gitea/modules/util"
|
||||
|
|
|
@ -12,7 +12,7 @@ import (
|
|||
"code.gitea.io/gitea/modules/base"
|
||||
"code.gitea.io/gitea/modules/context"
|
||||
"code.gitea.io/gitea/modules/log"
|
||||
"code.gitea.io/gitea/modules/markdown"
|
||||
"code.gitea.io/gitea/modules/markup/markdown"
|
||||
"code.gitea.io/gitea/modules/setting"
|
||||
|
||||
"github.com/Unknwon/paginater"
|
||||
|
|
|
@ -95,11 +95,11 @@ func renderDirectory(ctx *context.Context, treeLink string) {
|
|||
buf = append(buf, d...)
|
||||
newbuf := markup.Render(readmeFile.Name(), buf, treeLink, ctx.Repo.Repository.ComposeMetas())
|
||||
if newbuf != nil {
|
||||
ctx.Data["IsMarkdown"] = true
|
||||
ctx.Data["IsMarkup"] = true
|
||||
} else {
|
||||
// FIXME This is the only way to show non-markdown files
|
||||
// instead of a broken "View Raw" link
|
||||
ctx.Data["IsMarkdown"] = true
|
||||
ctx.Data["IsMarkup"] = false
|
||||
newbuf = bytes.Replace(buf, []byte("\n"), []byte(`<br>`), -1)
|
||||
}
|
||||
ctx.Data["FileContent"] = string(newbuf)
|
||||
|
@ -197,10 +197,8 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st
|
|||
|
||||
tp := markup.Type(blob.Name())
|
||||
isSupportedMarkup := tp != ""
|
||||
// FIXME: currently set IsMarkdown for compatible
|
||||
ctx.Data["IsMarkdown"] = isSupportedMarkup
|
||||
|
||||
readmeExist := isSupportedMarkup || markup.IsReadmeFile(blob.Name())
|
||||
ctx.Data["IsMarkup"] = isSupportedMarkup
|
||||
readmeExist := markup.IsReadmeFile(blob.Name())
|
||||
ctx.Data["ReadmeExist"] = readmeExist
|
||||
if readmeExist && isSupportedMarkup {
|
||||
ctx.Data["FileContent"] = string(markup.Render(blob.Name(), buf, path.Dir(treeLink), ctx.Repo.Repository.ComposeMetas()))
|
||||
|
|
|
@ -18,8 +18,8 @@ import (
|
|||
"code.gitea.io/gitea/modules/auth"
|
||||
"code.gitea.io/gitea/modules/base"
|
||||
"code.gitea.io/gitea/modules/context"
|
||||
"code.gitea.io/gitea/modules/markdown"
|
||||
"code.gitea.io/gitea/modules/markup"
|
||||
"code.gitea.io/gitea/modules/markup/markdown"
|
||||
)
|
||||
|
||||
const (
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue