diff --git a/src/yasi_applets/disks/__init__.py b/src/yasi_applets/disks/__init__.py new file mode 100644 index 0000000..d9ee8c2 --- /dev/null +++ b/src/yasi_applets/disks/__init__.py @@ -0,0 +1,7 @@ +from flask import Blueprint + +bp = Blueprint('disks', __name__, + template_folder='') + +from yasi_applets.disks import routes + diff --git a/src/yasi_applets/disks/disks.html b/src/yasi_applets/disks/disks.html new file mode 100644 index 0000000..5af5b2f --- /dev/null +++ b/src/yasi_applets/disks/disks.html @@ -0,0 +1,155 @@ +{% extends "layout.html" %} +{% block body %} + +
+ +

How would you like to install Debian?

+ +
+ +
+
+ +
+


Proposed layout:

+
+ + + + + + + + + + +
+
+

+ {{ disk['name'] }} ({{(disk['size']/1024000000)|round(0)|int }} GB) - Serial: {{ disk['serial'] }} +

+{% for child in disk['children'] %} + +
+
+

{{ child['name'] }} ({{ (child['size']/1024000000)|round(2) }} GiB)

+

{{ child['mountpoint'] }} + {{ child['fstype'] }} +

+
+
+
+{% endfor %} + {% if disk['maj:min'] == "252:0" %} +
+
+

{{ disk['name'] }} ({{ (disk['size']/1024000000)|round(2) }} GiB)

+

/dev/{{ disk['name'] }} + swap +

+
+
+ {% endif %} +
+
+ + + + + +
+{% endfor %} + + + + +
+
+ + + + + +{% endblock %} diff --git a/src/yasi_applets/disks/disks_partition.html b/src/yasi_applets/disks/disks_partition.html new file mode 100644 index 0000000..2e77737 --- /dev/null +++ b/src/yasi_applets/disks/disks_partition.html @@ -0,0 +1,88 @@ + diff --git a/src/yasi_applets/disks/routes.py b/src/yasi_applets/disks/routes.py new file mode 100644 index 0000000..6fea14e --- /dev/null +++ b/src/yasi_applets/disks/routes.py @@ -0,0 +1,65 @@ +from yasi_applets.disks import bp +from flask import Flask, request, session, redirect, \ + url_for, render_template, flash, Blueprint +import dmm.lsblk as lsblk +from flask import current_app + +@bp.route('/disks') +def disks(): + """ + Disks screen for the webui. + """ + blockdevs = lsblk.list_block_devices() + print(lsblk.list_block_devices()) + menu = current_app.config['CONFIG']['settings']['menu_order'].split(" ") + next_step_url = menu[menu.index("disks")+1] + if menu[menu.index("disks")] == 1: + previous_step_url = False + else: + previous_step_url = menu[menu.index("disks")-1] + + add_disks_button = '  ' + add_swap_button = '  ' + bottom_menu = add_disks_button + add_swap_button + build_summary() + + return render_template('disks.html', blockdevs=blockdevs, + menu=current_app.config['CONFIG']['settings']['menu'], + menu_order=current_app.config['CONFIG']['settings']['menu_order'].split(), + previous_step = previous_step_url, + next_step = next_step_url, + bottom_menu = bottom_menu) + + +@bp.route('/disks/partition/') +def disks_partition(part): + """ + Partition modal for the webui partition screen. + """ + print("Partition is: " + part) + partition = part + return render_template('disks_partition.html', + menu=current_app.config['CONFIG']['settings']['menu'], + partition=partition) + + +def build_menu(): + """ + Define menu items and paths. + """ + # proper one once translations are done: + #current_app.config['CONFIG']['settings']['menu']['welcome'] = (build_stringlist()['menu_item'], "/welcome", 10) + current_app.config['CONFIG']['settings']['menu']['disks'] = ("Disks", "/disks", 30) + + +def build_summary(): + """ + Write up a summary of what this module will do. + """ + current_app.config['CONFIG']['Summary']['disks'] = {} + current_app.config['CONFIG']['Summary']['disks']['heading'] = "Disks and Partitions" + current_app.config['CONFIG']['Summary']['disks']['bleh'] = current_app.config['CONFIG']['recipe']['popcon']['enable_popcon'] + current_app.config['CONFIG']['Summary']['disks']['text'] = "Pre-configured disk layout." + return("ok?") + +build_menu() diff --git a/src/yasi_applets/hardware/__init__.py b/src/yasi_applets/hardware/__init__.py new file mode 100644 index 0000000..909cc54 --- /dev/null +++ b/src/yasi_applets/hardware/__init__.py @@ -0,0 +1,7 @@ +from flask import Blueprint + +bp = Blueprint('hardware', __name__, + template_folder='') + +from yasi_applets.hardware import routes + diff --git a/src/yasi_applets/hardware/hardware.html b/src/yasi_applets/hardware/hardware.html new file mode 100644 index 0000000..ea84634 --- /dev/null +++ b/src/yasi_applets/hardware/hardware.html @@ -0,0 +1,41 @@ +{% extends "layout.html" %} +{% block body %} + +

Would you like fries with that?

+ +
+ +
+ +Real-time Clock + +
+

Date / time. / timezone


+ +
+
+
+ +
+ +Firmware + +
+

Install additional firmware.


