diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/app/__init__.py b/app/__init__.py new file mode 100644 index 0000000..24fdf84 --- /dev/null +++ b/app/__init__.py @@ -0,0 +1,7 @@ +from flask import Flask + +app = Flask(__name__, instance_relative_config = True) + +from app import views + +app.config.from_object('config') diff --git a/app/js/multiform.js b/app/js/multiform.js new file mode 100644 index 0000000..548028e --- /dev/null +++ b/app/js/multiform.js @@ -0,0 +1,32 @@ +// https://github.com/sebkouba/dynamic-flask-form +$(function() { + $("div[data-toggle=fieldset]").each(function() { + var $this = $(this); + + //Add new entry + $this.find("button[data-toggle=fieldset-add-row]").click(function() { + var target = $($(this).data("target")) + console.log(target); + var oldrow = target.find("[data-toggle=fieldset-entry]:last"); + var row = oldrow.clone(true, true); + console.log(row.find(":input")[0]); + var elem_id = row.find(":input")[0].id; + var elem_num = parseInt(elem_id.replace(/.*-(\d{1,4})-.*/m, '$1')) + 1; + row.attr('data-id', elem_num); + row.find(":input").each(function() { + console.log(this); + var id = $(this).attr('id').replace('-' + (elem_num - 1) + '-', '-' + (elem_num) + '-'); + $(this).attr('name', id).attr('id', id).val('').removeAttr("checked"); + }); + oldrow.after(row); + }); //End add new entry + + //Remove row + $this.find("button[data-toggle=fieldset-remove-row]").click(function() { + if($this.find("[data-toggle=fieldset-entry]").length > 1) { + var thisRow = $(this).closest("[data-toggle=fieldset-entry]"); + thisRow.remove(); + } + }); //End remove row + }); +}); \ No newline at end of file diff --git a/app/templates/_formhelper.html b/app/templates/_formhelper.html new file mode 100644 index 0000000..5790894 --- /dev/null +++ b/app/templates/_formhelper.html @@ -0,0 +1,12 @@ +{% macro render_field(field) %} +
WARNING: Please note that this site may have you submit sensitive
+ information such as passwords, usernames, and the like.
+ In the interests of full disclosure and respect for privacy, it is important that you know that these are
+ entirely viewable to me, or whomever runs the instance of this website.
+ It is highly recommended that you generate it with dummy values for those sensitive fields
+ (denoted with *sensitive
), and replace those locally in a
+ plaintext editor or XML editor of your choice after downloading the generated configuration file.
A tool to generate XML configuration files for AIF-NG.
+This tool will let you generate configuration files for AIF-NG. I, the author of this generator and of AIF-NG, + recognize that not everyone is comfortable with writing XML from scratch — even if they use something like an IDE + with XML support (I recommend PyCharm Community Edition; it will validate your config as you go as long as you include the XSD in the header!).
+ +So without further ado, head on over to the generator or for more information on using this tool, + try the usage page.
+{% endblock %} \ No newline at end of file diff --git a/app/templates/storage/disk.html b/app/templates/storage/disk.html new file mode 100644 index 0000000..d838110 --- /dev/null +++ b/app/templates/storage/disk.html @@ -0,0 +1,17 @@ +{% extends "base.html" %}{% block title %}AIF-NG Configurator | Disks{% endblock %}{% block body %} + +In this section, you must specify device path names of the target disk(s) to install to. It is highly + recommended to use actual device paths, but you can specify ONE entry as "auto" which will use the first + available unformatted disk. It is not recommended to combine "auto" and actual device path(s).
+DISK FORM
+In this section, you will configure disks/partitions and filesystems to use for your installation. Optionally, you + can also add support for LVM, LUKS, and/or mdadm.
+ + +{% endblock %} \ No newline at end of file diff --git a/app/templates/storage/luks.html b/app/templates/storage/luks.html new file mode 100644 index 0000000..e69de29 diff --git a/app/templates/storage/lvm.py b/app/templates/storage/lvm.py new file mode 100644 index 0000000..e69de29 diff --git a/app/templates/storage/mdadm.html b/app/templates/storage/mdadm.html new file mode 100644 index 0000000..e69de29 diff --git a/app/views.py b/app/views.py new file mode 100644 index 0000000..400c803 --- /dev/null +++ b/app/views.py @@ -0,0 +1,33 @@ +from flask import render_template, make_response, request, flash +from app import app +# from flask_wtf import Form +from wtforms import Form, BooleanField, PasswordField, StringField, TextAreaField, validators + + +class DiskForm(): + disk = TextAreaField(label = 'Disk(s):', + validators = [validators.required(), + validators.Regexp((r'^(/dev/([A-Za-z0-9_]+/)?' + r'[A-Za-z0-9_]+[0-9]?|' + r'auto)$'))], + default = '/dev/sda') + + +class GeneratorForm(Form): + version = StringField(label = 'Version:', + validators = [validators.required()], + default = '0.2.0') + + +@app.route('/', methods = ['GET']) +def index(): + return(render_template('index.html')) + + +@app.route('/generator', methods = ['GET', 'POST']) +def generator(): + form = GeneratorForm(request.form) + if request.method == 'POST' and form.validate(): + print(form) + flash('Generated!') + return(render_template('generator.html', form = form)) diff --git a/config.py b/config.py new file mode 100644 index 0000000..bcf673f --- /dev/null +++ b/config.py @@ -0,0 +1,3 @@ +# Flask debugging - DISABLE FOR PRODUCTION ENVIRONMENTS +DEBUG = True +#DEBUG = False diff --git a/run.py b/run.py new file mode 100755 index 0000000..2fbd814 --- /dev/null +++ b/run.py @@ -0,0 +1,8 @@ +#!/usr/bin/env python3 + +from app import app + +if __name__ == '__main__': + # app.run() + app.run(host = 'localhost', port = 5001, debug = True) + diff --git a/uwsgi.ini b/uwsgi.ini new file mode 100644 index 0000000..6f60f1f --- /dev/null +++ b/uwsgi.ini @@ -0,0 +1,18 @@ +[uwsgi] +plugin = python +py-autoreload = 1 +#uid = http +#gid = http +socket = /run/uwsgi/aifng_config.sock +chown-socket = http:http +processes = 4 +master = 1 +base = /usr/local/lib/aif-ng_configgen +chdir = %(base) +#mount = /=%(base)/run.py +wsgi-file = %(base)/run.py +chmod-socket = 660 +callable = app +cgi-helper =.py=python +logto = /var/log/uwsgi/%n.log +vacuum \ No newline at end of file