Static Sites with Sphinx and Markdown Transcripts
Chapter: More Authoring
0:00 We'll close out with two short segments.
0:03 Sometimes you want to include a static file in your sight something that can be downloaded
0:09 by clicking a link. Maybe it's a pdf.
0:12 Maybe it's some code, maybe it's an image and you don't want it rendered in
0:17 the page. For example, click here for the full sized image as it turns
0:22 out. Sphinx has a role that you can add to your links to turn the
0:29 link into a downloadable link instead of something that would try to navigate to the
0:36 URL for that link.
0:39 When it's processed, the downloadable file pointed to that by that link for example
0:45 'example.py' would be copied into a under downloads directory and then given some unique file
0:54 name so that it's hashed and whenever it changed it would get lead to a new
0:59 one and then that hash file name is inserted into the to the link text that's
1:05 generated and put into the document.
1:09 Let's take a look at this in action.
1:10 Going to go back to my editor gonna paste in a little bit of text that
1:14 allows us to download the python logo instead of just displaying it in line.
1:21 And for that we put the location of the file in back quotes which is kind
1:28 of a common markdown thing to do but we preface it with curly brackets and a
1:33 directive. And what that's saying is this thing inside the curly brackets is a Sphinx
1:41 roll, which is in our case download now that I save,
1:48 I can go back over, take a look at the rendered output,
1:52 scroll down and I see that you can download the python logo and then I get
1:58 some link text which is the file name,
2:00 some styling and when I mouse over it I can see down in the bottom corner
2:07 the URL.
2:09 Is some really long set of digits followed by python-logo.png.
2:14 So that when you download it it will actually save on your computer with that.
2:19 If I click on it's going to prompt me to save it with a file name
2:25 and that's the file name by default.
2:28 What if I don't want that As the link text this follows a convention that you'll
2:33 see a lot in MyST where you can put this in greater than less than and
2:41 put the logo some text that goes in the place of the file name and when
2:50 I go back over I see that that is now my link text.
2:55 This download functionality uses roles. We talked about this a little bit earlier on the
3:02 figure element and how we can link to it using the role and we'll talk a
3:06 lot more about this later in the course because roles are a really unique facility for Sphinx.