From ce9c22d0b1ccba534135f60ad4742871ae401345 Mon Sep 17 00:00:00 2001 From: Cailean Finn Date: Sun, 28 Sep 2025 00:53:25 +0200 Subject: [PATCH] finished --- ContentfulService.py | 57 ++++++++++++++++++ __pycache__/ContentfulService.cpython-310.pyc | Bin 1740 -> 2846 bytes app.py | 36 +++-------- templates/index.html | 6 +- templates/list-exhibitions.html | 8 +-- templates/list.html | 11 +++- 6 files changed, 81 insertions(+), 37 deletions(-) diff --git a/ContentfulService.py b/ContentfulService.py index c9fdef2..9088fba 100644 --- a/ContentfulService.py +++ b/ContentfulService.py @@ -1,6 +1,7 @@ import contentful import markdown import os +import re class ContentfulService: def __init__(self, space_id, access_token): @@ -44,4 +45,60 @@ class ContentfulService: } location_list.append(content) return location_list + + def get_exhibition_list_info(self): + entries = self.client.entries({'content_type': 'exhibitionList'}) + exhibition_list = [] + for e in entries: + title = getattr(e, 'title') + + description = getattr(e, 'description') + description = markdown.markdown(description) + + start_date = getattr(e, 'start_date') + start_date = start_date.strftime('%#d %b %Y') if start_date else None + + end_date = getattr(e, 'end_date') + end_date = end_date.strftime('%#d %b %Y') if end_date else None + + location = getattr(e, 'location') + + slug = title.lower() # Convert to lowercase + slug = re.sub(r'[^a-z0-9\s-]', '', slug) # Remove non-alphanumeric characters + slug = re.sub(r'[\s-]+', '-', slug).strip('-') # Replace spaces and repeated hyphens + url = slug + + content = { + 'title': title, + 'location': location, + 'description': description, + 'start_date': start_date, + 'end_date': end_date, + 'url': url + } + + exhibition_list.append(content) + return exhibition_list + + def get_sponser_logos(self): + entries = self.client.entries({'content_type': 'sponser'}) + supp_img = [] + prio_img = [] + top_img = [] + for e in entries: + src = getattr(e, 'logo') + idx = getattr(e, 'type') + + content = 'https:{0}'.format(src.url()) + + + if idx == '1': + top_img.append(content) + elif idx == '2': + prio_img.append(content) + else: + supp_img.append(content) + + + return supp_img, prio_img, top_img \ No newline at end of file diff --git a/__pycache__/ContentfulService.cpython-310.pyc b/__pycache__/ContentfulService.cpython-310.pyc index 9f0f05bb3b71c526283a2f6e52db221ef892d066..430c93fb2ddda1139aeb267d3e5b1616e33c3730 100644 GIT binary patch delta 1321 zcmZux-HsbI6dv0%9?xVp-R_pOKxt{A+oo;AwnAFqmcI*7B~&Ctwk1l}v)O?(GuU2H zwvKYKE8sTF4HpO{5^vDg=mS)~;5CqXfjGxaX%=-Xe{+0}?PL4S&ZjnlQ~p}s@0tVne>iNVtU1Bx4Z#Sy$P^NLLx{?Qi^qLQ3Y+1QxKty zlIMj#&61EDT>X`|CNG=vn6eU>8n^G2bp*!Clm+TyP(!b<>t0n6ULdcbNQS5(8G+_N zU-JO8AZ#r8cT`O}C?6|4`>WuL!MSDGl8-Limf3KZfkwnaBeAZ^k5j^M3>O}Rn;r*51gn}QKHq2P3c{p zIbd7uI9A99>Mb}Eg{SlkJXP(rlF^ja|3qh2 zkBz(47WD?dy8Rj^cpKpzge`;@Nxg-c6$QYjLqB^F1QATUBG$5tJ_0Wf!(J$0M@y}) SgHiv+uQYM62%tNZHTo}rsVA-g delta 289 zcmbOyc7~TPpO=@50SMUL&SY$3pU5Y}s5Mbrn$Mjfg(-!(g&~ExnJJ2SVvHK2%EV?> zmS6@=j){BjF|uu*&Dh4sST$LRxrR|_@_gorjGUVdS%etV1b}8~vJ^=JsUjH=Aqyhp zK%%TgtRS`!khsO3o?4PvQc?t#zQvYUP>`CJqRCan22&Bmo0FfMSdy8a7oU?^Tyl#s z71_+mD_Pwb') def exhibition_type(ex_type): @@ -53,6 +55,8 @@ def exhibition_type(ex_type): ex_type = "UTA" elif ex_type == "ethics-studio": ex_type = "ES" + elif ex_type == "starts4waterii": + ex_type = "S4W2" exhibitions = get_all_content('exhibition') return render_template('list-exhibitions.html', title="Exhibitions", content=exhibitions, ex_type=ex_type) @@ -148,33 +152,7 @@ def process_content(entries, type): # Sort the content list by the 'title' key alphabetically content_list.sort(key=lambda x: x['title'].lower()) - return content_list - -def get_support_images(): - # Specify the folder where images are stored - image_folder = os.path.join(app.static_folder, 'images/support') - - # Define a list of supported image file extensions - valid_extensions = ['.jpg', '.jpeg', '.png', '.gif', '.bmp'] - - # List to hold the image file names - image_files = [] - prio_image_files = [] - prio_image_top_files = [] - - # Loop through files in the directory - for filename in os.listdir(image_folder): - # Check if the file is an image (by extension) - if os.path.splitext(filename)[1].lower() in valid_extensions: - if os.path.splitext(filename)[0].lower() == "dg" or os.path.splitext(filename)[0].lower() == "sw": - prio_image_top_files.append(filename) - elif os.path.splitext(filename)[0].lower() == "french-emb" or os.path.splitext(filename)[0].lower() == "nn" or os.path.splitext(filename)[0].lower() == "if": - prio_image_files.append(filename) - else: - image_files.append(filename) - - return image_files, prio_image_files, prio_image_top_files - + return content_list def format_datetime(dt): date_str = dt.strftime('%d.%m.%y') diff --git a/templates/index.html b/templates/index.html index f4e3551..483a81a 100644 --- a/templates/index.html +++ b/templates/index.html @@ -40,7 +40,7 @@
{% for img in prio_img_top %}
- +
{% endfor %}
@@ -48,7 +48,7 @@
{% for img in prio_img %}
- +
{% endfor %}
@@ -56,7 +56,7 @@
{% for img in sup_img_list %}
- +
{% endfor %}
diff --git a/templates/list-exhibitions.html b/templates/list-exhibitions.html index 3261a4f..6838803 100644 --- a/templates/list-exhibitions.html +++ b/templates/list-exhibitions.html @@ -7,9 +7,9 @@ {% include '_nav.html' %} {% include '_list-header.html'%}
- {% if ex_type == "UTA" %} + {% if ex_type == "S4W2" %}
- Unsettling the Algorithm ↑ + STARTS4WaterII ↑
{% endif %} {% if ex_type == "LAN" %} @@ -27,8 +27,8 @@ {% for event in content %} {% if event.exh_type == ex_type %} - {% if ex_type == "UTA"%} - + {% if ex_type == "S4W2"%} + {% endif %} {% if ex_type == "LAN"%} diff --git a/templates/list.html b/templates/list.html index 89d92d5..1007ecf 100644 --- a/templates/list.html +++ b/templates/list.html @@ -18,7 +18,16 @@ {% endif %} {% if title == 'Exhibitions' %} - {% include '_ex.html' %} + {% for ex in exhibition_info %} +
+

{{ ex.title }}

+ {{ ex.description | safe }} +
+

Date: {{ ex.start_date }} -> {{ ex.end_date }}

+

Location: {{ ex.location }}

+
+
+ {% endfor %} {% endif %} {% endif %}