diff --git a/README.md b/README.md index 9b47b44..8b37084 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,20 @@ Dependencies - flask + - flask-babel - pytest - coverage - libjs-htmx - libjs-material-design-lite + - xapp-gtk3-module + + +## Development + +### Translations + +Upstream PyBabel documentation: +https://python-babel.github.io/flask-babel/index.html#translating-applications + +in the ./daemon directory, run the following to regenerate the translations file: + +```pybabel extract -F babel.cfg -o messages.pot .``` diff --git a/src/applets/disks/__pycache__/__init__.cpython-312.pyc b/src/applets/disks/__pycache__/__init__.cpython-312.pyc index a050941..bc17290 100644 Binary files a/src/applets/disks/__pycache__/__init__.cpython-312.pyc and b/src/applets/disks/__pycache__/__init__.cpython-312.pyc differ diff --git a/src/applets/disks/__pycache__/routes.cpython-312.pyc b/src/applets/disks/__pycache__/routes.cpython-312.pyc index 08259fe..12ba9b5 100644 Binary files a/src/applets/disks/__pycache__/routes.cpython-312.pyc and b/src/applets/disks/__pycache__/routes.cpython-312.pyc differ diff --git a/src/applets/main/__pycache__/__init__.cpython-312.pyc b/src/applets/main/__pycache__/__init__.cpython-312.pyc index 406caeb..edf656d 100644 Binary files a/src/applets/main/__pycache__/__init__.cpython-312.pyc and b/src/applets/main/__pycache__/__init__.cpython-312.pyc differ diff --git a/src/applets/main/__pycache__/routes.cpython-312.pyc b/src/applets/main/__pycache__/routes.cpython-312.pyc index 48f7168..0b560e7 100644 Binary files a/src/applets/main/__pycache__/routes.cpython-312.pyc and b/src/applets/main/__pycache__/routes.cpython-312.pyc differ diff --git a/src/applets/software/__pycache__/__init__.cpython-312.pyc b/src/applets/software/__pycache__/__init__.cpython-312.pyc index 5429afd..34974b6 100644 Binary files a/src/applets/software/__pycache__/__init__.cpython-312.pyc and b/src/applets/software/__pycache__/__init__.cpython-312.pyc differ diff --git a/src/applets/software/__pycache__/routes.cpython-312.pyc b/src/applets/software/__pycache__/routes.cpython-312.pyc index 7c50dff..ea3eeb4 100644 Binary files a/src/applets/software/__pycache__/routes.cpython-312.pyc and b/src/applets/software/__pycache__/routes.cpython-312.pyc differ diff --git a/src/applets/software/software.html b/src/applets/software/software.html index 3dcfb7a..73b0fd4 100644 --- a/src/applets/software/software.html +++ b/src/applets/software/software.html @@ -1,22 +1,15 @@ {% extends "layout.html" %} {% block body %} -
-

Would you like fries with that?


-

- -
-
-
-
diff --git a/src/applets/summary/__pycache__/__init__.cpython-312.pyc b/src/applets/summary/__pycache__/__init__.cpython-312.pyc index 75da8f0..7d1050b 100644 Binary files a/src/applets/summary/__pycache__/__init__.cpython-312.pyc and b/src/applets/summary/__pycache__/__init__.cpython-312.pyc differ diff --git a/src/applets/summary/__pycache__/routes.cpython-312.pyc b/src/applets/summary/__pycache__/routes.cpython-312.pyc index 7208e66..7d838eb 100644 Binary files a/src/applets/summary/__pycache__/routes.cpython-312.pyc and b/src/applets/summary/__pycache__/routes.cpython-312.pyc differ diff --git a/src/applets/summary/summary.html b/src/applets/summary/summary.html index ba1b1c0..ac88fe1 100644 --- a/src/applets/summary/summary.html +++ b/src/applets/summary/summary.html @@ -1,19 +1,8 @@ {% extends "layout.html" %} {% block body %} -
-

