Skip to content

Commit

Permalink
[change] Updated version switcher and offline docs URLs
Browse files Browse the repository at this point in the history
- Fixed repeated versions in version map on consecutive builds
- Fixed double logo on narrow screen

---------

Co-authored-by: Federico Capoano <[email protected]>
  • Loading branch information
pandafy and nemesifier authored Oct 24, 2024
1 parent 4616370 commit 519da77
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 79 deletions.
122 changes: 76 additions & 46 deletions _static/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -149,12 +149,10 @@ code.download {
}

#content a:not(.toc-backref),
#right-sidebar ul li a[data-current=true],
#doc-versions a {
#right-sidebar ul li a[data-current=true] {
color: var(--link-color) !important;
}
#content a:not(.toc-backref,.image-reference):hover,
#doc-versions a:hover {
#content a:not(.toc-backref,.image-reference):hover {
filter: brightness(135%);
}
#content a:not(.toc-backref,.image-reference):visited {
Expand Down Expand Up @@ -286,10 +284,6 @@ header.sticky a.items-center > img,
padding-bottom: 0;
}

#left-sidebar > a > img {
display: inline
}

header.sticky > div.container {
height: 85px
}
Expand Down Expand Up @@ -372,50 +366,86 @@ main > div .flex.justify-between.items-center.pt-6 {
}

/* version switcher */
#doc-versions {
position: fixed;
bottom: 20px;
right: 20px;
padding: 10px;
margin: 0;
list-style: none;
z-index: 1000;
font-size: 0.9rem;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
border-radius: 5px;
background: var(--background-color);
.doc-versions {
font-size: 14px;
padding-left: 8px;
padding-right: 8px;
font-weight: 600;
}

#doc-versions .other {
display: none;
.doc-versions .dropdown {
display: inline-block;
}

#doc-versions:hover .other {
display: block;
.doc-versions .dropbtn {
padding: 4px 5px 4px 15px;
margin-left: 6px;
font-size: 14px;
}

#doc-versions li a {
text-decoration: none;
color: var(--link-color);
.doc-versions .dropbtn svg {
rotate: 90deg;
display: inline;
margin-left: 5px;
}

#doc-versions li a:hover {
text-decoration: underline;
.doc-versions .dropbtn,
.doc-versions .dropdown-content {
min-width: 75px;
border-radius: 8px;
border: 1px solid hsl(var(--border));
background-color: var(--background-color);
font-size: 14px;
text-align: left;
}

#doc-versions li {
margin: 5px 0;
.doc-versions .dropdown-content {
position: absolute;
border-radius: 0 0 8px 8px;
box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
z-index: 1;
text-align: center;
margin: -1px 0 0 6px;
}

#doc-versions .download-links {
margin-top: 5px;
.doc-versions .dropbtn.disabled {
min-width: unset;
padding-right: 16px;
cursor: not-allowed;
filter: brightness(0.9);
}

#doc-versions .download-links a {
text-decoration: none;
color: var(--link-color);
.doc-versions .dropdown-content a {
color: var(--theme-link-color);
padding: 4px 5px 4px 15px !important;
text-decoration: none !important;
display: block !important;
border-bottom: 1px solid var(--theme-border-color);
text-align: left;
}

#doc-versions .download-links a:hover {
text-decoration: underline;
.doc-versions .dropdown-content a:hover {
color: var(--button-hover-color);
}
.doc-versions .dropbtn.active {
border-radius: 8px 8px 0 0;
}
.offline-docs {
margin-top: 8px;
padding-top: 8px;
padding-right: 16px;
border-top: 1px solid hsl(var(--border));
font-size: 12px;
}
.offline-docs .heading {
padding: 7px 9px;
}
.offline-docs h6 {
text-transform: uppercase;
font-weight: 600;
}
.offline-docs .urls {
color: #D4D4D8;
padding: 0px 8px;
}
.offline-docs .urls a {
display: inline-block !important;
width: fit-content !important;
padding: 0px 8px !important;
color: #1F78D1;
}
.offline-docs .urls a:first-child {
padding-left: 0px !important;
}
12 changes: 12 additions & 0 deletions _templates/downloads.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<div class="offline-docs">
<div class="heading">
<h6>OFFLINE DOCS</h6>
</div>
<p class="urls">
<a href="{{ docs_root }}/{{ current_ow_version }}/OpenWISP-{{ current_ow_version }}.pdf" target="_blank">
PDF</a>
|
<a href="{{ docs_root }}/{{ current_ow_version }}/OpenWISP-{{ current_ow_version }}.epub" target="_blank">
ePUB</a>
</p>
</div>
27 changes: 0 additions & 27 deletions _templates/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,33 +5,6 @@
<link rel="canonical" href="{{ html_baseurl }}{{ docs_root }}/{{ current_ow_version }}/{{ pagename }}.html" />
{% endblock %}

