Message Boards Message Boards

1
|
3187 Views
|
0 Replies
|
1 Total Likes
View groups...
Share
Share this post:

Best practices for uploading notebooks and creating download hyperlinks?

Posted 6 years ago

cross posted on mathematica.stackexchange.com

I want to export _Notebook to the Cloud as a .nb file a make it available to download via hyperlink in different places.

This is rather a code-review question because I have the working solution. The problem is that it does not feel idiomatic:

(*uploading notebook*)
co = CloudExport[
  ExportString[   Notebook[{Cell[BoxData@ToBoxes@Defer[1 + 1], "Input"]}]  , "NB"    ]
, "Text"
, "test/notebook.nb"
]

(*cloud object with a download link*)
With[
  { hyperlink = StringTemplate[     "<a href = \"``\" download>Download notebook</a>"    ] @ First @ co   }
, CloudDeploy[
    Column[{ EmbeddedHTML[hyperlink], Manipulate[x, {x, 0, 1}]}]
  , "test/fileHyperlink"
  ]
]

I want to address following issues:

  • Exporting .nb via ExportString + Text.

Straightforward CloudExport as "NB" or CloudDeploy would be better but I can't restrict it to not being treated as a Cloud Notebook and what is fetched otherwise is an html file.

  • Download link

It is nice that EmbeddCode almost works but one would expect Hyperlink to do that. I failed to find correct syntax for it e.g. Hyperlink[lbl, File[url]] redirects to plain text .nb in a browser.

Is there a better way or is it a way to go?

POSTED BY: Kuba Podkalicki
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract