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

Allow resources to be fetched from another location #271

Open
azerupi opened this issue May 15, 2017 · 5 comments
Open

Allow resources to be fetched from another location #271

azerupi opened this issue May 15, 2017 · 5 comments
Labels
A-CDN Area: Hosted dependencies A-Rendering Area: Rendering C-enhancement Category: Enhancement or feature request E-Medium Experience: Medium S-Wishlist Status: Wishlist

Comments

@azerupi
Copy link
Contributor

azerupi commented May 15, 2017

Some resources are loaded through a CDN if possible with a local fallback. An option to deactivate the CDNs when rendering is wanted. See #46

An option could be given in the config file, but I think it would fit better as a CLI argument.
On the template side, we could add a cdn variable that evaluates to true or false and use if ... tags in handlebars.

@azerupi azerupi added A-Rendering Area: Rendering E-Medium Experience: Medium S-Wishlist Status: Wishlist C-enhancement Category: Enhancement or feature request labels May 15, 2017
@tjis
Copy link

tjis commented May 16, 2017

Ideally, we have more flexibility than just a true or false for cdn. When resources cannot be sourced through a cdn, they'll still need to be found in another way.
In debian, we ship javascript libraries in separate packages, which are then symlinked or copied. mdbook cannot have any knowledge of this process though, so I imagine we'll need to configure our intentions somehow.
A simple solution would be to make the resource url configurable somewhere, but default to the cdn.

@azerupi
Copy link
Contributor Author

azerupi commented May 16, 2017

So I am a little lost with what would be actually required. Currently, the strategy is to fetch from a CDN to have cache benefits and parallel loading. If the CDN fails we send the local version. This strategy does not really benefit books that are not hosted online though. But I am not sure it hurts either.

If someone could clearly formulate the problem that needs to be solved and what they expect mdBook to do or allow, that would help us immensely! :)

@tjis
Copy link

tjis commented May 18, 2017

Alright. The problem is as follows.
Debian packages aren't supposed to make network connections without the user's consent. Also, packages aren't supposed to contain embedded resources that could be provided by other packages instead. Therefore, both the CDN and the fallback are problematic for Debian.
We are running into this issue while packaging rust, which uses mdBook to build the various rust books. In order to make the generated books comply with debian policy, we strip the embedded resources from mdBook and alter the templates so that the generated documentation complies.
But this is far from ideal. Not only might future mdBook changes break our present patch, it also means we have to ship a patched copy of mdBook with the rust source package, rather than using a pristine packaged version of mdBook and build-depend on that.

The solution to our problem would be if mdbook could be supplied with alternative means to retrieve third-party dependencies, rather than having the current CDN+fallback method hardcoded. Then debian could ship rust with the books configured to use the debian locations.

If this is something your project is willing to consider, I could provide a patch and we could work from there.

@azerupi
Copy link
Contributor Author

azerupi commented May 18, 2017

Ooh I see now, thank you for the explanation!
I would totally be ok with adding an option to allow this. I am not sure if this is common enough to put a key in the config file, but controlling this with environment variables seems like a good plan to begin with. :)

@azerupi azerupi changed the title Disable CDNs Allow resources to be fetched from another location May 18, 2017
@Michael-F-Bryan
Copy link
Contributor

I've created a new PR (#541) for updating config values using environment variables which is the first step required for fixing this issue. The HTML renderer needs to be cleaned up and restructured now that #507 has landed, so hopefully the second half of this issue (the concept of a configurable Resource) will just "fall out".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-CDN Area: Hosted dependencies A-Rendering Area: Rendering C-enhancement Category: Enhancement or feature request E-Medium Experience: Medium S-Wishlist Status: Wishlist
Projects
None yet
Development

No branches or pull requests

4 participants