forked from ruangrupa/konfluks
Compare commits
2 Commits
3297991d83
...
e32743ecd5
Author | SHA1 | Date |
---|---|---|
knoflook | e32743ecd5 | |
knoflook | 1f21d0475f |
|
@ -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
|
||||
|
|
|
@ -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 %}
|
||||
|
|
Loading…
Reference in New Issue