From 20fe598be76ec53977d2ac18cba35bfa31990c17 2012-08-31 21:42:21 From: Greg Caporaso Date: 2012-08-31 21:42:21 Subject: [PATCH] updated the documentation to describe the FileLink and FileLinks objects. skipping DirectoryLink right now as I don't think this will be widely used --- diff --git a/docs/examples/notebooks/00_notebook_tour.ipynb b/docs/examples/notebooks/00_notebook_tour.ipynb index e8f2602..fdc26f0 100644 --- a/docs/examples/notebooks/00_notebook_tour.ipynb +++ b/docs/examples/notebooks/00_notebook_tour.ipynb @@ -981,6 +981,118 @@ "cell_type": "markdown", "metadata": {}, "source": [ + "## Linking to files and directories for viewing in the browser\n", + "\n", + "It is also possible to link directly to files or directories so they can be opened in browser. This is especially convenient if you're interacting with a tool within IPython that generates HTML pages, and you'd like to easily be able to open those in a new browser window. Alternatively, if your IPython notebook server is on a remote system, creating links provides an easy way to download any files that get generated.\n", + "\n", + "As we saw above, there are a bunch of `.ipynb` files in our current directory." + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "!ls" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "output_type": "stream", + "stream": "stdout", + "text": [ + "00_notebook_tour.ipynb formatting.ipynb\r\n", + "01_notebook_introduction.ipynb octavemagic_extension.ipynb\r\n", + "Animations_and_Progress.ipynb publish_data.ipynb\r\n", + "Capturing Output.ipynb python-logo.svg\r\n", + "Script Magics.ipynb rmagic_extension.ipynb\r\n", + "animation.m4v sympy.ipynb\r\n", + "cython_extension.ipynb sympy_quantum_computing.ipynb\r\n", + "display_protocol.ipynb trapezoid_rule.ipynb\r\n" + ] + } + ], + "prompt_number": 6 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "If we want to create a link to one of them, we can call use the `FileLink` object." + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from IPython.display import FileLink\n", + "FileLink('00_notebook_tour.ipynb')" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "html": [ + "00_notebook_tour.ipynb
" + ], + "output_type": "pyout", + "prompt_number": 2, + "text": [ + "" + ] + } + ], + "prompt_number": 2 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "Alternatively, if we want to link to all of them, we can use the `FileLinks` object, passing `'.'` to indicate that we want links generated for the current working directory. Note that if there were other directories under the current directory, `FileLinks` would work in a recursive manner creating links to files in all sub-directories as well." + ] + }, + { + "cell_type": "code", + "collapsed": false, + "input": [ + "from IPython.display import FileLink\n", + "FileLinks('.')" + ], + "language": "python", + "metadata": {}, + "outputs": [ + { + "html": [ + "00_notebook_tour.ipynb
\n", + "01_notebook_introduction.ipynb
\n", + "animation.m4v
\n", + "Animations_and_Progress.ipynb
\n", + "Capturing Output.ipynb
\n", + "cython_extension.ipynb
\n", + "display_protocol.ipynb
\n", + "formatting.ipynb
\n", + "octavemagic_extension.ipynb
\n", + "publish_data.ipynb
\n", + "python-logo.svg
\n", + "rmagic_extension.ipynb
\n", + "Script Magics.ipynb
\n", + "sympy.ipynb
\n", + "sympy_quantum_computing.ipynb
\n", + "trapezoid_rule.ipynb
" + ], + "output_type": "pyout", + "prompt_number": 7, + "text": [ + "" + ] + } + ], + "prompt_number": 7 + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ "### External sites\n", "\n", "You can even embed an entire page from another site in an iframe; for example this is today's Wikipedia\n",