From 1fafef256fc5fb764fb880770b625a65fc50cab5 Mon Sep 17 00:00:00 2001 From: "J.Ironman" Date: Fri, 13 Mar 2026 10:38:26 +0100 Subject: [PATCH 01/25] implementation of BluePrint, fixed local dependencies of pytest "test_load_no_file" --- mslib/mscolab/app/__init__.py | 55 ++++++++------ mslib/mscolab/server.py | 4 +- mslib/mswms/app/__init__.py | 76 +++++++++++-------- mslib/static/templates/footer.html | 4 +- mslib/static/templates/theme.html | 10 +-- mslib/static/templates/user/status.html | 2 +- tests/_test_msui/test_satellite_dockwidget.py | 11 +-- 7 files changed, 89 insertions(+), 73 deletions(-) diff --git a/mslib/mscolab/app/__init__.py b/mslib/mscolab/app/__init__.py index 2387c8422..106c20c05 100644 --- a/mslib/mscolab/app/__init__.py +++ b/mslib/mscolab/app/__init__.py @@ -29,7 +29,7 @@ import sqlalchemy from flask_migrate import Migrate -from flask import Flask +from flask import Flask, Blueprint import mslib @@ -57,20 +57,26 @@ def file_exists(filepath=None): DOCS_STATIC_DIR = os.path.join(DOCS_SERVER_PATH, 'static') DOCS_IMG_DIR = os.path.join(DOCS_STATIC_DIR, 'img') DOCS_DOCS_DIR = os.path.join(DOCS_STATIC_DIR, 'docs') +DOCS_TEMPLATES_DIR = os.path.join(DOCS_STATIC_DIR, 'templates') # This can be used to set a location by SCRIPT_NAME for testing. e.g. export SCRIPT_NAME=/demo/ SCRIPT_NAME = os.environ.get('SCRIPT_NAME', '/') +docs_bp = Blueprint( + "docs", + __name__, + template_folder=os.path.join(DOCS_TEMPLATES_DIR) +) + # in memory database for testing # app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///' -APP = Flask(__name__, template_folder=os.path.join(DOCS_STATIC_DIR, 'templates')) +APP = Flask(__name__, template_folder=os.path.join(DOCS_TEMPLATES_DIR)) APP.config.from_object(mscolab_settings) # Expose docs path for callers/tests and make it part of Flask config for consistency. APP.config['DOCS_SERVER_PATH'] = DOCS_SERVER_PATH APP.route = prefix_route(APP.route, SCRIPT_NAME) -APP.jinja_env.globals.update(file_exists=file_exists) -APP.jinja_env.globals["imprint"] = APP.config['IMPRINT'] -APP.jinja_env.globals["gdpr"] = APP.config['GDPR'] + + def _xstatic(name): @@ -102,8 +108,9 @@ def create_app(imprint=None, gdpr=None): APP.jinja_env.globals.update(file_exists=file_exists) APP.jinja_env.globals["imprint"] = imprint_file APP.jinja_env.globals["gdpr"] = gdpr_file + APP.jinja_env.globals.update(get_topmenu=get_topmenu) - @APP.route('/xstatic//') + @docs_bp.route('/xstatic//') def files(name, filename): base_path = _xstatic(name) if base_path is None: @@ -112,22 +119,20 @@ def files(name, filename): abort(404) return send_from_directory(base_path, filename) - @APP.route('/mss_theme/img/') + @docs_bp.route('/mss_theme/img/') def mss_theme(filename): base_path = os.path.join(DOCS_IMG_DIR) return send_from_directory(base_path, filename) - APP.jinja_env.globals.update(get_topmenu=get_topmenu) - - @APP.route("/index") + @docs_bp.route("/index") def index(): return render_template("/index.html") - @APP.route("/mss/about") - @APP.route("/mss") + @docs_bp.route("/mss/about") + @docs_bp.route("/mss") def about(): _file = os.path.join(DOCS_DOCS_DIR, 'about.md') - img_url = url_for('overview') + img_url = url_for('docs.overview') md_overrides = ('![image](/mss/overview.png)', f'![image]({img_url})') html_overrides = ('image', @@ -135,13 +140,13 @@ def about(): content = get_content(_file, md_overrides=md_overrides, html_overrides=html_overrides) return render_template("/content.html", act="about", content=content) - @APP.route("/mss/install") + @docs_bp.route("/mss/install") def install(): _file = os.path.join(DOCS_DOCS_DIR, 'installation.md') content = get_content(_file) return render_template("/content.html", act="install", content=content) - @APP.route("/mss/help") + @docs_bp.route("/mss/help") def help(): # noqa: A001 _file = os.path.join(DOCS_DOCS_DIR, 'help.md') html_overrides = ('Waypoint Tutorial/') + @docs_bp.route('/xstatic//') def files(name, filename): base_path = _xstatic(name) if base_path is None: @@ -142,20 +152,20 @@ def files(name, filename): abort(404) return send_from_directory(base_path, filename) - @APP.route('/mss_theme/img/') + @docs_bp.route('/mss_theme/img/') def mss_theme(filename): - base_path = os.path.join(DOCS_SERVER_PATH, 'static', 'img') + base_path = os.path.join(DOCS_IMG_DIR) return send_from_directory(base_path, filename) - @APP.route("/index") + @docs_bp.route("/index") def index(): return render_template("/index.html") - @APP.route("/mss/about") - @APP.route("/mss") + @docs_bp.route("/mss/about") + @docs_bp.route("/mss") def about(): - _file = os.path.join(DOCS_SERVER_PATH, 'static', 'docs', 'about.md') - img_url = url_for('overview') + _file = os.path.join(DOCS_DOCS_DIR, 'about.md') + img_url = url_for('docs.overview') md_overrides = ('![image](/mss/overview.png)', f'![image]({img_url})') html_overrrides = ('image', @@ -163,15 +173,15 @@ def about(): content = get_content(_file, md_overrides=md_overrides, html_overrides=html_overrrides) return render_template("/content.html", act="about", content=content) - @APP.route("/mss/install") + @docs_bp.route("/mss/install") def install(): - _file = os.path.join(DOCS_SERVER_PATH, 'static', 'docs', 'installation.md') + _file = os.path.join(DOCS_DOCS_DIR, 'installation.md') content = get_content(_file) return render_template("/content.html", act="install", content=content) - @APP.route("/mss/help") + @docs_bp.route("/mss/help") def help(): # noqa: A001 - _file = os.path.join(DOCS_SERVER_PATH, 'static', 'docs', 'help.md') + _file = os.path.join(DOCS_DOCS_DIR, 'help.md') html_overrides = ('Waypoint Tutorial', 'Waypoint Tutorial
{% if file_exists(imprint) %} -
+ {% endif %} {% if file_exists(gdpr) %} -
+ {% endif %} diff --git a/mslib/static/templates/theme.html b/mslib/static/templates/theme.html index d094472b4..5881c4d14 100644 --- a/mslib/static/templates/theme.html +++ b/mslib/static/templates/theme.html @@ -8,9 +8,9 @@ - + Mission Support System Collaboration Platform - +
@@ -19,7 +19,7 @@