{% block footer %}
{{ super() }}
<ul id="doc-versions">
{% for ow_version in ow_versions %}
{% if ow_version != current_ow_version %}
<li class="other">
<a href="{{ docs_root }}/{{ ow_version }}/{{ pagename }}.html"">{{ ow_version }}</a>
</li>
{% endif %}
{% endfor %}
<li class="current">
<p>
{{ _('Current version') }}:
<strong>{{ current_ow_version }}</strong>
</p>
<p class="download-links">
{{ _('Downloads') }}:
<a href="{{ docs_root }}/{{ current_ow_version }}/OpenWISP-{{ current_ow_version }}.pdf" target="_blank">
PDF</a>
|
<a href="{{ docs_root }}/{{ current_ow_version }}/OpenWISP-{{ current_ow_version }}.epub" target="_blank">
ePUB</a>
</p>
</li>
</ul>
{% endblock %}

{% block scripts %}
{{ super() }}
<!-- Matomo -->
Expand Down
21 changes: 21 additions & 0 deletions _templates/version_switcher.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<div class="doc-versions">
<label>Version</label>
<div class="dropdown" x-data="{ showVersionSwitcher: false }">
<button type="button" class="dropbtn {% if not ow_versions|length > 1 %} disabled {% endif %}"
{% if ow_versions|length > 1 %} @click="showVersionSwitcher = !showVersionSwitcher" :class="{'active': showVersionSwitcher}
{% endif %}
">{{ current_ow_version }}{% if ow_versions|length > 1 %}<svg fill="currentColor" height="18px"
stroke="none" viewBox="0 0 24 24" width="18px" xmlns="http://www.w3.org/2000/svg">
<path d="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"></path>
</svg>{% endif %}
</button>
<div x-show="showVersionSwitcher" class="dropdown-content" :class="{'hidden': !showVersionSwitcher}"
@click.away="showVersionSwitcher = false" class="dropdown-content">
{% for ow_version in ow_versions %}
{% if ow_version != current_ow_version %}
<a href="{{ docs_root }}/{{ ow_version }}/{{ pagename }}.html">{{ ow_version }}</a>
{% endif %}
{% endfor %}
</div>
</div>
</div>
9 changes: 4 additions & 5 deletions conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,17 +148,16 @@
'logo_dark': 'assets/design/openwisp-logo.svg',
'logo_light': 'assets/design/openwisp-logo-black.svg',
}
html_permalinks_icon = ""
html_static_path = ["_static"]
html_css_files = ["custom.css"]
html_permalinks_icon = ''
html_static_path = ['_static']
html_css_files = ['custom.css']
html_use_index = False # Don't create index
html_domain_indices = False # Don't need module indices
html_copy_source = False # Don't need sources

# Custom sidebar templates, maps document names to template names.
#
# html_sidebars = {
# }
html_sidebars = {'**': ['version_switcher.html', 'sidebar_toc.html', 'downloads.html']}

# Add any paths that contain custom themes here, relative to this directory.
# html_theme_path = ['_theme']
Expand Down
3 changes: 2 additions & 1 deletion version_switcher/event_callbacks.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ def update_version_map(app, docname, content):
if app.builder.name != 'version_map':
return
try:
app.builder.ow_version_map[docname].append(app.config.version)
if app.config.version not in app.builder.ow_version_map[docname]:
app.builder.ow_version_map[docname].append(app.config.version)
except KeyError:
app.builder.ow_version_map[docname] = [app.config.version]

Expand Down

0 comments on commit 519da77

Please sign in to comment.