I have a number of public notebooks with addresses like
Is there a way to setup sharing of the whole directory?
Mathematica Stack Exchange is a question and answer site for users of Wolfram Mathematica. It only takes a minute to sign up.
Sign up to join this communityI have a number of public notebooks with addresses like
Is there a way to setup sharing of the whole directory?
We don't have a way to set up an automatic index page yet. But if there is a cloud object index.html
or index.nb
in the directory, it will be served as the index page for the directory (as long as the viewer has permission to that object). This could be a static page (including a notebook), or it could be generated dynamically.
E.g. the following code deploys a Delayed
object that serves a simple (HTML) index page for the cloud directory testdir
:
getItem[CloudObject[url_, ___]] :=
ExportString[
XMLElement[
"li", {}, {XMLElement["a", {"href" -> url}, {FileNameTake[url]}]}],
"XML"]
getIndexPage[obj_CloudObject] :=
StringJoin[
"<html><head><title>Directory Index</title></head><body><ul>",
getItem /@ CloudObjects[obj], "</ul></body></html>"]
CloudDeploy[
Delayed[getIndexPage[
ParentDirectory[
CloudObject[$EvaluationCloudObject,
CloudObjectNameFormat -> "CloudUserUUID"]]], "HTML"],
CloudObject["testdir/index.html"]]
Note the use of CloudObjectNameFormat
so that the $EvaluationCloudObject
is considered in its named form, making sure that ParentDirectory
does the right thing.
Use the option Permissions->"Public"
(or CloudPublish
instead of CloudDeploy
) if you want to make the index page public.
In the future, we'll make this configurable using a CloudObject
option on the directory itself. Perhaps it will be something like DirectoryIndexObject
, where the default Automatic
would look for index.html
or index.nb
as it does now, and would serve an automatically generated index page if they don't exist – as long as the requester has Read permission on the directory.