1
0
Fork 0
mirror of https://github.com/YunoHost/apps.git synced 2024-09-03 20:06:07 +02:00

appgenerator: cleanup a bunch of stuff to try to focus on what matters for now

This commit is contained in:
Alexandre Aubin 2023-10-27 13:33:23 +02:00 committed by Alexandre Aubin
parent b9fb28083d
commit e785764d7d
2 changed files with 55 additions and 105 deletions

View file

@ -45,11 +45,7 @@ YOLOGEN_VERSION = "0.7.5"
GENERATOR_DICT = {"GENERATOR_VERSION": YOLOGEN_VERSION}
#### Create FLASK and Jinja Environments
url_prefix = ""
# url_prefix = '/yunohost-app-generator'
# app = Flask(__name__)
app = Flask(__name__) # Blueprint('main', __name__, url_prefix=url_prefix)
app = Flask(__name__)
app.config["SECRET_KEY"] = token_urlsafe(16) # Necessary for the form CORS
cors = CORS(app)
@ -261,9 +257,9 @@ class manifestForm(DependenciesForm):
choices=[
("all", "Toutes les architectures"),
("amd64", "amd64"),
("arm64", "arm64"),
("i386", "i386"),
("todo", "TODO : list more architectures"),
("armhf", "armhf"),
("arm64", "arm64"),
],
default=["all"],
validators=[DataRequired()],
@ -629,10 +625,7 @@ class appGeneratorForm(
parameters = dict(GENERATOR_DICT)
template_manifest = environment.get_template("manifest.j2")
manifest = dict(GENERATOR_DICT)
template_install = environment.get_template("install.j2")
install = dict(GENERATOR_DICT)
#### Initialising variables
@ -641,7 +634,7 @@ install = dict(GENERATOR_DICT)
#### Web pages
@app.route(url_prefix + "/", methods=["GET", "POST"])
@app.route("/", methods=["GET", "POST"])
def main_form():
if not "appGeneratorForm" in locals():
main_form = appGeneratorForm()
@ -654,7 +647,6 @@ def main_form():
for key, value in results.items():
parameters[key] = value
parameters["preview"] = True
# print(install)
if main_form.validate_on_submit():
parameters["invalid_form"] = False
print()
@ -791,7 +783,6 @@ def main_form():
systemd_config_file=parameters["systemd_config_file"],
custom_config_file=parameters["custom_config_file"],
cron_config_file=parameters["cron_config_file"],
url_prefix=url_prefix,
)
else:
print("[DEBUG] Formulaire invalide: ", main_form.errors)
@ -802,13 +793,14 @@ def main_form():
parameters["preview"] = False
return render_template(
"index.html", parameters=install, main_form=main_form, url_prefix=url_prefix
"index.html", main_form=main_form
)
@app.route("/install")
def install_page():
return render_template(template_install, parameters=install)
template_install = environment.get_template("install.j2")
return render_template(template_install)
@app.route("/generator", methods=("GET", "POST"))

View file

@ -37,9 +37,7 @@
}
}
}
</script>
<script>
function showPage(tag,page) {
console.log("ERREUR");
console.log(tag);
@ -49,9 +47,7 @@
function clearPage(tag) {
document.getElementById(tag).innerHTML = ``;
}
</script>
<script>
function copyCodeBlock(code_block) {
var codeBlock = document.querySelector(code_block);
var codeText = codeBlock.textContent;
@ -64,10 +60,7 @@
alert("Une erreur s'est produite lors de la copie du code.");
});
}
</script>
<script>
function generateContent(file) {
// Generate file content
if (file == 'manifest') {
@ -107,8 +100,7 @@
}
return template_file_content;
}
</script>
<script>
function downloadFile(file) {
const content = generateContent(file); // Generate file content (it's not an actual file);
const dataUrl = 'data:text/plain;charset=utf-8,' + encodeURIComponent(content);
@ -141,11 +133,9 @@
}
link.href = dataUrl;
}
</script>
<script>
function download_zip() {
var xhr = new XMLHttpRequest();
@ -237,9 +227,8 @@
</ul>
-->
<p style="text-align: center; margin-left:5%">Version: {{ parameters['GENERATOR_VERSION'] }}</p>
<h1 class="message" , style="text-align:center">Formulaire de génération d'une application Yunohost</h1>
<form id="main-form" method="POST" action="{{ url_prefix }}/"> <! "action" is not needed to submit on the same page>
<h1 class="message" style="text-align:center">Formulaire de génération d'une application Yunohost</h1>
<form id="main-form" method="POST">
{{ main_form.hidden_tag() }}
@ -853,35 +842,4 @@ End of the result part
</body>
<footer class="py-3 mt-auto" style="margin-left: 38% ;margin-top:30px">
<nav>
<ul class="nav" style="text-align:center;">
<li class="nav-item" style="float:left"><a href="https://yunohost.org/docs"
rel="noopener" target="_blank"
class="nav-link text-secondary"><span data-v-d85b127e=""
data-v-ae4f6aeb=""
aria-hidden="true"
class="icon fa fa-book"></span>
Documentation </a></li>
<li class="nav-item" style="float:left"><a href="https://yunohost.org/"
rel="noopener" target="_blank"
class="nav-link text-secondary"><span data-v-d85b127e=""
data-v-ae4f6aeb=""
aria-hidden="true"
class="icon fa fa-life-ring"></span>
Découvrir Yunohost </a></li>
<li class="nav-item" style="justify-content:right"><a href="https://donate.yunohost.org/"
rel="noopener" target="_blank"
class="nav-link text-secondary"><span
data-v-d85b127e=""
data-v-ae4f6aeb=""
aria-hidden="true"
class="icon fa fa-heart"></span>
Faire un don </a></li>
<li id="generator-version" class="navbar-text" style="display: inline-block; margin-left: auto">Propulsé par
YoloGen {{ parameters['GENERATOR_VERSION']}}.
</li>
</ul>
</nav>
</footer>
</html>