Add the ability to link to text resource for IDE #328
Reference in New Issue
Block a user
Delete Branch "kurt/327"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Very basic feature, puts the url of the resource in the url for the ide
to fetch when it loads. I haven't added the ability to create these
links as it probably needs some consideration with how it fits into the
IDE.
Should work with any url that returns text but obviously has to CORS
enable since it's in the browser, of which gitlab raw content is not
which is kinda bizzare.
works with github raw content like so:
https://cadhub.xyz/dev-ide/openScad#fetch_text_v1=https://raw.githubusercontent.com/aaevan/openscad_objects/main/fire_tablet_bottom_corner.scad
however I would recommend url encoding it with
encodeURIComponentincase there are special characters in the path
http://cadhub.xyz/dev-ide/openScad#fetch_text_v1=https%3A%2F%2Fraw.githubusercontent.com%2Faaevan%2Fopenscad_objects%2Fmain%2Ffire_tablet_bottom_corner.scad
In the case of github, linking to raw is the safest, however it will try
and get to the raw content from the web-app url i.e. the following still
works:
https://cadhub.xyz/dev-ide/openScad#fetch_text_v1=https://github.com/aaevan/openscad_objects/blob/main/fire_tablet_bottom_corner.scad
Resolves #327
@@ -0,0 +1,21 @@// import { githubSafe } from './IdeToolbarNew.js'// TODO jest doesn't like ECMAScript modules and is failing further down in the tree because three ES modulesI need to sort out testing :(
@@ -4,3 +4,3 @@[](https://app.netlify.com/sites/cadhubxyz/deploys)<!-- [](https://app.netlify.com/sites/cadhubxyz/deploys) -->Removing because more than often it displays as failed, when what really happened is build was cancel because there was a change to the docs not the app so the build finished early. Not sure if this can be sorted out or not.
@@ -8,0 +14,4 @@.replace('/blob/', '/'): urlconst prepareEncodedUrl = flow(decodeURIComponent, githubSafe)Trying to ease my way into some functional concepts. This is just a helper that makes a function the equivalent of
Not really needed in this case with only two functions, but the idea is one of the dis-incentives of making small easy to understand functions is that chaining them is pain to write and read
a(b(c(input)))so you just make oneabc(input).