Skip to content
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

✨ NEW: Option for download button #245

Merged
merged 7 commits into from
Nov 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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