From b31bf3489034ea3327f7a645bcda9a08a57f4712 Mon Sep 17 00:00:00 2001 From: Leigh Morresi <275001+dgtlmoon@users.noreply.github.com> Date: Mon, 1 Mar 2021 15:09:37 +0100 Subject: [PATCH] Check for new version --- README.md | 2 +- backend/__init__.py | 22 ++++++++++++++++------ backend/static/css/styles.css | 15 ++++++++++++++- backend/templates/base.html | 13 +++++++------ changedetection.py | 6 +++++- 5 files changed, 43 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index 3dc4736d..c76996d9 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ Docker Pulls - Change detection latest tag version + Change detection latest tag version ## Self-hosted change monitoring of web pages. diff --git a/backend/__init__.py b/backend/__init__.py index 06744202..00b0ba81 100644 --- a/backend/__init__.py +++ b/backend/__init__.py @@ -513,18 +513,28 @@ def changedetection_app(config=None, datastore_o=None): # Check for new version and anonymous stats def check_for_new_version(): import requests - app.config['NEW_VERSION_AVAILABLE'] = True + import urllib3 urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) while not app.config.exit.is_set(): - r = requests.post("https://changedetection.io/check-ver.php", - data={'version': datastore.data['version_tag'], - 'app_guid': datastore.data['app_guid']}, + try: + r = requests.post("https://changedetection.io/check-ver.php", + data={'version': datastore.data['version_tag'], + 'app_guid': datastore.data['app_guid']}, - verify=False) + verify=False) + except: + pass + + try: + if "new_version" in r.text: + app.config['NEW_VERSION_AVAILABLE'] = True + except: + pass - app.config.exit.wait(10) + # Check daily + app.config.exit.wait(86400) # Requests for checking on the site use a pool of thread Workers managed by a Queue. diff --git a/backend/static/css/styles.css b/backend/static/css/styles.css index 180ac5ef..da504eef 100644 --- a/backend/static/css/styles.css +++ b/backend/static/css/styles.css @@ -252,4 +252,17 @@ footer { #feed-icon { vertical-align: middle; -} \ No newline at end of file +} + +#version { + position: absolute; + top: 80px; + right: 0px; + font-size: 8px; + background: #fff; + padding: 10px; +} + +#new-version-text a{ + color: #e07171; +} diff --git a/backend/templates/base.html b/backend/templates/base.html index f9e89e06..03afb75a 100644 --- a/backend/templates/base.html +++ b/backend/templates/base.html @@ -19,11 +19,11 @@
ChangeDetection.io {% if current_diff_url %} - {{ current_diff_url }} + {{ current_diff_url }} {% else %} - {% if new_version_available %} - A new version is available - {% endif %} + {% if new_version_available %} + A new version is available + {% endif %} {% endif %}
- +
v{{ version }}
{% block header %}{% endblock %} diff --git a/changedetection.py b/changedetection.py index f593548d..3a112c9c 100644 --- a/changedetection.py +++ b/changedetection.py @@ -52,7 +52,11 @@ def main(argv): @app.context_processor def inject_version(): - return dict(version=datastore.data['tag']) + return dict(version=datastore.data['version_tag']) + + @app.context_processor + def inject_new_version_available(): + return dict(new_version_available=app.config['NEW_VERSION_AVAILABLE']) if ssl_mode: # @todo finalise SSL config, but this should get you in the right direction if you need it.