You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@airflow.apache.org by ka...@apache.org on 2020/11/24 01:45:10 UTC
[airflow-site] branch master updated: Customizable navbar (#309)
This is an automated email from the ASF dual-hosted git repository.
kamilbregula pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/airflow-site.git
The following commit(s) were added to refs/heads/master by this push:
new 1e9bbab Customizable navbar (#309)
1e9bbab is described below
commit 1e9bbab7908209fa517661a88deed24ad7f47f6b
Author: Kamil BreguĊa <mi...@users.noreply.github.com>
AuthorDate: Tue Nov 24 02:45:00 2020 +0100
Customizable navbar (#309)
---
sphinx_airflow_theme/demo/docs.sh | 7 +-
.../sphinx_airflow_theme/__init__.py | 25 ++++++-
.../sphinx_airflow_theme/footer.html | 7 ++
.../sphinx_airflow_theme/header.html | 81 ++++------------------
4 files changed, 52 insertions(+), 68 deletions(-)
diff --git a/sphinx_airflow_theme/demo/docs.sh b/sphinx_airflow_theme/demo/docs.sh
index 3348e82..e74c7b0 100755
--- a/sphinx_airflow_theme/demo/docs.sh
+++ b/sphinx_airflow_theme/demo/docs.sh
@@ -41,7 +41,12 @@ EOF
function ensure_that_documentation_is_built {
if [[ ! -f _build/html/index.html ]] ; then
echo "Documentation is not built. Start build."
- sphinx-build -M html "${SOURCE_DIR}" "${BUILD_DIR}" -E
+ # -E don't use a saved environment, always read all files
+ # -T show full traceback on exception
+ sphinx-build \
+ -E \
+ -T \
+ "${SOURCE_DIR}" "${BUILD_DIR}"
fi
}
diff --git a/sphinx_airflow_theme/sphinx_airflow_theme/__init__.py b/sphinx_airflow_theme/sphinx_airflow_theme/__init__.py
index 5132835..2dc7265 100644
--- a/sphinx_airflow_theme/sphinx_airflow_theme/__init__.py
+++ b/sphinx_airflow_theme/sphinx_airflow_theme/__init__.py
@@ -16,6 +16,7 @@
# under the License.
from os import path
+from sphinx.application import Sphinx
__version__ = '0.0.1'
__version_full__ = __version__
@@ -27,7 +28,29 @@ def get_html_theme_path():
return cur_dir
+def setup_my_func(app, pagename, templatename, context, doctree):
+ context["navbar_links"] = app.config.sphinx_airflow_theme_navbar_links
+ context["hide_website_buttons"] = (
+ app.config.sphinx_airflow_theme_hide_website_buttons
+ )
+
+
# See http://www.sphinx-doc.org/en/stable/theming.html#distribute-your-theme-as-a-python-package
-def setup(app):
+def setup(app: Sphinx):
+ app.add_config_value(
+ 'sphinx_airflow_theme_navbar_links',
+ default=[
+ {'href': '/docs/', 'text': 'Documentation'}
+ ],
+ rebuild='html'
+ )
+ app.add_config_value(
+ 'sphinx_airflow_theme_hide_website_buttons',
+ default=False,
+ rebuild='html',
+ types=[bool]
+ )
+
app.add_html_theme('sphinx_airflow_theme', path.abspath(path.dirname(__file__)))
app.add_stylesheet('_gen/css//main-custom.min.css')
+ app.connect("html-page-context", setup_my_func)
diff --git a/sphinx_airflow_theme/sphinx_airflow_theme/footer.html b/sphinx_airflow_theme/sphinx_airflow_theme/footer.html
index c7ce5e5..73c656e 100644
--- a/sphinx_airflow_theme/sphinx_airflow_theme/footer.html
+++ b/sphinx_airflow_theme/sphinx_airflow_theme/footer.html
@@ -90,6 +90,8 @@
</a>
</div>
+ {% if hide_website_buttons %}
+
<div class="footer-section__media-section--button-with-text">
<span class="footer-section__media-section--text">Want to be a part of Apache Airflow?</span>
<a href="/community">
@@ -98,6 +100,8 @@
</a>
</div>
+ {% endif %}
+
</div>
<div class="footer-section footer-section__policies-section">
<div class="footer-section">
@@ -119,6 +123,7 @@
<a href="https://www.apache.org/security/" class="footer-section__policies-section--policy-item">
<span>Security</span>
</a>
+ {% if hide_website_buttons %}
<a href="/docs" class="footer-section__policies-section--policy-item">
<span>Season of Docs</span>
@@ -144,6 +149,8 @@
</div>
</div>
+ {% endif %}
+
</div>
</div>
<span class="footer-section__policies-section--disclaimer">
diff --git a/sphinx_airflow_theme/sphinx_airflow_theme/header.html b/sphinx_airflow_theme/sphinx_airflow_theme/header.html
index 4421696..d2cd138 100644
--- a/sphinx_airflow_theme/sphinx_airflow_theme/header.html
+++ b/sphinx_airflow_theme/sphinx_airflow_theme/header.html
@@ -55,51 +55,18 @@
<div class="navbar__menu-content" id="main_navbar">
<div class="navbar__links-container">
-
- <a class="navbar__text-link " href="/community/">
- Community
- </a>
-
- <a class="navbar__text-link " href="/meetups/">
- Meetups
- </a>
-
- <a class="navbar__text-link " href="/docs/">
- Documentation
- </a>
-
- {#
- TODO: Temporary solution. Uncomment when roadmap content is ready.
-
- <a class="navbar__text-link " href="/roadmap/">
- Roadmap
- </a>
- #}
-
- <a class="navbar__text-link " href="/use-cases/">
- Use cases
- </a>
-
- <a class="navbar__text-link " href="/blog/">
- Blog
- </a>
-
+ {% for link in navbar_links %}
+ <a class="navbar__text-link" href="{{ link.href }}/">
+ {{ link.text }}
+ </a>
+ {% endfor %}
</div>
- {#
- TODO: Temporary solution. Replace the link to docs with commented code when texts on install page are ready.
-
- <a href="/install/">
-
- <button id="" class="btn-filled bodytext__medium--white ">Install</button>
-
- </a>
- #}
+ {% if hide_website_buttons %}
<a href="/docs/stable/start.html">
-
- <button id="" class="btn-filled bodytext__medium--white ">Install</button>
-
+ <button class="btn-filled bodytext__medium--white">Install</button>
</a>
+ {% endif %}
</div>
@@ -143,38 +110,20 @@
<div class="navbar__menu-content" id="main_navbar">
<div class="navbar__links-container">
-
- <a class="navbar__text-link " href="/community/">
- Community
- </a>
-
- <a class="navbar__text-link " href="/meetups/">
- Meetups
- </a>
-
- <a class="navbar__text-link " href="/docs/">
- Documentation
- </a>
-
- <a class="navbar__text-link " href="/roadmap/">
- Roadmap
- </a>
-
- <a class="navbar__text-link " href="/use-cases/">
- Use cases
- </a>
-
- <a class="navbar__text-link " href="/blog/">
- Blog
- </a>
+ {% for link in navbar_links %}
+ <a class="navbar__text-link" href="{{ link.href }}/">
+ {{ link.text }}
+ </a>
+ {% endfor %}
</div>
-
+ {% if hide_website_buttons %}
<a href="/install/">
<button id="" class="btn-filled bodytext__medium--white ">Install</button>
</a>
+ {% endif %}
</div>
</div>