Skip to content

Conversation

jonasfranz
Copy link
Member

Fixes #2718

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

Screenshot

screenshot

Signed-off-by: Jonas Franz <info@jonasfranz.software>
@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
Signed-off-by: Jonas Franz <info@jonasfranz.software>
@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

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

Signed-off-by: Jonas Franz <info@jonasfranz.software>
{{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

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

{{end}}
</h4>
<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
readmeExist := markup.IsReadmeFile(blob.Name())
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.

Signed-off-by: Jonas Franz <info@jonasfranz.software>
}

.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 <info@jonasfranz.software>
if isTextFile {
d, _ := ioutil.ReadAll(dataRc)
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

Signed-off-by: Jonas Franz <info@jonasfranz.software>
@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 .IsMarkup}}
{{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

5 participants