From 9698bc81df2d2e729ef094f811a02338f8a30c0c Mon Sep 17 00:00:00 2001 From: Oliver Date: Mon, 11 Oct 2021 19:04:27 +1100 Subject: [PATCH 01/10] Improve hooks --- docs/hooks.py | 27 ++++++++++++++++++++------- 1 file changed, 20 insertions(+), 7 deletions(-) diff --git a/docs/hooks.py b/docs/hooks.py index 5ffc76a..7c34550 100644 --- a/docs/hooks.py +++ b/docs/hooks.py @@ -27,17 +27,30 @@ 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}" - config['site_url'] = url + print("Building within READTHEDOCS environment!") + print(f" - Version: {rtd_version}") + print(f" - Language: {rtd_language}") + + else: + print("'READTHEDOCS' environment variable not found") + print("Building for localhost configuration!") + + assets_dir = '/assets' + site_url = config['site_url'] + + config['assets_dir'] = assets_dir + config['site_url'] = site_url + config['readthedocs'] = rtd + + print(f"config.site_url = '{site_url}'") + print(f"config.assets_dir = '{assets_dir}'") return config From 35fc12c8dd03c6121dbe9340eb9d18fbced22a56 Mon Sep 17 00:00:00 2001 From: Oliver Date: Mon, 11 Oct 2021 19:04:38 +1100 Subject: [PATCH 02/10] Fix image include --- _includes/img.html | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/_includes/img.html b/_includes/img.html index 874f6d6..b1ea4f3 100644 --- a/_includes/img.html +++ b/_includes/img.html @@ -1,13 +1,7 @@ -{% 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 %} {% else %} -{% set doc_url = assets + '/images/' + url %} +{% set img_url = config.assets_dir + '/images/' + url %} {% endif %}
@@ -15,9 +9,9 @@ {% elif doc_url %} - + {% endif %} - {{ description }} Date: Mon, 11 Oct 2021 19:09:46 +1100 Subject: [PATCH 05/10] Fix image URL for splide galleries --- _includes/splide_image.html | 7 +------ docs/contribute.md | 8 +------- 2 files changed, 2 insertions(+), 13 deletions(-) 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! From 645942827e3952466a5eb22c170e5d3fa773f81d Mon Sep 17 00:00:00 2001 From: Oliver Date: Mon, 11 Oct 2021 20:10:20 +1100 Subject: [PATCH 06/10] Fix readthedocs context --- docs/hooks.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/docs/hooks.py b/docs/hooks.py index ff37ce0..29d97a8 100644 --- a/docs/hooks.py +++ b/docs/hooks.py @@ -56,10 +56,11 @@ def on_config(config, *args, **kwargs): assets_dir = '/assets' site_url = config['site_url'] + config.readthedocs = False + config['assets_dir'] = assets_dir config['site_url'] = site_url - config['readthedocs'] = rtd - + print(f"config.site_url = '{site_url}'") print(f"config.assets_dir = '{assets_dir}'") From 6552b90959078ac793247090a566f9838158b13d Mon Sep 17 00:00:00 2001 From: Oliver Date: Mon, 11 Oct 2021 20:16:47 +1100 Subject: [PATCH 07/10] Fix assets directory --- _includes/img.html | 6 +++--- docs/hooks.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/_includes/img.html b/_includes/img.html index b1ea4f3..9d0983c 100644 --- a/_includes/img.html +++ b/_includes/img.html @@ -1,5 +1,5 @@ {% if 'http' in url %} -{% set doc_url = url %} +{% set img_url = url %} {% else %} {% set img_url = config.assets_dir + '/images/' + url %} {% endif %} @@ -8,7 +8,7 @@ {% if id %} - {% elif doc_url %} + {% elif img_url %} {% endif %} {{ description }} - {% if id or doc_url %} + {% if id or img_url %} {% endif %} diff --git a/docs/hooks.py b/docs/hooks.py index 29d97a8..701e941 100644 --- a/docs/hooks.py +++ b/docs/hooks.py @@ -32,7 +32,7 @@ def on_config(config, *args, **kwargs): rtd_language = os.environ['READTHEDOCS_LANGUAGE'] site_url = f"https://inventree.readthedocs.io/{rtd_language}/{rtd_version}" - assets_dir = f"/{rtd_language}/{rtd_version}" + assets_dir = f"/{rtd_language}/{rtd_version}/assets" print("Building within READTHEDOCS environment!") print(f" - Version: {rtd_version}") From 712983ef56e66ff92e945e398d5d183e04f850b0 Mon Sep 17 00:00:00 2001 From: Oliver Date: Mon, 11 Oct 2021 20:18:46 +1100 Subject: [PATCH 08/10] Fix context map setting --- docs/hooks.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/hooks.py b/docs/hooks.py index 701e941..ecf2451 100644 --- a/docs/hooks.py +++ b/docs/hooks.py @@ -47,7 +47,7 @@ def on_config(config, *args, **kwargs): readthedocs[k] = os.environ[key] # Supply this to the context - config.readthedocs = readthedocs + config['readthedocs'] = readthedocs else: print("'READTHEDOCS' environment variable not found") @@ -56,7 +56,7 @@ def on_config(config, *args, **kwargs): assets_dir = '/assets' site_url = config['site_url'] - config.readthedocs = False + config['readthedocs'] = False config['assets_dir'] = assets_dir config['site_url'] = site_url From 4da64d8fd9c51d9bbec702f8901f90f033595443 Mon Sep 17 00:00:00 2001 From: Oliver Date: Mon, 11 Oct 2021 20:21:49 +1100 Subject: [PATCH 09/10] Dumb --- docs/hooks.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/hooks.py b/docs/hooks.py index ecf2451..a7d38a2 100644 --- a/docs/hooks.py +++ b/docs/hooks.py @@ -42,7 +42,7 @@ def on_config(config, *args, **kwargs): readthedocs = {} for key in os.environ.keys(): - if key.lower().startswith('READTHEDOCS_'): + if key.startswith('READTHEDOCS_'): k = key.replace('READTHEDOCS_', '').lower() readthedocs[k] = os.environ[key] From 8bc8306a5039d0d07b52f1878cc108e47f2981b7 Mon Sep 17 00:00:00 2001 From: Oliver Date: Mon, 11 Oct 2021 20:48:32 +1100 Subject: [PATCH 10/10] Fix 404 error page --- _includes/overrides/404.html | 32 +++++++++++++++++++++++++++----- _includes/overrides/home.html | 4 ++-- docs/part/part.md | 6 ------ 3 files changed, 29 insertions(+), 13 deletions(-) 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 @@