hugo-future-imperfect-slim icon indicating copy to clipboard operation
hugo-future-imperfect-slim copied to clipboard

ENHANCEMENT: If Installed, Load Vendor Files Locally

Open twatzl opened this issue 4 years ago • 6 comments

Bug Report

Describe the bug

Pretty much as the title says. The scripts are still loaded from cloudflare even though setting enableCDN=false

To Reproduce

  1. create page
  2. enable highlightjs
  3. disable cdn

Expected behavior

When enableCDN=false no scripts are loaded from external pages.

I guess the issue is line 48 in this file: https://github.com/pacollins/hugo-future-imperfect-slim/blob/master/layouts/partials/head.html

If I have time I might open a PR. Maybe next weekend or so, but for now I am busy getting my blog to work again.

twatzl avatar Jan 24 '21 17:01 twatzl

It is functioning as intended at the moment. We no longer host all of the different highlighting themes as part of the theme because of bloat.

If .Site.Params.highlightjsTheme is included, it loads that theme via CDN. If it is left blank, then it loads the default.css theme. The could probably be reworked to allow for users to download and implement custom themes for highlight.js.

https://github.com/pacollins/hugo-future-imperfect-slim/blob/80efb2da6db0c9ffdf8609b216ba1b772b1a803b/layouts/partials/head.html#L46-L52

The easy solution to make this better understood is to make sure that highlightjsTheme is blank in the example config.

Hope that helps - I am happy to continue the discussion.

pacollins avatar Jan 24 '21 17:01 pacollins

Thanks. Ok. For me it's kinda unexpected to have CDNs still load when explicitely disabled. So I would rather have a note saying "Hey you gotta manually download the highlight.js theme and put it in your static folder if you disable CDN." It would be ok for me having to tweak that manually rather than using a CDN. Also you have to keep in mind that in Europe with GDPR it's quite a sensitive topic as I would have to inform my users, offer opt out and so on. I mean I would probably be fine, but also I don't want to risk any fines for a private blog, so in order to be 100% sure disabling all external things is the safer way.

In short: I would rather throw an error and have the user manually download the theme.

twatzl avatar Jan 24 '21 18:01 twatzl

Noted! I am an American and a hobbyist, so I have 0 understanding of GDPR.

Let's work out a way to fix this and get it GDPR compliant! :)

On Sun, Jan 24, 2021 at 1:24 PM twatzl [email protected] wrote:

Thanks. Ok. For me it's kinda unexpected to have CDNs still load when explicitely disabled. So I would rather have a note saying "Hey you gotta manually download the highlight.js theme and put it in your static folder if you disable CDN." It would be ok for me having to tweak that manually rather than using a CDN. Also you have to keep in mind that in Europe with GDPR it's quite a sensitive topic as I would have to inform my users, offer opt out and so on. I mean I would probably be fine, but also I don't want to risk any fines for a private blog, so in order to be 100% sure disabling all external things is the safer way.

In short: I would rather throw an error and have the user manually download the theme.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/pacollins/hugo-future-imperfect-slim/issues/218#issuecomment-766407860, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACWVJSJT65TRNJ6SUJVPKG3S3RQXPANCNFSM4WQVXUNA .

pacollins avatar Jan 24 '21 18:01 pacollins

As I said I would simply extend the documentation and let user put the scripts there manually and not load external scripts at all if enableCDN=false. That way there is nothing unexpected happening.

I think according to GDPR the use of CDNs would even be an exemption (as it's a technical requirement), but I am not a lawyer and so I rather disable all CDNs.

Edit: I might have time to create a PR for this in the coming weeks, but I can't promise anything.

twatzl avatar Jan 31 '21 11:01 twatzl

I have updated the Wiki, but I think we can get creative and have the theme recognize a local default and prioritize that.

I am changing the name of this issue to reflect an improvement on this block of code.

pacollins avatar Jan 31 '21 16:01 pacollins

@twatzl As I'm living in :fr:, I'd love to know more about GDPR. I've a workaround for this problem in GitHub Actions and/or GitLab CI & CD: manually fetch the a copy of the script during the site build (in .github/workflow/{file}.yml and/or .gitlab-ci.yml) if highlightjs = true in config.js.

hljsTheme=$((grep highlightjsTheme config.toml || echo "default") | awk '{ print $NF }' | tr -d '"')
curl -L -O "https://cdnjs.cloudflare.com/ajax/libs/highlight.js/{VERS}/styles/$hljsTheme.min.css"

so that during page rendering, the highlight.js theme file is fetched from {baseURL}$hljsTheme.min.css

VincentTam avatar Mar 08 '21 13:03 VincentTam