Browse Source

Render plain text README.txt monospaced (#2721)

Signed-off-by: Jonas Franz <info@jonasfranz.software>
for-closed-social
Jonas Franz 7 years ago
committed by Lauris BH
parent
commit
f4190f8df8
4 changed files with 12 additions and 5 deletions
  1. +1
    -1
      public/css/index.css
  2. +4
    -0
      public/less/_repository.less
  3. +3
    -2
      routers/repo/view.go
  4. +4
    -2
      templates/repo/view_file.tmpl

+ 1
- 1
public/css/index.css
File diff suppressed because it is too large
View File


+ 4
- 0
public/less/_repository.less View File

@ -270,6 +270,10 @@
}
}
.plain-text {
padding: 1em 2em 1em 2em;
}
.code-view {
* {
font-size: 12px;

+ 3
- 2
routers/repo/view.go View File

@ -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

+ 4
- 2
templates/repo/view_file.tmpl View File

@ -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…
Cancel
Save