
time_published will be put to the right of the view_count in related videos Author will now always be above the other stats, since it doesn't make a difference in the big search result boxes since the description snippet is always very short (However, it's important the author isn't inline with the other stats in related video boxes since those are so narrow and the author name can be very long)
93 lines
4.3 KiB
HTML
93 lines
4.3 KiB
HTML
{% macro text_runs(runs) %}
|
|
{%- if runs[0] is mapping -%}
|
|
{%- for text_run in runs -%}
|
|
{%- if text_run.get("bold", false) -%}
|
|
<b>{{ text_run["text"] }}</b>
|
|
{%- elif text_run.get('italics', false) -%}
|
|
<i>{{ text_run["text"] }}</i>
|
|
{%- else -%}
|
|
{{ text_run["text"] }}
|
|
{%- endif -%}
|
|
{%- endfor -%}
|
|
{%- elif runs -%}
|
|
{{ runs }}
|
|
{%- endif -%}
|
|
{% endmacro %}
|
|
|
|
{% macro item(info, description=false, horizontal=true, include_author=true, include_badges=true) %}
|
|
<div class="item-box {{ info['type'] + '-item-box' }} {{'horizontal-item-box' if horizontal else 'vertical-item-box'}} {{'has-description' if description else 'no-description'}}">
|
|
{% if info['error'] %}
|
|
{{ info['error'] }}
|
|
{% else %}
|
|
<div class="item {{ info['type'] + '-item' }}">
|
|
<a class="thumbnail-box" href="{{ info['url'] }}" title="{{ info['title'] }}">
|
|
<img class="thumbnail-img" src="{{ info['thumbnail'] }}">
|
|
{% if info['type'] != 'channel' %}
|
|
<div class="thumbnail-info">
|
|
<span>{{ (info['video_count']|string + ' videos') if info['type'] == 'playlist' else info['duration'] }}</span>
|
|
</div>
|
|
{% endif %}
|
|
</a>
|
|
|
|
<div class="title"><a class="title" href="{{ info['url'] }}" title="{{ info['title'] }}">{{ info['title'] }}</a></div>
|
|
|
|
{% if include_author %}
|
|
{% if info.get('author_url') %}
|
|
<address title="{{ info['author'] }}">By <a href="{{ info['author_url'] }}">{{ info['author'] }}</a></address>
|
|
{% else %}
|
|
<address title="{{ info['author'] }}"><b>{{ info['author'] }}</b></address>
|
|
{% endif %}
|
|
{% endif %}
|
|
<ul class="stats {{'horizontal-stats' if horizontal else 'vertical-stats'}}">
|
|
{% if info['type'] == 'channel' %}
|
|
<li><span>{{ info['approx_subscriber_count'] }} subscribers</span></li>
|
|
<li><span>{{ info['video_count'] }} videos</span></li>
|
|
{% else %}
|
|
{% if info.get('approx_view_count') %}
|
|
<li><span class="views">{{ info['approx_view_count'] }} views</span></li>
|
|
{% endif %}
|
|
{% if info.get('time_published') %}
|
|
<li><time>{{ info['time_published'] }}</time></li>
|
|
{% endif %}
|
|
{% endif %}
|
|
</ul>
|
|
|
|
{% if description %}
|
|
<span class="description">{{ text_runs(info.get('description', '')) }}</span>
|
|
{% endif %}
|
|
{% if include_badges %}
|
|
<span class="badges">{{ info['badges']|join(' | ') }}</span>
|
|
{% endif %}
|
|
</div>
|
|
{% if info['type'] == 'video' %}
|
|
<input class="item-checkbox" type="checkbox" name="video_info_list" value="{{ info['video_info'] }}" form="playlist-edit">
|
|
{% endif %}
|
|
{% endif %}
|
|
</div>
|
|
|
|
{% endmacro %}
|
|
|
|
{% macro page_buttons(estimated_pages, url, parameters_dictionary) %}
|
|
{% set current_page = parameters_dictionary.get('page', 1)|int %}
|
|
{% set parameters_dictionary = parameters_dictionary.to_dict() %}
|
|
{% if current_page is le(5) %}
|
|
{% set page_start = 1 %}
|
|
{% set page_end = [9, estimated_pages]|min %}
|
|
{% else %}
|
|
{% set page_start = current_page - 4 %}
|
|
{% set page_end = [current_page + 4, estimated_pages]|min %}
|
|
{% endif %}
|
|
|
|
{% for page in range(page_start, page_end+1) %}
|
|
{% if page == current_page %}
|
|
<div class="page-button">{{ page }}</div>
|
|
{% else %}
|
|
{# IMPORTANT: Jinja SUCKS #}
|
|
{# https://stackoverflow.com/questions/36886650/how-to-add-a-new-entry-into-a-dictionary-object-while-using-jinja2 #}
|
|
{% set _ = parameters_dictionary.__setitem__('page', page) %}
|
|
<a class="page-button" href="{{ url + '?' + parameters_dictionary|urlencode }}">{{ page }}</a>
|
|
{% endif %}
|
|
{% endfor %}
|
|
|
|
{% endmacro %}
|