Skip to content
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

better support of local presentations with external resources #207

Open
oupala opened this issue Apr 28, 2020 · 1 comment
Open

better support of local presentations with external resources #207

oupala opened this issue Apr 28, 2020 · 1 comment
Labels

Comments

@oupala
Copy link
Contributor

oupala commented Apr 28, 2020

Due to recent improvement on browsers' security model, it is now not possible any more to open and view local presentations with external resources.

As decktape is using Chromium to display presentations in order to generate a pdf, it does not work either when opening a local presentation:

Loading page file:///builds/<namespaceofyourrepo>/<nameofyourrepo>/index.html ...
Page error: Error
    at XMLHttpRequest.s.onload (file:///builds/<namespaceofyourrepo>/<nameofyourrepo>/js/remark.min.js:17:19338)
Loading page finished with status: 0

The reason why it doesn't work is written on the wiki of remark: remark can't load an external file from a local filesystem.

When working locally, with your slideshow HTML opened directly from disk, using the sourceUrl won't work out of the box. This requires hosting your files using a web server, which can be accomplished in multiple ways.

The behavior of Firefox about CORS and file:/// schema changed in version 68. And Chrome has probably adopted the same behavior. As decktape is based on puppeteer which is based on Chrome, there is no hope from the Chrome side.

One solution would be to make decktape able to launch a small webserver so that decktape can generate a pdf from the webserver.

This is the advice of the documentation of remark:

This requires hosting your files using a web server, which can be accomplished in multiple ways, e.g. by running python3 -m http.server in the directory of your index.html file. With a web server up and running, say on port 8000, you should be able to access your files via http://localhost:8000.

We cannot even blame remarkjs as the limitation comes from the browsers, Firefox and Chrome. We cannot blame Firefox and Chrome as they add security features to help the user, and they are following the W3C recommendations. We cannot blame decktape as decktape was working perfectly until the browsers added security features.

But, it will be useless to ask remarkjs to change as they don't have control over browsers' security features. It will be useless to ask the browsers to move as they already moved to enhance security.

This is why I think the solution is to enable a webserver into decktape.

The issue is not specific to remark as it is about all presentations where the content is into an external resource: the logic in an html file, the content in another file (somehow a markdown file).

It is not only a CI problem as some user might want to download a presentation on GitHub or GitLab and convert it to pdf. They are not necessarily expert enough to start a webserver on their own. There would probably not be able to understand why the presentation does not appear in the browser, it is quite hard to understand the cryptic error messages from the web developer console.

This is why I think it could be the job of decktape to handle such complexity to make user's life easier, even for beginners. This would be a key feature to make html and markdown presentation used widely on the internet.

I know this would add complexity to decktape. And I think that we should avoid unnecessary complexity. However, in this case, I think that this would not be useless complexity, this would be a useful complexity for real usecases.

@oupala
Copy link
Contributor Author

oupala commented Apr 28, 2020

See #118 for more history about this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants