From f26eb40910559ec3e0b9fe5c3886363bc20f11db Mon Sep 17 00:00:00 2001 From: Oliver Date: Mon, 11 Oct 2021 20:50:09 +1100 Subject: [PATCH] Merge pull request #190 from inventree/404-fix-2 404 fix 2 (cherry picked from commit ee445a8ef650e19bac5bdc465fdc6d4c7f76154d) --- _includes/img.html | 20 +++++++----------- _includes/overrides/404.html | 32 +++++++++++++++++++++++----- _includes/overrides/home.html | 4 ++-- _includes/splide_image.html | 7 +------ docs/contribute.md | 8 +------ docs/hooks.py | 39 ++++++++++++++++++++++++++++------- docs/part/part.md | 2 -- 7 files changed, 70 insertions(+), 42 deletions(-) diff --git a/_includes/img.html b/_includes/img.html index 874f6d6..9d0983c 100644 --- a/_includes/img.html +++ b/_includes/img.html @@ -1,36 +1,30 @@ -{% if 'readthedocs.org' in config.docs_dir %} -{% set assets = '/en/latest/assets' %} -{% else %} -{% set assets = '/assets' %} -{% endif %} - {% if 'http' in url %} -{% set doc_url = url %} +{% set img_url = url %} {% else %} -{% set doc_url = assets + '/images/' + url %} +{% set img_url = config.assets_dir + '/images/' + url %} {% endif %}
{% if id %} - {% elif doc_url %} - + {% elif img_url %} + {% endif %} - {{ description }} - {% if id or doc_url %} + {% if id or img_url %} {% endif %} {% if id %} - {{ description }} + {{ description }} {% endif %}
diff --git a/_includes/overrides/404.html b/_includes/overrides/404.html index b9468fc..70389c4 100644 --- a/_includes/overrides/404.html +++ b/_includes/overrides/404.html @@ -1,7 +1,29 @@ -{% extends "main.html" %} +{% extends "base.html" %} + +{% block tabs %} +{{ super() }} + +{% endblock %} + +{% block site_nav %} +{% endblock %} + {% block content %} -

- {% include ".icons/fontawesome/regular/sad-tear.svg" %} - Uh oh - Page not found... -

+ + +
+
+
+

+ + Page not found +

+
+
+ {% endblock %} \ No newline at end of file diff --git a/_includes/overrides/home.html b/_includes/overrides/home.html index a04eaf5..8aabcfb 100644 --- a/_includes/overrides/home.html +++ b/_includes/overrides/home.html @@ -23,10 +23,10 @@
- Features + Features - Install + Install Source Code diff --git a/_includes/splide_image.html b/_includes/splide_image.html index fbf32ac..3dc90ed 100644 --- a/_includes/splide_image.html +++ b/_includes/splide_image.html @@ -1,13 +1,8 @@ -{% if 'readthedocs.org' in config.docs_dir %} -{% set assets = '/en/latest/assets' %} -{% else %} -{% set assets = '/assets' %} -{% endif %} {% if 'http' in src %} {% set img_url = src %} {% else %} -{% set img_url = assets + '/images/' + src %} +{% set img_url = config.assets_dir + '/images/' + src %} {% endif %}
  • diff --git a/docs/contribute.md b/docs/contribute.md index d0978f7..e4e35db 100644 --- a/docs/contribute.md +++ b/docs/contribute.md @@ -36,15 +36,9 @@ If you see any sections of the documentation that require work (i.e. denoted wit ### Donate -{% if 'readthedocs.org' in config.docs_dir %} -{% set assets = '/en/latest/assets' %} -{% else %} -{% set assets = '/assets' %} -{% endif %} - Finally, if you are unable to provide contributions as listed above, or you find InvenTree to be useful, please consider donating to support its ongoing development. [ Donate ](https://www.paypal.com/cgi-bin/webscr?cmd=_donations&business=T4M976M5URSUE¤cy_code=AUD){: .md-button .md-button--primary } -PayPal Logo +PayPal Logo Financial donations directly support the ongoing development of the InvenTree project. If you benefit from the InvenTree project, please consider contributing to maintain vibrant development of this software! diff --git a/docs/hooks.py b/docs/hooks.py index 5ffc76a..a7d38a2 100644 --- a/docs/hooks.py +++ b/docs/hooks.py @@ -27,17 +27,42 @@ def on_config(config, *args, **kwargs): rtd = os.environ.get('READTHEDOCS', False) - if not rtd: - print("'READTHEDOCS' environment variable not found") - print("Building for localhost configuration!") - - else: + if rtd: rtd_version = os.environ['READTHEDOCS_VERSION'] rtd_language = os.environ['READTHEDOCS_LANGUAGE'] - url = f"https://inventree.readthedocs.io/{rtd_language}/{rtd_version}" + site_url = f"https://inventree.readthedocs.io/{rtd_language}/{rtd_version}" + assets_dir = f"/{rtd_language}/{rtd_version}/assets" - config['site_url'] = url + print("Building within READTHEDOCS environment!") + print(f" - Version: {rtd_version}") + print(f" - Language: {rtd_language}") + + # Add *all* readthedocs related keys + readthedocs = {} + + for key in os.environ.keys(): + if key.startswith('READTHEDOCS_'): + k = key.replace('READTHEDOCS_', '').lower() + readthedocs[k] = os.environ[key] + + # Supply this to the context + config['readthedocs'] = readthedocs + + else: + print("'READTHEDOCS' environment variable not found") + print("Building for localhost configuration!") + + assets_dir = '/assets' + site_url = config['site_url'] + + config['readthedocs'] = False + + config['assets_dir'] = assets_dir + config['site_url'] = site_url + + print(f"config.site_url = '{site_url}'") + print(f"config.assets_dir = '{assets_dir}'") return config diff --git a/docs/part/part.md b/docs/part/part.md index e1f0e80..996cdaa 100644 --- a/docs/part/part.md +++ b/docs/part/part.md @@ -4,8 +4,6 @@ title: Parts ## Part -config.site_url: {{ config.site_url }} - The *Part* is the core element of the InvenTree ecosystem. A Part object is the archetype of any stock item in your inventory. Parts are arranged in heirarchical categories which are used to organise and filter parts by function. ## Part Category