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

cdn dependency #1

Open
rnwgnr opened this issue Oct 6, 2020 · 16 comments
Open

cdn dependency #1

rnwgnr opened this issue Oct 6, 2020 · 16 comments

Comments

@rnwgnr
Copy link

rnwgnr commented Oct 6, 2020

I just came across NoPaste. The concept of not "storing" the data at all seems very appealing to me.

Relaying on external CDNs to ship most of the required files seems counter-intuitive to me.

Have you ever considered creating a deployable package which includes the dependencys so that they are shipped from the local host?

@bokub
Copy link
Owner

bokub commented Oct 8, 2020

Hi,

That is not a bad idea at all,

My only requirement for this project is that everyone should be able to use the files from the git repository immediately, without having to build anything.

Maybe I could bundle all the dependencies into a single file, and add it to the source files, maybe using webpack? I'll try to do something

@rnwgnr
Copy link
Author

rnwgnr commented Oct 9, 2020

My only requirement for this project is that everyone should be able to use the files from the git repository immediately, without having to build anything.

Fair enough.

Maybe I could bundle all the dependencies into a single file, and add it to the source files, maybe using webpack? I'll try to do something

Sounds good. 👍

@TheFrenchGhosty
Copy link

TheFrenchGhosty commented Nov 28, 2021

@bokub Any news? I just started hosting an instance on PussTheCat.org ( https://nopaste.pussthecat.org/ ) and it's one of my only complaint with it. If you don't do it, I'll surely fork the project and do it.

@bokub
Copy link
Owner

bokub commented Nov 28, 2021

Well, I couldn't manage to do that in an elegant way.. 🤷🏻‍♂️

Feel free to submit a PR, I'm curious to see what can be done, but I think the easiest way to get rid of the CDN is just to download the files and host them yourself.

@TheFrenchGhosty
Copy link

TheFrenchGhosty commented Nov 28, 2021

@bokub If I do it, I'll just do it "the easy way": download the files served by the CDNs, and serve them internally (similar to how I fixed the namazso.eu website: namazso/namazso.eu#2

@bokub
Copy link
Owner

bokub commented Nov 28, 2021

Yeah that's the easiest thing to do.

For NoPaste, it's just one css file and one js file.

@TheFrenchGhosty
Copy link

@bokub Okay so I started doing it, and I am currently stuck:
I don't know what to do to remove this call, since it's calling multiple scripts: https://github.com/TheFrenchGhosty/nopaste/blob/master/scripts/script.js#L19

Also, it's currently broken for whatever reason: https://github.com/TheFrenchGhosty/nopaste

@bokub
Copy link
Owner

bokub commented Dec 14, 2021

In the current code, if I replace %N with css, the URL will point to https://cdn.jsdelivr.net/npm/[email protected]/mode/css/css.js which contains the code for CSS syntax highlighting. It's the CDN version of this file.

If you want to serve the modes yourself, you need to download and host every .js file of the ./mode folder of CodeMirror (https://github.com/codemirror/CodeMirror/tree/5.58.1/mode), if possible at tag 5.58.1, then edit the URL so it points to your files (%N being a placeholder for the mode name).

@TheFrenchGhosty
Copy link

TheFrenchGhosty commented Dec 14, 2021

@bokub Alright, I finally have all resources loaded internally, however it's still broken and I don't know why, any idea?

Edit:

Those are the errors:

s

Edit 2:

Here a PR if you want to fix it: #8

@bokub
Copy link
Owner

bokub commented Dec 14, 2021

It's "broken" because you forgot to include CodeMirror...

image

@TheFrenchGhosty
Copy link

@bokub Oh I completely missed that!

So this fixed it, but it's now complaining about not being able to load the compression library:

1
2

I tried various path but I couldn't make it to work, any idea?

@bokub
Copy link
Owner

bokub commented Dec 14, 2021

You need to provide the whole URL, not just "./scripts/lzma_worker.js"!

Otherwise, I think you can replace the first lines of script.js with this (I'm not 100% sure tho):

- const blob = new Blob(['importScripts("https://cdn.jsdelivr.net/npm/[email protected]/src/lzma_worker.min.js");']);
- const lzma = new LZMA(window.URL.createObjectURL(blob));
+ const lzma = new LZMA("./scripts/lzma_worker.js");

@TheFrenchGhosty
Copy link

@bokub And it's working! Thanks a lot!

@TheFrenchGhosty
Copy link

One last issue (it's working perfectly so I don't know if it maters or not):

s

@bokub
Copy link
Owner

bokub commented Dec 14, 2021

It's because you're opening the files directly with your browser (file:https:///) instead of using a file server, which would be accessible on http:https://localhost

@TheFrenchGhosty
Copy link

TheFrenchGhosty commented Dec 14, 2021

@bokub Ah, that's good to know!

Thanks for the help :)

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

Successfully merging a pull request may close this issue.

3 participants