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

appstore: display unusual ram requirement, arch limitation, pre-install notes, emojis

This commit is contained in:
Alexandre Aubin 2023-09-01 21:57:21 +02:00
parent eddaf494a4
commit 352aeac146
4 changed files with 51 additions and 6 deletions

View file

@ -13,6 +13,7 @@ import sys
from slugify import slugify
from flask import Flask, send_from_directory, render_template, session, redirect, request
from github import Github, InputGitAuthor
from emoji import emojize
locale = "en"
app = Flask(__name__, static_url_path='/assets', static_folder="assets")
@ -72,6 +73,28 @@ wishlist = toml.load(open("../wishlist.toml"))
app.secret_key = ''.join([str(random.randint(0, 9)) for i in range(99)])
def human_to_binary(size: str) -> int:
symbols = ("K", "M", "G", "T", "P", "E", "Z", "Y")
factor = {}
for i, s in enumerate(symbols):
factor[s] = 1 << (i + 1) * 10
suffix = size[-1]
size = size[:-1]
if suffix not in symbols:
raise YunohostError(
f"Invalid size suffix '{suffix}', expected one of {symbols}"
)
try:
size_ = float(size)
except Exception:
raise YunohostError(f"Failed to convert size {size} to float")
return int(size_ * factor[suffix])
@app.route('/favicon.ico')
def favicon():
return send_from_directory('assets', 'favicon.png')
@ -138,7 +161,7 @@ def app_info(app_id):
description_path = None
if description_path:
with open(description_path) as f:
infos["full_description_html"] = pycmarkgfm.gfm_to_html(f.read())
infos["full_description_html"] = emojize(pycmarkgfm.gfm_to_html(f.read()), language="alias")
else:
infos["full_description_html"] = infos['manifest']['description'][locale]
@ -150,7 +173,7 @@ def app_info(app_id):
pre_install_path = None
if pre_install_path:
with open(pre_install_path) as f:
infos["pre_install_html"] = pycmarkgfm.gfm_to_html(f.read())
infos["pre_install_html"] = emojize(pycmarkgfm.gfm_to_html(f.read()), language="alias")
infos["screenshot"] = None
@ -168,6 +191,9 @@ def app_info(app_id):
] = f"data:image/{ext};charset=utf-8;base64,{data}"
break
ram_build_requirement = infos["manifest"]["integration"]["ram"]["build"]
infos["manifest"]["integration"]["ram"]["build_binary"] = human_to_binary(ram_build_requirement)
return render_template("app.html", user=session.get('user', {}), app_id=app_id, infos=infos, catalog=catalog)

View file

@ -4,3 +4,4 @@ PyGithub
toml
pycmarkgfm
gunicorn
emoji

View file

@ -62,16 +62,31 @@
<div class="from-markdown">{{ infos["full_description_html"]|safe }}</div>
{% if infos["screenshot"] %}
<img src="{{ infos["screenshot"] }}" />
<img class="my-3" src="{{ infos["screenshot"] }}" />
{% endif %}
{% if infos["manifest"]["integration"]["architectures"] != "all" %}
<div class="my-3 rounded-md bg-orange-200 text-orange-800 px-5 py-2">
<i class="fa fa-exclamation-triangle fa-fw"></i> This app is only compatible with these specific architectures : {{ infos["manifest"]["integration"]["architectures"]|join(', ') }}
</div>
{% endif %}
<p>{{ infos["manifest"]["integration"] }}</p>
<div class="from-markdown">{{ infos["pre_install_html"] | safe }}</div>
{% if infos["manifest"]["integration"]["ram"]["build_binary"] >= 500 * 1024 * 1024 %}
<div class="my-3 rounded-md bg-orange-200 text-orange-800 px-5 py-2">
<i class="fa fa-exclamation-triangle fa-fw"></i> This app requires an unusual amount of RAM to build : {{ infos["manifest"]["integration"]["ram"]["build"] }}
</div>
{% endif %}
{% if infos["pre_install_html"] %}
<div class="my-3 rounded-md bg-blue-200 text-blue-800 px-5 py-2">
<h3 class="inline-block text-xl mb-2 font-semibold">Important infos before installing</h3>
<div class="from-markdown">{{ infos["pre_install_html"] | safe }}</div>
</div>
{% endif %}
{% if infos["antifeatures"] %}
<h3 class="inline-block text-xl mb-2 font-semibold">Anti-features</h3> <p class="inline-block text-sm">(This app has features you may not like)</p>
<div class="mb-3 rounded-md bg-red-200 text-red-800 px-5 py-2">
<div class="my-3 rounded-md bg-red-200 text-red-800 px-5 py-2">
<ul>
{% for antifeature in infos["antifeatures"] %}
<li class="mb-1"><i class="fa fa-{{ catalog['antifeatures'][antifeature]['icon'] }} fa-fw" aria-hidden="true"></i> {{ catalog['antifeatures'][antifeature]['description'][locale] }}</li>

View file

@ -40,6 +40,9 @@
padding: revert;
list-style: disc;
}
.from-markdown a {
@apply text-blue-600;
}
}
</style>
</head>