Codeberg/Community
54
325
Fork
You've already forked Community
12

Render HTML files #249

Open
opened 2020年09月07日 09:19:04 +02:00 by ivan-paleo · 37 comments

Apparently, just like GitHub, HTML files are not rendered on Codeberg.
For GitHub repos, it is possible to use https://htmlpreview.github.io/, but it doesn't work with Codeberg repos.

It is not an issue per se, maybe more like a feature request. Or maybe there is already a way to deal with this.

Thanks!

Apparently, just like GitHub, HTML files are not rendered on Codeberg. For GitHub repos, it is possible to use https://htmlpreview.github.io/, but it doesn't work with Codeberg repos. It is not an issue per se, maybe more like a feature request. Or maybe there is already a way to deal with this. Thanks!

A similar solution could be implemented using Codeberg Pages.

(削除) Maybe we can ask the authors of htmlpreview to put their site under a free software license. That way we could simply re-use it here. (削除ここまで) See next comment below :)

A similar solution could be implemented using [Codeberg Pages](https://pages.codeberg.org/). ~~Maybe we can ask the authors of htmlpreview to put their site under a free software license. That way we could simply re-use it here.~~ See next comment below :)

Oh, I just saw in the README of https://github.com/htmlpreview/htmlpreview.github.com that they have put it under the Apache License 2.0 :)

Oh, I just saw in the README of https://github.com/htmlpreview/htmlpreview.github.com that they have put it under the Apache License 2.0 :)

Looking at the code, it seems to be quite closely tied to Github / Bitbucket and it seems to use an external proxy. So 1-to-1 adaption won't work. But it might be a good base to develop a variant that works for Codeberg.

Would you be interested in developing such an adaption? :)

For Media proxy, there's already an issue open: #196

Looking at the code, it seems to be quite closely tied to Github / Bitbucket and it seems to use an external proxy. So 1-to-1 adaption won't work. But it might be a good base to develop a variant that works for Codeberg. Would you be interested in developing such an adaption? :) For Media proxy, there's already an issue open: #196

Euu... I would be interested in testing it, but I definitely have no idea about this kind of software... I use GitHub/Codeberg for R projects only; that's where my programming skills start and end!

Euu... I would be interested in testing it, but I definitely have no idea about this kind of software... I use GitHub/Codeberg for R projects only; that's where my programming skills start and end!

A similar solution could be implemented using Codeberg Pages.

As far as I understand it, Pages would not help me in that case because I render Rmd scripts to HTML. These HTML files have to be in the same repo as the rest of the analysis. That's why I think that having an HTML viewer (either built-in, the best case, or external like for GitHub) is the only solution.

But that means there is already a built-in tool to render HTML files. Could it be extended to repos as well? Like having the option to either show rendered or raw?

> A similar solution could be implemented using [Codeberg Pages](https://pages.codeberg.org/). > As far as I understand it, Pages would not help me in that case because I render Rmd scripts to HTML. These HTML files have to be in the same repo as the rest of the analysis. That's why I think that having an HTML viewer (either built-in, the best case, or external like for GitHub) is the only solution. But that means there is already a built-in tool to render HTML files. Could it be extended to repos as well? Like having the option to either show rendered or raw?

And by the way, being able to render HTML files would be an advantage over GitHub. Judging by the number of threads to ask how to render HTML files on GitHub, it seems there is a need for such a feature. It would be a nice "unique selling point" for Codeberg.

And by the way, being able to render HTML files would be an advantage over GitHub. Judging by the number of threads to ask how to render HTML files on GitHub, it seems there is a need for such a feature. It would be a nice "unique selling point" for Codeberg.

No problem :) Maybe someone else can have a look at the programming side of this.

It looks like htmlpreview works by fetching and rendering the HTML files with the help of JavaScript. That's why it would be possible to deploy it to Pages, which would be a relatively quick and easy fix for the problem you have described regarding Rmd scripts.

But you're right, there are other more integrated and user-friendly options like extending Gitea to display HTML previews, although there are considerations to be made, especially in regards of security.

Let's wait for some more feedback of the other people on Codeberg (Codebergians? Codebergers? 😄).

No problem :) Maybe someone else can have a look at the programming side of this. It looks like htmlpreview works by fetching and rendering the HTML files with the help of JavaScript. That's why it would be possible to deploy it to Pages, which would be a relatively quick and easy fix for the problem you have described regarding Rmd scripts. But you're right, there are other more integrated and user-friendly options like extending Gitea to display HTML previews, although there are considerations to be made, especially in regards of security. Let's wait for some more feedback of the other people on Codeberg (Codebergians? Codebergers? :smile:).

