Skip to content

Commit d3f28e5

Browse files
committed
make iframe work
1 parent 1041279 commit d3f28e5

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

modules/markup/renderer.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -333,16 +333,12 @@ func (err ErrUnsupportedRenderFile) Error() string {
333333
}
334334

335335
func renderButton(ctx *RenderContext, output io.Writer) error {
336-
_, err := io.WriteString(output, fmt.Sprintf(`
337-
<div>
338-
<a href="%s/%s/%s/render/%s/%s">%s</a>
339-
</div>`,
336+
_, err := io.WriteString(output, fmt.Sprintf(`<iframe src="%s/%s/%s/render/%s/%s" sandbox="allow-same-origin allow-scripts"></iframe>`,
340337
setting.AppSubURL,
341338
url.PathEscape(ctx.Metas["user"]),
342339
url.PathEscape(ctx.Metas["repo"]),
343340
ctx.Metas["BranchNameSubURL"],
344341
url.PathEscape(ctx.RelativePath),
345-
"View in New Page", // TODO: how to get to know the i18n here?
346342
))
347343
return err
348344
}

web_src/css/base.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
--opacity-disabled: 0.55;
2323
--height-loading: 16rem;
2424
--tab-size: 4;
25+
--render-height: 600px;
2526
/* base colors */
2627
--color-primary: #4183c4;
2728
--color-primary-contrast: #ffffff;

web_src/css/repo.css

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -440,7 +440,7 @@
440440

441441
.pdf-content {
442442
width: 100%;
443-
height: 600px;
443+
height: var(--render-height);
444444
border: none !important;
445445
display: flex;
446446
align-items: center;
@@ -1900,6 +1900,17 @@
19001900
.file-view.markup {
19011901
padding: 1em 2em;
19021902
}
1903+
1904+
.file-view.openapi {
1905+
padding: 0;
1906+
}
1907+
1908+
.file-view.openapi iframe {
1909+
width: 100%;
1910+
height: var(--render-height);
1911+
border: none;
1912+
}
1913+
19031914
.repository .activity-header {
19041915
display: flex;
19051916
justify-content: space-between;

0 commit comments

Comments
 (0)