Render plain text README.txt monospaced (#2721)

Signed-off-by: Jonas Franz <info@jonasfranz.software>
tokarchuk/v1.17
Jonas Franz 7 years ago committed by Lauris BH
parent 33647aa43b
commit f4190f8df8
  1. 2
      public/css/index.css
  2. 4
      public/less/_repository.less
  3. 5
      routers/repo/view.go
  4. 6
      templates/repo/view_file.tmpl

File diff suppressed because one or more lines are too long

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

@ -93,10 +93,11 @@ func renderDirectory(ctx *context.Context, treeLink string) {
if isTextFile { if isTextFile {
d, _ := ioutil.ReadAll(dataRc) d, _ := ioutil.ReadAll(dataRc)
buf = append(buf, d...) buf = append(buf, d...)
ctx.Data["IsRenderedHTML"] = true
if markup.Type(readmeFile.Name()) != "" { if markup.Type(readmeFile.Name()) != "" {
ctx.Data["IsMarkup"] = true
ctx.Data["FileContent"] = string(markup.Render(readmeFile.Name(), buf, treeLink, ctx.Repo.Repository.ComposeMetas())) ctx.Data["FileContent"] = string(markup.Render(readmeFile.Name(), buf, treeLink, ctx.Repo.Repository.ComposeMetas()))
} else { } else {
ctx.Data["IsRenderedHTML"] = true
ctx.Data["FileContent"] = string(bytes.Replace(buf, []byte("\n"), []byte(`<br>`), -1)) 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()) readmeExist := markup.IsReadmeFile(blob.Name())
ctx.Data["ReadmeExist"] = readmeExist ctx.Data["ReadmeExist"] = readmeExist
if markup.Type(blob.Name()) != "" { 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())) ctx.Data["FileContent"] = string(markup.Render(blob.Name(), buf, path.Dir(treeLink), ctx.Repo.Repository.ComposeMetas()))
} else if readmeExist { } else if readmeExist {
ctx.Data["IsRenderedHTML"] = true ctx.Data["IsRenderedHTML"] = true

@ -36,9 +36,11 @@
{{end}} {{end}}
</h4> </h4>
<div class="ui attached table segment"> <div class="ui attached table segment">
<div class="file-view {{if .IsRenderedHTML}}markdown{{else if .IsTextFile}}code-view{{end}} has-emoji"> <div class="file-view {{if .IsMarkup}}markdown{{else if .IsRenderedHTML}}plain-text{{else if .IsTextFile}}code-view{{end}} has-emoji">
{{if .IsRenderedHTML}} {{if .IsMarkup}}
{{if .FileContent}}{{.FileContent | Str2html}}{{end}} {{if .FileContent}}{{.FileContent | Str2html}}{{end}}
{{else if .IsRenderedHTML}}
<pre>{{if .FileContent}}{{.FileContent | Str2html}}{{end}}</pre>
{{else if not .IsTextFile}} {{else if not .IsTextFile}}
<div class="view-raw ui center"> <div class="view-raw ui center">
{{if .IsImageFile}} {{if .IsImageFile}}

Loading…
Cancel
Save