Skip to content

Commit

Permalink
Merge branch 'master' into dependabot/pip/sphinxawesome-theme-approx-…
Browse files Browse the repository at this point in the history
…eq-5.3.1
  • Loading branch information
nemesifier authored Nov 8, 2024
2 parents b3fcf5e + a49a43a commit 49ea612
Show file tree
Hide file tree
Showing 8 changed files with 146 additions and 16 deletions.
21 changes: 21 additions & 0 deletions _static/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -449,3 +449,24 @@ main > div .flex.justify-between.items-center.pt-6 {
.offline-docs .urls a:first-child {
padding-left: 0px !important;
}

/* navigation */
.navigation-dropdown {
border-radius: 0.75rem;
margin-left: -48%;
margin-top: 5px;
transition-duration: 0.4s;
transition-property: opacity;
color: var(--background-color);
padding-top: 0.5rem;
padding-bottom: 0.5rem;
border: 1px solid hsl(var(--border));
}
.navigation-dropdown a {
padding: .375rem 1rem;
white-space: nowrap;
width: 100%;
}
#left-sidebar nav.md\:hidden {
margin-top: 1rem !important;
}
Binary file added _static/docs-og.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
47 changes: 47 additions & 0 deletions _templates/header.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{% extends "!header.html" %}

{%- block header_main_nav %}
{%- if main_nav_links|tobool -%}
<nav class="flex items-center space-x-6 text-sm font-medium">
{%- for text, item in main_nav_links.items() %}
{%- if item is string %}
{# Single link #}
{%- set _active = "text-foreground" if pagename in item else "text-foreground/60" -%}
{%- set url = item if item.startswith("http") else item %}
<a href="{{ url }}" class="py-2 transition-colors hover:text-foreground/80 {{ _active }}"
rel="{{ 'nofollow noopener' if url.startswith('http') else '' }}">{{ text }}</a>
{%- elif item is mapping %}
{# Nested links with focus and hover accessibility #}
<div x-data="{ open: false }" @focusin="open = true" @focusout="open = false" @mouseenter="open = true"
@mouseleave="open = false" class="relative navigation-link">
<a href="#" class="py-2 transition-colors hover:text-foreground/80 focus:outline-none" tabindex="0"
aria-haspopup="true" :aria-expanded="open.toString()">
{{ text }}
<svg fill="currentColor" height="24px" stroke="none" viewBox="0 0 24 24" width="24px"
xmlns="http://www.w3.org/2000/svg" class="rotate-90 inline">
<path d="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"></path>
</svg>
</a>
<div x-show="open"
x-transition:enter-start="opacity-0"
x-transition:enter-end="opacity-100 scale-100"
x-transition:leave="transition"
x-transition:leave-start="opacity-100 scale-100"
x-transition:leave-end="opacity-0"
class="absolute bg-background mt-2 z-10 transition navigation-dropdown"
style="display: none;">
{%- for subtext, suburl in item.items() %}
{%- set _active = "text-foreground" if pagename in suburl else "text-foreground/60" -%}
{%- set url = suburl if suburl.startswith("http") else suburl %}
<a href="{{ url }}" class="block px-4 py-2 text-sm transition-colors {{ _active }}" tabindex="0"
rel="{{ 'nofollow noopener' if suburl.startswith('http') else '' }}">
{{ subtext }}
</a>
{%- endfor %}
</div>
</div>
{%- endif %}
{%- endfor %}
</nav>
{%- endif %}
{%- endblock header_main_nav %}
3 changes: 3 additions & 0 deletions _templates/layout.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@

{% block linktags %}
{{ super() }}
<meta property="og:image" content="{{ html_baseurl }}{{ docs_root }}/{{ current_ow_version }}/_static/docs-og.png" />
<meta property="og:image:width" content="1200" />
<meta property="og:image:height" content="480" />
<link rel="canonical" href="{{ html_baseurl }}{{ docs_root }}/{{ current_ow_version }}/{{ pagename }}.html" />
{% endblock %}

Expand Down
38 changes: 38 additions & 0 deletions _templates/sidebar_main_nav_links.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
{#- Template for the main navigation links in the sidebar -#}
{% if main_nav_links|tobool %}
<nav class="flex flex-col font-bold md:hidden">
{%- for text, item in main_nav_links.items() %}
{%- if item is string %}
{# Single link #}
{%- set url = item if item.startswith("http") else pathto(item) %}
<a href="{{ url }}" class="block px-4 py-2 transition-colors hover:bg-gray-100 text-gray-800"
rel="{{ 'nofollow noopener' if item.startswith('http') else '' }}">
{{ text }}
</a>
{%- elif item is mapping %}
{# Nested links #}
<div x-data="{ open: false }" class="flex flex-col">
<a @click="open = !open" @focus="open = true" @blur="open = false"
class="flex items-center justify-between px-4 py-2 transition-colors hover:bg-gray-100 text-gray-800 w-full focus:outline-none"
:aria-expanded="open.toString()" aria-haspopup="true">
{{ text }}
<svg fill="currentColor" height="24px" stroke="none" viewBox="0 0 24 24" width="24px"
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>
</a>
<div x-show="open" x-transition class="flex flex-col pl-6 mt-2 space-y-1">
{%- for subtext, suburl in item.items() %}
{%- set sublink = suburl if suburl.startswith("http") else pathto(suburl) %}
<a href="{{ sublink }}"
class="block ml-2 px-4 py-2 text-sm transition-colors hover:bg-gray-100 text-gray-700"
rel="{{ 'nofollow noopener' if suburl.startswith('http') else '' }}">
{{ subtext }}
</a>
{%- endfor %}
</div>
</div>
{%- endif %}
{%- endfor %}
</nav>
{% endif %}
2 changes: 1 addition & 1 deletion _templates/sidebar_toc.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<nav class="table w-full min-w-full my-6 lg:my-8">
<nav class="table w-full min-w-full my-6 lg:my-8 mt-4">
{%- if theme_globaltoc_includehidden|tobool %}
{{ toctree(maxdepth=4, titles_only=true, collapse=True, includehidden=true) }}
{%- else %}
Expand Down
20 changes: 12 additions & 8 deletions _templates/version_switcher.html
Original file line number Diff line number Diff line change
@@ -1,16 +1,20 @@
<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">
<div class="dropdown" x-data="{ showVersionSwitcher: false, buttonWidth: 0 }"
x-init="buttonWidth = $refs.button.offsetWidth">
<button type="button" x-ref="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 %}
</svg>
{% endif %}
</button>
<div x-show="showVersionSwitcher" class="dropdown-content" :class="{'hidden': !showVersionSwitcher}"
@click.away="showVersionSwitcher = false" class="dropdown-content">
@click.away="showVersionSwitcher = false" style="display: none;" :style="{ width: buttonWidth + 'px' }">
{% for ow_version in ow_versions %}
{% if ow_version != current_ow_version %}
<a href="{{ docs_root }}/{{ ow_version }}/{{ pagename }}.html">{{ ow_version }}</a>
Expand Down
31 changes: 24 additions & 7 deletions conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,12 +136,6 @@
# documentation.

html_theme_options = {
'main_nav_links': {
'About': 'https://openwisp.org/',
'FAQ': 'https://openwisp.org/faq/',
'Support': 'https://openwisp.org/support/',
'Blog': 'https://openwisp.org/blog/',
},
'show_prev_next': True,
'show_scrolltop': True,
'show_breadcrumbs': True,
Expand All @@ -157,7 +151,14 @@

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

# Add any paths that contain custom themes here, relative to this directory.
# html_theme_path = ['_theme']
Expand Down Expand Up @@ -470,6 +471,22 @@
'docs_root': docs_root,
'stable_version': os.environ.get('STABLE_VERSION'),
'html_baseurl': os.environ.get('HTML_BASE_URL', ''),
'main_nav_links': {
'Features': 'https://openwisp.org/features/',
'About': {
'FAQ': 'https://openwisp.org/faq/',
'Source Code': 'https://openwisp.org/code/',
'History': 'https://openwisp.org/history/',
'Team': 'https://openwisp.org/team/',
'Partners': 'https://openwisp.org/partners/',
'Sponsorship': 'https://openwisp.org/sponsorship/',
},
'Support': {
'Community Support': 'https://openwisp.org/support/',
'Commercial Support': 'https://openwisp.org/commercial-support/',
},
'Blog': 'https://openwisp.org/blog/',
},
}

for ow_version in ow_docs_config['versions']:
Expand Down

0 comments on commit 49ea612

Please sign in to comment.