Add a prompt dialog;
Automate installation process; Minor changes to HTML templates; Thank you to LeXofLeviafan.
This commit is contained in:
parent
d29d335e5b
commit
4be8dad823
12 changed files with 80 additions and 13 deletions
|
@ -1,12 +1,14 @@
|
|||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
from jabbercard.config import Cache
|
||||
from jabbercard.utilities.toml import Toml
|
||||
from jabbercard.config import Cache, Data, Settings
|
||||
from jabbercard.http.instance import HttpInstance
|
||||
#import logging
|
||||
import os
|
||||
#from os.path import getsize, exists
|
||||
import re
|
||||
import shutil
|
||||
#import time
|
||||
import uvicorn
|
||||
|
||||
|
@ -16,10 +18,75 @@ def main():
|
|||
return http_instance.app
|
||||
|
||||
if __name__ == 'jabbercard.__main__':
|
||||
|
||||
directory = os.path.dirname(__file__)
|
||||
|
||||
# Copy data files
|
||||
directory_data = Data.get_directory()
|
||||
if not os.path.exists(directory_data):
|
||||
directory_assets = os.path.join(directory, 'assets')
|
||||
directory_assets_new = shutil.copytree(directory_assets, directory_data)
|
||||
print(f'Data directory {directory_assets_new} has been created and populated.')
|
||||
|
||||
# Copy settings files
|
||||
directory_settings = Settings.get_directory()
|
||||
if not os.path.exists(directory_settings):
|
||||
directory_configs = os.path.join(directory, 'configs')
|
||||
directory_settings_new = shutil.copytree(directory_configs, directory_settings)
|
||||
print(f'Settings directory {directory_settings_new} has been created and populated.')
|
||||
|
||||
# Create cache directories
|
||||
directory_cache = Cache.get_directory()
|
||||
if not os.path.exists(directory_cache): os.mkdir(directory_cache)
|
||||
if not os.path.exists(directory_cache):
|
||||
print(f'Creating a cache directory at {directory_cache}.')
|
||||
os.mkdir(directory_cache)
|
||||
for subdirectory in ('details', 'photo', 'qr', 'xep_0060'):
|
||||
subdirectory_cache = os.path.join(directory_cache, subdirectory)
|
||||
if not os.path.exists(subdirectory_cache): os.mkdir(subdirectory_cache)
|
||||
if not os.path.exists(subdirectory_cache):
|
||||
print(f'Creating a cache subdirectory at {subdirectory_cache}.')
|
||||
os.mkdir(subdirectory_cache)
|
||||
|
||||
# Configure settings file
|
||||
file_settings = os.path.join(directory_settings, 'settings.toml')
|
||||
data_settings = Toml.open_file_toml(file_settings)
|
||||
|
||||
# Configure account
|
||||
data_settings_account = data_settings['account']
|
||||
|
||||
settings_account = {
|
||||
'alias': 'Set an Alias',
|
||||
'xmpp': 'Set a Jabber ID',
|
||||
'pass': 'Input Password'
|
||||
}
|
||||
|
||||
for key in settings_account:
|
||||
data_settings_account_value = data_settings_account[key]
|
||||
if not data_settings_account_value:
|
||||
settings_account_message = settings_account[key]
|
||||
while not data_settings_account_value:
|
||||
data_settings_account_value = input(f'{settings_account_message}: ')
|
||||
data_settings_account[key] = data_settings_account_value
|
||||
|
||||
# Configure brand
|
||||
data_settings_brand = data_settings['brand']
|
||||
|
||||
settings_brand_default = {
|
||||
'name': 'XMPP',
|
||||
'chat': 'Dino',
|
||||
'news': 'Reeder',
|
||||
'site': 'https://xmpp.org'
|
||||
}
|
||||
|
||||
for key in settings_brand_default:
|
||||
data_settings_brand_value = data_settings_brand[key]
|
||||
if not data_settings_brand_value:
|
||||
settings_brand_default_value = settings_brand_default[key]
|
||||
data_settings_brand_value = input(f'Set brand {key} (default: "{settings_brand_default_value}"): ')
|
||||
if not data_settings_brand_value: data_settings_brand_value = settings_brand_default_value
|
||||
data_settings_brand[key] = data_settings_brand_value
|
||||
|
||||
Toml.save_to_toml(file_settings, data_settings)
|
||||
|
||||
# Start JabberCard
|
||||
app = main()
|
||||
uvicorn.run(app, host='127.0.0.1', port=8000, reload=False)
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
|
||||
<title>{{brand_name}}: {{action}} {% if alias %}{{alias}}{% else %}{{title}}{% endif %}</title>
|
||||
<title>{{action}} {% if alias %}{{alias}}{% else %}{{title}}{% endif %} ({{jid_bare}}) | {{brand_name}}</title>
|
||||
<meta name="description" content="{{action}} {% if alias %}{{alias}}{% else %}{{title}}{% endif %}" />
|
||||
<meta name="generator" content="Fast And Sleek Invite" />
|
||||
<meta name="uri" content="{{xmpp_uri}}" />
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
|
||||
<title>{{brand_name}}: {{action}} {{title}}</title>
|
||||
<title>{{action}} {{title}} ({{jid_bare}}) | {{brand_name}}</title>
|
||||
<meta name="description" content="{{action}} {{title}}" />
|
||||
<meta name="generator" content="Fast And Sleek Invite" />
|
||||
<meta name="uri" content="{{xmpp_uri}}" />
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
|
||||
<title>{{brand_name}}: Download</title>
|
||||
<title>Download Clients | {{brand_name}}</title>
|
||||
<meta name="description" content="Download an XMPP client and access to the world's foremost and premier publishing and telecommunication platform with top-tier encryption, privacy and security that are to be offered as of yet." />
|
||||
<meta name="generator" content="Fast And Sleek Invite" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
|
||||
<title>{{brand_name}}: {{action}} {% if alias %}{{alias}}{% else %}{{title}}{% endif %}</title>
|
||||
<title>{{action}} {% if alias %}{{alias}}{% else %}{{title}}{% endif %} ({{jid_bare}}) | {{brand_name}}</title>
|
||||
<meta name="description" content="{{action}} {% if alias %}{{alias}}{% else %}{{title}}{% endif %}" />
|
||||
<meta name="generator" content="Fast And Sleek Invite" />
|
||||
<meta name="uri" content="{{xmpp_uri}}" />
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
|
||||
<title>{{brand_name}} : Welcome</title>
|
||||
<title>Welcome | {{brand_name}}</title>
|
||||
<meta name="description" content="This is an XMPP lookup service, powered by FASI (Fast And Sleek Invite)." />
|
||||
<meta name="generator" content="Fast And Sleek Invite" />
|
||||
<meta name="uri" content="{{xmpp_uri}}" />
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
|
||||
<title>{{brand_name}}: {{action}} {% if alias %}{{alias}}{% else %}{{title}}{% endif %}</title>
|
||||
<title>Articles {% if alias %}{{alias}}{% else %}{{title}}{% endif %} ({{jid_bare}}) | {{brand_name}}</title>
|
||||
<meta name="description" content="{{action}} {% if alias %}{{alias}}{% else %}{{title}}{% endif %}" />
|
||||
<meta name="generator" content="Fast And Sleek Invite" />
|
||||
<meta name="uri" content="{{xmpp_uri}}" />
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
|
||||
<title>{{brand_name}}: {{action}} {{title}}</title>
|
||||
<title>{{action}} {{title}} | {{brand_name}}</title>
|
||||
<meta name="description" content="{{action}} {{title}}" />
|
||||
<meta name="generator" content="Fast And Sleek Invite" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
|
||||
<title>{{brand_name}}: System</title>
|
||||
<title>Operating Systems | {{brand_name}}</title>
|
||||
<meta name="description" content="Operating System Selection" />
|
||||
<meta name="generator" content="Fast And Sleek Invite" />
|
||||
<meta name="uri" content="{{xmpp_uri}}" />
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=UTF-8" />
|
||||
<title>{{brand_name}}: {{action}} {% if alias %}{{alias}}{% else %}{{title}}{% endif %}</title>
|
||||
<title>{{action}} {% if alias %}{{alias}}{% else %}{{title}}{% endif %} ({{jid_bare}}) | {{brand_name}}</title>
|
||||
<meta name="description" content="{{action}} {% if alias %}{{alias}}{% else %}{{title}}{% endif %}" />
|
||||
<meta name="generator" content="Fast And Sleek Invite" />
|
||||
<meta name="uri" content="{{xmpp_uri}}" />
|
||||
|
|
|
@ -73,4 +73,4 @@ jabbercard = "jabbercard.__main__:main"
|
|||
platforms = ["any"]
|
||||
|
||||
[tool.setuptools.package-data]
|
||||
"*" = ["*.toml"]
|
||||
"*" = ["*.css", "*.svg", "*.toml", "*.xhtml"]
|
||||
|
|
Loading…
Reference in a new issue