Skip to content
1 change: 1 addition & 0 deletions routers/repo/view.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ func renderFile(ctx *context.Context, entry *git.TreeEntry, treeLink, rawLink st
ctx.Data["ReadmeExist"] = readmeExist
if markup.Type(blob.Name()) != "" {
ctx.Data["IsRenderedHTML"] = true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ctx.Data["IsRenderedHTML"] = true can be removed (check other places, same as markup.Type) if ctx.Data["IsMarkup"] = true is set, then you can remove nested if from template and use else if.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where should I remove the if in template? (Could you provide a Line?)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ctx.Data["IsMarkup"] = true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please look for other places with markup.Type check. I think it (ctx.Data["IsMarkup"] = true) should be added also there (I found https://github.com/JonasFranzDEV/gitea/blob/5aca5a8a3d618630d10272445badcbea5381683f/routers/repo/view.go#L97).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

ctx.Data["FileContent"] = string(markup.Render(blob.Name(), buf, path.Dir(treeLink), ctx.Repo.Repository.ComposeMetas()))
} else if readmeExist {
ctx.Data["IsRenderedHTML"] = true
Expand Down
6 changes: 5 additions & 1 deletion templates/repo/view_file.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,11 @@
<div class="ui attached table segment">
<div class="file-view {{if .IsRenderedHTML}}markdown{{else if .IsTextFile}}code-view{{end}} has-emoji">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add here {{.IsMarkup}}markdown{{else}}plain-text{{end}} in place of markdown and in _repository.less file after line 271 add style:

.plain-text { padding: 1em 2em 1em 2em;	}

I think this way looks much better:
attels

Copy link
Member Author

@jonasfranz jonasfranz Oct 16, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks actually like this:

screenshot2

Is this still okay? I've left the <pre> stuff in place.

EDIT:
It looks fine Chrome (I've used safari). Maybe it is a cache problem in Safari.

Copy link
Member

@lafriks lafriks Oct 16, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be fine in all, try cleaning cache (also did you do make generate-stylesheets?)

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also did you do make generate-stylesheets?

Yes

{{if .IsRenderedHTML}}
{{if .FileContent}}{{.FileContent | Str2html}}{{end}}
{{if .IsMarkup}}
{{if .FileContent}}{{.FileContent | Str2html}}{{end}}
{{else}}
<pre>{{if .FileContent}}{{.FileContent | Str2html}}{{end}}</pre>
Copy link
Member

@Morlinest Morlinest Oct 16, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is rly Str2html needed here?
<pre> should be inside {{if .FileContent}} block.

Edit: Probably it's safe to always use Str2html

{{end}}
{{else if not .IsTextFile}}
<div class="view-raw ui center">
{{if .IsImageFile}}
Expand Down