<commit_before>{% from 'message_box.html' import message_box %}

{% macro _hidden_events_block(class, category, events_by_month, format_event_date, is_recent, happening_now,
                             before=none, after=none, message_first=true) %}
    {% set message=caller() %}
    {% macro render_message() %}
        {% call message_box('info', icon=false) %}
            <div class="content smaller">
                <span class="js-show-message">
                    {{ message }}
                    <a class="js-toggle-list" href="#">{% trans %}Show{% endtrans %}</a>
                    <span class="icon-spinner js-spinner"></span>
                </span>
                <span class="js-hide-message">
                    {{ message }}
                    <a class="js-toggle-list" href="#">{% trans %}Hide{% endtrans %}</a>
                </span>
            </div>
        {% endcall %}
    {% endmacro %}

    {% macro render_list() %}
        <div class="events"
             data-event-list-url="{{ url_for('.event_list', category) }}"
             {% if after %}data-event-list-after="{{ after }}"{% endif %}
             {% if before %}data-event-list-before="{{ before }}"{% endif %}>
            {%- if events_by_month -%}
                {{ event_list_block(events_by_month, format_event_date, is_recent, happening_now) }}
            {%- endif -%}
        </div>
    {% endmacro %}

    <div class="{{ class }}">
        {% if message_first %}
            {{ render_message() }}
            {{ render_list() }}
        {% else %}
            {{ render_list() }}
            {{ render_message() }}
        {% endif %}
    </div>
{% endmacro %}

