-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ca90510
commit 03c49e3
Showing
11 changed files
with
199 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
7 changes: 7 additions & 0 deletions
7
python/jupytercad_core/jupyter-config/server-config/jupytercad_core.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"ServerApp": { | ||
"jpserver_extensions": { | ||
"jupytercad_core": true | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import json | ||
from pathlib import Path | ||
|
||
from jupyter_server.base.handlers import APIHandler | ||
from jupyter_server.utils import url_path_join, ApiPath, to_os_path | ||
import tornado | ||
|
||
|
||
class JCadExportHandler(APIHandler): | ||
@tornado.web.authenticated | ||
def post(self): | ||
body = self.get_json_body() | ||
|
||
# Get filename removing the drive prefix | ||
file_name = body["path"].split(":")[1] | ||
export_name = body["newName"] | ||
|
||
root_dir = Path(self.contents_manager.root_dir).resolve() | ||
file_name = Path(to_os_path(ApiPath(file_name), str(root_dir))) | ||
|
||
with open(file_name, "r") as fobj: | ||
file_content = fobj.read() | ||
|
||
jcad = dict( | ||
objects=[ | ||
dict( | ||
name=Path(export_name).stem, | ||
visible=True, | ||
shape="Part::Any", | ||
parameters=dict( | ||
Content=file_content, Type=str(Path(Path(file_name).suffix[1:])) | ||
), | ||
) | ||
], | ||
metadata={}, | ||
options={}, | ||
outputs={}, | ||
) | ||
|
||
with open(Path(file_name).parents[0] / export_name, "w") as fobj: | ||
fobj.write(json.dumps(jcad, indent=2)) | ||
|
||
self.finish(json.dumps({"done": True})) | ||
|
||
|
||
def setup_handlers(web_app): | ||
host_pattern = ".*$" | ||
|
||
base_url = web_app.settings["base_url"] | ||
route_pattern = url_path_join(base_url, "jupytercad", "export") | ||
handlers = [(route_pattern, JCadExportHandler)] | ||
web_app.add_handlers(host_pattern, handlers) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file added
BIN
+57 KB
ui-tests/tests/ui.spec.ts-snapshots/JCAD-export-3M-CONNECTOR-STEP-linux.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.