diff --git a/archivist/sites/furaffinity/templatetags/custom_filters.py b/archivist/sites/furaffinity/templatetags/custom_filters.py new file mode 100644 index 0000000..cb9d70c --- /dev/null +++ b/archivist/sites/furaffinity/templatetags/custom_filters.py @@ -0,0 +1,47 @@ +# custom_filters.py +from django import template + +import nh3 + +from bs4 import BeautifulSoup + +register = template.Library() + +@register.filter +def is_image(file_url): + image_extensions = ['.png', '.jpg', '.jpeg', '.gif', '.webp'] + return file_url.lower().endswith(tuple(image_extensions)) + + +@register.filter +def is_flash(file_url): + flash_extensions = ['.swf'] + return file_url.lower().endswith(tuple(flash_extensions)) + + +@register.filter +def is_pdf(file_url): + pdf_extensions = ['.pdf'] + return file_url.lower().endswith(tuple(pdf_extensions)) + +@register.filter +def descriptionHtml2Text(description): + if description.startswith("