|
|
@ -16,8 +16,8 @@ client = contentful.Client(SPACE_ID, ACCESS_TOKEN) |
|
|
|
|
|
|
|
@app.route('/') |
|
|
|
def index(): |
|
|
|
sup_img = get_support_images() |
|
|
|
return render_template('index.html', title='', sup_img_list=sup_img) |
|
|
|
sup_img, prio_img = get_support_images() |
|
|
|
return render_template('index.html', title='', sup_img_list=sup_img, prio_img=prio_img) |
|
|
|
|
|
|
|
@app.route('/grph') |
|
|
|
def graphics(): |
|
|
@ -70,7 +70,14 @@ def get_all_content(type): |
|
|
|
def get_content_by_title(title, pre_type): |
|
|
|
type = pre_type[:-1] |
|
|
|
entries = client.entries({'query': title, 'limit': 5}) |
|
|
|
exact_matches = [entry for entry in entries if getattr(entry, f'title_of_{type}') == title] |
|
|
|
exact_matches = [] |
|
|
|
for entry in entries: |
|
|
|
try: |
|
|
|
if getattr(entry, f'title_of_{type}') == title: |
|
|
|
exact_matches = [entry] |
|
|
|
except: |
|
|
|
pass |
|
|
|
|
|
|
|
content_list = process_content(exact_matches, type) |
|
|
|
return content_list |
|
|
|
|
|
|
@ -120,6 +127,8 @@ def process_content(entries, type): |
|
|
|
'exh_type': exh_type |
|
|
|
} |
|
|
|
content_list.append(content) |
|
|
|
print(content) |
|
|
|
print("\n") |
|
|
|
# Sort the content list by the 'title' key alphabetically |
|
|
|
content_list.sort(key=lambda x: x['title'].lower()) |
|
|
|
|
|
|
@ -134,14 +143,18 @@ def get_support_images(): |
|
|
|
|
|
|
|
# List to hold the image file names |
|
|
|
image_files = [] |
|
|
|
prio_image_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: |
|
|
|
image_files.append(filename) |
|
|
|
if os.path.splitext(filename)[0].lower() == "dg" or os.path.splitext(filename)[0].lower() == "sw": |
|
|
|
prio_image_files.append(filename) |
|
|
|
else: |
|
|
|
image_files.append(filename) |
|
|
|
|
|
|
|
return image_files |
|
|
|
return image_files, prio_image_files |
|
|
|
|
|
|
|
|
|
|
|
def format_datetime(dt): |
|
|
|