{% macro event_list(events_by_month, format_event_date, is_recent, happening_now, category, future_event_count,
                    past_event_count, future_threshold, past_threshold, future_events_by_month=[],
                    past_events_by_month=[], show_future_events=false, show_past_events=false,
                    has_hidden_events=false, is_flat=false, request_params={}) %}
    {#- request_params parameter provided for template extensions -#}
    {% if has_hidden_events %}
        {% call message_box('highlight', icon=true) %}
            <div class="content smaller">
                <span class="js-show-message">
                    {% trans %}Some events in the list below have been hidden.{% endtrans %}
                </span>
            </div>
        {% endcall %}
    {% endif %}

    <div class="event-list"
         data-show-future-events-url="{{ url_for('.show_future_events', category) }}"
         data-show-past-events-url="{{ url_for('.show_past_events', category) }}">
        {% if future_event_count %}
            {% call _hidden_events_block('future-events', category, future_events_by_month, format_event_date,
                                        is_recent, happening_now, after=future_threshold) %}
                {% trans count=future_event_count -%}
                    There is one event in the future.
                {%- pluralize -%}
                    There are {{ count }} events in the future.
                {%- endtrans %}
            {% endcall %}
        {% endif %}
        <div>
            {{ event_list_block(events_by_month, format_event_date, is_recent, happening_now) }}
        </div>
        {% if past_event_count %}
            {% call _hidden_events_block('past-events', category, past_events_by_month, format_event_date, is_recent,
                                        happening_now, before=past_threshold, message_first=false) %}
                {% trans count=past_event_count -%}
                    There is one event in the past.
                {%- pluralize -%}
                    There are {{ count }} events in the past.
                {%- endtrans %}
            {% endcall %}
        {% endif %}
    </div>
    <script>
        setupCategoryDisplayEventList({{ (show_future_events and not future_events_by_month) | tojson }},
                                      {{ (show_past_events and not past_events_by_month) | tojson }},
                                      {{ is_flat | tojson }},
                                      {{ request_params | tojson }});
    </script>
{% endmacro %}

{% macro event_list_block(events_by_month, format_event_date, is_recent, happening_now) %}
    {% for month in events_by_month %}
        <h4 class="{% if month.is_current %}current-month{% endif %}">
            <span>{{ month.name }}</span>
        </h4>
        <ul>
            {% for event in month.events %}
                {% set is_lecture = (event.type == 'lecture') %}
                <li>
                    <span class="event-icons">
                        <a class="icon-calendar" href="{{ url_for('events.export_event_ical', event) }}"></a>
                        {% if session.user and event in session.user.favorite_events %}
                            <i class="icon-star" title="{% trans %}You have favorited this event.{% endtrans %}"></i>
                        {% endif%}
                    </span>
                    <span class="list-name">
                        <span class="date {% if happening_now(event) %}today{% endif %}">
                            {{ format_event_date(event) }}
                        </span>
                        <div class="event-title">
                            <a href="{{ event.url }}">
                                {{ event.get_verbose_title(show_speakers=is_lecture, show_series_pos=is_lecture) | striptags }}
                            </a>
                            <span class="protected">
                                {% if event.visibility == 0 %}
                                    <span class="ui label mini grey"
                                          title="{% trans %}This event is hidden.{% endtrans %}">
                                        {%- trans %}hidden{% endtrans -%}
                                    </span>
                                {% endif %}
                                {% if event.is_self_protected %}
                                    <span class="icon-shield" data-type="restricted" title="{% trans %}Protected{% endtrans %}"></span>
                                {% endif %}

                                {% if is_recent(event.created_dt) %}
                                    <span class="ui label mini blue"
                                          title="{% trans %}This event is new.{% endtrans %}">
                                        {%- trans %}new{% endtrans -%}
                                    </span>
                                {% endif %}
                            </span>
                            {% if event.label %}
                                <span class="ui label basic mini {{ event.label.color }}"
                                      title="{{ event.label_message }}">
                                    {{- event.label.title -}}
                                </span>
                            {% endif %}
                        </div>
                    </span>
                </li>
            {% endfor %}
        </ul>
    {% endfor %}
{% endmacro %}<commit_msg>Add event-status-labels template hook (#5466)<commit_after>{% from 'message_box.html' import message_box %}

{% macro _hidden_events_block(class, category, events_by_month, format_event_date, is_recent, happening_now,
                             before=none, after=none, message_first=true) %}
    {% set message=caller() %}
    {% macro render_message() %}
        {% call message_box('info', icon=false) %}
            <div class="content smaller">
                <span class="js-show-message">
                    {{ message }}
                    <a class="js-toggle-list" href="#">{% trans %}Show{% endtrans %}</a>
                    <span class="icon-spinner js-spinner"></span>
                </span>
                <span class="js-hide-message">
                    {{ message }}
                    <a class="js-toggle-list" href="#">{% trans %}Hide{% endtrans %}</a>
                </span>
            </div>
        {% endcall %}
    {% endmacro %}

    {% macro render_list() %}
        <div class="events"
             data-event-list-url="{{ url_for('.event_list', category) }}"
             {% if after %}data-event-list-after="{{ after }}"{% endif %}
             {% if before %}data-event-list-before="{{ before }}"{% endif %}>
            {%- if events_by_month -%}
                {{ event_list_block(events_by_month, format_event_date, is_recent, happening_now) }}
            {%- endif -%}
        </div>
    {% endmacro %}

    <div class="{{ class }}">
        {% if message_first %}
            {{ render_message() }}
            {{ render_list() }}
        {% else %}
            {{ render_list() }}
            {{ render_message() }}
        {% endif %}
    </div>
{% endmacro %}

{% macro event_list(events_by_month, format_event_date, is_recent, happening_now, category, future_event_count,
                    past_event_count, future_threshold, past_threshold, future_events_by_month=[],
                    past_events_by_month=[], show_future_events=false, show_past_events=false,
                    has_hidden_events=false, is_flat=false, request_params={}) %}
    {#- request_params parameter provided for template extensions -#}
    {% if has_hidden_events %}
        {% call message_box('highlight', icon=true) %}
            <div class="content smaller">
                <span class="js-show-message">
                    {% trans %}Some events in the list below have been hidden.{% endtrans %}
                </span>
            </div>
        {% endcall %}
    {% endif %}

    <div class="event-list"
         data-show-future-events-url="{{ url_for('.show_future_events', category) }}"
         data-show-past-events-url="{{ url_for('.show_past_events', category) }}">
        {% if future_event_count %}
            {% call _hidden_events_block('future-events', category, future_events_by_month, format_event_date,
                                        is_recent, happening_now, after=future_threshold) %}
                {% trans count=future_event_count -%}
                    There is one event in the future.
                {%- pluralize -%}
                    There are {{ count }} events in the future.
                {%- endtrans %}
            {% endcall %}
        {% endif %}
        <div>
            {{ event_list_block(events_by_month, format_event_date, is_recent, happening_now) }}
        </div>
        {% if past_event_count %}
            {% call _hidden_events_block('past-events', category, past_events_by_month, format_event_date, is_recent,
                                        happening_now, before=past_threshold, message_first=false) %}
                {% trans count=past_event_count -%}
                    There is one event in the past.
                {%- pluralize -%}
                    There are {{ count }} events in the past.
                {%- endtrans %}
            {% endcall %}
        {% endif %}
    </div>
    <script>
        setupCategoryDisplayEventList({{ (show_future_events and not future_events_by_month) | tojson }},
                                      {{ (show_past_events and not past_events_by_month) | tojson }},
                                      {{ is_flat | tojson }},
                                      {{ request_params | tojson }});
    </script>
{% endmacro %}

{% macro event_list_block(events_by_month, format_event_date, is_recent, happening_now) %}
    {% for month in events_by_month %}
        <h4 class="{% if month.is_current %}current-month{% endif %}">
            <span>{{ month.name }}</span>
        </h4>
        <ul>
            {% for event in month.events %}
                {% set is_lecture = (event.type == 'lecture') %}
                <li>
                    <span class="event-icons">
                        <a class="icon-calendar" href="{{ url_for('events.export_event_ical', event) }}"></a>
                        {% if session.user and event in session.user.favorite_events %}
                            <i class="icon-star" title="{% trans %}You have favorited this event.{% endtrans %}"></i>
                        {% endif%}
                    </span>
                    <span class="list-name">
                        <span class="date {% if happening_now(event) %}today{% endif %}">
                            {{ format_event_date(event) }}
                        </span>
                        <div class="event-title">
                            <a href="{{ event.url }}">
                                {{ event.get_verbose_title(show_speakers=is_lecture, show_series_pos=is_lecture) | striptags }}
                            </a>
                            <span class="protected">
                                {% if event.visibility == 0 %}
                                    <span class="ui label mini grey"
                                          title="{% trans %}This event is hidden.{% endtrans %}">
                                        {%- trans %}hidden{% endtrans -%}
                                    </span>
                                {% endif %}
                                {% if event.is_self_protected %}
                                    <span class="icon-shield" data-type="restricted" title="{% trans %}Protected{% endtrans %}"></span>
                                {% endif %}

                                {% if is_recent(event.created_dt) %}
                                    <span class="ui label mini blue"
                                          title="{% trans %}This event is new.{% endtrans %}">
                                        {%- trans %}new{% endtrans -%}
                                    </span>
                                {% endif %}
                                {{ template_hook('event-status-labels', event=event) }}
                            </span>
                            {% if event.label %}
                                <span class="ui label basic mini {{ event.label.color }}"
                                      title="{{ event.label_message }}">
                                    {{- event.label.title -}}
                                </span>
                            {% endif %}
                        </div>
                    </span>
                </li>
            {% endfor %}
        </ul>
    {% endfor %}
{% endmacro %}
{'fraction_non_alphanumeric': 0.1320897577092511, 'fraction_numerical': 0.0006883259911894273, 'mean_word_length': 1.3324771231337293, 'pattern_counts': {'":': 0, '<': 119, '<?xml version=': 0, '>': 119, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 61, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3313092', 'n_tokens_mistral': 4035, 'n_tokens_neox': 3529, 'n_words': 770}