Compare commits

...

2 Commits

Author SHA1 Message Date
knoflook e32743ecd5
cal: set featured_image in template 2022-02-03 15:32:25 +01:00
knoflook 1f21d0475f
cal: add event name to filename 2022-02-03 12:50:15 +01:00
2 changed files with 12 additions and 1 deletions

View File

@ -75,6 +75,7 @@ def create_metadata(event):
"duration": date.compress(event.duration),
"location": event.location,
"uid": event.uid,
"featured_image": "",
"images": find_imageURLS(event.description), # currently not used in template
}
@ -110,6 +111,11 @@ def localize_time(date):
)
return localized_begins
def sanitize_name(name):
sanitized = "".join([c if c.isalnum() or c == " " else "-" for c in name])
if len(sanitized) > 20:
return sanitized[:20]
return sanitized
def create_event_post(post_dir, event):
"""
@ -153,6 +159,8 @@ def create_event_post(post_dir, event):
event_metadata["description"] = event_metadata["description"].replace(
img, "![]({})".format(img_name)
)
if event_metadata["featured_image"] == "":
event_metadata["featured_image"] = img_name
if img_name in existing_images:
existing_images.remove(img_name)
@ -186,7 +194,7 @@ def update_event_post(post_dir, event):
def main():
for event in list(cal.events):
post_dir = os.path.join(output_dir, event.uid)
post_dir = os.path.join(output_dir, sanitize_name(event.name) + "-" + event.uid)
if event.uid not in existing_posts:
# if there is an event we dont already have, make it

View File

@ -8,6 +8,9 @@ event_end: "{{ event.end }}"
duration: "{{ event.duration }}"
localized_begin: "{{ event.localized_begin }}"
uid: "{{ event.uid }}"
{% if event.featured_image %}
featured_image: "{{ event.featured_image }}"
{% endif %}
{% if event.location %}
location: "{{ event.location }}"
{% endif %}