-
Notifications
You must be signed in to change notification settings - Fork 104
Add download button for Jupyter notebooks in tutorial pages #642
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 1 commit
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
54f23e3
Add download button for Jupyter notebooks in tutorial pages
ff55d5a
Refactor Quarto rendering and remove download notebook script
8dd8fbf
Merge branch 'main' into add_notebook_dl
AoifeHughes 091e1a1
Update to Turing 0.40
mhauru fc4df94
Update version in _quarto.yml
mhauru df1f9cd
Fix DPPL 0.37 run_ad change
mhauru 14973ad
Fix VI tutorial
mhauru 06bb33d
Fix model-manual's use of contexts
mhauru e7519c9
Fix references to __context__
mhauru 4530247
Fix use of addlogprob for log prior
mhauru 57c3162
Fix typo
mhauru 2065a14
Regenerate manifest
mhauru 2babb2d
Remove version pin of DelayDiffEq and update Manifest
mhauru b41a4cb
Fix call to evaluate
mhauru 425539d
Add note about contexts tutorial being out of date
mhauru dde0ed3
Apply suggestions from code review
mhauru a32ec1b
Add ipynb format support
1e7f351
maybe added links to dl?
e455881
Merge branch 'add_notebook_dl' of https://github.com/TuringLang/docs …
d1bacac
reset mainifest
a78fac4
dont execute ipynb
98bf999
bump local changes
60a07a8
Merge branch 'main' into add_notebook_dl
AoifeHughes af7ceb4
add post-render script for converting .quarto_ipynb files to .ipynb
4459016
Merge branch 'add_notebook_dl' of https://github.com/TuringLang/docs …
7f00453
Refactor notebook generation process and clean up tutorial metadata
708d22b
Merge branch 'main' into add_notebook_dl
AoifeHughes 64c62a4
please work :(
1c6fad9
Merge branch 'add_notebook_dl' of github.com:TuringLang/docs into add…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -28,4 +28,5 @@ venv | |
site_libs | ||
.DS_Store | ||
index_files | ||
digest.txt | ||
digest.txt | ||
**/*.quarto_ipynb |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<script> | ||
document.addEventListener('DOMContentLoaded', function() { | ||
// Only add button if we're on a tutorial page | ||
const path = window.location.pathname; | ||
if (path.includes('/tutorials/') || path.includes('/usage/')) { | ||
// Extract the notebook name from the URL | ||
const pathParts = path.split('/'); | ||
const section = pathParts[pathParts.length - 2]; | ||
|
||
// Create download button | ||
const downloadBtn = document.createElement('a'); | ||
downloadBtn.className = 'btn btn-primary download-notebook-btn'; | ||
downloadBtn.innerHTML = '<i class="bi bi-download"></i> Download as Notebook'; | ||
|
||
// Generate GitHub raw URL for the notebook | ||
const baseUrl = 'https://raw.githubusercontent.com/TuringLang/docs/main'; | ||
const notebookPath = path.replace('.html', '.ipynb'); | ||
downloadBtn.href = baseUrl + notebookPath; | ||
downloadBtn.download = section + '.ipynb'; | ||
|
||
// Insert button after title or in TOC area | ||
const tocTitle = document.querySelector('.toc-title'); | ||
if (tocTitle) { | ||
tocTitle.parentNode.insertBefore(downloadBtn, tocTitle.nextSibling); | ||
} else { | ||
const articleHeader = document.querySelector('header.quarto-title-block'); | ||
if (articleHeader) { | ||
articleHeader.appendChild(downloadBtn); | ||
} | ||
} | ||
} | ||
}); | ||
</script> | ||
|
||
<style> | ||
.download-notebook-btn { | ||
display: inline-block; | ||
margin: 1rem 0; | ||
padding: 0.5rem 1rem; | ||
background-color: var(--bs-primary); | ||
color: white; | ||
text-decoration: none; | ||
border-radius: 0.25rem; | ||
font-size: 0.9rem; | ||
} | ||
|
||
.download-notebook-btn:hover { | ||
background-color: var(--bs-primary-dark); | ||
color: white; | ||
text-decoration: none; | ||
} | ||
|
||
.download-notebook-btn i { | ||
margin-right: 0.5rem; | ||
} | ||
</style> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.