+ +
+
+
+ + +{% endblock %} diff --git a/src/yasi_applets/hardware/routes.py b/src/yasi_applets/hardware/routes.py new file mode 100644 index 0000000..e9eb455 --- /dev/null +++ b/src/yasi_applets/hardware/routes.py @@ -0,0 +1,65 @@ +from yasi_applets.hardware import bp +from flask import Flask, request, session, redirect, \ + url_for, render_template, flash, Blueprint +from flask import current_app + +@bp.route('/hardware') +def webui_hardware(): + """ + Hardware screen for the webui. + """ + menu = current_app.config['CONFIG']['settings']['menu_order'].split(" ") + next_step_url = menu[menu.index("hardware")+1] + if menu[menu.index("hardware")] == 1: + previous_step_url = False + else: + previous_step_url = menu[menu.index("hardware")-1] + + sources_button = '  ' + blends_button = '  ' + bottom_menu = sources_button + blends_button + build_summary() + + return render_template('hardware.html', + menu=current_app.config['CONFIG']['settings']['menu'], + menu_order=current_app.config['CONFIG']['settings']['menu_order'].split(), + previous_step = previous_step_url, + next_step = next_step_url, + bottom_menu = bottom_menu, + popcon=current_app.config['CONFIG']['recipe']['popcon']['enable_popcon']) + + +@bp.route('/hardware/settings', methods=['GET', 'POST']) +def hardware_settings(): + """ + Receive settings for the hardware applet. + """ + if request.method == 'POST': + popcon = "popcon" in request.form + current_app.config['CONFIG']['recipe']['popcon']['enable_popcon'] = popcon + print(current_app.config['CONFIG']['recipe']['popcon']['enable_popcon']) + build_summary() + return ('', 204) + + +def build_menu(): + """ + Define menu items and paths. + """ + # proper one once translations are done: + #current_app.config['CONFIG']['settings']['menu']['welcome'] = (build_stringlist()['menu_item'], "/welcome", 10) + current_app.config['CONFIG']['settings']['menu']['hardware'] = ("Hardware", "/hardware", 40) + + +def build_summary(): + """ + Write up a summary of what this module will do. + """ + current_app.config['CONFIG']['Summary']['hardware'] = {} + current_app.config['CONFIG']['Summary']['hardware']['heading'] = "Hardware" + current_app.config['CONFIG']['Summary']['hardware']['bleh'] = current_app.config['CONFIG']['recipe']['popcon']['enable_popcon'] + current_app.config['CONFIG']['Summary']['hardware']['text'] = "Participate in Popularity Contest: " + str(current_app.config['CONFIG']['recipe']['popcon']['enable_popcon']) + "
No desktop environment selected." + return("ok?") + + +build_menu() diff --git a/src/yasi_applets/install/__init__.py b/src/yasi_applets/install/__init__.py new file mode 100644 index 0000000..2462621 --- /dev/null +++ b/src/yasi_applets/install/__init__.py @@ -0,0 +1,9 @@ +from flask import Blueprint + +bp = Blueprint('install', __name__, + template_folder='', + static_folder='static', + static_url_path='/welcome/static') + +from yasi_applets.install import routes + diff --git a/src/yasi_applets/install/install.html b/src/yasi_applets/install/install.html new file mode 100644 index 0000000..008cf1f --- /dev/null +++ b/src/yasi_applets/install/install.html @@ -0,0 +1,52 @@ +{% extends "layout.html" %} +{% block body %} + +
+

+ + Installing... + +

+ +
+ +
+

+ Installing system, the rest of the process is automated. +

+ +

+ +