Ready to install! Please review all changes.

-
- -

- -
-
-
-
-
diff --git a/src/applets/users/__pycache__/__init__.cpython-312.pyc b/src/applets/users/__pycache__/__init__.cpython-312.pyc index 3bcd7a8..527cb29 100644 Binary files a/src/applets/users/__pycache__/__init__.cpython-312.pyc and b/src/applets/users/__pycache__/__init__.cpython-312.pyc differ diff --git a/src/applets/users/__pycache__/routes.cpython-312.pyc b/src/applets/users/__pycache__/routes.cpython-312.pyc index a4708cf..6f7cf21 100644 Binary files a/src/applets/users/__pycache__/routes.cpython-312.pyc and b/src/applets/users/__pycache__/routes.cpython-312.pyc differ diff --git a/src/applets/users/users.html b/src/applets/users/users.html index 994fc00..c8aa0c6 100644 --- a/src/applets/users/users.html +++ b/src/applets/users/users.html @@ -1,8 +1,6 @@ {% extends "layout.html" %} {% block body %} -
-

Let's set up an initial user.


@@ -46,16 +44,7 @@
-

- -
-
-
- - - - {% endblock %} diff --git a/src/applets/welcome/__pycache__/__init__.cpython-312.pyc b/src/applets/welcome/__pycache__/__init__.cpython-312.pyc index 7d8c2c5..ac1fc3a 100644 Binary files a/src/applets/welcome/__pycache__/__init__.cpython-312.pyc and b/src/applets/welcome/__pycache__/__init__.cpython-312.pyc differ diff --git a/src/applets/welcome/__pycache__/routes.cpython-312.pyc b/src/applets/welcome/__pycache__/routes.cpython-312.pyc index cf83579..f65f4b4 100644 Binary files a/src/applets/welcome/__pycache__/routes.cpython-312.pyc and b/src/applets/welcome/__pycache__/routes.cpython-312.pyc differ diff --git a/src/applets/welcome/routes.py b/src/applets/welcome/routes.py index 5b96902..6cbc542 100644 --- a/src/applets/welcome/routes.py +++ b/src/applets/welcome/routes.py @@ -1,8 +1,12 @@ from applets.welcome import bp from flask import Flask, request, session, redirect, \ url_for, render_template, flash, Blueprint +import gettext import dmm.lsblk as lsblk +# Set up Gettext +en_i18n = gettext.translation("welcome", './locales', fallback=True, languages=['af', 'en']) +en_i18n.install() @bp.route('/welcome',methods=['GET', 'POST', 'PUT']) def welcome_index(): @@ -11,13 +15,19 @@ def welcome_index(): this app in a browser. """ blkid = lsblk.list_scsi_devices() - return render_template('welcome.html', blkid=blkid) - #return ("Welcome to System Installer Daemon POC
" - # "This is the Welcome Index") + string_dict = build_stringlist() + return render_template('welcome.html', string_dict=string_dict) -@bp.route('/welcome2') -def welcome2_index(): - return ("Changins some text in our htmx front-end") - +def build_stringlist(): + """ + Return all the strings that is used in this applet." + """ + string_dict = {} + string_dict['welcome_text'] = _("Welcome! This setup program will install Debian on to your system.") + string_dict['confirm_text'] = _("Please confirm the following details:") + string_dict['language_text'] = _("Language:") + string_dict['keylayout_text'] = _("Keyboard Layout:") + string_dict['timezone_text'] = _("Time Zone:") + return string_dict diff --git a/src/applets/welcome/welcome.html b/src/applets/welcome/welcome.html index 51caef9..f1ac5ce 100644 --- a/src/applets/welcome/welcome.html +++ b/src/applets/welcome/welcome.html @@ -1,16 +1,11 @@ {% extends "layout.html" %} {% block body %} -
+Debian Image banner +

{{ string_dict['welcome_text'] }}

+

{{ string_dict['confirm_text'] }}

