Skip to content

Commit

Permalink
make iframe work
Browse files Browse the repository at this point in the history
  • Loading branch information
silverwind committed Aug 29, 2023
1 parent 1041279 commit d3f28e5
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 6 deletions.
6 changes: 1 addition & 5 deletions modules/markup/renderer.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,16 +333,12 @@ func (err ErrUnsupportedRenderFile) Error() string {
}

func renderButton(ctx *RenderContext, output io.Writer) error {
_, err := io.WriteString(output, fmt.Sprintf(`
<div>
<a href="%s/%s/%s/render/%s/%s">%s</a>
</div>`,
_, err := io.WriteString(output, fmt.Sprintf(`<iframe src="%s/%s/%s/render/%s/%s" sandbox="allow-same-origin allow-scripts"></iframe>`,
setting.AppSubURL,
url.PathEscape(ctx.Metas["user"]),
url.PathEscape(ctx.Metas["repo"]),
ctx.Metas["BranchNameSubURL"],
url.PathEscape(ctx.RelativePath),
"View in New Page", // TODO: how to get to know the i18n here?
))
return err
}
Expand Down
1 change: 1 addition & 0 deletions web_src/css/base.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
--opacity-disabled: 0.55;
--height-loading: 16rem;
--tab-size: 4;
--render-height: 600px;
/* base colors */
--color-primary: #4183c4;
--color-primary-contrast: #ffffff;
Expand Down
13 changes: 12 additions & 1 deletion web_src/css/repo.css
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@

.pdf-content {
width: 100%;
height: 600px;
height: var(--render-height);
border: none !important;
display: flex;
align-items: center;
Expand Down Expand Up @@ -1900,6 +1900,17 @@
.file-view.markup {
padding: 1em 2em;
}

.file-view.openapi {
padding: 0;
}

.file-view.openapi iframe {
width: 100%;
height: var(--render-height);
border: none;
}

.repository .activity-header {
display: flex;
justify-content: space-between;
Expand Down

0 comments on commit d3f28e5

Please sign in to comment.