forked from mirror/gitea
Render plain text README.txt monospaced (#2721)
Signed-off-by: Jonas Franz <info@jonasfranz.software>
This commit is contained in:
parent
33647aa43b
commit
f4190f8df8
File diff suppressed because one or more lines are too long
@ -270,6 +270,10 @@
|
||||
}
|
||||
}
|
||||
|
||||
.plain-text {
|
||||
padding: 1em 2em 1em 2em;
|
||||
}
|
||||
|
||||
.code-view {
|
||||
* {
|
||||
font-size: 12px;
|
||||
|
@ -93,10 +93,11 @@ func renderDirectory(ctx *context.Context, treeLink string) {
|
||||
if isTextFile {
|
||||
d, _ := ioutil.ReadAll(dataRc)
|
||||
buf = append(buf, d...)
|
||||
ctx.Data["IsRenderedHTML"] = true
|
||||
if markup.Type(readmeFile.Name()) != "" {
|
||||
ctx.Data["IsMarkup"] = true
|
||||
ctx.Data["FileContent"] = string(markup.Render(readmeFile.Name(), buf, treeLink, ctx.Repo.Repository.ComposeMetas()))
|
||||
} else {
|
||||
ctx.Data["IsRenderedHTML"] = true
|
||||
ctx.Data["FileContent"] = string(bytes.Replace(buf, []byte("\n"), []byte(`<br>`), -1))
|
||||
}
|
||||
}
|
||||
@ -194,7 +195,7 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st
|
||||
readmeExist := markup.IsReadmeFile(blob.Name())
|
||||
ctx.Data["ReadmeExist"] = readmeExist
|
||||
if markup.Type(blob.Name()) != "" {
|
||||
ctx.Data["IsRenderedHTML"] = true
|
||||
ctx.Data["IsMarkup"] = true
|
||||
ctx.Data["FileContent"] = string(markup.Render(blob.Name(), buf, path.Dir(treeLink), ctx.Repo.Repository.ComposeMetas()))
|
||||
} else if readmeExist {
|
||||
ctx.Data["IsRenderedHTML"] = true
|
||||
|
@ -36,9 +36,11 @@
|
||||
{{end}}
|
||||
</h4>
|
||||
<div class="ui attached table segment">
|
||||
<div class="file-view {{if .IsRenderedHTML}}markdown{{else if .IsTextFile}}code-view{{end}} has-emoji">
|
||||
{{if .IsRenderedHTML}}
|
||||
<div class="file-view {{if .IsMarkup}}markdown{{else if .IsRenderedHTML}}plain-text{{else if .IsTextFile}}code-view{{end}} has-emoji">
|
||||
{{if .IsMarkup}}
|
||||
{{if .FileContent}}{{.FileContent | Str2html}}{{end}}
|
||||
{{else if .IsRenderedHTML}}
|
||||
<pre>{{if .FileContent}}{{.FileContent | Str2html}}{{end}}</pre>
|
||||
{{else if not .IsTextFile}}
|
||||
<div class="view-raw ui center">
|
||||
{{if .IsImageFile}}
|
||||
|
Loading…
Reference in New Issue
Block a user