For GitHub repos, it is possible to use https://htmlpreview.github.io/, but it doesn't work with Codeberg repos.

I put together a quick fork for htmlpreview at htmlpreview.codeberg.eu for use with Codeberg repos. It's only a short term solution, hopefully we can get a preview option on Gitea.

> For GitHub repos, it is possible to use https://htmlpreview.github.io/, but it doesn't work with Codeberg repos. I put together a quick fork for htmlpreview at [htmlpreview.codeberg.eu](https://htmlpreview.codeberg.eu/) for use with Codeberg repos. It's only a short term solution, hopefully we can get a preview option on Gitea.

For GitHub repos, it is possible to use https://htmlpreview.github.io/, but it doesn't work with Codeberg repos.

I put together a quick fork for htmlpreview at htmlpreview.codeberg.eu for use with Codeberg repos. It's only a short term solution, hopefully we can get a preview option on Gitea.

Of course, a preview option would be best, but your fork for htmlpreview is already wonderful, especially in such a short time!

> > For GitHub repos, it is possible to use https://htmlpreview.github.io/, but it doesn't work with Codeberg repos. > > I put together a quick fork for htmlpreview at [htmlpreview.codeberg.eu](https://htmlpreview.codeberg.eu/) for use with Codeberg repos. It's only a short term solution, hopefully we can get a preview option on Gitea. Of course, a preview option would be best, but your fork for htmlpreview is already wonderful, especially in such a short time!
Member
Copy link

But that means there is already a built-in tool to render HTML files. Could it be extended to repos as well? Like having the option to either show rendered or raw?

This would be a nice contribution to gitea (toggle between source and preview for all preview-able file formats).

> But that means there is already a built-in tool to render HTML files. Could it be extended to repos as well? Like having the option to either show rendered or raw? This would be a nice contribution to gitea (toggle between source and preview for all preview-able file formats).

I put together a quick fork for htmlpreview at htmlpreview.codeberg.eu for use with Codeberg repos. It's only a short term solution, hopefully we can get a preview option on Gitea.