-

Welcome! This setup program will install Debian on to your system.

- -
- -
- -
- + {{ string_dict['language_text'] }} -
-
- + {{ string_dict['keylayout_text'] }} -
-
+
-
- + {{ string_dict['timezone_text'] }} -
-
-





- -
-
-
-
diff --git a/src/static/welcome.css b/src/static/system-installer.css similarity index 100% rename from src/static/welcome.css rename to src/static/system-installer.css diff --git a/src/system-installer-daemon b/src/system-installer-daemon index 81c4c74..5e14a43 100755 --- a/src/system-installer-daemon +++ b/src/system-installer-daemon @@ -12,6 +12,8 @@ import importlib # configuration VERSION = "0.00" +BABEL_TRANSLATION_DIRECTORIES="translations" +BABEL_DOMAIN="translations" SECRET_KEY = "exampls" DEV_MODE = True APPS = "main welcome users disks software summary" @@ -25,6 +27,7 @@ if DEV_MODE: app = Flask(__name__) app.config.from_object(__name__) + # Register blueprints here for APP in APPS.split(" "): print(f"Loading applet: {APP} ") @@ -48,3 +51,4 @@ if __name__ == '__main__': port=8080, url_scheme='http', expose_tracebacks=DEV_MODE) + diff --git a/src/system-installer-daemon.py b/src/system-installer-daemon.py deleted file mode 100755 index 81c4c74..0000000 --- a/src/system-installer-daemon.py +++ /dev/null @@ -1,50 +0,0 @@ -#!/usr/bin/env python3 -""" -Welcome to SID - The System Installer Daemon! -""" - -from flask import Flask, request, session, redirect, \ - url_for, render_template, flash, Blueprint -from waitress import serve -import logging -import dmm.lsblk as lsblk -import importlib - -# configuration -VERSION = "0.00" -SECRET_KEY = "exampls" -DEV_MODE = True -APPS = "main welcome users disks software summary" - -if DEV_MODE: - print("Note: Starting in devmode!") - DEBUG = True - tracebacks = True - -# create our application in flask -app = Flask(__name__) -app.config.from_object(__name__) - -# Register blueprints here -for APP in APPS.split(" "): - print(f"Loading applet: {APP} ") - # Dynamically import the blueprint module - module = importlib.import_module(f"applets.{APP}") - # Get the blueprint (bp) from the imported module - bp = getattr(module, "bp") - # Register the blueprint with the app - app.register_blueprint(bp) - -# configure logs -# logging.basicConfig() -logger = logging.getLogger('waitress') -if DEV_MODE == "1": - logger.setLevel(logging.DEBUG) - logger.debug("logger set to DEBUG") - -if __name__ == '__main__': - serve(app, - host='0.0.0.0', - port=8080, - url_scheme='http', - expose_tracebacks=DEV_MODE) diff --git a/src/system-installer-web-client b/src/system-installer-web-client index 25ae0d0..8f832a4 100755 --- a/src/system-installer-web-client +++ b/src/system-installer-web-client @@ -13,7 +13,7 @@ def on_closed(): window = webview.create_window('System Installer', LOCATION, transparent=True, easy_drag=False, frameless=True, - width=1030, focus=True, zoomable=True, + width=1050, focus=True, zoomable=True, confirm_close=True) window.events.closed += on_closed diff --git a/src/templates/header.html b/src/templates/header.html index 59b4472..0958aa4 100644 --- a/src/templates/header.html +++ b/src/templates/header.html @@ -1,5 +1,5 @@ -
+
@@ -11,5 +11,4 @@
-
diff --git a/src/templates/layout.html b/src/templates/layout.html index 409a8a9..34f980a 100644 --- a/src/templates/layout.html +++ b/src/templates/layout.html @@ -4,16 +4,21 @@ - + - + -
+
{% include "header.html" %} + +
{% block body %} {% endblock %} +
+ +{% include "footer.html" %}