Skip to content

Render plain text README.txt monospaced #2721

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Oct 16, 2017

Conversation

jonasfranz
Copy link
Member

Fixes #2718

Will add <pre>TEXT</pre> at the readme page.

Screenshot

screenshot

@codecov-io
Copy link

codecov-io commented Oct 16, 2017

Codecov Report

Merging #2721 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #2721   +/-   ##
=======================================
  Coverage   26.96%   26.96%           
=======================================
  Files          87       87           
  Lines       17297    17297           
=======================================
  Hits         4664     4664           
  Misses      11953    11953           
  Partials      680      680

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 33647aa...030ae40. Read the comment docs.

@tboerger tboerger added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Oct 16, 2017
@Morlinest
Copy link
Member

This will break markdown rendering.

@jonasfranz
Copy link
Member Author

@Morlinest Why? It is not used when markup is rendered. (See acaf4b3)

@Morlinest
Copy link
Member

@JonasFranzDEV I was checking your first version (commit). Will look at it again.

ctx.Data["FileContent"] = string(markup.Render(blob.Name(), buf, path.Dir(treeLink), ctx.Repo.Repository.ComposeMetas()))
} else if readmeExist {
ctx.Data["IsRenderedHTML"] = true
ctx.Data["IsMarkup"] = false
Copy link
Member

Choose a reason for hiding this comment

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

You can keep only ctx.Data["IsMarkup"] = true

@@ -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">
{{if .IsRenderedHTML}}
<pre>{{if .FileContent}}{{.FileContent | Str2html}}{{end}}</pre>
{{if not .IsMarkup}}
Copy link
Member

Choose a reason for hiding this comment

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

Switch order, test for {{if .IsMarkup}}

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

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

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

@lafriks lafriks added the type/enhancement An improvement of existing functionality label Oct 16, 2017
@lafriks lafriks added this to the 1.3.0 milestone Oct 16, 2017
@@ -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.

@@ -270,6 +270,10 @@
}
}

.plain-text {
padding: 1em 2em 1em 2em;
Copy link
Member

Choose a reason for hiding this comment

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

Something looks wrong with spacing

Fixed spacing at repository.less

Signed-off-by: Jonas Franz <[email protected]>
@@ -95,6 +95,7 @@ func renderDirectory(ctx *context.Context, treeLink string) {
buf = append(buf, d...)
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.

Move this line to line 101

@lafriks
Copy link
Member

lafriks commented Oct 16, 2017

LGTM

@tboerger tboerger added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Oct 16, 2017
{{if .FileContent}}{{.FileContent | Str2html}}{{end}}
{{else if .IsRenderedHTML}}
<pre>{{if .FileContent}}{{.FileContent | Str2html}}{{end}}</pre>
Copy link
Member

Choose a reason for hiding this comment

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

Move <pre> inside {{if .FileContent}} block. Don't need to render empty tag.

Copy link
Member

Choose a reason for hiding this comment

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

@Morlinest it is better to render it because of margins as css is accounted for plain-text to have pre inside

Copy link
Member

Choose a reason for hiding this comment

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

@lafriks OK then

@Morlinest
Copy link
Member

LGTM

@tboerger tboerger added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Oct 16, 2017
@lafriks lafriks merged commit f4190f8 into go-gitea:master Oct 16, 2017
@jonasfranz jonasfranz deleted the monospaced-readme-txt branch October 17, 2017 06:59
@go-gitea go-gitea locked and limited conversation to collaborators Nov 23, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. type/enhancement An improvement of existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

render plain text README.txt with monospace font
5 participants