<commit_before>
{# ==========================================================================

   post_preview.render()

   ==========================================================================

   Description:

   Render an article when given:

   settings:

   settings.heading:            A string with the title of the post.
   settings.body:               A string with content of post preview/post summary.
   settings.author:             An array with authors of the post.
   settings.published_date:     A datetime object with published date.

   settings.image_url:          A string with the url of the thumbnail image.
   settings.image_alt:          A string with the alt text of the thumbnail image.

   settings.post_category:      An array with the categories for the post. Up to 2.
   settings.post_tags:          An array with the post tags for the post.

   settings.event_start_dt:     A datetime object with the time of the event.
   settings.event_stream_link:  A string with livestream link
   settings.event_venue:        A string with the event venue.
   settings.event_street:       A string with the event street.
   settings.event_city:         A string with the event city.
   settings.event_state:        A string with the event state.
   settings.event_zip:          A string with the event zip.

   settings.comments_close_date: A datetime object marking the deadline of the comment period.
   settings.preview_link_text:   A string with the description text of an external link.
   settings.preview_link_url:    A string with the url of an external link.

   path:                        A string with the path for the homepage of the pagetype
                                `/blog/`, `/newsroom/`

   ========================================================================== #}

{% import 'macros/category-slug.html' as category_slug %}
{% import 'macros/time.html' as time %}
{% from 'macros/util/format/url.html' import location_image_url as location_image_url %}

{% macro render(post, type='', form_id=0, url='') %}
    {% set url = url or get_page_state_url({'request':request}, post) %}
    <article class="o-post-preview">
        <div class="meta-header">
            <span class="date meta-header_right">
                Published {{ time.render(post.date_published, {'date':true}) }}
            </span>
            {# Newsroom Blog category logic #}
            {% if 'newsroom' in type %}
                {% if is_blog(post) %}
                    {{ category_slug.render('blog',
                            url,
                            'post_slug meta-header_left',
                            false, form_id) }}
                {% endif %}
            {% else %}
                {% for cat in post.categories.all() %}
                    {% if loop.index > 1 %}
                        |
                    {% endif %}
                    {{ category_slug.render(cat.name,
                            url,
                            'post_slug meta-header_left',
                            false, form_id) }}
                {% endfor %}
            {% endif %}
        </div>
         {% if 'EventPage' in post.specific_class.__name__ %}
            {% if post.specific.start_dt %}
                <div class="o-post-preview_image-container">
                    <time class="calendar-icon"
                          data-month="{{ post.specific.start_dt | date('%b') }}"
                          data-day="{{ post.specific.start_dt | date('%-d') }}"
                          datetime="{{ post.specific.start_dt | date('%c') }}">
                        <span class="u-visually-hidden">{{ post.specific.start_dt| date('%b %-d, %Y') }}</span>
                    </time>
                    {% if post.specific.live_stream_link %}
                        <img class="o-post-preview_image"
                             src="http://placehold.it/160x90"
                             alt="Livestream event">
                    {% else %}
                        <img class="o-post-preview_image"
                             src="{{ location_image_url({
                                     'location': post.specific.venue_city
                                     | default('Washington, DC', true)
                                     | urlencode,
                                     'zoom':     '12',
                                     'scale':    '2',
                                     'size':     '276x155'
                                     }) }}"
                             alt="Google Maps image of {{ post.specific.venue_name }}">
                    {% endif %}
                </div>
            {% endif %}
        {% elif post.preview_image %}
            {% set photo = image(post.preview_image, 'original') %}
            <div class="o-post-preview_image-container">
                <img class="o-post-preview_image"
                     src="{{ photo.url }}"
                     alt="{{ post.preview_image.alt if post.preview_image.alt else '' }}">
            </div>
        {% endif %}
        <div class="o-post-preview_content">

            <h3 class="o-post-preview_title">
                <a href="{{ get_page_state_url({'request':request}, post) }}">
                    {{ post.preview_title | safe if post.preview_title else post.title }}
                </a>
            </h3>

            {% if 'EventPage' in post.specific_class.__name__ %}
                {% if post.specific.start_dt %}
                    <span class="o-post-preview_subtitle h6">
                    {% if post.specific.venue_city and post.specific.venue_state %}
                        {{ post.specific.venue_city }}, {{ post.specific.venue_state }}
                    {% endif %}
                            {{ post.specific.venue_name if post.specific.venue_name else '' }}
                    {{ 'Livecast' if post.specific.live_stream_url else '' }}
                     -
                    {{ time.render(post.specific.start_dt) }}
                    </span>
                {% endif %}
            {% endif %}
            {% if post.comments_close_date %}
                <span class="o-post-preview_subtitle h6">
                    Comments close {{ time.render(post.comments_close_date, {'date':true}) }}
                </span>
            {% endif %}
            {% if post.preview_description %}
                <div class="o-post-preview_description">
                    {{ post.preview_description | safe }}
                </div>
            {% endif %}
            <div class="post_meta">
                {% for author in post.authors.names() %}
                    <span class="o-post-preview_byline">
                        {% if loop.index == 1  %}
                            By <a href="{{ url }}?filter{{ form_id }}_authors={{ author }}">
                                {{ author }}
                                </a>
                        {% elif loop.last == true %}
                            and <a href="{{ url }}?filter{{ form_id }}_authors={{ author }}">
                                {{ author }}
                                </a>
                        {% else %}
                            ,<a href="{{ url }}?filter{{ form_id }}_authors={{ author }}">
                                {{ author }}
                                </a>
                        {% endif %}
                    </span>
                {% endfor %}

                {% if post.tags.names() | length %}
                    {%- import 'tags.html' as tags %}
                    {{ tags.render(post.tags.names(), url, true, false, form_id) }}
                {% endif %}
            </div>
            {% if post.preview_link_url and post.preview_link_text %}
                <a href="{{ post.preview_link_url }}" class="jump-link jump-link__underline">
                    {{ post.preview_link_text }}<commit_msg>fixed urls in post preview filtering<commit_after>
{# ==========================================================================

   post_preview.render()

   ==========================================================================

   Description:

   Render an article when given:

   settings:

   settings.heading:            A string with the title of the post.
   settings.body:               A string with content of post preview/post summary.
   settings.author:             An array with authors of the post.
   settings.published_date:     A datetime object with published date.

   settings.image_url:          A string with the url of the thumbnail image.
   settings.image_alt:          A string with the alt text of the thumbnail image.

   settings.post_category:      An array with the categories for the post. Up to 2.
   settings.post_tags:          An array with the post tags for the post.

   settings.event_start_dt:     A datetime object with the time of the event.
   settings.event_stream_link:  A string with livestream link
   settings.event_venue:        A string with the event venue.
   settings.event_street:       A string with the event street.
   settings.event_city:         A string with the event city.
   settings.event_state:        A string with the event state.
   settings.event_zip:          A string with the event zip.

   settings.comments_close_date: A datetime object marking the deadline of the comment period.
   settings.preview_link_text:   A string with the description text of an external link.
   settings.preview_link_url:    A string with the url of an external link.

   path:                        A string with the path for the homepage of the pagetype
                                `/blog/`, `/newsroom/`

   ========================================================================== #}

{% import 'macros/category-slug.html' as category_slug %}
{% import 'macros/time.html' as time %}
{% from 'macros/util/format/url.html' import location_image_url as location_image_url %}

{% macro render(post, type='', form_id=0, url='') %}
    {% set page_url = url or get_page_state_url({'request':request}, page) %}
    {% set post_url = get_page_state_url({'request':request}, post) %}
    <article class="o-post-preview">
        <div class="meta-header">
            <span class="date meta-header_right">
                Published {{ time.render(post.date_published, {'date':true}) }}
            </span>
            {# Newsroom Blog category logic #}
            {% if 'newsroom' in type %}
                {% if is_blog(post) %}
                    {{ category_slug.render('blog',
                            page_url,
                            'post_slug meta-header_left',
                            false, form_id) }}
                {% endif %}
            {% else %}
                {% for cat in post.categories.all() %}
                    {% if loop.index > 1 %}
                        |
                    {% endif %}
                    {{ category_slug.render(cat.name,
                            page_url,
                            'post_slug meta-header_left',
                            false, form_id) }}
                {% endfor %}
            {% endif %}
        </div>
         {% if 'EventPage' in post.specific_class.__name__ %}
            {% if post.specific.start_dt %}
                <div class="o-post-preview_image-container">
                    <time class="calendar-icon"
                          data-month="{{ post.specific.start_dt | date('%b') }}"
                          data-day="{{ post.specific.start_dt | date('%-d') }}"
                          datetime="{{ post.specific.start_dt | date('%c') }}">
                        <span class="u-visually-hidden">{{ post.specific.start_dt| date('%b %-d, %Y') }}</span>
                    </time>
                    {% if post.specific.live_stream_link %}
                        <img class="o-post-preview_image"
                             src="http://placehold.it/160x90"
                             alt="Livestream event">
                    {% else %}
                        <img class="o-post-preview_image"
                             src="{{ location_image_url({
                                     'location': post.specific.venue_city
                                     | default('Washington, DC', true)
                                     | urlencode,
                                     'zoom':     '12',
                                     'scale':    '2',
                                     'size':     '276x155'
                                     }) }}"
                             alt="Google Maps image of {{ post.specific.venue_name }}">
                    {% endif %}
                </div>
            {% endif %}
        {% elif post.preview_image %}
            {% set photo = image(post.preview_image, 'original') %}
            <div class="o-post-preview_image-container">
                <img class="o-post-preview_image"
                     src="{{ photo.url }}"
                     alt="{{ post.preview_image.alt if post.preview_image.alt else '' }}">
            </div>
        {% endif %}
        <div class="o-post-preview_content">

            <h3 class="o-post-preview_title">
                <a href="{{ post_url }}">
                    {{ post.preview_title | safe if post.preview_title else post.title }}
                </a>
            </h3>

            {% if 'EventPage' in post.specific_class.__name__ %}
                {% if post.specific.start_dt %}
                    <span class="o-post-preview_subtitle h6">
                    {% if post.specific.venue_city and post.specific.venue_state %}
                        {{ post.specific.venue_city }}, {{ post.specific.venue_state }}
                    {% endif %}
                            {{ post.specific.venue_name if post.specific.venue_name else '' }}
                    {{ 'Livecast' if post.specific.live_stream_url else '' }}
                     -
                    {{ time.render(post.specific.start_dt) }}
                    </span>
                {% endif %}
            {% endif %}
            {% if post.comments_close_date %}
                <span class="o-post-preview_subtitle h6">
                    Comments close {{ time.render(post.comments_close_date, {'date':true}) }}
                </span>
            {% endif %}
            {% if post.preview_description %}
                <div class="o-post-preview_description">
                    {{ post.preview_description | safe }}
                </div>
            {% endif %}
            <div class="post_meta">
                {% for author in post.authors.names() %}
                    <span class="o-post-preview_byline">
                        {% if loop.index == 1  %}
                            By <a href="{{ page_url }}?filter{{ form_id }}_authors={{ author }}">
                                {{ author }}
                                </a>
                        {% elif loop.last == true %}
                            and <a href="{{ page_url }}?filter{{ form_id }}_authors={{ author }}">
                                {{ author }}
                                </a>
                        {% else %}
                            ,<a href="{{ page_url }}?filter{{ form_id }}_authors={{ author }}">
                                {{ author }}
                                </a>
                        {% endif %}
                    </span>
                {% endfor %}

                {% if post.tags.names() | length %}
                    {%- import 'tags.html' as tags %}
                    {{ tags.render(post.tags.names(), page_url, true, false, form_id) }}
                {% endif %}
            </div>
            {% if post.preview_link_url and post.preview_link_text %}
                <a href="{{ post.preview_link_url }}" class="jump-link jump-link__underline">
                    {{ post.preview_link_text }}
{'fraction_non_alphanumeric': 0.14116094986807387, 'fraction_numerical': 0.0027641663525568537, 'mean_word_length': 1.329382499268364, 'pattern_counts': {'":': 0, '<': 79, '<?xml version=': 0, '>': 81, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 20, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2137086', 'n_tokens_mistral': 4196, 'n_tokens_neox': 3766, 'n_words': 938}