diff --git a/Prototypes/Cloud.wl b/Prototypes/Cloud.wl new file mode 100644 index 0000000..07df471 --- /dev/null +++ b/Prototypes/Cloud.wl @@ -0,0 +1,12 @@ +CreateNotebookRenderAPI[] := Module[ {function,api,form}, + function = Function[ Module[{nb, co}, nb = Import[URLDownload[#url]]; co = CloudPublish[nb]; HTTPRedirect[First[co]] ]]; + api = APIFunction[{"url" -> "String"}, function, "CloudCDF"]; + CloudDeploy[api, CloudObject["api/render-notebook"], Permissions -> "Public"]; + form = FormFunction[{"url" -> "String"}, function, "CloudCDF"]; + CloudDeploy[form, CloudObject["form/render-notebook"], Permissions -> "Public"]; +]; + +RenderOnlineNotebook[ url_ ] := Module[{}, + If[ Not @ $CloudConnected, CloudConnect[] ]; + SystemOpen[ First[$CloudRootDirectory] <> "/api/render-notebook?url=" <> URLEncode[url]]; +]; diff --git a/Prototypes/PacletInfo.m b/Prototypes/PacletInfo.m index 1986dfb..761a012 100644 --- a/Prototypes/PacletInfo.m +++ b/Prototypes/PacletInfo.m @@ -54,7 +54,8 @@ "Prototypes`$LocalAppDataDirectory", "Prototypes`$LocalResourceObjects", "Prototypes`$RoamingAppDataDirectory", -"Prototypes`$UUIDStringPattern", "Prototypes`LayeredGeoGraphics"}, +"Prototypes`$UUIDStringPattern", "Prototypes`LayeredGeoGraphics", +"Prototypes`RenderOnlineNotebook","Prototypes`CreateNotebookRenderAPI"}, Context -> {"Prototypes`"} } } ] diff --git a/Prototypes/Prototypes.wl b/Prototypes/Prototypes.wl index 85d5663..4fafa65 100644 --- a/Prototypes/Prototypes.wl +++ b/Prototypes/Prototypes.wl @@ -9,7 +9,7 @@ Begin["`Private`"]; Module[ {files}, (* load in any session *) - files = {"Build.wl", "Dataset.wl", "Files.wl", + files = {"Build.wl", "Dataset.wl", "Files.wl", "Cloud.wl", "Image.wl", "Language.wl", "Paclet.wl", "Formats.wl", "Resources.wl", "Search.wl", "String.wl", "Color.wl", "Entities.wl", "WolframAlpha.wl", "Translation.wl","GeoGraphics.wl"}; diff --git a/Prototypes/Usage.wl b/Prototypes/Usage.wl index d3b0d25..01c8946 100644 --- a/Prototypes/Usage.wl +++ b/Prototypes/Usage.wl @@ -105,3 +105,6 @@ TranslationCell::usage = "TranslationCell[text,lang] prints a \"Text\" cell cont GeoService::usage = "GeoService[name] provides GeoServer 'name' for geographical functions. Use GeoService[\"Properties\"] for a list. Use with GeoServer option."; LayeredGeoGraphics::usage = "LayeredGeoGraphics[primitives,layers] creates a layered GeoGraphics map for the specified GeoService layers"; FormatDetect::usage = "FormatDetect[format,data] checks if 'data' (String/List/ByteArray) matches 'format' (PNG/JPG/GIF)"; +(* cloud *) +CreateNotebookRenderAPI::usage = "CreateNotebookRenderAPI[] creates the cloud api functions used by RenderOnlineNotebook"; +RenderOnlineNotebook::usage = "RenderOnlineNotebook[url] reads 'url' and opens a private editable copy";