From ce3bc609ede5224d38363c27795c691c3af722cd Mon Sep 17 00:00:00 2001 From: kitoy Date: Mon, 3 Aug 2026 01:12:36 +0200 Subject: [PATCH] Add footer in page --- app/models/sites.py | 28 +++++---- app/templates/_print_colors-footer.css | 4 ++ app/templates/admin/_blocs-list.html | 4 +- app/templates/edit.html.tpl | 59 +++++++++++++++++-- app/templates/index.html.tpl | 5 +- .../themes/chocolate/blocs/edit/footer.html | 15 +++++ .../themes/chocolate/blocs/footer.html | 4 ++ 7 files changed, 100 insertions(+), 19 deletions(-) create mode 100644 app/templates/_print_colors-footer.css create mode 100644 app/templates/themes/chocolate/blocs/edit/footer.html create mode 100644 app/templates/themes/chocolate/blocs/footer.html diff --git a/app/models/sites.py b/app/models/sites.py index 48c128a..0e4eb96 100644 --- a/app/models/sites.py +++ b/app/models/sites.py @@ -73,17 +73,24 @@ class DataSite: if not page.exists(): raise FileNotFoundError(f"Le fichier page.json n'existe pas : {page}") - datas = json.loads(page.read_text()) + datas = json.loads(page.read_text())['blocs'] else: - datas = self.datas + datas = self.datas['blocs'].copy() + if 'footer' in datas.keys(): + del datas['footer'] + return datas + def get_footer(self): + datas = self.datas['blocs'] + if 'footer' in datas.keys(): + return datas['footer'] + else: + return None + def update_bloc(self, bloc, form, files=None): - print (form) - for field in form(): - print(field) if files != None: f = files['image'] @@ -160,7 +167,7 @@ class DataSite: def save_server_info(self, serverInfos=dict()): self.datas['publish'] = serverInfos self.update_json() - + def get_theme(self): return self.datas['config']['theme'] @@ -239,7 +246,6 @@ class DataSite: serverInfos['Address']) test_login = subprocess.check_output(test_connect, shell=True, stderr=subprocess.STDOUT) if "Login incorrect" in str(test_login) : - print ("Mauvais login") return False else: return True @@ -248,15 +254,13 @@ class DataSite: def publish(self, serverInfos=dict(), password=str()): userDir = Path(PurePosixPath(self.user_folder)) - - - upload = "lftp -u \"{}\",\"{}\" -p {} {} -e ' mirror -R public {}; chmod -R o+rx ./; bye;'".format(serverInfos['username'], + upload = "lftp -u \"{}\",\"{}\" -p {} {}:{} -e 'mirror -R ./public ./; bye;'".format(serverInfos['username'], password, serverInfos['Port'], serverInfos['Address'], serverInfos['folder']) - set_permissions = "lftp -u \"{}\",\"{}\" -p {} {} -e 'chmod -R o+rx ./; bye;'".format(serverInfos['username'], + set_permissions = "lftp -u \"{}\",\"{}\" -p {} {}:{} -e 'chmod -R o+rx ./; bye;'".format(serverInfos['username'], password, serverInfos['Port'], serverInfos['Address'], @@ -283,4 +287,4 @@ class DataSite: - + diff --git a/app/templates/_print_colors-footer.css b/app/templates/_print_colors-footer.css new file mode 100644 index 0000000..04c28f2 --- /dev/null +++ b/app/templates/_print_colors-footer.css @@ -0,0 +1,4 @@ + {% if footer.fg_color != footer.bg_color %} + color: {{ footer.fg_color }}; background-color: {{ footer.bg_color }}; +{% endif %} + diff --git a/app/templates/admin/_blocs-list.html b/app/templates/admin/_blocs-list.html index 06a00f0..deea8e5 100644 --- a/app/templates/admin/_blocs-list.html +++ b/app/templates/admin/_blocs-list.html @@ -2,13 +2,13 @@
{% for item in myblocs.keys() %} - + {% if item != 'footer' %}
- + {% endif %} {% endfor %}
diff --git a/app/templates/edit.html.tpl b/app/templates/edit.html.tpl index ba696d2..e261d71 100644 --- a/app/templates/edit.html.tpl +++ b/app/templates/edit.html.tpl @@ -20,17 +20,46 @@ {% include 'admin/_menu-admin.html' %} {% macro print_colors() %} - {% endmacro %} +{% endmacro %} + +{% set bloc = header %} + +{% include 'themes/'+config.theme+'/header.html' ignore missing %} +{% if bloc is defined %} + + + + + + +{% endif %} + {% for bloc in myblocs.values() %} {% if blocEdit == bloc.name %} - - {% include 'themes/'+config.theme+'/blocs/edit/_'+bloc.type+'.html' %} + {% include 'themes/'+config.theme+'/blocs/edit/'+bloc.type+'.html' %} {% else %} + {% include 'themes/'+config.theme+'/blocs/'+bloc.type+'.html' %} + - {% include 'themes/'+config.theme+'/blocs/_'+bloc.type+'.html' %} + + {% endif %} {% endfor %} {% include '_flash_msgs.html' %} +{% set bloc = footer %} +{% include 'themes/'+config.theme+'/blocs/footer.html' ignore missing %} +{% if bloc.name %} + + + + +{% endif %} {% endblock %} {% block js %} + diff --git a/app/templates/index.html.tpl b/app/templates/index.html.tpl index ce8ee50..71f55e3 100644 --- a/app/templates/index.html.tpl +++ b/app/templates/index.html.tpl @@ -16,8 +16,11 @@ {% include 'themes/'+config.theme+'/_nav.html' %} {% for bloc in myblocs.values() %} - {% include 'themes/'+config.theme+'/blocs/_'+bloc.type+'.html' %} + {% include 'themes/'+config.theme+'/blocs/'+bloc.type+'.html' %} {% endfor %} + + {% set bloc = footer %} + {% include 'themes/'+config.theme+'/blocs/footer.html' %} {% endblock %} diff --git a/app/templates/themes/chocolate/blocs/edit/footer.html b/app/templates/themes/chocolate/blocs/edit/footer.html new file mode 100644 index 0000000..63596d1 --- /dev/null +++ b/app/templates/themes/chocolate/blocs/edit/footer.html @@ -0,0 +1,15 @@ + +
+
+ {{ form.csrf_token }} + +
+
+ {% include 'edit-tools/_form-base.html' %} + {% include 'edit-tools/_editor-wysiwyg.html' %} +
+
+ {% include 'edit-tools/_btn-save-cancel.html' %} +
+
+ {% include 'edit-tools/_disable-modify-button.html' %} diff --git a/app/templates/themes/chocolate/blocs/footer.html b/app/templates/themes/chocolate/blocs/footer.html new file mode 100644 index 0000000..e04a9dd --- /dev/null +++ b/app/templates/themes/chocolate/blocs/footer.html @@ -0,0 +1,4 @@ +