For an unknown reason, when I add a link to the HTML file preview in a README.md (e.g. [file](https://htmlpreview.codeberg.eu/?https://codeberg.org/ivan-paleo/initiationR/src/branch/master/initiationR.html), I get this error when I click on the link:

Error: Cannot load https%3A%2F%2Fcodeberg.org%2Fivan-paleo%2FinitiationR%2Fsrc%2Fbranch%2Fmaster%2FinitiationR.html=: 404 Invalid host

But if I copy the URL into the browser, the HTML file is previewed nicely.

Any idea what's wrong?

> I put together a quick fork for htmlpreview at [htmlpreview.codeberg.eu](https://htmlpreview.codeberg.eu/) for use with Codeberg repos. It's only a short term solution, hopefully we can get a preview option on Gitea. For an unknown reason, when I add a link to the HTML file preview in a README.md (e.g. `[file](https://htmlpreview.codeberg.eu/?https://codeberg.org/ivan-paleo/initiationR/src/branch/master/initiationR.html)`, I get this error when I click on the link: Error: Cannot load https%3A%2F%2Fcodeberg.org%2Fivan-paleo%2FinitiationR%2Fsrc%2Fbranch%2Fmaster%2FinitiationR.html=: 404 Invalid host But if I copy the URL into the browser, the HTML file is previewed nicely. Any idea what's wrong?

@hw @lhinderberger @ivan-paleo it is posible

just add this to app.ini:

[markup.html]
ENABLED = true
FILE_EXTENSIONS = .html
RENDER_COMMAND = "cat"
IS_INPUT_FILE = false
@hw @lhinderberger @ivan-paleo it is posible just add this to app.ini: ```ini [markup.html] ENABLED = true FILE_EXTENSIONS = .html RENDER_COMMAND = "cat" IS_INPUT_FILE = false ```

@6543 Sorry for being programmatically limited... But where should these commands be added? I guess I cannot/shouldn't be the one doing it...

@6543 Sorry for being programmatically limited... But where should these commands be added? I guess I cannot/shouldn't be the one doing it...

@ivan-paleo for you it's just an info - you don programm it, this are settigns

@ivan-paleo for you it's just an info - you don programm it, this are settigns

@ivan-paleo for you it's just an info - you don programm it, this are settigns

Ah OK, thank you. Then, I'll just wait until someone competent takes care of it :)

> @ivan-paleo for you it's just an info - you don programm it, this are settigns Ah OK, thank you. Then, I'll just wait until someone competent takes care of it :)

just add this to app.ini

What are the privacy / security implications - wouldn't it allow XSS attacks?

> just add this to app.ini What are the privacy / security implications - wouldn't it allow XSS attacks?

Any idea what's wrong?

That's just a guess, but I could imagine two things that could have gone wrone:

  • Maybe you need to URL-encode your link, so the link address becomes https://htmlpreview.codeberg.eu/?https%3A%2F%2Fcodeberg.org%2Fivan-paleo%2FinitiationR%2Fsrc%2Fbranch%2Fmaster%2FinitiationR.html
  • Maybe htmlpreview needs to explicitly urldecode the link passed into it?
> Any idea what's wrong? That's just a guess, but I could imagine two things that could have gone wrone: - Maybe you need to URL-encode your link, so the link address becomes `https://htmlpreview.codeberg.eu/?https%3A%2F%2Fcodeberg.org%2Fivan-paleo%2FinitiationR%2Fsrc%2Fbranch%2Fmaster%2FinitiationR.html` - Maybe htmlpreview needs to explicitly urldecode the link passed into it?
Member
Copy link

@hw @lhinderberger @ivan-paleo it is posible

just add this to app.ini:

[markup.html]
ENABLED = true
FILE_EXTENSIONS = .html
RENDER_COMMAND = "cat"
IS_INPUT_FILE = false

What about javascript/external security issues/source sanitization?

> @hw @lhinderberger @ivan-paleo it is posible > > just add this to app.ini: > > ```ini > [markup.html] > ENABLED = true > FILE_EXTENSIONS = .html > RENDER_COMMAND = "cat" > IS_INPUT_FILE = false > ``` What about javascript/external security issues/source sanitization?
Member
Copy link

A similar solution could be implemented using Codeberg Pages.

As far as I understand it, Pages would not help me in that case because I render Rmd scripts to HTML. These HTML files have to be in the same repo as the rest of the analysis.

why shouldn't this work with Codeberg pages? You can put both in the repo.

(this is not to say that HTML preview wouldn't be cool. We just need to be careful to do it properly and not create security issues)

> > A similar solution could be implemented using [Codeberg Pages](https://pages.codeberg.org/). > > > > As far as I understand it, Pages would not help me in that case because I render Rmd scripts to HTML. These HTML files have to be in the same repo as the rest of the analysis. why shouldn't this work with Codeberg pages? You can put both in the repo. (this is not to say that HTML preview wouldn't be cool. We just need to be careful to do it properly and not create security issues)

A similar solution could be implemented using Codeberg Pages.

As far as I understand it, Pages would not help me in that case because I render Rmd scripts to HTML. These HTML files have to be in the same repo as the rest of the analysis.

why shouldn't this work with Codeberg pages? You can put both in the repo.

(this is not to say that HTML preview wouldn't be cool. We just need to be careful to do it properly and not create security issues)

I totally agree with you about doing things properly!

I still cannot imagine how pages would help me here... Do you mean that I should/could copy/move the HTML file(s) from my repo to my pages, and then link to the file(s) in my pages from the repo? The files are generating by rendering my R scripts, so I would need to additionally copy/move the files to my pages... Possible but not quite ideal. But maybe I just do not really understand how pages work.

Still, I am wondering why HTML files can be rendered/previewed in pages but not in repos. Doesn't it mean that the functionality is there and that it could "just" be added to the repos?

> > > A similar solution could be implemented using [Codeberg Pages](https://pages.codeberg.org/). > > > > > > > As far as I understand it, Pages would not help me in that case because I render Rmd scripts to HTML. These HTML files have to be in the same repo as the rest of the analysis. > > why shouldn't this work with Codeberg pages? You can put both in the repo. > > (this is not to say that HTML preview wouldn't be cool. We just need to be careful to do it properly and not create security issues) > I totally agree with you about doing things properly! I still cannot imagine how pages would help me here... Do you mean that I should/could copy/move the HTML file(s) from my repo to my pages, and then link to the file(s) in my pages from the repo? The files are generating by rendering my R scripts, so I would need to additionally copy/move the files to my pages... Possible but not quite ideal. But maybe I just do not really understand how pages work. Still, I am wondering why HTML files can be rendered/previewed in pages but not in repos. Doesn't it mean that the functionality is there and that it could "just" be added to the repos?
  • Maybe you need to URL-encode your link, so the link address becomes https://htmlpreview.codeberg.eu/?https%3A%2F%2Fcodeberg.org%2Fivan-paleo%2FinitiationR%2Fsrc%2Fbranch%2Fmaster%2FinitiationR.html

That doesn't help unfortunately, same error...

> - Maybe you need to URL-encode your link, so the link address becomes `https://htmlpreview.codeberg.eu/?https%3A%2F%2Fcodeberg.org%2Fivan-paleo%2FinitiationR%2Fsrc%2Fbranch%2Fmaster%2FinitiationR.html` That doesn't help unfortunately, same error...
Member
Copy link

Do you mean that I should/could copy/move the HTML file(s) from my repo to my pages, and then link to the file(s) in my pages from the repo? The files are generating by rendering my R scripts, so I would need to additionally copy/move the files to my pages... Possible but not quite ideal. But maybe I just do not really understand how pages work.

You understand it correctly, that's exactly how it works -- codeberg pages is merely a versioned deployment storage facility: ;)

  • author the content in your content repo,
  • compile it to generate deployment files (in your case run the R script[s]),
  • deploy the compiled files and all dependencies to the pages repo.

You might for example using a script like this: https://codeberg.org/Codeberg/Documentation/src/branch/master/deploy.sh

  • (instead of git@codeberg.org:docs/pages.git you specify your own pages repo URL),
  • (instead of npm build you call your R script),
  • (instead of _site/* you specify the list/wildcard of your generated files and dependencies).

Doesn’t it mean that the functionality is there and that it could "just" be added to the repos?

The pages functionality is currently not part of gitea core (yet?), but external.

> Do you mean that I should/could copy/move the HTML file(s) from my repo to my pages, and then link to the file(s) in my pages from the repo? The files are generating by rendering my R scripts, so I would need to additionally copy/move the files to my pages... Possible but not quite ideal. But maybe I just do not really understand how pages work. You understand it correctly, that's exactly how it works -- codeberg pages is merely a versioned deployment storage facility: ;) - author the content in your content repo, - compile it to generate deployment files (in your case run the R script[s]), - deploy the compiled files and all dependencies to the pages repo. You might for example using a script like this: https://codeberg.org/Codeberg/Documentation/src/branch/master/deploy.sh - (instead of `git@codeberg.org:docs/pages.git` you specify your own pages repo URL), - (instead of `npm build` you call your R script), - (instead of `_site/*` you specify the list/wildcard of your generated files and dependencies). > Doesn’t it mean that the functionality is there and that it could "just" be added to the repos? The pages functionality is currently not part of gitea core (yet?), but external.

@hw you will have the default sanitization for markdown

@hw you will have the default sanitization for markdown
Member
Copy link

@hw you will have the default sanitization for markdown

we still need to wrap html into iframe, right?

> @hw you will have the default sanitization for markdown we still need to wrap html into iframe, right?

it depends how your html files look like

it depends how your html files look like
Member
Copy link

would it be of general interest to wrap all user content into <iframe sandbox ...> within gitea? This would also resolve the long-standing SVG security concerns?

would it be of general interest to wrap all user content into `<iframe sandbox ...>` within gitea? This would also resolve the long-standing SVG security concerns?

In combination with the media proxy from #196 to protect against unwanted tracking, that would be a good idea.

In combination with the media proxy from #196 to protect against unwanted tracking, that would be a good idea.
Member
Copy link

What is the general feeling, should files like HTML get rendered as source code or preview (for the time being where we have no toggle button to switch between preview and source view?)

What is the general feeling, should files like HTML get rendered as source code or preview (for the time being where we have no toggle button to switch between preview and source view?)

I'd vote for rendering them as source code and using n's htmlpreview fork as an interim solution.

I'd vote for rendering them as source code and using n's htmlpreview fork as an interim solution.

I would of course prefer to preview them, but that's due to my use of HTML files (as "reports" - the source code is irrelevant for me).

The HTML preview (given the links work correctly) is also a good interim solution.

I would of course prefer to preview them, but that's due to my use of HTML files (as "reports" - the source code is irrelevant for me). The HTML preview (given the links work correctly) is also a good interim solution.
Member
Copy link

sounds like having a toggle switch is the way to go then? This would be a gitea feature?

sounds like having a toggle switch is the way to go then? This would be a gitea feature?
Owner
Copy link

This will be implemented in the new Codeberg Pages (https://codeberg.org/momar/codeberg-pages), but it will still take some time - you will be able to use URLs like https://ivan-paleo.codeberg.page/initiationR/@master/initiationR.html to refer to specific repos (using the pages branch) & branches (with the @ prefix); specifying a branch will make it not indexable by search engines though.

We should probably add an "Open in Pages" button for this next to the "Raw" button.

This will be implemented in the new Codeberg Pages (https://codeberg.org/momar/codeberg-pages), but it will still take some time - you will be able to use URLs like https://ivan-paleo.codeberg.page/initiationR/@master/initiationR.html to refer to specific repos (using the `pages` branch) & branches (with the `@` prefix); specifying a branch will make it not indexable by search engines though. We should probably add an "Open in Pages" button for this next to the "Raw" button.
Member
Copy link

We should probably add an "Open in Pages" button for this next to the "Raw" button.

Is this what @fnetX has implemented in his PR, and is currently tested on codeberg-test?

> > We should probably add an "Open in Pages" button for this next to the "Raw" button. Is this what @fnetX has implemented in his PR, and is currently tested on codeberg-test?
Owner
Copy link

The current "Visit Page" button as it's live on e.g. https://codeberg.org/codeberg-fonts/pages is for repositories (I think that's what you mean?), while the "open in pages" button could be shown on a per-file basis (next to the raw button) when on a branch.

The current "Visit Page" button as it's live on e.g. https://codeberg.org/codeberg-fonts/pages is for repositories (I think that's what you mean?), while the "open in pages" button could be shown on a per-file basis (next to the raw button) when on a branch.
Owner
Copy link

FYI, that issue for the "visit page" button is tracked in #433

FYI, that issue for the "visit page" button is tracked in #433

Hi!

I was just migrating some repositories I had on Github over to here and I've found this. I have for example this HTML page that doesn't render https://codeberg.org/rinze/estudio-voto-blanco2011/src/branch/master/analisisVotoBlanco.html. Was there a long-term solution adopted in the end?

Thanks!

Hi! I was just migrating some repositories I had on Github over to here and I've found this. I have for example this HTML page that doesn't render https://codeberg.org/rinze/estudio-voto-blanco2011/src/branch/master/analisisVotoBlanco.html. Was there a long-term solution adopted in the end? Thanks!

I have a sitting html file in a repo and I do not want to start a Pages for that. I would like to just see its content. I found that I can mix github preview with raw codeberg pages:

dominant-sapiens/raw@438fb71980/ChatGPT/chat-gpt-abstract-icon-tech-effects.html

I have a sitting html file in a repo and I do not want to start a Pages for that. I would like to just see its content. I found that I can mix github preview with raw codeberg pages: https://htmlpreview.github.io/?https://codeberg.org/homo-ludens/dominant-sapiens/raw/commit/438fb719802dbfa72d1787b8f8c314d304de45ff/ChatGPT/chat-gpt-abstract-icon-tech-effects.html
Sign in to join this conversation.
No Branch/Tag specified
main
No results found.
Labels
Clear labels
accessibility

Reduces accessibility and is thus a "bug" for certain user groups on Codeberg.
bug

Something is not working the way it should. Does not concern outages.
bug
infrastructure

Errors evidently caused by infrastructure malfunctions or outages
Codeberg

This issue involves Codeberg's downstream modifications and settings and/or Codeberg's structures.
contributions welcome

Please join the discussion and consider contributing a PR!
docs

No bug, but an improvement to the docs or UI description will help
duplicate

This issue or pull request already exists
enhancement

New feature
infrastructure

Involves changes to the server setups, use `bug/infrastructure` for infrastructure-related user errors.
legal

An issue directly involving legal compliance
licence / ToS

involving questions about the ToS, especially licencing compliance
please chill
we are volunteers

Please consider editing your posts and remember that there is a human on the other side. We get that you are frustrated, but it's harder for us to help you this way.
public relations

Things related to Codeberg's external communication
question

More information is needed
question
user support

This issue contains a clearly stated problem. However, it is not clear whether we have to fix anything on Codeberg's end, but we're helping them fix it and/or find the cause.
s/Forgejo

Related to Forgejo. Please also check Forgejo's issue tracker.
s/Forgejo/migration

Migration related issues in Forgejo
s/Pages

Issues related to the Codeberg Pages feature
s/Weblate

Issue is related to the Weblate instance at https://translate.codeberg.org
s/Woodpecker

Woodpecker CI related issue
security

involves improvements to the sites security
service

Add a new service to the Codeberg ecosystem (instead of implementing into Gitea)
upstream

An open issue or pull request to an upstream repository to fix this issue (partially or completely) exists (i.e. Gitea, Forgejo, etc.)
wontfix

Codeberg's current set of contributors are not planning to spend time on delegating this issue.
Milestone
Clear milestone
No items
No milestone
Projects
Clear projects
No items
No project
Assignees
Clear assignees
No assignees
8 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Codeberg/Community#249
Reference in a new issue
Codeberg/Community
No description provided.
Delete branch "%!s()"

Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?