Python : Add instructions for download page;

SVG    : Add icons of XMPP clients;
TOML   : Add a list of XMPP clients;
XHTML  : Add a download page;
XHTML  : Remove unused code.
This commit is contained in:
Schimon Jehudah, Adv. 2024-10-20 17:30:06 +03:00
parent 714103a331
commit 4553e8aa5c
40 changed files with 5170 additions and 25 deletions

53
fasi.py
View file

@ -613,6 +613,59 @@ class HttpInstance:
response.headers['Content-Type'] = 'application/xhtml+xml'
return response
@self.app.get('/download')
@self.app.get('/download/{software}')
@self.app.get('/download/{software}/{kind}')
async def download_get(request: Request, software=None, kind=None):
# TODO admin, advanced, console, desktop, graphical, mobile
if not kind: kind = 'graphical'
if not software:
user_agent = request.headers.get("user-agent")
user_agent_lower = user_agent.lower()
match user_agent_lower:
case _ if 'linux' in user_agent_lower:
software = 'linux'
case _ if 'haiku' in user_agent_lower:
software = 'haiku'
case _ if 'android' in user_agent_lower:
software = 'divestos'
case _ if 'reactos' in user_agent_lower or 'windows' in user_agent_lower:
software = 'reactos'
case _ if 'ios' in user_agent_lower or 'macos' in user_agent_lower:
software = 'apple'
name = software.title()
if 'os' in software: name = name.replace('os', 'OS')
filename_clients = 'clients.toml'
clients = Data.open_file_toml(filename_clients)
client_selection = []
for client in clients:
if software in clients[client]:
client_selected = {
'name' : clients[client]['title'],
'about' : clients[client]['about'],
'features' : clients[client]['features'],
'iden' : client,
'href' : clients[client][software]}
client_selection.append(client_selected)
template_file = 'download.xhtml'
template_dict = {
'brand_name' : brand_name,
'brand_site' : brand_site,
'chat_client' : chat_client,
'client_selection' : client_selection,
'request' : request,
'software' : software,
'title' : name,
'url' : request.url._url}
response = templates.TemplateResponse(template_file, template_dict)
response.headers['Content-Type'] = 'application/xhtml+xml'
return response
@self.app.exception_handler(404)
def not_found_exception_handler(request: Request, exc: HTTPException):
action = 'Warning'