diff --git a/app/forms.py b/app/forms.py index 1dca64a..72cf5e5 100644 --- a/app/forms.py +++ b/app/forms.py @@ -14,7 +14,7 @@ class LoginForm(FlaskForm): class SettingsForm(FlaskForm): # Access point settings ssid = StringField('SSID', validators=[DataRequired()]) - wifi_password = PasswordField(_l('WiFi Password')) + wifi_password = StringField(_l('WiFi Password')) enable_access_point = BooleanField(_l('Enable Access Point')) # Customisation settings butterbox_name = StringField(_l('Butterbox Name'), validators=[DataRequired()]) diff --git a/app/routes.py b/app/routes.py index 9c40955..11aefdc 100644 --- a/app/routes.py +++ b/app/routes.py @@ -15,6 +15,8 @@ import secrets import string import glob import time +import qrcode +from datetime import datetime def gen_username() -> str: words = top_n_list("en", 5000) @@ -38,6 +40,12 @@ def get_file_icon_url(path: str) -> str: 'ppt', 'pptx']: return url_for("static", filename=f"images/extension-icons/ext-{suffix}.svg") return url_for("static", filename=f"images/extension-icons/ext-unknown.svg") +def get_last_modified(path: str) -> str: + mod_time = time.ctime(os.path.getmtime(path)) + #print(mod_time) + #dt = datetime.strptime(mod_time, "%a %b %d %H:%M:%S %Y") + #formatted_time = dt.strftime("%Y-%m-%d %H:%M") + return mod_time def get_files_in_path(path: str): file_list = [] @@ -46,7 +54,7 @@ def get_files_in_path(path: str): file_list = [ {"name": x.replace(path, "").strip("/"), "path": x, "is_file": os.path.isfile(x), "is_dir": os.path.isdir(x), - "filetype": get_file_suffix(x), "last_modified": time.ctime(os.path.getmtime(x)), + "filetype": get_file_suffix(x), "last_modified": get_last_modified(x), "icon_url": get_file_icon_url(x), "relative_path": x.replace(app.config["BUTTERBOX_USB_PATH"], "")} for x in list_of_files] @@ -71,6 +79,16 @@ def dump_settings(filename: str) -> None: @app.route('/') @app.route('/index') def index(): + display_wifi_password = False + wifi_password = get_setting("wifi_password") + if wifi_password: + wifi_ssid = get_setting("ssid") + wifi_encryption_type = "WPA2" + img = qrcode.make(f"WIFI:T:{wifi_encryption_type};S:{wifi_ssid};P:{wifi_password};;") + img.save("app/static/images/wifi_qr_code.png") + display_wifi_password = True + else: + os.remove("app/static/images/wifi_qr_code.png") enable_chat = get_setting("enable_chat") enable_app_store = get_setting("enable_app_store") enable_map_viewer = get_setting("enable_map_viewer") @@ -98,7 +116,7 @@ def index(): "name": name, "image": url_for("static", filename="images/explore-icon.svg"), "url": url_for("files", path=""),}) - return render_template('index.html', title='Home', get_setting=get_setting, services=service_array) + return render_template('index.html', title='Home', get_setting=get_setting, services=service_array, display_wifi_password=display_wifi_password) @app.route('/files/', defaults={'path': ''}) @app.route('/files/') diff --git a/app/static/butter_styles.css b/app/static/butter_styles.css index c45feec..d7e2e4a 100644 --- a/app/static/butter_styles.css +++ b/app/static/butter_styles.css @@ -18,4 +18,11 @@ html { padding: 10px; } +} +@media (max-width: 468px) { + + .file-viewer-date-modified { + display: none; + } + } \ No newline at end of file diff --git a/app/templates/admin.html b/app/templates/admin.html index 33a34b0..9523433 100644 --- a/app/templates/admin.html +++ b/app/templates/admin.html @@ -1,10 +1,16 @@ {% extends "base.html" %} {% block content %} -

{{ _('Application Settings') }}

+

{{ _('Application Settings') }}

+ {% import "bulma_wtf.html" as wtf %}
{{ form.hidden_tag() }} +

{{ form.submit( class="button is-link") }} + {% if config['SETTINGS_CHANGED'] %} + {{ form.apply_changes(class="button is-warning") }} + {% endif %} +

{{ wtf.form_input_field(form.ssid) }}

This is the name of the advertised Wi-Fi network. Current SSID: {{ get_setting('ssid') }}

@@ -56,11 +62,7 @@

This is the logo shown in the UI. Current logo:

-

{{ form.submit( class="button is-link") }} - {% if config['SETTINGS_CHANGED'] %} - {{ form.apply_changes(class="button is-warning") }} - {% endif %} -

+
Logout diff --git a/app/templates/base.html b/app/templates/base.html index c869fc7..47d81e2 100644 --- a/app/templates/base.html +++ b/app/templates/base.html @@ -19,7 +19,7 @@

{{ get_setting('butterbox_name') }}

-
{% block content %}{% endblock %}
+
{% with messages = get_flashed_messages() %} {% if messages %}
@@ -31,6 +31,9 @@
{% endif %} {% endwith %} + + {% block content %}{% endblock %} + diff --git a/app/templates/index.html b/app/templates/index.html index c258b68..b995f90 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -2,7 +2,8 @@ {% block content %}

Hi, welcome to the {{get_setting('butterbox_name')}}.

-

View and download the information you want from this offline box.

+

View and download the information you want from this offline box.

+
{% for service in services %} @@ -11,7 +12,14 @@
{% endfor %} - - + + + {% if display_wifi_password %} +
+

Connect to this box with wifi: + +

+ {% endif %} + {% endblock %} \ No newline at end of file diff --git a/app/templates/messaging.html b/app/templates/messaging.html index dac504f..dc09044 100644 --- a/app/templates/messaging.html +++ b/app/templates/messaging.html @@ -1,6 +1,7 @@ {% extends "base.html" %} {% block content %} +

{{ _('Secure Messaging') }}

To use secure messaging, install Delta Chat and then return to this page to create your local offline account

diff --git a/app/templates/usb-file-viewer.html b/app/templates/usb-file-viewer.html index df5e64f..dba7fbb 100644 --- a/app/templates/usb-file-viewer.html +++ b/app/templates/usb-file-viewer.html @@ -1,13 +1,15 @@ {% extends "base.html" %} {% block content %} +

{{ _('File Viewer') }}

+
- +
- + @@ -23,7 +25,7 @@ {% endif %} - + {% if f.is_file %} {% endif %}
File NameDate modifiedDate modified Download
{{ f.name}}{{ f.last_modified}}{{ f.last_modified}}Download