diff --git a/README.md b/README.md index d7513b9..38d38fc 100644 --- a/README.md +++ b/README.md @@ -51,6 +51,8 @@ Limit access to the configurator by adding allowed IP addresses / networks to th List of statically banned IP addresses, e.g. `BANNED_IPS = ["1.1.1.1", "2.2.2.2"]` ####BANLIMIT (integer) Ban IPs after n failed login attempts. Restart service to reset banning. The default of `0` disables this feature. `CREDENTIALS` has to be set for this to work. +####EXTENSIONS (list) +File extensions the file browser should include. __Note regarding `ALLOWED_NETWORKS`, `BANNED_IPS` and `BANLIMIT`__: The way this is implemented works in the following order: diff --git a/changelog.txt b/changelog.txt index 828ea4e..3068785 100644 --- a/changelog.txt +++ b/changelog.txt @@ -3,6 +3,7 @@ Version 0.0.8 (2017-02-nn) - Added confirmation dialog before saving files - Changes to toolbar with extended editor settings - Editor settings saved when Save-dialog is shown +- Allow setting file extensions to be shown in browser Version 0.0.7 (2017-02-01) - Inserted elements are selected as visual feedback diff --git a/configurator.py b/configurator.py index 3f81cc8..24ccbda 100755 --- a/configurator.py +++ b/configurator.py @@ -37,6 +37,8 @@ ALLOWED_NETWORKS = [] BANNED_IPS = [] # Ban IPs after n failed login attempts. Restart service to reset banning. The default of `0` disables this feature. BANLIMIT = 0 +# File extensions the file browser should include +EXTENSIONS = ['yaml', 'conf'] ### End of options RELEASEURL = "https://api.github.com/repos/danielperna84/hass-poc-configurator/releases/latest" @@ -337,7 +339,9 @@ def signal_handler(signal, frame): sys.exit(0) def load_settings(settingsfile): - global LISTENIP, LISTENPORT, BASEPATH, SSL_CERTIFICATE, SSL_KEY, HASS_API, HASS_API_PASSWORD, CREDENTIALS, ALLOWED_NETWORKS, BANNED_IPS, BANLIMIT + global LISTENIP, LISTENPORT, BASEPATH, SSL_CERTIFICATE, SSL_KEY, HASS_API, \ + HASS_API_PASSWORD, CREDENTIALS, ALLOWED_NETWORKS, BANNED_IPS, BANLIMIT, \ + EXTENSIONS try: if os.path.isfile(settingsfile): with open(settingsfile) as fptr: @@ -353,6 +357,7 @@ def load_settings(settingsfile): ALLOWED_NETWORKS = settings.get("ALLOWED_NETWORKS", ALLOWED_NETWORKS) BANNED_IPS = settings.get("BANNED_IPS", BANNED_IPS) BANLIMIT = settings.get("BANLIMIT", BANLIMIT) + EXTENSIONS = settings.get("EXTENSIONS", EXTENSIONS) except Exception as err: print(err) print("Not loading static settings") @@ -412,7 +417,7 @@ def get_nodes_from_path(path): node_id = os.sep.join(path_nodes[0:idx+1]) if idx != 0: parent = os.sep.join(path_nodes[0:idx]) - if os.path.isfile(os.path.join(parent, node_name)) and (not node_name.endswith('.yaml') and not node_name.endswith('.conf')): + if os.path.isfile(os.path.join(parent, node_name)) and node_name.split('.')[-1] not in EXTENSIONS: continue else: parent = "#" diff --git a/settings.conf b/settings.conf index c47dbb3..607965a 100644 --- a/settings.conf +++ b/settings.conf @@ -9,5 +9,6 @@ "CREDENTIALS": null, "ALLOWED_NETWORKS": [], "BANNED_IPS": [], - "BANLIMIT": 0 + "BANLIMIT": 0, + "EXTENSIONS": ['yaml', 'conf'] } \ No newline at end of file