From 3956b3fd68aa9d54d4d84c180e4a143d3a32aafc Mon Sep 17 00:00:00 2001 From: dgtlmoon Date: Sat, 4 Dec 2021 15:23:23 +0100 Subject: [PATCH] Re #269 - Show current/correct BASE_URL information (#271) * Re #269 - Show current/correct BASE_URL information --- changedetectionio/__init__.py | 5 +++-- changedetectionio/store.py | 4 ++-- changedetectionio/templates/_common_fields.jinja | 4 ++-- changedetectionio/templates/edit.html | 4 ++-- changedetectionio/templates/settings.html | 6 +++--- 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/changedetectionio/__init__.py b/changedetectionio/__init__.py index e7b8f90e..118db95a 100644 --- a/changedetectionio/__init__.py +++ b/changedetectionio/__init__.py @@ -482,7 +482,8 @@ def changedetection_app(config=None, datastore_o=None): uuid=uuid, watch=datastore.data['watching'][uuid], form=form, - using_default_minutes=using_default_minutes + using_default_minutes=using_default_minutes, + current_base_url = datastore.data['settings']['application']['base_url'] ) return output @@ -548,7 +549,7 @@ def changedetection_app(config=None, datastore_o=None): if request.method == 'POST' and not form.validate(): flash("An error occurred, please see below.", "error") - output = render_template("settings.html", form=form) + output = render_template("settings.html", form=form, current_base_url = datastore.data['settings']['application']['base_url']) return output diff --git a/changedetectionio/store.py b/changedetectionio/store.py index 23376657..b2832400 100644 --- a/changedetectionio/store.py +++ b/changedetectionio/store.py @@ -208,8 +208,8 @@ class ChangeDetectionStore: # Re #152, Return env base_url if not overriden, @todo also prefer the proxy pass url env_base_url = os.getenv('BASE_URL','') - if self.__data['settings']['application']['base_url'] is None and len(env_base_url) >0: - self.__data['settings']['application']['base_url'] = env_base_url.strip('" ') + if not self.__data['settings']['application']['base_url']: + self.__data['settings']['application']['base_url'] = env_base_url.strip('" ') self.__data['has_unviewed'] = has_unviewed diff --git a/changedetectionio/templates/_common_fields.jinja b/changedetectionio/templates/_common_fields.jinja index 48c8ca35..58b997fc 100644 --- a/changedetectionio/templates/_common_fields.jinja +++ b/changedetectionio/templates/_common_fields.jinja @@ -1,7 +1,7 @@ {% from '_helpers.jinja' import render_field %} -{% macro render_notifications_field(form) %} +{% macro render_common_settings_form(form, current_base_url) %}
{{ render_field(form.notification_urls, rows=5, placeholder="Examples: @@ -78,7 +78,7 @@ URLs generated by changedetection.io (such as {diff_url}) require the BASE_URL environment variable set.
- Your BASE_URL var is currently "{{base_url}}" + Your BASE_URL var is currently "{{current_base_url}}"
diff --git a/changedetectionio/templates/edit.html b/changedetectionio/templates/edit.html index 8c96d9f6..c4f6ee62 100644 --- a/changedetectionio/templates/edit.html +++ b/changedetectionio/templates/edit.html @@ -1,7 +1,7 @@ {% extends 'base.html' %} {% block content %} {% from '_helpers.jinja' import render_field %} -{% from '_common_fields.jinja' import render_notifications_field %} +{% from '_common_fields.jinja' import render_common_settings_form %}
@@ -66,7 +66,7 @@ User-Agent: wonderbra 1.0") }} Note: These settings override the global settings.
- {{ render_notifications_field(form) }} + {{ render_common_settings_form(form, current_base_url) }}
diff --git a/changedetectionio/templates/settings.html b/changedetectionio/templates/settings.html index c4910f40..b684c94f 100644 --- a/changedetectionio/templates/settings.html +++ b/changedetectionio/templates/settings.html @@ -2,7 +2,7 @@ {% block content %} {% from '_helpers.jinja' import render_field %} -{% from '_common_fields.jinja' import render_notifications_field %} +{% from '_common_fields.jinja' import render_common_settings_form %} @@ -36,7 +36,7 @@ {{ render_field(form.base_url, placeholder="http://yoursite.com:5000/", class="m-d") }} - Base URL used for the {base_url} token in notifications, default value is the ENV var 'BASE_URL', + Base URL used for the {base_url} token in notifications, default value is the ENV var 'BASE_URL' (Currently "{{current_base_url}}"), read more here. @@ -51,7 +51,7 @@
- {{ render_notifications_field(form) }} + {{ render_common_settings_form(form, current_base_url) }}