Comments (5)
Looks good to me. Thanks and I'll merge #16
from emgithub.
If I'm not wrong, I think you mean two places to use jsDelivr:
- fetched file, by changing
const rawFileURL = `https://raw.githubusercontent.com/${user}/${repository}/${branch}/${file}`;
in https://github.com/yusanshi/embed-like-gist/blob/master/embed.js#L24. I saw your fork and you had added an optionfetchFromJsDelivr
. I think fetching from jsDelivr can even be the default, i.e., no need forfetchFromJsDelivr
. JsDelivr is reliable and doing this will benefit all users, especially for those in China. embed.js
, by changing${window.location.origin}/embed.js...
tohttps://cdn.jsdelivr.net/gh/yusanshi/embed-like-gist@master/embed.js...
in https://github.com/yusanshi/embed-like-gist/blob/master/404.html#L264. In this way, the embeding script tag will be<script src="https://cdn.jsdelivr.net/gh/yusanshi/embed-like-gist@master/embed.js?target=..."></script>
instead of<script src="https://emgithub.com/embed.js?target=..."></script>
. I think this will bring trouble to users following instructions at https://github.com/yusanshi/embed-like-gist#create-your-own-project. HardencodingserviceProvider
is not friendly to them. And their modifiedembed.js
(either in another GitHub repo or local) is not used at all so they must make some changes before deploying them.
In summary, I think the first one is completely OK, you can make a PR (just one line of code, I think, hahaha). The second one is likely a breaking change and we can talk it more.
By the way, as for the second one, I think GitHub Pages is accessible in most networks of China, although slower. If https://emgithub.com/embed.js
is accessible without any proxy in China, then only the first change is enough ๐
from emgithub.
Yes, the first point is the internal changes of embed.js, that is exactly what we need to do. But in my opinion, the fetchFromJsDelivr
option may be necessary, because jsDelivr always needs time to purge cache when raw file is updated, even if jsDelivr purge cache API is explicitly called by users. I think users need to know the disadvantages of using jsDelivr CDN, maybe we could explain it in the documentation.
The second point I said is what users need to do when copying links from emgithub.com (e.g. paste the link here https://github.com/yusanshi/homepage/blob/f72910bc16f9a706639d836d83aa3cb27a2a7249/_posts/2019-12-17-emgithub.md#L39-L53 in your blog), it is the userโs own Choice, although they will get such a problem. I don't think itโs a good idea to make changes in 404.html too as you said, maybe we can talk about โhow to help users solve this proble.
from emgithub.
I didn't realize the cache issue of jsDelivr and thanks for explaining this. So we can add a checkbox (text: Fetch from jsDelivr, maybe with a little question mark and when hovering on it a helping message is shown), or a dropdown with select
tag (Fetch from githubusercontent, jsDelivr)? Anyway it's just a little bit of my opinion. You can choose any implementation you like and I'll appreciate it if you can make a PR for it.
As for the second, maybe adding some text in README? For example, if you are having connection issues with https://emgithub.com/embed.js
, you can use a CDN for embed.js
. For example, replace https://emgithub.com/embed.js
with https://cdn.jsdelivr.net/gh/yusanshi/embed-like-gist@master/embed.js
in the JavaScript tag ...
However this will bring the serviceProvider
issue and it'll be a little dirty to fix this (e.g. serviceProvider = serviceProvider.includes("cdn") ? "https://emgithub.com" : serviceProvider
). I think this can be just put aside. https://emgithub.com/embed.js
is basically OK without a proxy from my own experience.
from emgithub.
I have implemented the feature of fetching files from jsDelivr, I tested it on local machine and it works, please check the pull request when you have time.
As for the serviceProvider
issue, I agree with you, and there is no change at the moment.
from emgithub.
Related Issues (20)
- Problem with permalink containing one line only HOT 4
- Theme request: arduino-dark HOT 3
- Hosting for demo GIF
- Rendering Jupyter Notebooks instead of showing raw code. HOT 4
- Embeds Fail to Render After Forking Repository and Using Github Pages HOT 2
- File does not update HOT 3
- Cannot Embed on Medium HOT 4
- [Feature Request] Show Full Path in Footer HOT 4
- TypeError: Cannot read properties of null (reading 'querySelector') at embed-v2.js:422:33 HOT 4
- [FEATURE REQUEST] Embed Github commit diff HOT 1
- [Feature Request] Compile to static HTML HOT 7
- [Question] Use markers instead of line numbers HOT 1
- serviceProvider value is wrong if served from a subdirectory HOT 1
- [feature request] Add dark mode option for markdown files HOT 4
- [Request] full view render HOT 5
- How long is the file cached? HOT 2
- Embed only certain lines HOT 5
- I found that there some code styles are different from GitHub and Gist. HOT 4
- Feature request: copy shortcut HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from emgithub.