diff --git a/app/classes/shared/helpers.py b/app/classes/shared/helpers.py index 602ee8ab..89b7ad5d 100644 --- a/app/classes/shared/helpers.py +++ b/app/classes/shared/helpers.py @@ -13,11 +13,13 @@ import logging from datetime import datetime from socket import gethostname + from app.classes.shared.console import console logger = logging.getLogger(__name__) try: + import requests from OpenSSL import crypto from argon2 import PasswordHasher @@ -96,6 +98,21 @@ class Helpers: return version_data + @staticmethod + def get_announcements(): + r = requests.get('https://craftycontrol.com/notify.json', timeout=2) + data = '[{"id":"1","date":"Unknown","title":"Error getting Announcements","desc":"Error getting ' \ + 'Announcements","link":""}] ' + + if r.status_code in [200, 201]: + try: + data = json.loads(r.content) + except: + pass + + return data + + def get_version_string(self): version_data = self.get_version() diff --git a/app/classes/web/ajax_handler.py b/app/classes/web/ajax_handler.py index 1b422848..03641140 100644 --- a/app/classes/web/ajax_handler.py +++ b/app/classes/web/ajax_handler.py @@ -74,6 +74,12 @@ class AjaxHandler(BaseHandler): logger.warning("Skipping Log Line due to error: {}".format(e)) pass + elif page == "announcements": + data = helper.get_announcements() + page_data['notify_data'] = data + self.render_page('ajax/notify.html', page_data) + + def post(self, page): user_data = json.loads(self.get_secure_cookie("user_data")) error = bleach.clean(self.get_argument('error', "WTF Error!")) diff --git a/app/classes/web/panel_handler.py b/app/classes/web/panel_handler.py index 977c51ad..b00a80ed 100644 --- a/app/classes/web/panel_handler.py +++ b/app/classes/web/panel_handler.py @@ -26,6 +26,7 @@ class PanelHandler(BaseHandler): defined_servers = controller.list_defined_servers() page_data = { + 'update_available': False, 'version_data': helper.get_version_string(), 'user_data': user_data, 'server_stats': { diff --git a/app/frontend/templates/ajax/notify.html b/app/frontend/templates/ajax/notify.html new file mode 100644 index 00000000..90683da6 --- /dev/null +++ b/app/frontend/templates/ajax/notify.html @@ -0,0 +1,14 @@ +{% for item in data['notify_data'] %} + +
{{ item['title'] }}
+ +