Skip to content

Commit

Permalink
✨ NEW: Option for download button
Browse files Browse the repository at this point in the history
  • Loading branch information
bknaepen authored Nov 8, 2020
1 parent c784d06 commit a1fa391
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@
"use_edit_page_button": True,
"use_issues_button": True,
"use_repository_button": True,
"use_download_button": True,
# For testing
# "home_page_in_toc": True,
# "single_page": True,
Expand Down
11 changes: 11 additions & 0 deletions docs/configure.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,17 @@ html_theme_options = {
...
}
```
## Download page button

You can add a button allowing users to download the currently viewed page in several formats: raw, pdf or ipynb if available. To include this button, use the following configuration:

```python
html_theme_options = {
...
"use_download_button": True,
...
}
```

## Use a single-page version of this theme

Expand Down
1 change: 1 addition & 0 deletions sphinx_book_theme/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ def add_header_level_recursive(ul, level):
"theme_use_edit_page_button",
"theme_use_repository_button",
"theme_use_issues_button",
"theme_use_download_button",
]
for key in btns:
if key in context:
Expand Down
1 change: 1 addition & 0 deletions sphinx_book_theme/theme.conf
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ navbar_footer_text =
extra_navbar = Theme by the <a href="https://ebp.jupyterbook.org">Executable Book Project</a>
extra_footer =
use_issues_button = False
use_download_button = True
use_repository_button = False
theme_dev_mode = False
show_navbar_depth = 1
4 changes: 2 additions & 2 deletions sphinx_book_theme/topbar/download.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{% if page_source_suffix and theme_use_download_button %}
<div class="dropdown-buttons-trigger">
<button id="dropdown-buttons-trigger" class="btn btn-secondary topbarbtn" aria-label="{{ translate('Download this page') }}"><i
class="fas fa-download"></i></button>

{% if page_source_suffix %}
<div class="dropdown-buttons">
<!-- ipynb file if we had a myst markdown file -->
{% if ipynb_source %}<a class="dropdown-buttons"
Expand All @@ -17,5 +17,5 @@
<button type="button" id="download-print" class="btn btn-secondary topbarbtn" title="{{ translate('Print to PDF') }}"
onClick="window.print()" data-toggle="tooltip" data-placement="left">.pdf</button>
</div>
{% endif %}
</div>
{% endif %}
1 change: 1 addition & 0 deletions src/jinja/theme.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ navbar_footer_text =
extra_navbar = Theme by the <a href="https://ebp.jupyterbook.org">Executable Book Project</a>
extra_footer =
use_issues_button = False
use_download_button = True
use_repository_button = False
theme_dev_mode = False
show_navbar_depth = 1

0 comments on commit a1fa391

Please sign in to comment.