<commit_before>import urllib.parse

from datetime import datetime

from django import template
from django.template import Template, Context, Library
from django.template import defaultfilters as filters
from django.utils.safestring import mark_safe

from museum.settings import STATIC_URL
from museum_site.models import File
from museum_site.constants import ADMIN_NAME

register = Library()


@register.filter
def as_template(raw):
    context_data = {"TODO": "TODO", "CROP": "CROP"}
    raw = "{% load static %}\n{% load site_tags %}\n{% load zzt_tags %}" + raw
    return Template(raw).render(Context(context_data))


@register.filter
def url_parse(raw):
    output = urllib.parse.quote(raw)
    return output


@register.simple_tag()
def content_warning(*args, **kwargs):
    output = """
        <div class="content-warning">
        <div class="text">
            <b class="heading">CONTENT WARNING</b>
            <p>The following content contains material which may be offensive
            to some audiences. It was most likely originally created by a
            teenager who has since grown up. This material does not necessarily
            reflect its creator's current opinions nor behaviors.</p>

            <p>Specifically, this page contains depictions of or references to:
            <br><b>{}</b></p>

            <div class="controls r">
                <span class="jsLink" name="cw-hide-all">Hide all future content<commit_msg>Adjust way items are returned with get_files_by_id.<commit_after>import os
import urllib.parse

from datetime import datetime

from django import template
from django.template import Template, Context, Library
from django.template import defaultfilters as filters
from django.utils.safestring import mark_safe

from museum.settings import STATIC_URL
from museum_site.models import File
from museum_site.constants import ADMIN_NAME, SITE_ROOT

register = Library()


@register.filter
def as_template(raw):
    context_data = {"TODO": "TODO", "CROP": "CROP"}
    raw = "{% load static %}\n{% load site_tags %}\n{% load zzt_tags %}" + raw
    return Template(raw).render(Context(context_data))


@register.filter
def get_files_by_id(raw):
    ids = list(map(int, raw.split(",")))
    print(ids)
    qs = File.objects.filter(pk__in=ids)
    files = {}
    for f in qs:
        print(f.title)
        files[str(f.id)] = f
    print(files.keys())
    return files


@register.filter
def url_parse(raw):
    output = urllib.parse.quote(raw)
    return output


@register.simple_tag()
def content_warning(*args, **kwargs):
    output = """
        <div class="content-warning">
        <div class="text">
            <b class="heading">CONTENT WARNING</b>
            <p>The following content contains material which may be offensive
            to some audiences. It was most likely originally created by a
            teenager who has since grown up. This material does not necessarily
            reflect its creator's current opinions nor behaviors.</p>

            <p>Specifically, this page contains depictions of or references to:
            <br><b>{}</b></p>

            <div class="controls r">
                <span class="jsLink" name="cw-hide-all">Hide all future content
{'fraction_non_alphanumeric': 0.10309597523219814, 'fraction_numerical': 0.0, 'mean_word_length': 3.2681638044914134, 'pattern_counts': {'":': 4, '<': 29, '<?xml version=': 0, '>': 29, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3937105', 'n_tokens_mistral': 918, 'n_tokens_neox': 897, 'n_words': 300}