diff --git a/tools/app_generator/app_generator.py b/tools/app_generator/app_generator.py index 98325aec..d2a520e2 100644 --- a/tools/app_generator/app_generator.py +++ b/tools/app_generator/app_generator.py @@ -13,6 +13,7 @@ from markupsafe import Markup # No longer imported from Flask # Form libraries from flask_wtf import FlaskForm +from flask_bootstrap import Bootstrap from wtforms import ( StringField, RadioField, @@ -42,6 +43,7 @@ from secrets import token_urlsafe #### Create FLASK and Jinja Environments app = Flask(__name__) +Bootstrap(app) app.config["SECRET_KEY"] = token_urlsafe(16) # Necessary for the form CORS cors = CORS(app) @@ -77,9 +79,10 @@ def markdown_file_to_html_string(file): ## PHP forms -class Form_PHP_Config(FlaskForm): +class Form_PHP(FlaskForm): + use_php = BooleanField("Nécessite PHP", default=False) php_config_file = SelectField( - "Type de fichier PHP :", + "Type de fichier PHP", choices=[ ( "php-fpm.conf", @@ -102,7 +105,7 @@ class Form_PHP_Config(FlaskForm): # 'title': "Choisir un fichier permettant un paramétrage d'options complémentaires. C'est généralement recommandé." php_config_file_content = TextAreaField( - "Saisissez le contenu du fichier de configuration PHP :", + "Saisissez le contenu du fichier de configuration PHP", validators=[Optional()], render_kw={ "class": "form-control", @@ -113,15 +116,11 @@ class Form_PHP_Config(FlaskForm): ) -class Form_PHP(Form_PHP_Config): - use_php = BooleanField("Nécessite PHP", default=False) - - ## NodeJS forms class Form_NodeJS(FlaskForm): use_nodejs = BooleanField("Nécessite NodeJS", default=False) use_nodejs_version = StringField( - "Version de NodeJS :", + "Version de NodeJS", render_kw={ "placeholder": "20", "class": "form-control", @@ -145,7 +144,7 @@ class Form_Python(FlaskForm): "Nécessite Python", default=False ) ## TODO -> python3, python3-pip, python3-ven dependencies by default python_dependencies_type = SelectField( - "Configuration des dépendances Python :", + "Configuration des dépendances Python", choices=[ ("requirements.txt", Markup("Fichier requirements.txt")), ("manual_list", "Liste manuelle"), @@ -154,7 +153,7 @@ class Form_Python(FlaskForm): validators=[DataRequired(), Optional()], ) python_requirements = TextAreaField( - "La liste de dépendances inclue dans le fichier requirements.txt :", + "La liste de dépendances inclue dans le fichier requirements.txt", render_kw={ "class": "form-control", "style": "width: 50%;height:5.5em;min-height: 5.5em; max-height: 55em;flex-grow: 1;box-sizing: border-box;", @@ -163,7 +162,7 @@ class Form_Python(FlaskForm): }, ) python_dependencies_list = StringField( - "Liste de dépendances python :", + "Liste de dépendances python", render_kw={ "placeholder": "tensorflow uvicorn fastapi", "class": "form-control", @@ -175,45 +174,33 @@ class GeneralInfos(FlaskForm): app_id = StringField( Markup( - """Identifiant (id) de l'application (en minuscule et sans espaces) :""" + "Identifiant (id) de l'application" ), + description="En minuscule et sans espace.", validators=[DataRequired(), Regexp("[a-z_1-9]+.*(?.btn { - padding:.25rem .5rem; - //font-size:.7875rem; - line-height:1.5; - border-radius:.2rem; -} - - -.form-control { - #display: block; - #width: 100%; - #height: calc(1.5em + .75rem + 2px); - padding: .375rem .75rem; - padding-right: 0.5rem; - margin-left:0.75rem; - font-size: .9rem; - font-weight: 400; - line-height: 1.5; - color: var(--gray-700); - background-color: var(--white); - background-clip: padding-box; - border: 1px solid var(--gray-400); - border-radius: .25rem; - transition: border-color .15s ease-in-out,box-shadow .15s ease-in-out; -} -.form-control.is-invalid { - border-color: var(--red); - padding-right: calc(1.5em + .75rem) !important; - background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' fill='none' stroke='var%28--red%29' viewBox='0 0 12 12'%3e%3ccircle cx='6' cy='6' r='4.5'/%3e%3cpath stroke-linejoin='round' d='M5.8 3.6h.4L6 6.5z'/%3e%3ccircle cx='6' cy='8.2' r='.6' fill='var%28--red%29' stroke='none'/%3e%3c/svg%3e"); - background-repeat: no-repeat; - background-position: right calc(.375em + .1875rem) center; - background-size: calc(.75em + .375rem) calc(.75em + .375rem); -} - - - -.custom-select { - - display: inline-block; - width: 100%; - height: calc(1.5em + .75rem + 2px); - padding: .375rem 1.75rem .375rem .75rem; - font-size: .9rem; - font-weight: 400; - line-height: 1.5; - color: var(--gray-700); - vertical-align: middle; - background: var(--white) url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' width='4' height='5' viewBox='0 0 4 5'%3e%3cpath fill='var%28--gray-800%29' d='M2 0L0 2h4zm0 5L0 3h4z'/%3e%3c/svg%3e") right .75rem center/8px 10px no-repeat; - border: 1px solid var(--gray-400); - border-radius: .25rem; - appearance: none; - -} - - -.nav { - display:flex; - flex-wrap:wrap; - padding-left:0; - margin-bottom:0; - list-style:none -} -.nav-tabs .nav-item.show .nav-link { - color:var(--gray-700); - background-color:var(--white); - border-color:var(--gray-300) var(--gray-300) var(--white) -} - -nav a { - margin-left: 50px; - // text-decoration: none; // removing links underline is a bad idea -} - -footer .nav-item:before { - /* content:"\2022"; */ - width:1rem; - display:inline-block; - margin-left:-1.15rem; - padding-top:1rem!important; - margin-top:auto!important; -} - - -.test { - color:red; -} \ No newline at end of file diff --git a/tools/app_generator/templates/index.html b/tools/app_generator/templates/index.html index bde208c4..5a231778 100644 --- a/tools/app_generator/templates/index.html +++ b/tools/app_generator/templates/index.html @@ -1,9 +1,17 @@ - - -
- - +{% import "bootstrap/wtf.html" as wtf %} +{% extends "bootstrap/base.html" %} + +{% block title %} +YunoHost app generator +{% endblock %} + +{% block styles %} +{{super()}} + +{% endblock %} + +{% block content %} -