Description
The general problem is this: how can jsCoq be embedded in every webpage on the web, under the following constraints:
- No access to the files hosted on the domain (only limited access to the HTML of the page),
- Making use of a CDN to deliver the files.
More specifically. I'm using a hosted Ghost instance, in which I want to embed jsCoq into some of the pages. The domain is out of my control (it is hosted by GhostPro) so I cannot host the required files. Nor can I edit the HTML code of the page in which jsCoq is inserted. Instead, I try to make use of jsDelivr, from which the static files can be served.
After several tries, the closest I could get in having a working jsCoq embedded on one of my pages, is to use the following snippet (which is inserted before the closing </body>
tag):
<script type="module" crossorigin="anonymous">
import { JsCoq } from 'https://cdn.jsdelivr.net/npm/wacoq@0.16.0/ui-js/index.min.js';
document.querySelectorAll('.site-main')[0].id = 'ide-wrapper';
var jscoq_ids = ['.snippet'];
var jscoq_opts = {
base_path: 'https://cdn.jsdelivr.net/npm/wacoq@0.16.0',
pkg_path: 'https://cdn.jsdelivr.net/npm/wacoq-bin@0.16.0/bin/coq',
node_modules_path: 'https://cdn.jsdelivr.net/npm/',
prelude: true,
implicit_libs: true,
editor: { mode: { 'company-coq': true } },
init_pkgs: ['init'],
all_pkgs: ['coq']
};
JsCoq.start(jscoq_ids, jscoq_opts);
</script>
A number of issues arise, of which the most important one is the following:
- Security Error: Content at url-of-my-post may not load data from https://cdn.jsdelivr.net/npm/wacoq-bin/dist/worker.js
Since the script tag is already marked with crossorigin
I have tried to avoid this error, but to no avail.
Several less important issues also arise:
- GET https://cdn.jsdelivr.net/npm/wacoq@0.16.0ui-images/wa-logo.svg
- GET https://cdn.jsdelivr.net/npm/wacoq@0.16.0ui-images/coq-logo.png
- GET https://cdn.jsdelivr.net/npm/wacoq@0.16.0docs/quick-help.html
These resources all resolve to 404 Not Found (notice the missing /)
After tweaking the base_path (adding a final / to the path), the GET request still fails but then due to having a slash too much:
- GET https://cdn.jsdelivr.net/npm/wacoq@0.16.0//ui-images/jscoq-splash.png
- GET https://cdn.jsdelivr.net/npm/wacoq@0.16.0//ui-images/egg.png
- GET https://cdn.jsdelivr.net/npm/wacoq@0.16.0//ui-images/wait.gif
Resulting in a 400 Bad Request (probably due to the double slash).
Any idea how to solve this issue?
Using jsCoq 1.16.0
The following snippet:
<script type="module" crossorigin="anonymous">
import { JsCoq } from 'https://cdn.jsdelivr.net/npm/jscoq@0.16.0/ui-js/index.min.js';
document.querySelectorAll('.site-main')[0].id = 'ide-wrapper';
var jscoq_ids = ['.snippet'];
var jscoq_opts = {
base_path: 'https://cdn.jsdelivr.net/npm/jscoq@0.16.0',
pkg_path: 'https://cdn.jsdelivr.net/npm/jscoq@0.16.0/coq-pkgs',
node_modules_path: 'https://cdn.jsdelivr.net/npm/',
prelude: true,
implicit_libs: true,
editor: { mode: { 'company-coq': true } },
init_pkgs: ['init'],
all_pkgs: ['coq']
};
JsCoq.start(jscoq_ids, jscoq_opts);
</script>
- Security Error: Content at url-of-my-post may not load data from https://cdn.jsdelivr.net/npm/jscoq@0.16.0/coq-js/jscoq_worker.bc.cjs.
The above error appears, which seems the reason why jsCoq won't load. Also the minor issues:
- GET https://cdn.jsdelivr.net/npm/jscoq@0.16.0ui-images/js-logo.svg
- GET https://cdn.jsdelivr.net/npm/jscoq@0.16.0ui-images/coq-logo.png
where both above give 404.
Other versions
I also tried 0.17.1, 0.15.0, and 0.14.0 These all leads to CORS issues, so I did not try these any further.