+ +
+ + +
+ +
+ + +
+
+ + +
+ +
+
Initializing...
+
+ + + + + +{% endblock %} diff --git a/src/yasi_applets/install/routes.py b/src/yasi_applets/install/routes.py new file mode 100644 index 0000000..635a824 --- /dev/null +++ b/src/yasi_applets/install/routes.py @@ -0,0 +1,109 @@ +from yasi_applets.install import bp +from flask import Flask, request, session, redirect, \ + url_for, render_template, flash, Blueprint, jsonify +from flask import current_app + +import subprocess +import threading + + +status = { + "status": "idle", # idle | running | finished + "output": "", + "exit_code": None, + "lines": [] +} + + +@bp.route('/install',methods=['GET', 'POST', 'PUT']) +def install_index(): + """ + The page you'd get if you access the root of + this app in a browser. + """ + install_start() + return render_template('install.html') + + +@bp.route('/install-start',methods=['GET', 'POST', 'PUT']) +def install_start(): + """ + Trigger the installation process + """ + print("The installation process is starting!... in theory at least") + if status["status"] == "running": + return jsonify({"status": "already running"}), 409 # Conflict + threading.Thread(target=run_script).start() + return jsonify({"status": "started"}) + print("did it finish?") + + +def run_script(): + global status + status["status"] = "running" + + process = subprocess.Popen( + ["bash", "/data/jonathan/devel/highvoltage/system-installer/daemon/src/fake-install-shell.sh"], + stdout = subprocess.PIPE, + stderr = subprocess.STDOUT, + text = True) + + lines = [] + for line in iter(process.stdout.readline,''): + #lines.append(line.strip()) + #status["output"] = "\n".join(lines) + status["lines"].append(line.strip()) + + process.wait() + status["status"] = 'finished' + status["exit_code"] = process.returncode + + print(lines) + print("status:", status["status"], "code:", status["exit_code"]) + + +@bp.route('/install/status', methods=['GET', 'POST']) +def install_status(): + """ + Update on the status of the installation process. + """ + + # Keep track of the last line posted, so that we can include + # any new lines not provided to the UI yet + last_line = int(request.args.get("last_line", 0)) + new_lines = status["lines"][last_line:] + + if not new_lines and status["status"] == "finished": + return "" # Empty response = HTMX will stop polling + + lines_html = "" + for i, line in enumerate(new_lines, start=last_line + 1): + lines_html += f'
{line}
' + + return { + "output": status['output'], + "status": status['status'], + "lines": lines_html, + "last_line": f'' + } + + +@bp.route('/install/cancel', methods=["POST"]) +def install_cancel(): + """ + Cancel the installation process. + """ + if status["status"] != "running" or not status["process"]: + return Response("No running script", status=400) + process["process"].terminate() + process["status"] = "cancelled" + process["exit_code"] = -1 + return Response("Cancelled", status=200) + + +@bp.route('/settings',methods=['GET', 'POST', 'PUT']) +def settings(): + """ + Manage settings for the installation module. + """ + print("Settings") diff --git a/src/yasi_applets/main/__init__.py b/src/yasi_applets/main/__init__.py new file mode 100644 index 0000000..d2430d8 --- /dev/null +++ b/src/yasi_applets/main/__init__.py @@ -0,0 +1,9 @@ +from flask import Blueprint + +bp = Blueprint('main', __name__, + template_folder='', + static_folder='static', + static_url_path='/main/static') + +from yasi_applets.main import routes + diff --git a/src/yasi_applets/main/help.html b/src/yasi_applets/main/help.html new file mode 100644 index 0000000..66cbf3c --- /dev/null +++ b/src/yasi_applets/main/help.html @@ -0,0 +1,18 @@ + diff --git a/src/yasi_applets/main/menu.html b/src/yasi_applets/main/menu.html new file mode 100644 index 0000000..dbe1f8f --- /dev/null +++ b/src/yasi_applets/main/menu.html @@ -0,0 +1,17 @@ + diff --git a/src/yasi_applets/main/quit.html b/src/yasi_applets/main/quit.html new file mode 100644 index 0000000..5c4b96e --- /dev/null +++ b/src/yasi_applets/main/quit.html @@ -0,0 +1,19 @@ + diff --git a/src/yasi_applets/main/routes.py b/src/yasi_applets/main/routes.py new file mode 100644 index 0000000..efb7a05 --- /dev/null +++ b/src/yasi_applets/main/routes.py @@ -0,0 +1,49 @@ +from yasi_applets.welcome import bp +from flask import Flask, request, session, redirect, \ + url_for, render_template, flash, Blueprint +# we use this neat little trick to get config data from the main app +from flask import current_app +import gettext +import dmm.lsblk as lsblk + +@bp.route('/') +def index(): + """ + The page you'd get if you access the root of + this app in a browser. + """ + return ("Welcome to System Installer Daemon POC
" + "Version: Unavailable") + + +@bp.route('/api/v0') +def apihome(): + """ + Not sure what this function should do, but have + a feeling that it should exist. + """ + return ("0") + + +@bp.route('/main/help',methods=['GET', 'POST', 'PUT']) +def main_welcome(): + """ + Manages the main help system. + """ + return render_template('help.html') + + +@bp.route('/main/quit',methods=['GET', 'POST', 'PUT']) +def main_quit(): + """ + Manages the quit dialog. + """ + return render_template('quit.html') + + +@bp.route('/main/menu',methods=['GET', 'POST', 'PUT']) +def main_menu(): + """ + Manages the main menu. + """ + return render_template('menu.html') diff --git a/src/yasi_applets/main/static/bulma.css b/src/yasi_applets/main/static/bulma.css new file mode 120000 index 0000000..b0f56c8 --- /dev/null +++ b/src/yasi_applets/main/static/bulma.css @@ -0,0 +1 @@ +/usr/share/bulma/css/bulma.css \ No newline at end of file diff --git a/src/yasi_applets/main/static/fork-awesome.css b/src/yasi_applets/main/static/fork-awesome.css new file mode 120000 index 0000000..4feee90 --- /dev/null +++ b/src/yasi_applets/main/static/fork-awesome.css @@ -0,0 +1 @@ +/usr/share/fonts-fork-awesome/css/fork-awesome.css \ No newline at end of file diff --git a/src/yasi_applets/main/static/htmx.min.js b/src/yasi_applets/main/static/htmx.min.js new file mode 120000 index 0000000..5d13217 --- /dev/null +++ b/src/yasi_applets/main/static/htmx.min.js @@ -0,0 +1 @@ +/usr/share/javascript/htmx/htmx.min.js \ No newline at end of file diff --git a/src/yasi_applets/main/static/icons/highvoltage.png b/src/yasi_applets/main/static/icons/highvoltage.png new file mode 100644 index 0000000..b4d24ac Binary files /dev/null and b/src/yasi_applets/main/static/icons/highvoltage.png differ diff --git a/src/yasi_applets/main/static/icons/keyboard.png b/src/yasi_applets/main/static/icons/keyboard.png new file mode 100644 index 0000000..6a9c483 Binary files /dev/null and b/src/yasi_applets/main/static/icons/keyboard.png differ diff --git a/src/yasi_applets/main/static/icons/keyboard.svg b/src/yasi_applets/main/static/icons/keyboard.svg new file mode 100644 index 0000000..ad577e3 --- /dev/null +++ b/src/yasi_applets/main/static/icons/keyboard.svg @@ -0,0 +1,53 @@ + + + + + + + + + diff --git a/src/yasi_applets/main/static/icons/language.jpg b/src/yasi_applets/main/static/icons/language.jpg new file mode 100644 index 0000000..7f3a5fb Binary files /dev/null and b/src/yasi_applets/main/static/icons/language.jpg differ diff --git a/src/yasi_applets/main/static/icons/language.svg b/src/yasi_applets/main/static/icons/language.svg new file mode 100644 index 0000000..1fa3c12 --- /dev/null +++ b/src/yasi_applets/main/static/icons/language.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/yasi_applets/main/static/icons/tab-new-symbolic.svg b/src/yasi_applets/main/static/icons/tab-new-symbolic.svg new file mode 100644 index 0000000..3d2119d --- /dev/null +++ b/src/yasi_applets/main/static/icons/tab-new-symbolic.svg @@ -0,0 +1,8 @@ + + + + + + + + diff --git a/src/yasi_applets/main/static/slide1.png b/src/yasi_applets/main/static/slide1.png new file mode 100644 index 0000000..59f8bc0 Binary files /dev/null and b/src/yasi_applets/main/static/slide1.png differ diff --git a/src/yasi_applets/main/static/system-installer-blippie.css b/src/yasi_applets/main/static/system-installer-blippie.css new file mode 100644 index 0000000..de6ad4e --- /dev/null +++ b/src/yasi_applets/main/static/system-installer-blippie.css @@ -0,0 +1,37 @@ +html { + /* Overwrite the white that is set by bulma.css */ +body { + display: flex; + font-family: Noto Sans; + color: white; + overflow: hidden; + min-width: 1050px; + min-height: 600px; +} + +.frame { + border-radius: 10px; + background-color: #0f1933; + padding: 15px 15px 15px 15px; + width: 100%; + min-height: 600px; + position: absolute; + top: 0px; + bottom: 0px; +} + +.applet a:link a:hover a:active { + color: yellow; +} + +.applet { + width: 100%; + height: 470px; + bottom: 0px; + overflow-y: scroll; + overflow-x: hidden; +} + +.radio:hover { + color: #f1f1f1; +} diff --git a/src/yasi_applets/main/static/system-installer-dark.css b/src/yasi_applets/main/static/system-installer-dark.css new file mode 100644 index 0000000..576599a --- /dev/null +++ b/src/yasi_applets/main/static/system-installer-dark.css @@ -0,0 +1,41 @@ +html { + /* Overwrite the white that is set by bulma.css */ + background: transparent; +} + +body { + display: flex; + font-family: Sans; Roboto; Lato; Noto Sans; + color: white; + overflow: hidden; + min-width: 1050px; + min-height: 600px; +} + +html, body {margin: 0; height: 100%; overflow: hidden;} + +.frame { + border-radius: 10px; + background-color: #404040; + padding: 15px 15px 15px 15px; + width: 100%; + min-height: 600px; + position: absolute; + top: 0px; + bottom: 0px; +} + +.applet a:link a:hover a:active { + color: yellow; +} + +.applet { + width: 100%; + height: 442px; + overflow-y: scroll; + overflow-x: hidden; +} + +.radio:hover { + color: #f1f1f1; +} diff --git a/src/yasi_applets/main/static/system-installer-light.css b/src/yasi_applets/main/static/system-installer-light.css new file mode 100644 index 0000000..15f7acd --- /dev/null +++ b/src/yasi_applets/main/static/system-installer-light.css @@ -0,0 +1,37 @@ +html { + /* Overwrite the white that is set by bulma.css */ + background-color: transparent; +} + +body { + display: flex; + font-family: Noto Sans; + color: white; + overflow: hidden; + min-width: 1050px; + min-height: 600px; +} + +.frame { + border-radius: 10px; + background-color: #e9e8e4; + padding: 15px; + max-width: 1050px; +} + +.applet a:link a:hover a:active { + color: yellow; +} + +.applet { + color: #383838; + width: 1040px; + height: 470px; + overflow-y: scroll; + overflow-x: hidden; + padding-right: 20px; +} + +.radio:hover { + color: #404040; +} diff --git a/src/yasi_applets/main/static/system-installer.css b/src/yasi_applets/main/static/system-installer.css new file mode 120000 index 0000000..6db37bc --- /dev/null +++ b/src/yasi_applets/main/static/system-installer.css @@ -0,0 +1 @@ +system-installer-dark.css \ No newline at end of file diff --git a/src/yasi_applets/software/__init__.py b/src/yasi_applets/software/__init__.py new file mode 100644 index 0000000..07553e7 --- /dev/null +++ b/src/yasi_applets/software/__init__.py @@ -0,0 +1,9 @@ +from flask import Blueprint + +bp = Blueprint('software', __name__, + template_folder='', + static_folder='static', + static_url_path='/software/static') + +from yasi_applets.software import routes + diff --git a/src/yasi_applets/software/routes.py b/src/yasi_applets/software/routes.py new file mode 100644 index 0000000..de8f884 --- /dev/null +++ b/src/yasi_applets/software/routes.py @@ -0,0 +1,81 @@ +from yasi_applets.software import bp +from flask import Flask, request, session, redirect, \ + url_for, render_template, flash, Blueprint +from flask import current_app + +@bp.route('/software') +def webui_software(): + """ + Software screen for the webui. + """ + menu = current_app.config['CONFIG']['settings']['menu_order'].split(" ") + next_step_url = menu[menu.index("software")+1] + if menu[menu.index("software")] == 1: + previous_step_url = False + else: + previous_step_url = menu[menu.index("software")-1] + + sources_button = '  ' + blends_button = '  ' + bottom_menu = sources_button + blends_button + # Leave out useless buttons until they do more + bottom_menu = '' + build_summary() + + return render_template('software.html', + menu=current_app.config['CONFIG']['settings']['menu'], + menu_order=current_app.config['CONFIG']['settings']['menu_order'].split(), + previous_step = previous_step_url, + next_step = next_step_url, + bottom_menu = bottom_menu, + popcon=current_app.config['CONFIG']['recipe']['popcon']['enable_popcon'], + desktop=current_app.config['CONFIG']['recipe']['install_desktop_environment']['packages']) + + +@bp.route('/software/settings', methods=['GET', 'POST']) +def software_settings(): + """ + Receive settings for the software applet. + """ + if request.method == 'POST': + popcon = "popcon" in request.form + current_app.config['CONFIG']['recipe']['popcon']['enable_popcon'] = popcon + print(current_app.config['CONFIG']['recipe']['popcon']['enable_popcon']) + build_summary() + return ('', 204) + + +@bp.route('/software/select-desktop', methods=['GET', 'POST']) +def software_select_desktop(): + """ + Select a desktop environment for installation + """ + if request.method == 'POST': + desktop = request.form['software-desktop'] + print(desktop) + current_app.config['CONFIG']['recipe']['install_desktop_environment']['packages'] = desktop + build_summary() + return ('', 204) + + +def build_menu(): + """ + Define menu items and paths. + """ + # proper one once translations are done: + #current_app.config['CONFIG']['settings']['menu']['welcome'] = (build_stringlist()['menu_item'], "/welcome", 10) + current_app.config['CONFIG']['settings']['menu']['software'] = ("Software", "/software", 40) + + +def build_summary(): + """ + Write up a summary of what this module will do. + """ + current_app.config['CONFIG']['Summary']['software'] = {} + current_app.config['CONFIG']['Summary']['software']['heading'] = "Software" + current_app.config['CONFIG']['Summary']['software']['bleh'] = current_app.config['CONFIG']['recipe']['popcon']['enable_popcon'] + current_app.config['CONFIG']['Summary']['software']['text'] = "Participate in Popularity Contest: " + str(current_app.config['CONFIG']['recipe']['popcon']['enable_popcon']) + "
Desktop environment selected: " + str(current_app.config['CONFIG']['recipe']['install_desktop_environment']['packages']) + return("ok?") + + +build_menu() diff --git a/src/yasi_applets/software/software.html b/src/yasi_applets/software/software.html new file mode 100644 index 0000000..13fc4f5 --- /dev/null +++ b/src/yasi_applets/software/software.html @@ -0,0 +1,80 @@ +{% extends "layout.html" %} +{% block body %} + +

Would you like fries with that?

+ +
+ Popularity Contest +

+

The Popularity Contest (popcon) is a programme where anonymous data is sent back to Debian, tracking the number of packages installed. More information can be obtained at https://popcon.debian.org.


+ + +
+ +
+

Desktop Environment

+
+

Would you like to install a graphical environment for this system?

+ +
+ +
+ +
+ + + + + + + +{% endblock %} diff --git a/src/yasi_applets/software/static/img/console.png b/src/yasi_applets/software/static/img/console.png new file mode 100644 index 0000000..bcf7974 Binary files /dev/null and b/src/yasi_applets/software/static/img/console.png differ diff --git a/src/yasi_applets/software/static/img/gnome.jpeg b/src/yasi_applets/software/static/img/gnome.jpeg new file mode 100644 index 0000000..ecfdbc7 Binary files /dev/null and b/src/yasi_applets/software/static/img/gnome.jpeg differ diff --git a/src/yasi_applets/software/static/img/kde.jpeg b/src/yasi_applets/software/static/img/kde.jpeg new file mode 100644 index 0000000..5cf14c2 Binary files /dev/null and b/src/yasi_applets/software/static/img/kde.jpeg differ diff --git a/src/yasi_applets/software/static/img/lxde.jpeg b/src/yasi_applets/software/static/img/lxde.jpeg new file mode 100644 index 0000000..f5de15e Binary files /dev/null and b/src/yasi_applets/software/static/img/lxde.jpeg differ diff --git a/src/yasi_applets/software/static/img/mate.jpeg b/src/yasi_applets/software/static/img/mate.jpeg new file mode 100644 index 0000000..a4c9801 Binary files /dev/null and b/src/yasi_applets/software/static/img/mate.jpeg differ diff --git a/src/yasi_applets/software/static/img/xfce.jpeg b/src/yasi_applets/software/static/img/xfce.jpeg new file mode 100644 index 0000000..d5a0409 Binary files /dev/null and b/src/yasi_applets/software/static/img/xfce.jpeg differ diff --git a/src/yasi_applets/summary/__init__.py b/src/yasi_applets/summary/__init__.py new file mode 100644 index 0000000..ab030b5 --- /dev/null +++ b/src/yasi_applets/summary/__init__.py @@ -0,0 +1,7 @@ +from flask import Blueprint + +bp = Blueprint('summary', __name__, + template_folder='') + +from yasi_applets.summary import routes + diff --git a/src/yasi_applets/summary/routes.py b/src/yasi_applets/summary/routes.py new file mode 100644 index 0000000..6ed2113 --- /dev/null +++ b/src/yasi_applets/summary/routes.py @@ -0,0 +1,42 @@ +from yasi_applets.summary import bp +from flask import Flask, request, session, redirect, \ + url_for, render_template, flash, Blueprint +from flask import current_app + +@bp.route('/summary',methods=['GET', 'POST', 'PUT']) +def summary_index(): + """ + The page you'd get if you access the root of + this app in a browser. + """ + build_menu() + menu = current_app.config['CONFIG']['settings']['menu_order'].split(" ") + previous_step_url = menu[menu.index("summary")-1] + next_step_url = "install" + + config = current_app.config['CONFIG'] + print (current_app.config['CONFIG']['Summary']) + html = (str(current_app.config['CONFIG']['Summary']['welcome']) + "
" + str(current_app.config['CONFIG']['Summary']['software'])) + summary = config['Summary'] + + return render_template('summary.html', + menu=current_app.config['CONFIG']['settings']['menu'], + menu_order=current_app.config['CONFIG']['settings']['menu_order'].split(), + previous_step=previous_step_url, + next_step=next_step_url, + config=config, + html=html, + summary=summary) + + +def build_menu(): + """ + Define menu items and paths. + """ + # proper one once translations are done: + #current_app.config['CONFIG']['settings']['menu']['welcome'] = (build_stringlist()['menu_item'], "/welcome", 10) + current_app.config['CONFIG']['settings']['menu']['summary'] = ("Summary", "/summary", 60) + + +build_menu() + diff --git a/src/yasi_applets/summary/summary.html b/src/yasi_applets/summary/summary.html new file mode 100644 index 0000000..375f30e --- /dev/null +++ b/src/yasi_applets/summary/summary.html @@ -0,0 +1,30 @@ +{% extends "layout.html" %} +{% block body %} + +

Ready to install! Please review all changes.

+ +

This is the last chance to back out before committing to install, please ensure all the details are correct.

+ +
+ +{% for module in summary %} + +

{{ summary[module]['heading'] }}

+ + +{{ summary[module]['text']|safe }} + +

+ +{% endfor %} + +

+ + + + + + + +{% endblock %} diff --git a/src/yasi_applets/users/__init__.py b/src/yasi_applets/users/__init__.py new file mode 100644 index 0000000..6f0acb3 --- /dev/null +++ b/src/yasi_applets/users/__init__.py @@ -0,0 +1,10 @@ +from flask import Blueprint + +bp = Blueprint('users', __name__, + template_folder='', + static_folder='static', + static_url_path='/users/static') + + +from yasi_applets.users import routes + diff --git a/src/yasi_applets/users/locales/af/LC_MESSAGES/users.mo b/src/yasi_applets/users/locales/af/LC_MESSAGES/users.mo new file mode 100644 index 0000000..a3f474d Binary files /dev/null and b/src/yasi_applets/users/locales/af/LC_MESSAGES/users.mo differ diff --git a/src/yasi_applets/users/locales/af/LC_MESSAGES/users.po b/src/yasi_applets/users/locales/af/LC_MESSAGES/users.po new file mode 100644 index 0000000..480f0a5 --- /dev/null +++ b/src/yasi_applets/users/locales/af/LC_MESSAGES/users.po @@ -0,0 +1,65 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-06-20 15:48+0200\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: routes.py:33 +msgid "Let's set up an initial user." +msgstr "Kom on stel 'n gebruiker op." + +msgid "Users" +msgstr "Gebruikers" + +#: routes.py:34 +msgid "Full Name" +msgstr "Volle Naam" + +#: routes.py:35 +msgid "Username" +msgstr "Gebruikersnaam" + +#: routes.py:36 +msgid "This username is available" +msgstr "Hierdie gebruikersnaam is nie beskikbaar nie." + +#: routes.py:37 +msgid "This username is not available" +msgstr "Hierdie gebruikersnaam is nie beskikbaar nie." + +#: routes.py:38 +msgid "This username is reserved by the system" +msgstr "Hierdie gebruikersnaam is reserveerd deur vir die sisteem." + +#: routes.py:39 +msgid "The username must be one word, lowercase, with no special characters" +msgstr "Die gebruikersnaam moet een woord wees, kleinletters, met geen spesiale karakters." + +#: routes.py:40 +msgid "Password" +msgstr "Wagwoord" + +#: routes.py:41 +msgid "Password (confirm)" +msgstr "Wagwoord (bevestig)" + +#: routes.py:42 +msgid "These passwords do now match" +msgstr "Hierdie wagwoorde is nie dieselfde nie" + +#: routes.py:43 +msgid "This password is too short" +msgstr "Hierdie wagwoord is te kort" diff --git a/src/yasi_applets/users/locales/users.pot b/src/yasi_applets/users/locales/users.pot new file mode 100644 index 0000000..beefb58 --- /dev/null +++ b/src/yasi_applets/users/locales/users.pot @@ -0,0 +1,62 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-06-20 15:48+0200\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: routes.py:33 +msgid "Let's set up an initial user." +msgstr "" + +#: routes.py:34 +msgid "Full Name" +msgstr "" + +#: routes.py:35 +msgid "Username" +msgstr "" + +#: routes.py:36 +msgid "This username is available" +msgstr "" + +#: routes.py:37 +msgid "This username is not available" +msgstr "" + +#: routes.py:38 +msgid "This username is reserved by the system" +msgstr "" + +#: routes.py:39 +msgid "The username must be one word, lowercase, with no special characters" +msgstr "" + +#: routes.py:40 +msgid "Password" +msgstr "" + +#: routes.py:41 +msgid "Password (confirm)" +msgstr "" + +#: routes.py:42 +msgid "These passwords do now match" +msgstr "" + +#: routes.py:43 +msgid "This password is too short" +msgstr "" diff --git a/src/yasi_applets/users/routes.py b/src/yasi_applets/users/routes.py new file mode 100644 index 0000000..2babece --- /dev/null +++ b/src/yasi_applets/users/routes.py @@ -0,0 +1,126 @@ +from yasi_applets.software import bp +from flask import Flask, request, session, redirect, \ + url_for, render_template, flash, Blueprint +import gettext +# we use this neat little trick to get config data from the main app +from flask import current_app + +# Set up Gettext +def set_language(LANG): + """ + Sets language for this applet + """ + translations = gettext.translation("users", './applets/users/locales', + fallback=True, languages=[LANG]) + translations.install() + _ = translations.gettext + +set_language('') + + +@bp.route('/users') +def users_root(): + """ + Users screen for the webui. + """ + set_language(current_app.config['CONFIG']['settings']['language']) + string_dict = build_stringlist() + build_menu() + menu = current_app.config['CONFIG']['settings']['menu_order'].split(" ") + next_step_url = menu[menu.index("users")+1] + if menu[menu.index("users")] == 1: + previous_step_url = False + else: + previous_step_url = menu[menu.index("users")-1] + + root_button = '  ' + ldap_button = '  ' + ad_button = '  ' + csv_button = '  ' + bottom_menu = root_button + ldap_button + ad_button + csv_button + bottom_menu = "" + + initial_user = current_app.config['CONFIG']['recipe']['users']['users'][0] + + build_summary() + + return render_template('users.html', string_dict=string_dict, + menu=current_app.config['CONFIG']['settings']['menu'], + menu_order=current_app.config['CONFIG']['settings']['menu_order'].split(), + previous_step=previous_step_url, + next_step=next_step_url, + bottom_menu=bottom_menu, + initial_user=initial_user) + + +@bp.route('/users/user-check/', methods=['GET', 'POST', 'PUT']) +def check_user(): + if request.method == 'POST': + username = request.form["username"] + fullname = request.form["fullname"] + current_app.config['CONFIG']['recipe']['users']['users'][0]['username'] = username + current_app.config['CONFIG']['recipe']['users']['users'][0]['fullname'] = fullname + if username in ["root", "games"]: + return('

That username is not available

') + else: + return('

That username is available

') + build_summary() + return("") + + +@bp.route('/users/password-check/', methods=['GET', 'POST', 'PUT']) +def check_password(): + if request.method == 'POST': + password = request.form["password"] + password_confirm = request.form["password_confirm"] + current_app.config['CONFIG']['recipe']['users']['users'][0]['password'] = password + current_app.config['CONFIG']['recipe']['users']['users'][0]['password_confirm'] = password_confirm + if password != password_confirm: + return('

Passwords do not match

') + else: + return('

Passwords match

') + build_summary() + return("") + + +def build_stringlist(): + """ + Return all the strings that is used in this applet. + """ + string_dict = {} + string_dict['menu_item'] = _("Users") + string_dict['initial_user_text'] = _("Let's set up an initial user.") + string_dict['full_name'] = _("Full Name") + string_dict['user_name'] = _("Username") + string_dict['user_name_hint'] = _("One word, all lowercase") + string_dict['user_name_available'] = _("This username is available") + string_dict['user_name_not_available'] = _("This username is not available") + string_dict['user_name_reserved'] = _("This username is reserved by the system") + string_dict['user_name_characters'] = _("The username must be one word, lowercase, with no special characters") + string_dict['password'] = _("Password") + string_dict['password_confirm'] = _("Password (confirm)") + string_dict['password_nomatch'] = _("These passwords do now match") + string_dict['password_tooshort'] = _("This password is too short") + return string_dict + + +def build_menu(): + """ + Define menu items and paths. + """ + current_app.config['CONFIG']['settings']['menu']['users'] = (build_stringlist()['menu_item'], "/users", 20) + print(current_app.config['CONFIG']['settings']['menu']) + + +def build_summary(): + """ + Write up a summary of what this module will do. + """ + current_app.config['CONFIG']['Summary']['users'] = {} + current_app.config['CONFIG']['Summary']['users']['heading'] = "Users and Identity" + current_app.config['CONFIG']['Summary']['users']['bleh'] = current_app.config['CONFIG']['recipe']['popcon']['enable_popcon'] + current_app.config['CONFIG']['Summary']['users']['settings'] = current_app.config['CONFIG']['recipe']['users']['users'] + current_app.config['CONFIG']['Summary']['users']['text'] = "Add primary user with the username: " + str(current_app.config['CONFIG']['recipe']['users']['users'][0]['username']) + return("ok?") + +build_menu() diff --git a/src/yasi_applets/users/routes.py.bak b/src/yasi_applets/users/routes.py.bak new file mode 100644 index 0000000..2dfbc4f --- /dev/null +++ b/src/yasi_applets/users/routes.py.bak @@ -0,0 +1,24 @@ +from applets.software import bp +from flask import Flask, request, session, redirect, \ + url_for, render_template, flash, Blueprint +# we use this neat little trick to get config data from the main app +from flask import current_app + + +def build_stringlist(): + """ + Return all the strings that is used in this applet. + """ + string_dict = {} + string_dict['initial_user_text'] = _("Let's set up an initial user.") + string_dict['full_name'] = _("Full Name") + string_dict['user_name'] = _("Username") + string_dict['user_name_available'] = _("This username is available") + string_dict['user_name_not_available'] = _("This username is not available") + string_dict['user_name_reserved'] = _("This username is reserved by the system") + string_dict['user_name_characters'] = _("The username must be one word, lowercase, with no special characters") + string_dict['password'] = _("Password") + string_dict['password_confirm'] = _("Password (confirm)") + string_dict['password_nomatch'] = _("These passwords do now match") + string_dict['password_tooshort'] = _("This password is too short") + return string_dict diff --git a/src/yasi_applets/users/static/img/avatar-default.svg b/src/yasi_applets/users/static/img/avatar-default.svg new file mode 100644 index 0000000..4e08bb5 --- /dev/null +++ b/src/yasi_applets/users/static/img/avatar-default.svg @@ -0,0 +1,22 @@ + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/yasi_applets/users/users.html b/src/yasi_applets/users/users.html new file mode 100644 index 0000000..17a4705 --- /dev/null +++ b/src/yasi_applets/users/users.html @@ -0,0 +1,73 @@ +{% extends "layout.html" %} +{% block body %} + +

{{ string_dict['initial_user_text'] }}

+ +
+ +
+ + + +
+ +
+ +
+ + + + + +
+
+ +
+ +
+ + + + + +
+
+

{{ string_dict['user_name_hint'] }}

+
+
+ +
+ +
+ + + + +
+
+ +
+ +
+ + + + +
+

+
+
+
+ + + +
+ + + + +{% endblock %} diff --git a/src/yasi_applets/welcome/__init__.py b/src/yasi_applets/welcome/__init__.py new file mode 100644 index 0000000..aa36f8b --- /dev/null +++ b/src/yasi_applets/welcome/__init__.py @@ -0,0 +1,8 @@ +from flask import Blueprint + +bp = Blueprint('welcome', __name__, + template_folder='', + static_folder='static', + static_url_path='/welcome/static') + +from yasi_applets.welcome import routes diff --git a/src/yasi_applets/welcome/locales/af/LC_MESSAGES/welcome.mo b/src/yasi_applets/welcome/locales/af/LC_MESSAGES/welcome.mo new file mode 100644 index 0000000..1c850e9 Binary files /dev/null and b/src/yasi_applets/welcome/locales/af/LC_MESSAGES/welcome.mo differ diff --git a/src/yasi_applets/welcome/locales/af/LC_MESSAGES/welcome.po b/src/yasi_applets/welcome/locales/af/LC_MESSAGES/welcome.po new file mode 100644 index 0000000..2f33cb4 --- /dev/null +++ b/src/yasi_applets/welcome/locales/af/LC_MESSAGES/welcome.po @@ -0,0 +1,33 @@ +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-12-15 21:52+0200\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: en\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: UTF-8\n" + +#: routes.py:27 +msgid "Welcome! This setup program will install Debian on to your system." +msgstr "Welkom! Hierdie program sal jou deur die proses lei om Debian te installeer na jou sisteem." + +#: routes.py:28 +msgid "Please confirm the following details:" +msgstr "Bevestig asseblief die volgende:" + +#: routes.py:29 +msgid "Language:" +msgstr "Taal:" + +#: routes.py:30 +msgid "Keyboard Layout:" +msgstr "Knoppies Uitleg:" + +#: routes.py:31 +msgid "Time Zone:" +msgstr "Tyd Zone:" diff --git a/src/yasi_applets/welcome/locales/en-za/LC_MESSAGES/welcome.mo b/src/yasi_applets/welcome/locales/en-za/LC_MESSAGES/welcome.mo new file mode 100644 index 0000000..bffd36d Binary files /dev/null and b/src/yasi_applets/welcome/locales/en-za/LC_MESSAGES/welcome.mo differ diff --git a/src/yasi_applets/welcome/locales/en-za/LC_MESSAGES/welcome.po b/src/yasi_applets/welcome/locales/en-za/LC_MESSAGES/welcome.po new file mode 100644 index 0000000..821daeb --- /dev/null +++ b/src/yasi_applets/welcome/locales/en-za/LC_MESSAGES/welcome.po @@ -0,0 +1,33 @@ +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-12-15 21:52+0200\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: en-za\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: UTF-8\n" + +#: routes.py:27 +msgid "Welcome! This setup program will install Debian on to your system." +msgstr "Howzit! This setup program will install Debian on to your system." + +#: routes.py:28 +msgid "Please confirm the following details:" +msgstr "Please confirm the following details:" + +#: routes.py:29 +msgid "Language:" +msgstr "Language:" + +#: routes.py:30 +msgid "Keyboard Layout:" +msgstr "Keyboard Layout:" + +#: routes.py:31 +msgid "Time Zone:" +msgstr "Time Zone:" diff --git a/src/yasi_applets/welcome/locales/en/LC_MESSAGES/welcome.mo b/src/yasi_applets/welcome/locales/en/LC_MESSAGES/welcome.mo new file mode 100644 index 0000000..5fde0b8 Binary files /dev/null and b/src/yasi_applets/welcome/locales/en/LC_MESSAGES/welcome.mo differ diff --git a/src/yasi_applets/welcome/locales/en/LC_MESSAGES/welcome.po b/src/yasi_applets/welcome/locales/en/LC_MESSAGES/welcome.po new file mode 100644 index 0000000..21ecfc6 --- /dev/null +++ b/src/yasi_applets/welcome/locales/en/LC_MESSAGES/welcome.po @@ -0,0 +1,33 @@ +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-12-15 21:52+0200\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: en\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: UTF-8\n" + +#: routes.py:27 +msgid "Welcome! This setup program will install Debian on to your system." +msgstr "Welcomen! This setup program will install Debian on to your system." + +#: routes.py:28 +msgid "Please confirm the following details:" +msgstr "Please confirmen the following details:" + +#: routes.py:29 +msgid "Language:" +msgstr "Language:" + +#: routes.py:30 +msgid "Keyboard Layout:" +msgstr "Keyboard Layout:" + +#: routes.py:31 +msgid "Time Zone:" +msgstr "Time Zone:" diff --git a/src/yasi_applets/welcome/locales/fr/LC_MESSAGES/welcome.mo b/src/yasi_applets/welcome/locales/fr/LC_MESSAGES/welcome.mo new file mode 100644 index 0000000..6e9bcab Binary files /dev/null and b/src/yasi_applets/welcome/locales/fr/LC_MESSAGES/welcome.mo differ diff --git a/src/yasi_applets/welcome/locales/fr/LC_MESSAGES/welcome.po b/src/yasi_applets/welcome/locales/fr/LC_MESSAGES/welcome.po new file mode 100644 index 0000000..e0a9dce --- /dev/null +++ b/src/yasi_applets/welcome/locales/fr/LC_MESSAGES/welcome.po @@ -0,0 +1,33 @@ +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-12-15 21:52+0200\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: fr\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: UTF-8\n" + +#: routes.py:27 +msgid "Welcome! This setup program will install Debian on to your system." +msgstr "Bienvienue! This setup program will install Debian on to your system." + +#: routes.py:28 +msgid "Please confirm the following details:" +msgstr "Please confirmen the following details:" + +#: routes.py:29 +msgid "Language:" +msgstr "Language:" + +#: routes.py:30 +msgid "Keyboard Layout:" +msgstr "Keyboard Layout:" + +#: routes.py:31 +msgid "Time Zone:" +msgstr "Time Zone:" diff --git a/src/yasi_applets/welcome/locales/welcome.pot b/src/yasi_applets/welcome/locales/welcome.pot new file mode 100644 index 0000000..5081e1e --- /dev/null +++ b/src/yasi_applets/welcome/locales/welcome.pot @@ -0,0 +1,38 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2024-12-15 21:52+0200\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: routes.py:27 +msgid "Welcome! This setup program will install Debian on to your system." +msgstr "" + +#: routes.py:28 +msgid "Please confirm the following details:" +msgstr "" + +#: routes.py:29 +msgid "Language:" +msgstr "" + +#: routes.py:30 +msgid "Keyboard Layout:" +msgstr "" + +#: routes.py:31 +msgid "Time Zone:" +msgstr "" diff --git a/src/yasi_applets/welcome/routes.py b/src/yasi_applets/welcome/routes.py new file mode 100644 index 0000000..fe99714 --- /dev/null +++ b/src/yasi_applets/welcome/routes.py @@ -0,0 +1,114 @@ +from yasi_applets.welcome import bp +from flask import Flask, request, session, redirect, \ + url_for, render_template, flash, Blueprint +# we use this neat little trick to get config data from the main app +from flask import current_app +import gettext +import dmm.lsblk as lsblk +import dmm.timezone as timezone + +# Set up Gettext +def set_language(LANG): + """ + Sets language for this applet + """ + translations = gettext.translation("welcome", './applets/welcome/locales', + fallback=True, languages=[LANG]) + translations.install() + _ = translations.gettext + + +@bp.route('/welcome',methods=['GET', 'POST', 'PUT']) +def welcome_index(): + """ + The page you'd get if you access the root of + this app in a browser. + """ + set_language(current_app.config['CONFIG']['settings']['language']) + if request.method == 'POST': + if "lang" in request.form.keys(): + current_app.config['CONFIG']['settings']['language'] = request.form["lang"] + LANG = current_app.config['CONFIG']['settings']['language'] + set_language(LANG) + FORMLANG = request.form["lang"] + if "keyboard" in request.form.keys(): + print(request.form["keyboard"]) + if "timezone" in request.form.keys(): + print(request.form["timezone"]) + global lang + lang = current_app.config['CONFIG']['settings']['language'] + blkid = lsblk.list_scsi_devices() + string_dict = build_stringlist() + build_menu() + build_summary() + menu = current_app.config['CONFIG']['settings']['menu_order'].split(" ") + next_step_url = menu[menu.index("welcome")+1] + previous_step_url = menu[menu.index("welcome")-1] + + print("index is: " , menu.index("welcome")) + if menu.index("welcome") == 0: + previous_step_url = False + else: + previous_step_url = menu[menu.index("users")-1] + + print("next is: " + next_step_url) + print("previous is: " , previous_step_url) + power_button = '' + internet_button = '  ' + bottom_menu = power_button + internet_button + + return render_template('welcome.html', + string_dict=string_dict, selected_lang=lang, + menu=current_app.config['CONFIG']['settings']['menu'], + menu_order=current_app.config['CONFIG']['settings']['menu_order'].split(), + timezones=timezone.list_timezones()[1].split("\n"), + previous_step=previous_step_url, + next_step=next_step_url, + bottom_menu=bottom_menu) + + +def build_stringlist(): + """ + Return all the strings that is used in this applet." + """ + string_dict = {} + string_dict['menu_item'] = _("Welcome") + 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:") + string_dict['basicsettings_text'] = _("Basic Settings:") + lang_dict = {} + lang_dict['af'] = _("Afrikaans") + lang_dict['en'] = _("English (International)") + lang_dict['en-us'] = _("English (United States)") + lang_dict['en-uk'] = _("English (United Kingdom)") + lang_dict['en-za'] = _("English (South Africa)") + string_dict['lang_list'] = lang_dict + return string_dict + +def build_menu(): + """ + Define menu items and paths. + """ + current_app.config['CONFIG']['settings']['menu']['welcome'] = (build_stringlist()['menu_item'], "/welcome", 10) + + +def build_summary(): + """ + Write up a summary of what this module will do. + """ + html = ("Basic settings

Language: " + lang + "

") + if not 'Summary' in current_app.config['CONFIG']: + current_app.config['CONFIG']['Summary'] = {} + current_app.config['CONFIG']['Summary']['welcome'] = {} + current_app.config['CONFIG']['Summary']['welcome']['heading'] = "Basic Settings" + print(current_app.config['CONFIG']['Summary']['welcome']) + text = "Language: " + str(current_app.config['CONFIG']['settings']['language']) + current_app.config['CONFIG']['Summary']['welcome']['text'] = text + return(html) + + +set_language(current_app.config['CONFIG']['settings']['language']) +build_menu diff --git a/src/yasi_applets/welcome/static/img/banner.png b/src/yasi_applets/welcome/static/img/banner.png new file mode 100644 index 0000000..51df1e4 Binary files /dev/null and b/src/yasi_applets/welcome/static/img/banner.png differ diff --git a/src/yasi_applets/welcome/welcome.html b/src/yasi_applets/welcome/welcome.html new file mode 100644 index 0000000..b5f8a26 --- /dev/null +++ b/src/yasi_applets/welcome/welcome.html @@ -0,0 +1,38 @@ +{% extends "layout.html" %} +{% block body %} + +Debian Image banner + +

{{ string_dict['welcome_text'] }}

+

{{ string_dict['confirm_text'] }}


+ +
+ {{ string_dict['language_text'] }} + +
+
+ +
+ {{ string_dict['keylayout_text'] }} + +
+
+ +{% endblock %}