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:
parent
b9fb28083d
commit
e785764d7d
2 changed files with 55 additions and 105 deletions
|
@ -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"))
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
||||
|
@ -172,54 +162,54 @@
|
|||
|
||||
//var url = '/download_as_zip?app_id=' + '{{ parameters['app_id'] }}' + '&template_manifest_content=' + template_manifest_content + '&template_install_content=' + template_install_content + '&template_remove_content=' + template_remove_content + '&template_backup_content=' + template_backup_content + '&template_restore_content=' + template_restore_content + '&template_upgrade_content=' + template_upgrade_content + '&template_config_content=' + template_config_content + '&template_change_url_content=' + template_change_url_content + '&custom_config_file=' + custom_config_file+ '&custom_config_file_content=' + custom_config_file_content + '&nginx_config_file=' + nginx_config_file + '&systemd_config_file=' + systemd_config_file + '&use_php=' + use_php + '&php_config_file=' + php_config_file + '&php_config_file_content=' + php_config_file_content;
|
||||
|
||||
var formData = new FormData();
|
||||
console.log(formData)
|
||||
formData.append('app_id', "{{ parameters['app_id'] }}");
|
||||
console.log(formData)
|
||||
//formData.append('template_manifest_content', template_manifest_content);
|
||||
//formData.append('template_install_content', template_install_content);
|
||||
//formData.append('template_remove_content', template_remove_content);
|
||||
//formData.append('template_backup_content', template_backup_content);
|
||||
//formData.append('template_restore_content', template_restore_content);
|
||||
//formData.append('template_upgrade_content', template_upgrade_content);
|
||||
//formData.append('template_config_content', template_config_content);
|
||||
formData.append('custom_config_file', custom_config_file);
|
||||
formData.append('custom_config_file_content', custom_config_file_content);
|
||||
formData.append('systemd_config_file', systemd_config_file);
|
||||
formData.append('nginx_config_file', nginx_config_file);
|
||||
formData.append('cron_config_file', cron_config_file);
|
||||
formData.append('use_php', use_php);
|
||||
formData.append('php_config_file', php_config_file);
|
||||
formData.append('php_config_file_content', php_config_file_content);
|
||||
var url = '/download_zip?' + new URLSearchParams(formData).toString()
|
||||
var formData = new FormData();
|
||||
console.log(formData)
|
||||
formData.append('app_id', "{{ parameters['app_id'] }}");
|
||||
console.log(formData)
|
||||
//formData.append('template_manifest_content', template_manifest_content);
|
||||
//formData.append('template_install_content', template_install_content);
|
||||
//formData.append('template_remove_content', template_remove_content);
|
||||
//formData.append('template_backup_content', template_backup_content);
|
||||
//formData.append('template_restore_content', template_restore_content);
|
||||
//formData.append('template_upgrade_content', template_upgrade_content);
|
||||
//formData.append('template_config_content', template_config_content);
|
||||
formData.append('custom_config_file', custom_config_file);
|
||||
formData.append('custom_config_file_content', custom_config_file_content);
|
||||
formData.append('systemd_config_file', systemd_config_file);
|
||||
formData.append('nginx_config_file', nginx_config_file);
|
||||
formData.append('cron_config_file', cron_config_file);
|
||||
formData.append('use_php', use_php);
|
||||
formData.append('php_config_file', php_config_file);
|
||||
formData.append('php_config_file_content', php_config_file_content);
|
||||
var url = '/download_zip?' + new URLSearchParams(formData).toString()
|
||||
|
||||
xhr.open('GET', url, true);
|
||||
//xhr.open('GET', '/download_as_zip', true);
|
||||
xhr.responseType = 'blob';
|
||||
xhr.open('GET', url, true);
|
||||
//xhr.open('GET', '/download_as_zip', true);
|
||||
xhr.responseType = 'blob';
|
||||
|
||||
console.log('Generating the zip archive using the following parameters:')
|
||||
console.log(url)
|
||||
console.log('Generating the zip archive using the following parameters:')
|
||||
console.log(url)
|
||||
|
||||
xhr.onload = function() { // onload // onreadystatechange
|
||||
console.log("Running XHR")
|
||||
console.log(xhr.status)
|
||||
if (xhr.readyState === 4 && xhr.status === 200) {
|
||||
var blob = new Blob([xhr.response], { type: 'application/zip' });
|
||||
var url = URL.createObjectURL(blob);
|
||||
var link = document.createElement('a');
|
||||
link.href = url;
|
||||
link.download = '{{ parameters['app_id'] }}' + '.zip'; // archive name
|
||||
link.click();
|
||||
URL.revokeObjectURL(url);
|
||||
} else {
|
||||
alert('Error while generating the zip archive. Error code: ' + xhr.status)
|
||||
xhr.onload = function() { // onload // onreadystatechange
|
||||
console.log("Running XHR")
|
||||
console.log(xhr.status)
|
||||
if (xhr.readyState === 4 && xhr.status === 200) {
|
||||
var blob = new Blob([xhr.response], { type: 'application/zip' });
|
||||
var url = URL.createObjectURL(blob);
|
||||
var link = document.createElement('a');
|
||||
link.href = url;
|
||||
link.download = '{{ parameters['app_id'] }}' + '.zip'; // archive name
|
||||
link.click();
|
||||
URL.revokeObjectURL(url);
|
||||
} else {
|
||||
alert('Error while generating the zip archive. Error code: ' + xhr.status)
|
||||
}
|
||||
}
|
||||
}
|
||||
console.log(xhr)
|
||||
console.log(xhr.status)
|
||||
xhr.send();
|
||||
console.log(xhr)
|
||||
console.log(xhr.status)
|
||||
console.log(xhr)
|
||||
console.log(xhr.status)
|
||||
xhr.send();
|
||||
console.log(xhr)
|
||||
console.log(xhr.status)
|
||||
}
|
||||
</script>
|
||||
<title>YunoHost app generator</title>
|
||||
|
@ -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>
|
||||
|
|
Loading…
Add table
Reference in a new issue